OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/dom_ui/options/advanced_options_handler.h" | 5 #include "chrome/browser/dom_ui/options/advanced_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 localized_strings->SetString("linkDoctorPref", | 115 localized_strings->SetString("linkDoctorPref", |
116 l10n_util::GetStringUTF16(IDS_OPTIONS_LINKDOCTOR_PREF)); | 116 l10n_util::GetStringUTF16(IDS_OPTIONS_LINKDOCTOR_PREF)); |
117 localized_strings->SetString("suggestPref", | 117 localized_strings->SetString("suggestPref", |
118 l10n_util::GetStringUTF16(IDS_OPTIONS_SUGGEST_PREF)); | 118 l10n_util::GetStringUTF16(IDS_OPTIONS_SUGGEST_PREF)); |
119 localized_strings->SetString("tabsToLinksPref", | 119 localized_strings->SetString("tabsToLinksPref", |
120 l10n_util::GetStringUTF16(IDS_OPTIONS_TABS_TO_LINKS_PREF)); | 120 l10n_util::GetStringUTF16(IDS_OPTIONS_TABS_TO_LINKS_PREF)); |
121 localized_strings->SetString("fontSettingsInfo", | 121 localized_strings->SetString("fontSettingsInfo", |
122 l10n_util::GetStringUTF16(IDS_OPTIONS_FONTSETTINGS_INFO)); | 122 l10n_util::GetStringUTF16(IDS_OPTIONS_FONTSETTINGS_INFO)); |
123 localized_strings->SetString("defaultZoomLevelLabel", | 123 localized_strings->SetString("defaultZoomLevelLabel", |
124 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL)); | 124 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL)); |
| 125 localized_strings->SetString("defaultFontSizeLabel", |
| 126 l10n_util::GetStringUTF16(IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL)); |
| 127 localized_strings->SetString("fontSizeLabelVerySmall", |
| 128 l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL)); |
| 129 localized_strings->SetString("fontSizeLabelSmall", |
| 130 l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_SMALL)); |
| 131 localized_strings->SetString("fontSizeLabelMedium", |
| 132 l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM)); |
| 133 localized_strings->SetString("fontSizeLabelLarge", |
| 134 l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_LARGE)); |
| 135 localized_strings->SetString("fontSizeLabelVeryLarge", |
| 136 l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE)); |
| 137 localized_strings->SetString("fontSizeLabelCustom", |
| 138 l10n_util::GetStringUTF16(IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM)); |
125 localized_strings->SetString("fontSettingsCustomizeFontsButton", | 139 localized_strings->SetString("fontSettingsCustomizeFontsButton", |
126 l10n_util::GetStringUTF16( | 140 l10n_util::GetStringUTF16( |
127 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON)); | 141 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON)); |
128 localized_strings->SetString("advancedSectionTitlePrivacy", | 142 localized_strings->SetString("advancedSectionTitlePrivacy", |
129 dom_options_util::StripColon( | 143 dom_options_util::StripColon( |
130 l10n_util::GetStringUTF16( | 144 l10n_util::GetStringUTF16( |
131 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY))); | 145 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY))); |
132 localized_strings->SetString("advancedSectionTitleContent", | 146 localized_strings->SetString("advancedSectionTitleContent", |
133 dom_options_util::StripColon( | 147 dom_options_util::StripColon( |
134 l10n_util::GetStringUTF16( | 148 l10n_util::GetStringUTF16( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 l10n_util::GetStringUTF16(IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE)); | 187 l10n_util::GetStringUTF16(IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE)); |
174 localized_strings->SetString("disableWebServices", | 188 localized_strings->SetString("disableWebServices", |
175 l10n_util::GetStringUTF16(IDS_OPTIONS_DISABLE_WEB_SERVICES)); | 189 l10n_util::GetStringUTF16(IDS_OPTIONS_DISABLE_WEB_SERVICES)); |
176 } | 190 } |
177 | 191 |
178 void AdvancedOptionsHandler::Initialize() { | 192 void AdvancedOptionsHandler::Initialize() { |
179 DCHECK(dom_ui_); | 193 DCHECK(dom_ui_); |
180 SetupMetricsReportingCheckbox(); | 194 SetupMetricsReportingCheckbox(); |
181 SetupMetricsReportingSettingVisibility(); | 195 SetupMetricsReportingSettingVisibility(); |
182 SetupDefaultZoomLevel(); | 196 SetupDefaultZoomLevel(); |
| 197 SetupFontSizeLabel(); |
183 SetupDownloadLocationPath(); | 198 SetupDownloadLocationPath(); |
184 SetupAutoOpenFileTypesDisabledAttribute(); | 199 SetupAutoOpenFileTypesDisabledAttribute(); |
185 SetupProxySettingsSection(); | 200 SetupProxySettingsSection(); |
186 #if defined(OS_WIN) | 201 #if defined(OS_WIN) |
187 SetupSSLConfigSettings(); | 202 SetupSSLConfigSettings(); |
188 #endif | 203 #endif |
189 #if !defined(OS_CHROMEOS) | 204 #if !defined(OS_CHROMEOS) |
190 if (cloud_print_proxy_ui_enabled_) { | 205 if (cloud_print_proxy_ui_enabled_) { |
191 SetupCloudPrintProxySection(); | 206 SetupCloudPrintProxySection(); |
192 RefreshCloudPrintStatusFromService(); | 207 RefreshCloudPrintStatusFromService(); |
(...skipping 15 matching lines...) Expand all Loading... |
208 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); | 223 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); |
209 #if !defined(OS_CHROMEOS) | 224 #if !defined(OS_CHROMEOS) |
210 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, | 225 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, |
211 g_browser_process->local_state(), this); | 226 g_browser_process->local_state(), this); |
212 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); | 227 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); |
213 #endif | 228 #endif |
214 default_download_location_.Init(prefs::kDownloadDefaultDirectory, | 229 default_download_location_.Init(prefs::kDownloadDefaultDirectory, |
215 prefs, this); | 230 prefs, this); |
216 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); | 231 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); |
217 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); | 232 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); |
| 233 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); |
| 234 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, prefs, |
| 235 this); |
218 proxy_prefs_.reset( | 236 proxy_prefs_.reset( |
219 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); | 237 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
220 | 238 |
221 // Return result from the superclass. | 239 // Return result from the superclass. |
222 return handler; | 240 return handler; |
223 } | 241 } |
224 | 242 |
225 void AdvancedOptionsHandler::RegisterMessages() { | 243 void AdvancedOptionsHandler::RegisterMessages() { |
226 // Setup handlers specific to this panel. | 244 // Setup handlers specific to this panel. |
227 DCHECK(dom_ui_); | 245 DCHECK(dom_ui_); |
228 dom_ui_->RegisterMessageCallback("selectDownloadLocation", | 246 dom_ui_->RegisterMessageCallback("selectDownloadLocation", |
229 NewCallback(this, | 247 NewCallback(this, |
230 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); | 248 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); |
231 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", | 249 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", |
232 NewCallback(this, | 250 NewCallback(this, |
233 &AdvancedOptionsHandler::HandleAutoOpenButton)); | 251 &AdvancedOptionsHandler::HandleAutoOpenButton)); |
234 dom_ui_->RegisterMessageCallback("defaultZoomLevelAction", | 252 dom_ui_->RegisterMessageCallback("defaultZoomLevelAction", |
235 NewCallback(this, &AdvancedOptionsHandler::HandleDefaultZoomLevel)); | 253 NewCallback(this, &AdvancedOptionsHandler::HandleDefaultZoomLevel)); |
| 254 dom_ui_->RegisterMessageCallback("defaultFontSizeAction", |
| 255 NewCallback(this, &AdvancedOptionsHandler::HandleDefaultFontSize)); |
236 #if !defined(OS_CHROMEOS) | 256 #if !defined(OS_CHROMEOS) |
237 dom_ui_->RegisterMessageCallback("metricsReportingCheckboxAction", | 257 dom_ui_->RegisterMessageCallback("metricsReportingCheckboxAction", |
238 NewCallback(this, | 258 NewCallback(this, |
239 &AdvancedOptionsHandler::HandleMetricsReportingCheckbox)); | 259 &AdvancedOptionsHandler::HandleMetricsReportingCheckbox)); |
240 #endif | 260 #endif |
241 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 261 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
242 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", | 262 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", |
243 NewCallback(this, | 263 NewCallback(this, |
244 &AdvancedOptionsHandler::ShowManageSSLCertificates)); | 264 &AdvancedOptionsHandler::ShowManageSSLCertificates)); |
245 #endif | 265 #endif |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 SetupDownloadLocationPath(); | 306 SetupDownloadLocationPath(); |
287 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { | 307 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { |
288 SetupAutoOpenFileTypesDisabledAttribute(); | 308 SetupAutoOpenFileTypesDisabledAttribute(); |
289 } else if (proxy_prefs_->IsObserved(*pref_name)) { | 309 } else if (proxy_prefs_->IsObserved(*pref_name)) { |
290 SetupProxySettingsSection(); | 310 SetupProxySettingsSection(); |
291 } else if (*pref_name == prefs::kCloudPrintEmail) { | 311 } else if (*pref_name == prefs::kCloudPrintEmail) { |
292 #if !defined(OS_CHROMEOS) | 312 #if !defined(OS_CHROMEOS) |
293 if (cloud_print_proxy_ui_enabled_) | 313 if (cloud_print_proxy_ui_enabled_) |
294 SetupCloudPrintProxySection(); | 314 SetupCloudPrintProxySection(); |
295 #endif | 315 #endif |
| 316 } else if (*pref_name == prefs::kWebKitDefaultFontSize || |
| 317 *pref_name == prefs::kWebKitDefaultFixedFontSize) { |
| 318 SetupFontSizeLabel(); |
296 } | 319 } |
297 } | 320 } |
298 } | 321 } |
299 | 322 |
300 void AdvancedOptionsHandler::HandleSelectDownloadLocation( | 323 void AdvancedOptionsHandler::HandleSelectDownloadLocation( |
301 const ListValue* args) { | 324 const ListValue* args) { |
302 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); | 325 PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs(); |
303 select_folder_dialog_ = SelectFileDialog::Create(this); | 326 select_folder_dialog_ = SelectFileDialog::Create(this); |
304 select_folder_dialog_->SelectFile( | 327 select_folder_dialog_->SelectFile( |
305 SelectFileDialog::SELECT_FOLDER, | 328 SelectFileDialog::SELECT_FOLDER, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 } | 369 } |
347 | 370 |
348 void AdvancedOptionsHandler::HandleDefaultZoomLevel(const ListValue* args) { | 371 void AdvancedOptionsHandler::HandleDefaultZoomLevel(const ListValue* args) { |
349 UserMetricsRecordAction(UserMetricsAction("Options_ChangeDefaultZoomLevel")); | 372 UserMetricsRecordAction(UserMetricsAction("Options_ChangeDefaultZoomLevel")); |
350 int zoom_level; | 373 int zoom_level; |
351 if (ExtractIntegerValue(args, &zoom_level)) { | 374 if (ExtractIntegerValue(args, &zoom_level)) { |
352 default_zoom_level_.SetValue(static_cast<double>(zoom_level)); | 375 default_zoom_level_.SetValue(static_cast<double>(zoom_level)); |
353 } | 376 } |
354 } | 377 } |
355 | 378 |
| 379 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { |
| 380 int font_size; |
| 381 if (ExtractIntegerValue(args, &font_size)) { |
| 382 if (font_size > 0) { |
| 383 default_font_size_.SetValue(font_size); |
| 384 default_fixed_font_size_.SetValue(font_size); |
| 385 SetupFontSizeLabel(); |
| 386 } |
| 387 } |
| 388 } |
| 389 |
356 #if defined(OS_WIN) | 390 #if defined(OS_WIN) |
357 void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( | 391 void AdvancedOptionsHandler::HandleCheckRevocationCheckbox( |
358 const ListValue* args) { | 392 const ListValue* args) { |
359 std::string checked_str = WideToUTF8(ExtractStringValue(args)); | 393 std::string checked_str = WideToUTF8(ExtractStringValue(args)); |
360 bool enabled = (checked_str == "true"); | 394 bool enabled = (checked_str == "true"); |
361 std::string metric = | 395 std::string metric = |
362 (enabled ? "Options_CheckCertRevocation_Enable" | 396 (enabled ? "Options_CheckCertRevocation_Enable" |
363 : "Options_CheckCertRevocation_Disable"); | 397 : "Options_CheckCertRevocation_Disable"); |
364 UserMetricsRecordAction(UserMetricsAction(metric.c_str())); | 398 UserMetricsRecordAction(UserMetricsAction(metric.c_str())); |
365 net::SSLConfigServiceWin::SetRevCheckingEnabled(enabled); | 399 net::SSLConfigServiceWin::SetRevCheckingEnabled(enabled); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 #endif | 519 #endif |
486 } | 520 } |
487 | 521 |
488 void AdvancedOptionsHandler::SetupDefaultZoomLevel() { | 522 void AdvancedOptionsHandler::SetupDefaultZoomLevel() { |
489 // We're only interested in integer values, so convert to int. | 523 // We're only interested in integer values, so convert to int. |
490 FundamentalValue value(static_cast<int>(default_zoom_level_.GetValue())); | 524 FundamentalValue value(static_cast<int>(default_zoom_level_.GetValue())); |
491 dom_ui_->CallJavascriptFunction( | 525 dom_ui_->CallJavascriptFunction( |
492 L"options.AdvancedOptions.SetDefaultZoomLevel", value); | 526 L"options.AdvancedOptions.SetDefaultZoomLevel", value); |
493 } | 527 } |
494 | 528 |
| 529 void AdvancedOptionsHandler::SetupFontSizeLabel() { |
| 530 // We're only interested in integer values, so convert to int. |
| 531 FundamentalValue fixed_font_size(default_fixed_font_size_.GetValue()); |
| 532 FundamentalValue font_size(default_font_size_.GetValue()); |
| 533 dom_ui_->CallJavascriptFunction( |
| 534 L"options.AdvancedOptions.SetFontSize", fixed_font_size, |
| 535 font_size); |
| 536 } |
| 537 |
495 void AdvancedOptionsHandler::SetupDownloadLocationPath() { | 538 void AdvancedOptionsHandler::SetupDownloadLocationPath() { |
496 StringValue value(default_download_location_.GetValue().value()); | 539 StringValue value(default_download_location_.GetValue().value()); |
497 dom_ui_->CallJavascriptFunction( | 540 dom_ui_->CallJavascriptFunction( |
498 L"options.AdvancedOptions.SetDownloadLocationPath", value); | 541 L"options.AdvancedOptions.SetDownloadLocationPath", value); |
499 } | 542 } |
500 | 543 |
501 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { | 544 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
502 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 545 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
503 // We enable the button if the user has any auto-open file types registered. | 546 // We enable the button if the user has any auto-open file types registered. |
504 DownloadManager* manager = dom_ui_->GetProfile()->GetDownloadManager(); | 547 DownloadManager* manager = dom_ui_->GetProfile()->GetDownloadManager(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 FundamentalValue useSSL3Value(useSSL3Setting); | 600 FundamentalValue useSSL3Value(useSSL3Setting); |
558 dom_ui_->CallJavascriptFunction( | 601 dom_ui_->CallJavascriptFunction( |
559 L"options.AdvancedOptions.SetUseSSL3CheckboxState", | 602 L"options.AdvancedOptions.SetUseSSL3CheckboxState", |
560 useSSL3Value, disabledValue); | 603 useSSL3Value, disabledValue); |
561 FundamentalValue useTLS1Value(useTLS1Setting); | 604 FundamentalValue useTLS1Value(useTLS1Setting); |
562 dom_ui_->CallJavascriptFunction( | 605 dom_ui_->CallJavascriptFunction( |
563 L"options.AdvancedOptions.SetUseTLS1CheckboxState", | 606 L"options.AdvancedOptions.SetUseTLS1CheckboxState", |
564 useTLS1Value, disabledValue); | 607 useTLS1Value, disabledValue); |
565 } | 608 } |
566 #endif | 609 #endif |
OLD | NEW |