From 0f33fbe7305639dc7696134b12a3355fb0e50f2e Mon Sep 17 00:00:00 2001 From: hirono Date: Sun, 16 Nov 2014 19:17:34 -0800 Subject: [PATCH] Files.app: Show the drive options always in gear menu. 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} --- .../chromeos/extensions/file_manager/private_api_drive.cc | 6 ++++++ chrome/common/extensions/api/file_manager_private.idl | 4 ++++ .../file_manager/background/js/volume_manager.js | 3 ++- ui/file_manager/file_manager/foreground/js/file_manager.js | 2 +- .../file_manager/foreground/js/file_manager_commands.js | 4 +++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc index ae22c0cd661a..f08783754538 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc @@ -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" @@ -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); diff --git a/chrome/common/extensions/api/file_manager_private.idl b/chrome/common/extensions/api/file_manager_private.idl index a8c92bba0708..a1bad67918f1 100644 --- a/chrome/common/extensions/api/file_manager_private.idl +++ b/chrome/common/extensions/api/file_manager_private.idl @@ -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 diff --git a/ui/file_manager/file_manager/background/js/volume_manager.js b/ui/file_manager/file_manager/background/js/volume_manager.js index 596906d2e1b7..5f957315291e 100644 --- a/ui/file_manager/file_manager/background/js/volume_manager.js +++ b/ui/file_manager/file_manager/background/js/volume_manager.js @@ -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( diff --git a/ui/file_manager/file_manager/foreground/js/file_manager.js b/ui/file_manager/file_manager/foreground/js/file_manager.js index 47eacd22eed9..027cb80ad7e8 100644 --- a/ui/file_manager/file_manager/foreground/js/file_manager.js +++ b/ui/file_manager/file_manager/foreground/js/file_manager.js @@ -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(); }; /** diff --git a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js index b2e67383e574..3b1bf35ec005 100644 --- a/ui/file_manager/file_manager/foreground/js/file_manager_commands.js +++ b/ui/file_manager/file_manager/foreground/js/file_manager_commands.js @@ -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); } });