diff options
author | zvorygin@chromium.org <zvorygin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 11:43:57 +0000 |
---|---|---|
committer | zvorygin@chromium.org <zvorygin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 11:43:57 +0000 |
commit | 8b3e1646d50026a5c9a2326e22c6156a9a4b9a3a (patch) | |
tree | a0626a0024e0facadd21d8b0ea9c993b3909c32f /chrome | |
parent | fb42b4501886cedc1a43deaddb1fa008bee709cf (diff) | |
download | chromium_src-8b3e1646d50026a5c9a2326e22c6156a9a4b9a3a.zip chromium_src-8b3e1646d50026a5c9a2326e22c6156a9a4b9a3a.tar.gz chromium_src-8b3e1646d50026a5c9a2326e22c6156a9a4b9a3a.tar.bz2 |
FileBrowser: Added setting button for GData in filebrowser.
R=kaznacheev@chromium.org
BUG=chromium-os:27972
TEST=Navigate to GData and observe settings button with menu in top-right corner.
Review URL: https://chromiumcodereview.appspot.com/9875020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130596 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/extensions/file_browser_private_api.cc | 42 | ||||
-rw-r--r-- | chrome/browser/chromeos/extensions/file_browser_private_api.h | 17 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_function_registry.cc | 2 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/css/file_manager.css | 15 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/images/settings_button.png | bin | 0 -> 471 bytes | |||
-rw-r--r-- | chrome/browser/resources/file_manager/images/settings_button_pressed.png | bin | 0 -> 936 bytes | |||
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_manager.js | 43 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/mock_chrome.js | 6 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/main.html | 11 | ||||
-rw-r--r-- | chrome/common/extensions/api/fileBrowserPrivate.json | 34 |
10 files changed, 169 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.cc b/chrome/browser/chromeos/extensions/file_browser_private_api.cc index a4966df..c03d7d0 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.cc +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.cc @@ -34,6 +34,7 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_icon_set.h" #include "chrome/common/extensions/file_browser_handler.h" +#include "chrome/common/pref_names.h" #include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" @@ -1390,6 +1391,9 @@ bool FileDialogStringsFunction::RunImpl() { SET_STRING(IDS_FILE_BROWSER, UNSUPPORTED_FILESYSTEM_WARNING); SET_STRING(IDS_FILE_BROWSER, FORMATTING_WARNING); + SET_STRING(IDS_FILE_BROWSER, GDATA_SHOW_HOSTED_FILES_OPTION); + SET_STRING(IDS_FILE_BROWSER, GDATA_MOBILE_CONNECTION_OPTION); + SET_STRING(IDS_FILE_BROWSER, SELECT_FOLDER_TITLE); SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_FILE_TITLE); SET_STRING(IDS_FILE_BROWSER, SELECT_OPEN_MULTI_FILE_TITLE); @@ -1931,3 +1935,41 @@ void TransferFileFunction::OnTransferCompleted( SendResponse(false); } } + +// Read setting value. +bool GetGDataPreferencesFunction::RunImpl() { + scoped_ptr<DictionaryValue> value(new DictionaryValue()); + + const PrefService* service = profile_->GetPrefs(); + + value->SetBoolean("cellularDisabled", + service->GetBoolean(prefs::kDisableGDataOverCellular)); + + value->SetBoolean("hostedFilesDisabled", + service->GetBoolean(prefs::kDisableGDataHostedFiles)); + + result_.reset(value.release()); + return true; +} + +// Write setting value. +bool SetGDataPreferencesFunction::RunImpl() { + base::DictionaryValue* value = NULL; + + if (!args_->GetDictionary(0, &value) || !value) + return false; + + PrefService* service = profile_->GetPrefs(); + + bool tmp; + + if (value->GetBoolean("cellularDisabled", &tmp)) { + service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); + } + + if (value->GetBoolean("hostedFilesDisabled", &tmp)) { + service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); + } + + return true; +} diff --git a/chrome/browser/chromeos/extensions/file_browser_private_api.h b/chrome/browser/chromeos/extensions/file_browser_private_api.h index 231a60c..7f21030 100644 --- a/chrome/browser/chromeos/extensions/file_browser_private_api.h +++ b/chrome/browser/chromeos/extensions/file_browser_private_api.h @@ -14,6 +14,7 @@ #include "base/platform_file.h" #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" #include "chrome/browser/extensions/extension_function.h" +#include "chrome/browser/prefs/pref_service.h" #include "googleurl/src/url_util.h" class GURL; @@ -567,4 +568,20 @@ class TransferFileFunction : public FileBrowserFunction { DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.transferFile"); }; +// Read setting value. +class GetGDataPreferencesFunction : public SyncExtensionFunction { + protected: + virtual bool RunImpl() OVERRIDE; + private: + DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getGDataPreferences"); +}; + +// Write setting value. +class SetGDataPreferencesFunction : public SyncExtensionFunction { + protected: + virtual bool RunImpl() OVERRIDE; + private: + DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.setGDataPreferences"); +}; + #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ diff --git a/chrome/browser/extensions/extension_function_registry.cc b/chrome/browser/extensions/extension_function_registry.cc index 450baed..1546bef 100644 --- a/chrome/browser/extensions/extension_function_registry.cc +++ b/chrome/browser/extensions/extension_function_registry.cc @@ -375,6 +375,8 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<GetFileTransfersFunction>(); RegisterFunction<CancelFileTransfersFunction>(); RegisterFunction<TransferFileFunction>(); + RegisterFunction<GetGDataPreferencesFunction>(); + RegisterFunction<SetGDataPreferencesFunction>(); // Mediaplayer RegisterFunction<PlayMediaplayerFunction>(); diff --git a/chrome/browser/resources/file_manager/css/file_manager.css b/chrome/browser/resources/file_manager/css/file_manager.css index 3373519..5fd1c30 100644 --- a/chrome/browser/resources/file_manager/css/file_manager.css +++ b/chrome/browser/resources/file_manager/css/file_manager.css @@ -507,6 +507,21 @@ button.thumbnail-view[disabled] { background-image: url('../images/icon_thumb_view_on.png'); } +button.settings { + display: none; + margin-left: 8px; + width: 57px; +} + +[gdata] button.settings { + background-image: url('../images/settings_button.png'); + display: block; +} + +[gdata] button.settings:active { + background-image: url('../images/settings_button_pressed.png'); +} + .filelist-panel { -webkit-box-flex: 1; -webkit-box-orient: vertical; diff --git a/chrome/browser/resources/file_manager/images/settings_button.png b/chrome/browser/resources/file_manager/images/settings_button.png Binary files differnew file mode 100644 index 0000000..a11d3c2 --- /dev/null +++ b/chrome/browser/resources/file_manager/images/settings_button.png diff --git a/chrome/browser/resources/file_manager/images/settings_button_pressed.png b/chrome/browser/resources/file_manager/images/settings_button_pressed.png Binary files differnew file mode 100644 index 0000000..02b2cf8 --- /dev/null +++ b/chrome/browser/resources/file_manager/images/settings_button_pressed.png diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index b9be954..dc64075 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -622,6 +622,10 @@ FileManager.prototype = { this.dialogDom_.querySelector('.roots-context-menu'); cr.ui.Menu.decorate(this.rootsContextMenu_); + this.docsSettingsMenu_ = + this.dialogDom_.querySelector('#docs-settings'); + cr.ui.Menu.decorate(this.docsSettingsMenu_); + this.document_.addEventListener('command', this.onCommand_.bind(this)); } @@ -659,6 +663,7 @@ FileManager.prototype = { this.butter_ = this.dialogDom_.querySelector('.butter-bar'); this.unmountedPanel_ = this.dialogDom_.querySelector('.unmounted-panel'); + cr.ui.decorate('button[menu]', cr.ui.MenuButton); cr.ui.Table.decorate(this.table_); cr.ui.Grid.decorate(this.grid_); @@ -716,6 +721,23 @@ FileManager.prototype = { this.dialogDom_.querySelector('button.thumbnail-view').addEventListener( 'click', this.onThumbnailViewButtonClick_.bind(this)); + this.syncButton = this.dialogDom_.querySelector('#gdata-sync-settings'); + this.syncButton.addEventListener('click', + this.onGDataPrefClick_.bind(this, 'cellularDisabled')); + + this.hostedButton = this.dialogDom_.querySelector('#gdata-hosted-settings'); + this.hostedButton.addEventListener('click', + this.onGDataPrefClick_.bind(this, 'hostedFilesDisabled')); + + chrome.fileBrowserPrivate.getGDataPreferences( + function (result) { + if (!result.cellularDisabled) + this.syncButton.setAttribute('checked', 'checked'); + if (!result.hostedFilesDisabled) + this.hostedButton.setAttribute('checked', 'checked'); + }.bind(this) + ); + cr.ui.ComboButton.decorate(this.taskItems_); this.taskItems_.addEventListener('select', this.onTaskItemClicked_.bind(this)); @@ -4644,5 +4666,24 @@ FileManager.prototype = { setTimeout(doCheck, 1000 * 60); } } - } + }; + + /** + * Handler invoked on preference setting in gdata context menu. + * @param {String} pref The preference to alter. + * @param {Event} event The click event. + */ + FileManager.prototype.onGDataPrefClick_ = function(pref, event) { + var oldValue = event.target.hasAttribute('checked'); + var changeInfo = {}; + changeInfo[pref] = oldValue; + + chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); + + if (oldValue) { + event.target.removeAttribute('checked'); + } else { + event.target.setAttribute('checked', 'checked'); + } + }; })(); diff --git a/chrome/browser/resources/file_manager/js/mock_chrome.js b/chrome/browser/resources/file_manager/js/mock_chrome.js index 3871e1a..a4ff7f2 100644 --- a/chrome/browser/resources/file_manager/js/mock_chrome.js +++ b/chrome/browser/resources/file_manager/js/mock_chrome.js @@ -429,6 +429,12 @@ chrome.fileBrowserPrivate = { COPY_BUTTON_LABEL: 'Copy', CUT_BUTTON_LABEL: 'Cut', + UNMOUNT_DEVICE_BUTTON_LABEL: 'Unmount', + FORMAT_DEVICE_BUTTON_LABEL: 'Format', + + GDATA_MOBILE_CONNECTION_OPTION: 'Do not use mobile data for sync', + GDATA_SHOW_HOSTED_FILES_OPTION: 'Show Google Docs files', + PASTE_ITEMS_REMAINING: 'Pasting $1 items', PASTE_CANCELLED: 'Paste cancelled.', PASTE_TARGET_EXISTS_ERROR: 'Paste failed, item exists: $1', diff --git a/chrome/browser/resources/file_manager/main.html b/chrome/browser/resources/file_manager/main.html index 18a862bf..da07620 100644 --- a/chrome/browser/resources/file_manager/main.html +++ b/chrome/browser/resources/file_manager/main.html @@ -57,6 +57,7 @@ <script src="../shared/js/i18n_template.js"></script> <script src="../shared/js/cr.js"></script> + <script src="../shared/js/event_tracker.js"></script> <script src="../shared/js/cr/ui.js"></script> <script src="../shared/js/cr/event_target.js"></script> <script src="../shared/js/cr/ui/array_data_model.js"></script> @@ -82,6 +83,7 @@ <script src="../shared/js/cr/ui/position_util.js"></script> <script src="../shared/js/cr/ui/menu_item.js"></script> <script src="../shared/js/cr/ui/menu.js"></script> + <script src="../shared/js/cr/ui/menu_button.js"></script> <script src="../shared/js/cr/ui/context_menu_handler.js"></script> <script src="js/combobutton.js"></script> @@ -147,6 +149,13 @@ <menuitem command='#unmount'></menuitem> <menuitem command='#format'></menuitem> </menu> + + <menu id=docs-settings> + <menuitem id=gdata-sync-settings + i18n-content=GDATA_MOBILE_CONNECTION_OPTION></menuitem> + <menuitem id=gdata-hosted-settings + i18n-content=GDATA_SHOW_HOSTED_FILES_OPTION></menuitem> + </menu> <!-- TODO(bshe): Remove isAura flag after all chromeos use aura. --> <if expr="pp_ifdef('use_aura')"> @@ -177,6 +186,8 @@ <!-- The outter div is a hack to remove margin between buttons. --> <div><button class="detail-view" tabindex="4" disabled></button></div> <div><button class="thumbnail-view" tabindex="5"></button></div> + <div visibleif='this.dialogType_ == "full-page"'><button + menu="#docs-settings" class="settings" tabindex="6"></button></div> </div> <div class=dialog-body> <div class=filelist-panel> diff --git a/chrome/common/extensions/api/fileBrowserPrivate.json b/chrome/common/extensions/api/fileBrowserPrivate.json index 1195184a..179a934 100644 --- a/chrome/common/extensions/api/fileBrowserPrivate.json +++ b/chrome/common/extensions/api/fileBrowserPrivate.json @@ -816,6 +816,40 @@ ] } ] + }, + { + "name": "getGDataPreferences", + "description": "Retrieves File Browser preference.", + "parameters": [ + { + "name": "callback", + "type": "function", + "parameters": [ + { + "name": "result", + "type": "object", + "properties": { + "cellularDisabled": {"type":"boolean"}, + "hostedFilesDisabled": {"type":"boolean"} + } + } + ] + } + ] + }, + { + "name": "setGDataPreferences", + "description": "Sets File Browser preference.", + "parameters": [ + { + "name": "changeInfo", + "type": "object", + "properties": { + "cellularDisabled": {"type":"boolean", "optional":true}, + "hostedFilesDisabled": {"type":"boolean", "optional":true} + } + } + ] } ], "events": [ |