Skip to content

Commit

Permalink
Files.app: Show the drive options always in gear menu.
Browse files Browse the repository at this point in the history
This CL is workaround for M40 instead of submenu.  The mobile sync option is
shown only for the device that having an access for mobile network.

BUG=428134
TEST=run on linux build (with mock mobile network), on link (without mobile network)

Review URL: https://codereview.chromium.org/726463002

Cr-Commit-Position: refs/heads/master@{#304380}
  • Loading branch information
hirono-chromium authored and Commit bot committed Nov 17, 2014
1 parent 816b710 commit 0f33fbe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state_handler.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -811,6 +813,10 @@ bool FileManagerPrivateGetDriveConnectionStateFunction::RunSync() {
break;
}

result.has_cellular_network_access =
chromeos::NetworkHandler::Get()
->network_state_handler()
->FirstNetworkByType(chromeos::NetworkTypePattern::Mobile());
results_ = api::file_manager_private::GetDriveConnectionState::Results::
Create(result);

Expand Down
4 changes: 4 additions & 0 deletions chrome/common/extensions/api/file_manager_private.idl
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ dictionary DriveConnectionState {

// Reasons of offline.
DOMString? reason;

// Whether the device has a cellular network access or not. i.e. the |type|
// can be 'metered' or not.
boolean hasCellularNetworkAccess;
};

// Device event dispatched to listeners of onDeviceChaged. See also
Expand Down
3 changes: 2 additions & 1 deletion ui/file_manager/file_manager/background/js/volume_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ function VolumeManager() {
*/
this.driveConnectionState_ = {
type: VolumeManagerCommon.DriveConnectionType.OFFLINE,
reason: VolumeManagerCommon.DriveConnectionReason.NO_SERVICE
reason: VolumeManagerCommon.DriveConnectionReason.NO_SERVICE,
hasCellularNetworkAccess: false
};

chrome.fileManagerPrivate.onDriveConnectionStatusChanged.addListener(
Expand Down
2 changes: 1 addition & 1 deletion ui/file_manager/file_manager/foreground/js/file_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52;
* @return {boolean} True if those setting items should be shown.
*/
FileManager.prototype.shouldShowDriveSettings = function() {
return this.isOnDrive() && this.isSecretGearMenuShown_;
return this.isOnDrive();
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ CommandHandler.COMMANDS_['drive-sync-settings'] = /** @type {Command} */ ({
* @param {!FileManager} fileManager FileManager to use.
*/
canExecute: function(event, fileManager) {
event.canExecute = fileManager.shouldShowDriveSettings();
event.canExecute = fileManager.shouldShowDriveSettings() &&
fileManager.volumeManager.getDriveConnectionState().
hasCellularNetworkAccess;
event.command.setHidden(!event.canExecute);
}
});
Expand Down

0 comments on commit 0f33fbe

Please sign in to comment.