| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 localized_strings->SetString("improveBrowsingExperience", | 193 localized_strings->SetString("improveBrowsingExperience", |
| 194 l10n_util::GetStringUTF16(IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE)); | 194 l10n_util::GetStringUTF16(IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE)); |
| 195 localized_strings->SetString("disableWebServices", | 195 localized_strings->SetString("disableWebServices", |
| 196 l10n_util::GetStringUTF16(IDS_OPTIONS_DISABLE_WEB_SERVICES)); | 196 l10n_util::GetStringUTF16(IDS_OPTIONS_DISABLE_WEB_SERVICES)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void AdvancedOptionsHandler::Initialize() { | 199 void AdvancedOptionsHandler::Initialize() { |
| 200 DCHECK(dom_ui_); | 200 DCHECK(dom_ui_); |
| 201 SetupMetricsReportingCheckbox(); | 201 SetupMetricsReportingCheckbox(); |
| 202 SetupMetricsReportingSettingVisibility(); | 202 SetupMetricsReportingSettingVisibility(); |
| 203 SetupDefaultZoomLevel(); | |
| 204 SetupFontSizeLabel(); | 203 SetupFontSizeLabel(); |
| 205 SetupDownloadLocationPath(); | 204 SetupDownloadLocationPath(); |
| 206 SetupAutoOpenFileTypesDisabledAttribute(); | 205 SetupAutoOpenFileTypesDisabledAttribute(); |
| 207 SetupProxySettingsSection(); | 206 SetupProxySettingsSection(); |
| 208 #if defined(OS_WIN) | 207 #if defined(OS_WIN) |
| 209 SetupSSLConfigSettings(); | 208 SetupSSLConfigSettings(); |
| 210 #endif | 209 #endif |
| 211 #if !defined(OS_CHROMEOS) | 210 #if !defined(OS_CHROMEOS) |
| 212 if (cloud_print_proxy_ui_enabled_) { | 211 if (cloud_print_proxy_ui_enabled_) { |
| 213 SetupCloudPrintProxySection(); | 212 SetupCloudPrintProxySection(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 237 DCHECK(dom_ui_); | 236 DCHECK(dom_ui_); |
| 238 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); | 237 PrefService* prefs = dom_ui_->GetProfile()->GetPrefs(); |
| 239 #if !defined(OS_CHROMEOS) | 238 #if !defined(OS_CHROMEOS) |
| 240 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, | 239 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, |
| 241 g_browser_process->local_state(), this); | 240 g_browser_process->local_state(), this); |
| 242 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); | 241 cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this); |
| 243 #endif | 242 #endif |
| 244 default_download_location_.Init(prefs::kDownloadDefaultDirectory, | 243 default_download_location_.Init(prefs::kDownloadDefaultDirectory, |
| 245 prefs, this); | 244 prefs, this); |
| 246 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); | 245 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); |
| 247 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); | |
| 248 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); | 246 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); |
| 249 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, prefs, | 247 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, prefs, |
| 250 this); | 248 this); |
| 251 proxy_prefs_.reset( | 249 proxy_prefs_.reset( |
| 252 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); | 250 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
| 253 | 251 |
| 254 // Return result from the superclass. | 252 // Return result from the superclass. |
| 255 return handler; | 253 return handler; |
| 256 } | 254 } |
| 257 | 255 |
| 258 void AdvancedOptionsHandler::RegisterMessages() { | 256 void AdvancedOptionsHandler::RegisterMessages() { |
| 259 // Setup handlers specific to this panel. | 257 // Setup handlers specific to this panel. |
| 260 DCHECK(dom_ui_); | 258 DCHECK(dom_ui_); |
| 261 dom_ui_->RegisterMessageCallback("selectDownloadLocation", | 259 dom_ui_->RegisterMessageCallback("selectDownloadLocation", |
| 262 NewCallback(this, | 260 NewCallback(this, |
| 263 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); | 261 &AdvancedOptionsHandler::HandleSelectDownloadLocation)); |
| 264 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", | 262 dom_ui_->RegisterMessageCallback("autoOpenFileTypesAction", |
| 265 NewCallback(this, | 263 NewCallback(this, |
| 266 &AdvancedOptionsHandler::HandleAutoOpenButton)); | 264 &AdvancedOptionsHandler::HandleAutoOpenButton)); |
| 267 dom_ui_->RegisterMessageCallback("defaultZoomLevelAction", | |
| 268 NewCallback(this, &AdvancedOptionsHandler::HandleDefaultZoomLevel)); | |
| 269 dom_ui_->RegisterMessageCallback("defaultFontSizeAction", | 265 dom_ui_->RegisterMessageCallback("defaultFontSizeAction", |
| 270 NewCallback(this, &AdvancedOptionsHandler::HandleDefaultFontSize)); | 266 NewCallback(this, &AdvancedOptionsHandler::HandleDefaultFontSize)); |
| 271 #if !defined(OS_CHROMEOS) | 267 #if !defined(OS_CHROMEOS) |
| 272 dom_ui_->RegisterMessageCallback("metricsReportingCheckboxAction", | 268 dom_ui_->RegisterMessageCallback("metricsReportingCheckboxAction", |
| 273 NewCallback(this, | 269 NewCallback(this, |
| 274 &AdvancedOptionsHandler::HandleMetricsReportingCheckbox)); | 270 &AdvancedOptionsHandler::HandleMetricsReportingCheckbox)); |
| 275 #endif | 271 #endif |
| 276 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 272 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 277 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", | 273 dom_ui_->RegisterMessageCallback("showManageSSLCertificates", |
| 278 NewCallback(this, | 274 NewCallback(this, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 UserMetricsRecordAction( | 376 UserMetricsRecordAction( |
| 381 enabled ? | 377 enabled ? |
| 382 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : | 378 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : |
| 383 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); | 379 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); |
| 384 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); | 380 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); |
| 385 enable_metrics_recording_.SetValue(is_enabled); | 381 enable_metrics_recording_.SetValue(is_enabled); |
| 386 SetupMetricsReportingCheckbox(); | 382 SetupMetricsReportingCheckbox(); |
| 387 #endif | 383 #endif |
| 388 } | 384 } |
| 389 | 385 |
| 390 void AdvancedOptionsHandler::HandleDefaultZoomLevel(const ListValue* args) { | |
| 391 UserMetricsRecordAction(UserMetricsAction("Options_ChangeDefaultZoomLevel")); | |
| 392 int zoom_level; | |
| 393 if (ExtractIntegerValue(args, &zoom_level)) { | |
| 394 default_zoom_level_.SetValue(static_cast<double>(zoom_level)); | |
| 395 } | |
| 396 } | |
| 397 | |
| 398 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { | 386 void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) { |
| 399 int font_size; | 387 int font_size; |
| 400 if (ExtractIntegerValue(args, &font_size)) { | 388 if (ExtractIntegerValue(args, &font_size)) { |
| 401 if (font_size > 0) { | 389 if (font_size > 0) { |
| 402 default_font_size_.SetValue(font_size); | 390 default_font_size_.SetValue(font_size); |
| 403 default_fixed_font_size_.SetValue(font_size); | 391 default_fixed_font_size_.SetValue(font_size); |
| 404 SetupFontSizeLabel(); | 392 SetupFontSizeLabel(); |
| 405 } | 393 } |
| 406 } | 394 } |
| 407 } | 395 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // Don't show the reporting setting if we are in the guest mode. | 535 // Don't show the reporting setting if we are in the guest mode. |
| 548 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | 536 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 549 FundamentalValue visible(false); | 537 FundamentalValue visible(false); |
| 550 dom_ui_->CallJavascriptFunction( | 538 dom_ui_->CallJavascriptFunction( |
| 551 L"options.AdvancedOptions.SetMetricsReportingSettingVisibility", | 539 L"options.AdvancedOptions.SetMetricsReportingSettingVisibility", |
| 552 visible); | 540 visible); |
| 553 } | 541 } |
| 554 #endif | 542 #endif |
| 555 } | 543 } |
| 556 | 544 |
| 557 void AdvancedOptionsHandler::SetupDefaultZoomLevel() { | |
| 558 // We're only interested in integer values, so convert to int. | |
| 559 FundamentalValue value(static_cast<int>(default_zoom_level_.GetValue())); | |
| 560 dom_ui_->CallJavascriptFunction( | |
| 561 L"options.AdvancedOptions.SetDefaultZoomLevel", value); | |
| 562 } | |
| 563 | |
| 564 void AdvancedOptionsHandler::SetupFontSizeLabel() { | 545 void AdvancedOptionsHandler::SetupFontSizeLabel() { |
| 565 // We're only interested in integer values, so convert to int. | 546 // We're only interested in integer values, so convert to int. |
| 566 FundamentalValue fixed_font_size(default_fixed_font_size_.GetValue()); | 547 FundamentalValue fixed_font_size(default_fixed_font_size_.GetValue()); |
| 567 FundamentalValue font_size(default_font_size_.GetValue()); | 548 FundamentalValue font_size(default_font_size_.GetValue()); |
| 568 dom_ui_->CallJavascriptFunction( | 549 dom_ui_->CallJavascriptFunction( |
| 569 L"options.AdvancedOptions.SetFontSize", fixed_font_size, | 550 L"options.AdvancedOptions.SetFontSize", fixed_font_size, |
| 570 font_size); | 551 font_size); |
| 571 } | 552 } |
| 572 | 553 |
| 573 void AdvancedOptionsHandler::SetupDownloadLocationPath() { | 554 void AdvancedOptionsHandler::SetupDownloadLocationPath() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 FundamentalValue useSSL3Value(useSSL3Setting); | 616 FundamentalValue useSSL3Value(useSSL3Setting); |
| 636 dom_ui_->CallJavascriptFunction( | 617 dom_ui_->CallJavascriptFunction( |
| 637 L"options.AdvancedOptions.SetUseSSL3CheckboxState", | 618 L"options.AdvancedOptions.SetUseSSL3CheckboxState", |
| 638 useSSL3Value, disabledValue); | 619 useSSL3Value, disabledValue); |
| 639 FundamentalValue useTLS1Value(useTLS1Setting); | 620 FundamentalValue useTLS1Value(useTLS1Setting); |
| 640 dom_ui_->CallJavascriptFunction( | 621 dom_ui_->CallJavascriptFunction( |
| 641 L"options.AdvancedOptions.SetUseTLS1CheckboxState", | 622 L"options.AdvancedOptions.SetUseTLS1CheckboxState", |
| 642 useTLS1Value, disabledValue); | 623 useTLS1Value, disabledValue); |
| 643 } | 624 } |
| 644 #endif | 625 #endif |
| OLD | NEW |