From 56d8cf25ee047078688c8af5917fcfbc63ac749b Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Thu, 13 Jan 2011 02:03:54 +0000 Subject: Tidy up where possible. This simplifies the zoom select and fixes the sync select. Also add more error checking. BUG=none TEST=manual Review URL: http://codereview.chromium.org/6174009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71284 0039d316-1c4b-4281-b951-d872f2087c98 --- .../dom_ui/options/advanced_options_handler.cc | 19 ------------- .../dom_ui/options/advanced_options_handler.h | 7 ----- .../browser/dom_ui/options/core_options_handler.cc | 21 ++++++++++++-- .../browser/dom_ui/options/core_options_handler.h | 1 + .../resources/options/advanced_options.html | 3 +- .../browser/resources/options/advanced_options.js | 16 ----------- .../browser/resources/options/browser_options.html | 4 +-- .../browser/resources/options/browser_options.js | 1 + .../resources/options/clear_browser_data.html | 2 +- .../resources/options/clear_browser_data.js | 3 -- .../browser/resources/options/font_settings.html | 7 +++-- .../resources/options/personal_options.html | 2 +- chrome/browser/resources/options/pref_ui.js | 32 ++++++++++++++++------ chrome/browser/resources/options/preferences.js | 13 +++++++++ 14 files changed, 68 insertions(+), 63 deletions(-) diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.cc b/chrome/browser/dom_ui/options/advanced_options_handler.cc index 17c1d90..44033b7c 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/options/advanced_options_handler.cc @@ -200,7 +200,6 @@ void AdvancedOptionsHandler::Initialize() { DCHECK(dom_ui_); SetupMetricsReportingCheckbox(); SetupMetricsReportingSettingVisibility(); - SetupDefaultZoomLevel(); SetupFontSizeLabel(); SetupDownloadLocationPath(); SetupAutoOpenFileTypesDisabledAttribute(); @@ -244,7 +243,6 @@ DOMMessageHandler* AdvancedOptionsHandler::Attach(DOMUI* dom_ui) { default_download_location_.Init(prefs::kDownloadDefaultDirectory, prefs, this); auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); - default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, prefs, this); @@ -264,8 +262,6 @@ void AdvancedOptionsHandler::RegisterMessages() { dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", NewCallback(this, &AdvancedOptionsHandler::HandleAutoOpenButton)); - dom_ui_->RegisterMessageCallback("defaultZoomLevelAction", - NewCallback(this, &AdvancedOptionsHandler::HandleDefaultZoomLevel)); dom_ui_->RegisterMessageCallback("defaultFontSizeAction", NewCallback(this, &AdvancedOptionsHandler::HandleDefaultFontSize)); #if !defined(OS_CHROMEOS) @@ -387,14 +383,6 @@ void AdvancedOptionsHandler::HandleMetricsReportingCheckbox( #endif } -void AdvancedOptionsHandler::HandleDefaultZoomLevel(const ListValue* args) { - UserMetricsRecordAction(UserMetricsAction("Options_ChangeDefaultZoomLevel")); - int zoom_level; - if (ExtractIntegerValue(args, &zoom_level)) { - default_zoom_level_.SetValue(static_cast(zoom_level)); - } -} - void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { int font_size; if (ExtractIntegerValue(args, &font_size)) { @@ -554,13 +542,6 @@ void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() { #endif } -void AdvancedOptionsHandler::SetupDefaultZoomLevel() { - // We're only interested in integer values, so convert to int. - FundamentalValue value(static_cast(default_zoom_level_.GetValue())); - dom_ui_->CallJavascriptFunction( - L"options.AdvancedOptions.SetDefaultZoomLevel", value); -} - void AdvancedOptionsHandler::SetupFontSizeLabel() { // We're only interested in integer values, so convert to int. FundamentalValue fixed_font_size(default_fixed_font_size_.GetValue()); diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.h b/chrome/browser/dom_ui/options/advanced_options_handler.h index 0b9f7ad..033cb85 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.h +++ b/chrome/browser/dom_ui/options/advanced_options_handler.h @@ -55,11 +55,6 @@ class AdvancedOptionsHandler // if the user toggles the metrics reporting checkbox. void HandleMetricsReportingCheckbox(const ListValue* args); - // Callback for the "defaultZoomLevelAction" message. This is called if the - // user changes the default zoom level. |args| is an array that contains - // one item, the zoom level as a numeric value. - void HandleDefaultZoomLevel(const ListValue* args); - // Callback for the "defaultFontSizeAction" message. This is called if the // user changes the default font size. |args| is an array that contains // one item, the font size as a numeric value. @@ -134,7 +129,6 @@ class AdvancedOptionsHandler // Setup the visibility for the metrics reporting setting. void SetupMetricsReportingSettingVisibility(); - void SetupDefaultZoomLevel(); void SetupFontSizeLabel(); // Setup the download path based on user preferences. @@ -161,7 +155,6 @@ class AdvancedOptionsHandler FilePathPrefMember default_download_location_; StringPrefMember auto_open_files_; - RealPrefMember default_zoom_level_; IntegerPrefMember default_font_size_; IntegerPrefMember default_fixed_font_size_; scoped_ptr proxy_prefs_; diff --git a/chrome/browser/dom_ui/options/core_options_handler.cc b/chrome/browser/dom_ui/options/core_options_handler.cc index ab8a6d4..8fc118d 100644 --- a/chrome/browser/dom_ui/options/core_options_handler.cc +++ b/chrome/browser/dom_ui/options/core_options_handler.cc @@ -135,6 +135,8 @@ void CoreOptionsHandler::RegisterMessages() { NewCallback(this, &CoreOptionsHandler::HandleSetBooleanPref)); dom_ui_->RegisterMessageCallback("setIntegerPref", NewCallback(this, &CoreOptionsHandler::HandleSetIntegerPref)); + dom_ui_->RegisterMessageCallback("setRealPref", + NewCallback(this, &CoreOptionsHandler::HandleSetRealPref)); dom_ui_->RegisterMessageCallback("setStringPref", NewCallback(this, &CoreOptionsHandler::HandleSetStringPref)); dom_ui_->RegisterMessageCallback("setObjectPref", @@ -181,14 +183,25 @@ void CoreOptionsHandler::SetPref(const std::string& pref_name, case Value::TYPE_BOOLEAN: pref_service->SetBoolean(pref_name.c_str(), value_string == "true"); break; + case Value::TYPE_INTEGER: int int_value; - if (base::StringToInt(value_string, &int_value)) - pref_service->SetInteger(pref_name.c_str(), int_value); + CHECK(base::StringToInt(value_string, &int_value)); + pref_service->SetInteger(pref_name.c_str(), int_value); + + break; + + case Value::TYPE_REAL: + double double_value; + CHECK(base::StringToDouble(value_string, &double_value)); + pref_service->SetReal(pref_name.c_str(), double_value); + break; + case Value::TYPE_STRING: pref_service->SetString(pref_name.c_str(), value_string); break; + default: NOTREACHED(); return; @@ -299,6 +312,10 @@ void CoreOptionsHandler::HandleSetIntegerPref(const ListValue* args) { HandleSetPref(args, Value::TYPE_INTEGER); } +void CoreOptionsHandler::HandleSetRealPref(const ListValue* args) { + HandleSetPref(args, Value::TYPE_REAL); +} + void CoreOptionsHandler::HandleSetStringPref(const ListValue* args) { HandleSetPref(args, Value::TYPE_STRING); } diff --git a/chrome/browser/dom_ui/options/core_options_handler.h b/chrome/browser/dom_ui/options/core_options_handler.h index 7860525..cece8ae 100644 --- a/chrome/browser/dom_ui/options/core_options_handler.h +++ b/chrome/browser/dom_ui/options/core_options_handler.h @@ -83,6 +83,7 @@ class CoreOptionsHandler : public OptionsPageUIHandler { // item 2 - name of the metric identifier (optional). void HandleSetBooleanPref(const ListValue* args); void HandleSetIntegerPref(const ListValue* args); + void HandleSetRealPref(const ListValue* args); void HandleSetStringPref(const ListValue* args); void HandleSetObjectPref(const ListValue* args); diff --git a/chrome/browser/resources/options/advanced_options.html b/chrome/browser/resources/options/advanced_options.html index c370bfa..256ac39 100644 --- a/chrome/browser/resources/options/advanced_options.html +++ b/chrome/browser/resources/options/advanced_options.html @@ -80,7 +80,8 @@