diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 22:52:41 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-22 22:52:41 +0000 |
commit | a830cef7dcdadd9b016f3f0961de992fd0686f10 (patch) | |
tree | 84f8d46b80eefb7b92b3fef011fcbafca2f032c2 /chrome/browser | |
parent | 6c0a61ea15991256be5c53e4b32d15d141604e39 (diff) | |
download | chromium_src-a830cef7dcdadd9b016f3f0961de992fd0686f10.zip chromium_src-a830cef7dcdadd9b016f3f0961de992fd0686f10.tar.gz chromium_src-a830cef7dcdadd9b016f3f0961de992fd0686f10.tar.bz2 |
DOMUI Settings: UTH: Fix up the 'Web Content' section.
Added "Font Size Label" combo box with a list of font sizes.
BUG=63838
TEST=none
Review URL: http://codereview.chromium.org/6057003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69995 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
4 files changed, 96 insertions, 4 deletions
diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.cc b/chrome/browser/dom_ui/options/advanced_options_handler.cc index 9bb8ed0..9531d84 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.cc +++ b/chrome/browser/dom_ui/options/advanced_options_handler.cc @@ -122,6 +122,20 @@ void AdvancedOptionsHandler::GetLocalizedValues( l10n_util::GetStringUTF16(IDS_OPTIONS_FONTSETTINGS_INFO)); localized_strings->SetString("defaultZoomLevelLabel", l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL)); + localized_strings->SetString("defaultFontSizeLabel", + l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL)); + localized_strings->SetString("fontSizeLabelVerySmall", + l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL)); + localized_strings->SetString("fontSizeLabelSmall", + l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_SMALL)); + localized_strings->SetString("fontSizeLabelMedium", + l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM)); + localized_strings->SetString("fontSizeLabelLarge", + l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_LARGE)); + localized_strings->SetString("fontSizeLabelVeryLarge", + l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE)); + localized_strings->SetString("fontSizeLabelCustom", + l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM)); localized_strings->SetString("fontSettingsCustomizeFontsButton", l10n_util::GetStringUTF16( IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON)); @@ -180,6 +194,7 @@ void AdvancedOptionsHandler::Initialize() { SetupMetricsReportingCheckbox(); SetupMetricsReportingSettingVisibility(); SetupDefaultZoomLevel(); + SetupFontSizeLabel(); SetupDownloadLocationPath(); SetupAutoOpenFileTypesDisabledAttribute(); SetupProxySettingsSection(); @@ -215,6 +230,9 @@ DOMMessageHandler* AdvancedOptionsHandler::Attach(DOMUI* dom_ui) { 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); proxy_prefs_.reset( PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); @@ -233,6 +251,8 @@ void AdvancedOptionsHandler::RegisterMessages() { &AdvancedOptionsHandler::HandleAutoOpenButton)); dom_ui_->RegisterMessageCallback("defaultZoomLevelAction", NewCallback(this, &AdvancedOptionsHandler::HandleDefaultZoomLevel)); + dom_ui_->RegisterMessageCallback("defaultFontSizeAction", + NewCallback(this, &AdvancedOptionsHandler::HandleDefaultFontSize)); #if !defined(OS_CHROMEOS) dom_ui_->RegisterMessageCallback("metricsReportingCheckboxAction", NewCallback(this, @@ -293,6 +313,9 @@ void AdvancedOptionsHandler::Observe(NotificationType type, if (cloud_print_proxy_ui_enabled_) SetupCloudPrintProxySection(); #endif + } else if (*pref_name == prefs::kWebKitDefaultFontSize || + *pref_name == prefs::kWebKitDefaultFixedFontSize) { + SetupFontSizeLabel(); } } } @@ -353,6 +376,17 @@ void AdvancedOptionsHandler::HandleDefaultZoomLevel(const ListValue* args) { } } +void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { + int font_size; + if (ExtractIntegerValue(args, &font_size)) { + if (font_size > 0) { + default_font_size_.SetValue(font_size); + default_fixed_font_size_.SetValue(font_size); + SetupFontSizeLabel(); + } + } +} + #if defined(OS_WIN) void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( const ListValue* args) { @@ -492,6 +526,15 @@ void AdvancedOptionsHandler::SetupDefaultZoomLevel() { 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()); + FundamentalValue font_size(default_font_size_.GetValue()); + dom_ui_->CallJavascriptFunction( + L"options.AdvancedOptions.SetFontSize", fixed_font_size, + font_size); +} + void AdvancedOptionsHandler::SetupDownloadLocationPath() { StringValue value(default_download_location_.GetValue().value()); dom_ui_->CallJavascriptFunction( diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.h b/chrome/browser/dom_ui/options/advanced_options_handler.h index 6b1cb0a..0de52ab 100644 --- a/chrome/browser/dom_ui/options/advanced_options_handler.h +++ b/chrome/browser/dom_ui/options/advanced_options_handler.h @@ -60,6 +60,11 @@ class AdvancedOptionsHandler // 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. + void HandleDefaultFontSize(const ListValue* args); + #if defined(OS_WIN) // Callback for the "Check SSL Revocation" checkbox. This is needed so we // can support manual handling on Windows. @@ -117,6 +122,7 @@ class AdvancedOptionsHandler void SetupMetricsReportingSettingVisibility(); void SetupDefaultZoomLevel(); + void SetupFontSizeLabel(); // Setup the download path based on user preferences. void SetupDownloadLocationPath(); @@ -143,6 +149,8 @@ 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<PrefSetObserver> proxy_prefs_; scoped_ptr<OptionsManagedBannerHandler> banner_handler_; diff --git a/chrome/browser/resources/options/advanced_options.html b/chrome/browser/resources/options/advanced_options.html index 57d67ce..06b1473 100644 --- a/chrome/browser/resources/options/advanced_options.html +++ b/chrome/browser/resources/options/advanced_options.html @@ -63,10 +63,22 @@ <span i18n-content="tabsToLinksPref"></span> </label> </if> - <div><button id="fontSettingsCustomizeFontsButton" - i18n-content="fontSettingsCustomizeFontsButton"></button></div> <div> - <label style="display:inline;"> + <label> + <span i18n-content="defaultFontSizeLabel"></span> + <select id="defaultFontSize"> + <option value="9" i18n-content="fontSizeLabelVerySmall"></option> + <option value="12" i18n-content="fontSizeLabelSmall"></option> + <option value="16" i18n-content="fontSizeLabelMedium"></option> + <option value="20" i18n-content="fontSizeLabelLarge"></option> + <option value="24" i18n-content="fontSizeLabelVeryLarge"></option> + </select> + </label> + <button id="fontSettingsCustomizeFontsButton" + i18n-content="fontSettingsCustomizeFontsButton"></button> + </div> + <div> + <label> <span i18n-content="defaultZoomLevelLabel"></span> <select id="defaultZoomLevel"> <option value="-3">57%</option> diff --git a/chrome/browser/resources/options/advanced_options.js b/chrome/browser/resources/options/advanced_options.js index 051c3cf..0d52a90 100644 --- a/chrome/browser/resources/options/advanced_options.js +++ b/chrome/browser/resources/options/advanced_options.js @@ -59,7 +59,11 @@ var OptionsPage = options.OptionsPage; $('defaultZoomLevel').onchange = function(event) { chrome.send('defaultZoomLevelAction', [String(event.target.options[event.target.selectedIndex].value)]); - } + }; + $('defaultFontSize').onchange = function(event) { + chrome.send('defaultFontSizeAction', + [String(event.target.options[event.target.selectedIndex].value)]); + }; if (cr.isWindows || cr.isMac) { $('certificatesManageButton').onclick = function(event) { @@ -169,6 +173,31 @@ var OptionsPage = options.OptionsPage; selectCtl.selectedIndex = 4; // 100% }; + // Set the font size selected item. + AdvancedOptions.SetFontSize = function(fixed_font_size_value, + font_size_value) { + var selectCtl = $('defaultFontSize'); + if (fixed_font_size_value == font_size_value) { + for (var i = 0; i < selectCtl.options.length; i++) { + if (selectCtl.options[i].value == font_size_value) { + selectCtl.selectedIndex = i; + if ($('Custom')) + selectCtl.remove($('Custom').index); + return; + } + } + } + + // Add/Select Custom Option in the font size label list. + if (!$('Custom')) { + var option = new Option(localStrings.getString('fontSizeLabelCustom'), + -1, false, true); + option.setAttribute("id", "Custom"); + selectCtl.add(option); + } + $('Custom').selected = true; + }; + // Set the download path. AdvancedOptions.SetDownloadLocationPath = function(path) { if (!cr.isChromeOS) |