| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/options2/advanced_options_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/advanced_options_handler2.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 41 #include "grit/locale_settings.h" | 41 #include "grit/locale_settings.h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
| 44 | 44 |
| 45 #if !defined(OS_CHROMEOS) | 45 #if !defined(OS_CHROMEOS) |
| 46 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" | 46 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" |
| 47 #include "chrome/browser/ui/webui/options2/advanced_options_utils2.h" | 47 #include "chrome/browser/ui/webui/options2/advanced_options_utils2.h" |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 #if defined(OS_CHROMEOS) |
| 51 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 52 #include "chrome/browser/chromeos/cros_settings.h" |
| 53 #include "chrome/browser/ui/webui/options2/chromeos/system_settings_provider2.h" |
| 54 #endif |
| 55 |
| 50 using content::DownloadManager; | 56 using content::DownloadManager; |
| 51 using content::OpenURLParams; | 57 using content::OpenURLParams; |
| 52 using content::Referrer; | 58 using content::Referrer; |
| 53 using content::UserMetricsAction; | 59 using content::UserMetricsAction; |
| 54 | 60 |
| 55 namespace options2 { | 61 namespace options2 { |
| 56 | 62 |
| 57 AdvancedOptionsHandler::AdvancedOptionsHandler() { | 63 AdvancedOptionsHandler::AdvancedOptionsHandler() { |
| 58 | 64 |
| 59 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) | 65 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 { "passwordsAndAutofillGroupName", | 191 { "passwordsAndAutofillGroupName", |
| 186 IDS_OPTIONS_PASSWORDS_AND_FORMS_GROUP_NAME }, | 192 IDS_OPTIONS_PASSWORDS_AND_FORMS_GROUP_NAME }, |
| 187 { "passwordManagerEnabled", | 193 { "passwordManagerEnabled", |
| 188 IDS_OPTIONS_PASSWORD_MANAGER_ENABLE }, | 194 IDS_OPTIONS_PASSWORD_MANAGER_ENABLE }, |
| 189 { "managePasswords", | 195 { "managePasswords", |
| 190 IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, | 196 IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, |
| 191 { "autofillEnabled", | 197 { "autofillEnabled", |
| 192 IDS_OPTIONS_AUTOFILL_ENABLE }, | 198 IDS_OPTIONS_AUTOFILL_ENABLE }, |
| 193 { "manageAutofillSettings", | 199 { "manageAutofillSettings", |
| 194 IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, | 200 IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, |
| 201 #if defined(OS_CHROMEOS) |
| 202 { "datetimeTitle", |
| 203 IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME }, |
| 204 { "timezone", |
| 205 IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION }, |
| 206 { "use24HourClock", |
| 207 IDS_OPTIONS_SETTINGS_USE_24HOUR_CLOCK_DESCRIPTION }, |
| 208 { "accessibilityTitle", |
| 209 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY }, |
| 210 { "accessibilitySpokenFeedback", |
| 211 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION }, |
| 212 { "accessibilityHighContrast", |
| 213 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION }, |
| 214 { "accessibilityScreenMagnifier", |
| 215 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_DESCRIPTION }, |
| 216 { "accessibilityVirtualKeyboard", |
| 217 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_VIRTUAL_KEYBOARD_DESCRIPTION }, |
| 218 #endif |
| 195 }; | 219 }; |
| 196 | 220 |
| 197 RegisterStrings(localized_strings, resources, arraysize(resources)); | 221 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 198 RegisterCloudPrintStrings(localized_strings); | 222 RegisterCloudPrintStrings(localized_strings); |
| 199 RegisterTitle(localized_strings, "advancedPage", | 223 RegisterTitle(localized_strings, "advancedPage", |
| 200 IDS_OPTIONS_ADVANCED_TAB_LABEL); | 224 IDS_OPTIONS_ADVANCED_TAB_LABEL); |
| 201 | 225 |
| 202 localized_strings->SetString("privacyLearnMoreURL", | 226 localized_strings->SetString("privacyLearnMoreURL", |
| 203 google_util::AppendGoogleLocaleParam( | 227 google_util::AppendGoogleLocaleParam( |
| 204 GURL(chrome::kPrivacyLearnMoreURL)).spec()); | 228 GURL(chrome::kPrivacyLearnMoreURL)).spec()); |
| 205 | 229 |
| 206 localized_strings->SetString( | 230 localized_strings->SetString( |
| 207 "languageSectionLabel", | 231 "languageSectionLabel", |
| 208 l10n_util::GetStringFUTF16( | 232 l10n_util::GetStringFUTF16( |
| 209 IDS_OPTIONS_ADVANCED_LANGUAGE_LABEL, | 233 IDS_OPTIONS_ADVANCED_LANGUAGE_LABEL, |
| 210 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 234 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 211 | 235 |
| 212 #if defined(OS_CHROMEOS) | 236 #if defined(OS_CHROMEOS) |
| 213 localized_strings->SetString("cloudPrintLearnMoreURL", | 237 localized_strings->SetString("cloudPrintLearnMoreURL", |
| 214 google_util::AppendGoogleLocaleParam( | 238 google_util::AppendGoogleLocaleParam( |
| 215 GURL(chrome::kCloudPrintLearnMoreURL)).spec()); | 239 GURL(chrome::kCloudPrintLearnMoreURL)).spec()); |
| 240 |
| 241 // TODO(pastarmovj): replace this with a call to the CrosSettings list |
| 242 // handling functionality to come. |
| 243 localized_strings->Set("timezoneList", |
| 244 static_cast<chromeos::options2::SystemSettingsProvider*>( |
| 245 chromeos::CrosSettings::Get()->GetProvider( |
| 246 chromeos::kSystemTimezone))->GetTimezoneList()); |
| 216 #endif | 247 #endif |
| 217 #if defined(OS_MACOSX) | 248 #if defined(OS_MACOSX) |
| 218 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 249 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 219 if (profile_manager->GetNumberOfProfiles() > 1) { | 250 if (profile_manager->GetNumberOfProfiles() > 1) { |
| 220 localized_strings->SetString("macPasswordsWarning", | 251 localized_strings->SetString("macPasswordsWarning", |
| 221 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); | 252 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); |
| 222 } | 253 } |
| 223 #endif | 254 #endif |
| 224 } | 255 } |
| 225 | 256 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 SetupProxySettingsSection(); | 291 SetupProxySettingsSection(); |
| 261 SetupSSLConfigSettings(); | 292 SetupSSLConfigSettings(); |
| 262 #if !defined(OS_CHROMEOS) | 293 #if !defined(OS_CHROMEOS) |
| 263 if (cloud_print_connector_ui_enabled_) { | 294 if (cloud_print_connector_ui_enabled_) { |
| 264 SetupCloudPrintConnectorSection(); | 295 SetupCloudPrintConnectorSection(); |
| 265 RefreshCloudPrintStatusFromService(); | 296 RefreshCloudPrintStatusFromService(); |
| 266 } else { | 297 } else { |
| 267 RemoveCloudPrintConnectorSection(); | 298 RemoveCloudPrintConnectorSection(); |
| 268 } | 299 } |
| 269 #endif | 300 #endif |
| 301 #if defined(OS_CHROMEOS) |
| 302 SetupAccessibilityFeatures(); |
| 303 #endif |
| 270 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 304 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 271 SetupBackgroundModeSettings(); | 305 SetupBackgroundModeSettings(); |
| 272 #endif | 306 #endif |
| 273 | 307 |
| 274 } | 308 } |
| 275 | 309 |
| 276 void AdvancedOptionsHandler::RegisterMessages() { | 310 void AdvancedOptionsHandler::RegisterMessages() { |
| 277 // Register for preferences that we need to observe manually. These have | 311 // Register for preferences that we need to observe manually. These have |
| 278 // special behaviors that aren't handled by the standard prefs UI. | 312 // special behaviors that aren't handled by the standard prefs UI. |
| 279 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); | 313 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 297 | 331 |
| 298 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); | 332 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); |
| 299 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, prefs, this); | 333 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, prefs, this); |
| 300 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); | 334 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); |
| 301 #if !defined(OS_CHROMEOS) | 335 #if !defined(OS_CHROMEOS) |
| 302 proxy_prefs_.reset( | 336 proxy_prefs_.reset( |
| 303 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); | 337 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
| 304 #endif // !defined(OS_CHROMEOS) | 338 #endif // !defined(OS_CHROMEOS) |
| 305 | 339 |
| 306 // Setup handlers specific to this panel. | 340 // Setup handlers specific to this panel. |
| 307 web_ui()->RegisterMessageCallback("selectDownloadLocation", | 341 web_ui()->RegisterMessageCallback( |
| 342 "selectDownloadLocation", |
| 308 base::Bind(&AdvancedOptionsHandler::HandleSelectDownloadLocation, | 343 base::Bind(&AdvancedOptionsHandler::HandleSelectDownloadLocation, |
| 309 base::Unretained(this))); | 344 base::Unretained(this))); |
| 310 web_ui()->RegisterMessageCallback("autoOpenFileTypesAction", | 345 web_ui()->RegisterMessageCallback( |
| 346 "autoOpenFileTypesAction", |
| 311 base::Bind(&AdvancedOptionsHandler::HandleAutoOpenButton, | 347 base::Bind(&AdvancedOptionsHandler::HandleAutoOpenButton, |
| 312 base::Unretained(this))); | 348 base::Unretained(this))); |
| 313 web_ui()->RegisterMessageCallback("defaultFontSizeAction", | 349 web_ui()->RegisterMessageCallback( |
| 350 "defaultFontSizeAction", |
| 314 base::Bind(&AdvancedOptionsHandler::HandleDefaultFontSize, | 351 base::Bind(&AdvancedOptionsHandler::HandleDefaultFontSize, |
| 315 base::Unretained(this))); | 352 base::Unretained(this))); |
| 316 web_ui()->RegisterMessageCallback("defaultZoomFactorAction", | 353 web_ui()->RegisterMessageCallback( |
| 354 "defaultZoomFactorAction", |
| 317 base::Bind(&AdvancedOptionsHandler::HandleDefaultZoomFactor, | 355 base::Bind(&AdvancedOptionsHandler::HandleDefaultZoomFactor, |
| 318 base::Unretained(this))); | 356 base::Unretained(this))); |
| 319 #if !defined(OS_CHROMEOS) | 357 #if !defined(OS_CHROMEOS) |
| 320 web_ui()->RegisterMessageCallback("metricsReportingCheckboxAction", | 358 web_ui()->RegisterMessageCallback( |
| 359 "metricsReportingCheckboxAction", |
| 321 base::Bind(&AdvancedOptionsHandler::HandleMetricsReportingCheckbox, | 360 base::Bind(&AdvancedOptionsHandler::HandleMetricsReportingCheckbox, |
| 322 base::Unretained(this))); | 361 base::Unretained(this))); |
| 323 #endif | 362 #endif |
| 324 #if !defined(USE_NSS) && !defined(USE_OPENSSL) | 363 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 325 web_ui()->RegisterMessageCallback("showManageSSLCertificates", | 364 web_ui()->RegisterMessageCallback( |
| 365 "showManageSSLCertificates", |
| 326 base::Bind(&AdvancedOptionsHandler::ShowManageSSLCertificates, | 366 base::Bind(&AdvancedOptionsHandler::ShowManageSSLCertificates, |
| 327 base::Unretained(this))); | 367 base::Unretained(this))); |
| 328 #endif | 368 #endif |
| 329 web_ui()->RegisterMessageCallback("showCloudPrintManagePage", | 369 web_ui()->RegisterMessageCallback( |
| 370 "showCloudPrintManagePage", |
| 330 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintManagePage, | 371 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintManagePage, |
| 331 base::Unretained(this))); | 372 base::Unretained(this))); |
| 332 #if !defined(OS_CHROMEOS) | 373 #if !defined(OS_CHROMEOS) |
| 333 if (cloud_print_connector_ui_enabled_) { | 374 if (cloud_print_connector_ui_enabled_) { |
| 334 web_ui()->RegisterMessageCallback("showCloudPrintSetupDialog", | 375 web_ui()->RegisterMessageCallback( |
| 376 "showCloudPrintSetupDialog", |
| 335 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintSetupDialog, | 377 base::Bind(&AdvancedOptionsHandler::ShowCloudPrintSetupDialog, |
| 336 base::Unretained(this))); | 378 base::Unretained(this))); |
| 337 web_ui()->RegisterMessageCallback("disableCloudPrintConnector", | 379 web_ui()->RegisterMessageCallback( |
| 380 "disableCloudPrintConnector", |
| 338 base::Bind(&AdvancedOptionsHandler::HandleDisableCloudPrintConnector, | 381 base::Bind(&AdvancedOptionsHandler::HandleDisableCloudPrintConnector, |
| 339 base::Unretained(this))); | 382 base::Unretained(this))); |
| 340 } | 383 } |
| 341 web_ui()->RegisterMessageCallback("showNetworkProxySettings", | 384 web_ui()->RegisterMessageCallback( |
| 385 "showNetworkProxySettings", |
| 342 base::Bind(&AdvancedOptionsHandler::ShowNetworkProxySettings, | 386 base::Bind(&AdvancedOptionsHandler::ShowNetworkProxySettings, |
| 343 base::Unretained(this))); | 387 base::Unretained(this))); |
| 344 #endif | 388 #endif |
| 345 web_ui()->RegisterMessageCallback("checkRevocationCheckboxAction", | 389 web_ui()->RegisterMessageCallback( |
| 390 "checkRevocationCheckboxAction", |
| 346 base::Bind(&AdvancedOptionsHandler::HandleCheckRevocationCheckbox, | 391 base::Bind(&AdvancedOptionsHandler::HandleCheckRevocationCheckbox, |
| 347 base::Unretained(this))); | 392 base::Unretained(this))); |
| 348 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | 393 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 349 web_ui()->RegisterMessageCallback("backgroundModeAction", | 394 web_ui()->RegisterMessageCallback( |
| 395 "backgroundModeAction", |
| 350 base::Bind(&AdvancedOptionsHandler::HandleBackgroundModeCheckbox, | 396 base::Bind(&AdvancedOptionsHandler::HandleBackgroundModeCheckbox, |
| 351 base::Unretained(this))); | 397 base::Unretained(this))); |
| 352 #endif | 398 #endif |
| 399 #if defined(OS_CHROMEOS) |
| 400 web_ui()->RegisterMessageCallback( |
| 401 "spokenFeedbackChange", |
| 402 base::Bind(&AdvancedOptionsHandler::SpokenFeedbackChangeCallback, |
| 403 base::Unretained(this))); |
| 404 web_ui()->RegisterMessageCallback( |
| 405 "highContrastChange", |
| 406 base::Bind(&AdvancedOptionsHandler::HighContrastChangeCallback, |
| 407 base::Unretained(this))); |
| 408 web_ui()->RegisterMessageCallback( |
| 409 "screenMagnifierChange", |
| 410 base::Bind(&AdvancedOptionsHandler::ScreenMagnifierChangeCallback, |
| 411 base::Unretained(this))); |
| 412 web_ui()->RegisterMessageCallback( |
| 413 "virtualKeyboardChange", |
| 414 base::Bind(&AdvancedOptionsHandler::VirtualKeyboardChangeCallback, |
| 415 base::Unretained(this))); |
| 416 #endif |
| 353 } | 417 } |
| 354 | 418 |
| 355 void AdvancedOptionsHandler::Observe( | 419 void AdvancedOptionsHandler::Observe( |
| 356 int type, | 420 int type, |
| 357 const content::NotificationSource& source, | 421 const content::NotificationSource& source, |
| 358 const content::NotificationDetails& details) { | 422 const content::NotificationDetails& details) { |
| 359 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 423 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 360 std::string* pref_name = content::Details<std::string>(details).ptr(); | 424 std::string* pref_name = content::Details<std::string>(details).ptr(); |
| 361 if (*pref_name == prefs::kDownloadExtensionsToOpen) { | 425 if (*pref_name == prefs::kDownloadExtensionsToOpen) { |
| 362 SetupAutoOpenFileTypesDisabledAttribute(); | 426 SetupAutoOpenFileTypesDisabledAttribute(); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 bool enabled = checked_str == "true"; | 531 bool enabled = checked_str == "true"; |
| 468 content::RecordAction(enabled ? | 532 content::RecordAction(enabled ? |
| 469 UserMetricsAction("Options_BackgroundMode_Enable") : | 533 UserMetricsAction("Options_BackgroundMode_Enable") : |
| 470 UserMetricsAction("Options_BackgroundMode_Disable")); | 534 UserMetricsAction("Options_BackgroundMode_Disable")); |
| 471 background_mode_enabled_.SetValue(enabled); | 535 background_mode_enabled_.SetValue(enabled); |
| 472 } | 536 } |
| 473 | 537 |
| 474 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { | 538 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { |
| 475 base::FundamentalValue checked(background_mode_enabled_.GetValue()); | 539 base::FundamentalValue checked(background_mode_enabled_.GetValue()); |
| 476 web_ui()->CallJavascriptFunction( | 540 web_ui()->CallJavascriptFunction( |
| 477 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); | 541 "AdvancedOptions.SetBackgroundModeCheckboxState", checked); |
| 478 } | 542 } |
| 479 #endif | 543 #endif |
| 480 | 544 |
| 481 #if !defined(OS_CHROMEOS) | 545 #if !defined(OS_CHROMEOS) |
| 482 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { | 546 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { |
| 483 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); | 547 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); |
| 484 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui()->web_contents()); | 548 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui()->web_contents()); |
| 485 } | 549 } |
| 486 #endif | 550 #endif |
| 487 | 551 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); | 619 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); |
| 556 } else { | 620 } else { |
| 557 label_str = l10n_util::GetStringFUTF16( | 621 label_str = l10n_util::GetStringFUTF16( |
| 558 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_LABEL, | 622 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_LABEL, |
| 559 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), | 623 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), |
| 560 UTF8ToUTF16(email)); | 624 UTF8ToUTF16(email)); |
| 561 } | 625 } |
| 562 StringValue label(label_str); | 626 StringValue label(label_str); |
| 563 | 627 |
| 564 web_ui()->CallJavascriptFunction( | 628 web_ui()->CallJavascriptFunction( |
| 565 "options.AdvancedOptions.SetupCloudPrintConnectorSection", | 629 "AdvancedOptions.SetupCloudPrintConnectorSection", disabled, label, |
| 566 disabled, label, allowed); | 630 allowed); |
| 567 } | 631 } |
| 568 | 632 |
| 569 void AdvancedOptionsHandler::RemoveCloudPrintConnectorSection() { | 633 void AdvancedOptionsHandler::RemoveCloudPrintConnectorSection() { |
| 570 web_ui()->CallJavascriptFunction( | 634 web_ui()->CallJavascriptFunction( |
| 571 "options.AdvancedOptions.RemoveCloudPrintConnectorSection"); | 635 "AdvancedOptions.RemoveCloudPrintConnectorSection"); |
| 636 } |
| 637 #endif |
| 638 |
| 639 #if defined(OS_CHROMEOS) |
| 640 void AdvancedOptionsHandler::SpokenFeedbackChangeCallback( |
| 641 const ListValue* args) { |
| 642 bool enabled = false; |
| 643 args->GetBoolean(0, &enabled); |
| 644 |
| 645 chromeos::accessibility::EnableAccessibility(enabled, NULL); |
| 572 } | 646 } |
| 573 | 647 |
| 648 void AdvancedOptionsHandler::HighContrastChangeCallback(const ListValue* args) { |
| 649 bool enabled = false; |
| 650 args->GetBoolean(0, &enabled); |
| 651 |
| 652 chromeos::accessibility::EnableHighContrast(enabled); |
| 653 } |
| 654 |
| 655 void AdvancedOptionsHandler::ScreenMagnifierChangeCallback( |
| 656 const ListValue* args) { |
| 657 bool enabled = false; |
| 658 args->GetBoolean(0, &enabled); |
| 659 |
| 660 chromeos::accessibility::EnableScreenMagnifier(enabled); |
| 661 } |
| 662 |
| 663 void AdvancedOptionsHandler::VirtualKeyboardChangeCallback( |
| 664 const ListValue* args) { |
| 665 bool enabled = false; |
| 666 args->GetBoolean(0, &enabled); |
| 667 |
| 668 chromeos::accessibility::EnableVirtualKeyboard(enabled); |
| 669 } |
| 670 |
| 671 void AdvancedOptionsHandler::SetupAccessibilityFeatures() { |
| 672 PrefService* pref_service = g_browser_process->local_state(); |
| 673 base::FundamentalValue spoken_feedback_enabled( |
| 674 pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled)); |
| 675 web_ui()->CallJavascriptFunction( |
| 676 "AdvancedOptions.setSpokenFeedbackCheckboxState", |
| 677 spoken_feedback_enabled); |
| 678 base::FundamentalValue high_contrast_enabled( |
| 679 pref_service->GetBoolean(prefs::kHighContrastEnabled)); |
| 680 web_ui()->CallJavascriptFunction( |
| 681 "AdvancedOptions.setHighContrastCheckboxState", |
| 682 high_contrast_enabled); |
| 683 base::FundamentalValue screen_magnifier_enabled( |
| 684 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)); |
| 685 web_ui()->CallJavascriptFunction( |
| 686 "AdvancedOptions.setScreenMagnifierCheckboxState", |
| 687 screen_magnifier_enabled); |
| 688 base::FundamentalValue virtual_keyboard_enabled( |
| 689 pref_service->GetBoolean(prefs::kVirtualKeyboardEnabled)); |
| 690 web_ui()->CallJavascriptFunction( |
| 691 "AdvancedOptions.setVirtualKeyboardCheckboxState", |
| 692 virtual_keyboard_enabled); |
| 693 } |
| 574 #endif | 694 #endif |
| 575 | 695 |
| 576 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() { | 696 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() { |
| 577 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) | 697 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 578 base::FundamentalValue checked(enable_metrics_recording_.GetValue()); | 698 base::FundamentalValue checked(enable_metrics_recording_.GetValue()); |
| 579 base::FundamentalValue disabled(enable_metrics_recording_.IsManaged()); | 699 base::FundamentalValue disabled(enable_metrics_recording_.IsManaged()); |
| 580 web_ui()->CallJavascriptFunction( | 700 web_ui()->CallJavascriptFunction( |
| 581 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, | 701 "AdvancedOptions.SetMetricsReportingCheckboxState", checked, disabled); |
| 582 disabled); | |
| 583 #endif | 702 #endif |
| 584 } | 703 } |
| 585 | 704 |
| 586 void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() { | 705 void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() { |
| 587 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) | 706 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) |
| 588 // Don't show the reporting setting if we are in the guest mode. | 707 // Don't show the reporting setting if we are in the guest mode. |
| 589 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | 708 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 590 base::FundamentalValue visible(false); | 709 base::FundamentalValue visible(false); |
| 591 web_ui()->CallJavascriptFunction( | 710 web_ui()->CallJavascriptFunction( |
| 592 "options.AdvancedOptions.SetMetricsReportingSettingVisibility", | 711 "AdvancedOptions.SetMetricsReportingSettingVisibility", visible); |
| 593 visible); | |
| 594 } | 712 } |
| 595 #endif | 713 #endif |
| 596 } | 714 } |
| 597 | 715 |
| 598 void AdvancedOptionsHandler::SetupFontSizeSelector() { | 716 void AdvancedOptionsHandler::SetupFontSizeSelector() { |
| 599 // We're only interested in integer values, so convert to int. | 717 // We're only interested in integer values, so convert to int. |
| 600 base::FundamentalValue font_size(default_font_size_.GetValue()); | 718 base::FundamentalValue font_size(default_font_size_.GetValue()); |
| 601 web_ui()->CallJavascriptFunction( | 719 web_ui()->CallJavascriptFunction("AdvancedOptions.SetFontSize", font_size); |
| 602 "options.AdvancedOptions.SetFontSize", font_size); | |
| 603 } | 720 } |
| 604 | 721 |
| 605 void AdvancedOptionsHandler::SetupPageZoomSelector() { | 722 void AdvancedOptionsHandler::SetupPageZoomSelector() { |
| 606 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 723 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 607 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); | 724 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); |
| 608 double default_zoom_factor = | 725 double default_zoom_factor = |
| 609 WebKit::WebView::zoomLevelToZoomFactor(default_zoom_level); | 726 WebKit::WebView::zoomLevelToZoomFactor(default_zoom_level); |
| 610 | 727 |
| 611 // Generate a vector of zoom factors from an array of known presets along with | 728 // Generate a vector of zoom factors from an array of known presets along with |
| 612 // the default factor added if necessary. | 729 // the default factor added if necessary. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 627 int percent = static_cast<int>(factor * 100 + 0.5); | 744 int percent = static_cast<int>(factor * 100 + 0.5); |
| 628 option->Append(Value::CreateStringValue( | 745 option->Append(Value::CreateStringValue( |
| 629 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); | 746 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); |
| 630 option->Append(Value::CreateDoubleValue(factor)); | 747 option->Append(Value::CreateDoubleValue(factor)); |
| 631 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); | 748 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); |
| 632 option->Append(Value::CreateBooleanValue(selected)); | 749 option->Append(Value::CreateBooleanValue(selected)); |
| 633 zoom_factors_value.Append(option); | 750 zoom_factors_value.Append(option); |
| 634 } | 751 } |
| 635 | 752 |
| 636 web_ui()->CallJavascriptFunction( | 753 web_ui()->CallJavascriptFunction( |
| 637 "options.AdvancedOptions.SetupPageZoomSelector", zoom_factors_value); | 754 "AdvancedOptions.SetupPageZoomSelector", zoom_factors_value); |
| 638 } | 755 } |
| 639 | 756 |
| 640 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { | 757 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
| 641 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. | 758 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
| 642 // We enable the button if the user has any auto-open file types registered. | 759 // We enable the button if the user has any auto-open file types registered. |
| 643 DownloadManager* manager = | 760 DownloadManager* manager = |
| 644 web_ui()->web_contents()->GetBrowserContext()->GetDownloadManager(); | 761 web_ui()->web_contents()->GetBrowserContext()->GetDownloadManager(); |
| 645 bool disabled = !(manager && | 762 bool disabled = !(manager && |
| 646 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); | 763 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); |
| 647 base::FundamentalValue value(disabled); | 764 base::FundamentalValue value(disabled); |
| 648 web_ui()->CallJavascriptFunction( | 765 web_ui()->CallJavascriptFunction( |
| 649 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); | 766 "AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); |
| 650 } | 767 } |
| 651 | 768 |
| 652 void AdvancedOptionsHandler::SetupProxySettingsSection() { | 769 void AdvancedOptionsHandler::SetupProxySettingsSection() { |
| 653 #if !defined(OS_CHROMEOS) | 770 #if !defined(OS_CHROMEOS) |
| 654 // Disable the button if proxy settings are managed by a sysadmin or | 771 // Disable the button if proxy settings are managed by a sysadmin or |
| 655 // overridden by an extension. | 772 // overridden by an extension. |
| 656 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 773 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 657 const PrefService::Preference* proxy_config = | 774 const PrefService::Preference* proxy_config = |
| 658 pref_service->FindPreference(prefs::kProxy); | 775 pref_service->FindPreference(prefs::kProxy); |
| 659 bool is_extension_controlled = (proxy_config && | 776 bool is_extension_controlled = (proxy_config && |
| 660 proxy_config->IsExtensionControlled()); | 777 proxy_config->IsExtensionControlled()); |
| 661 | 778 |
| 662 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || | 779 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || |
| 663 is_extension_controlled); | 780 is_extension_controlled); |
| 664 | 781 |
| 665 // Get the appropriate info string to describe the button. | 782 // Get the appropriate info string to describe the button. |
| 666 string16 label_str; | 783 string16 label_str; |
| 667 if (is_extension_controlled) { | 784 if (is_extension_controlled) { |
| 668 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); | 785 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); |
| 669 } else { | 786 } else { |
| 670 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, | 787 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, |
| 671 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 788 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 672 } | 789 } |
| 673 StringValue label(label_str); | 790 StringValue label(label_str); |
| 674 | 791 |
| 675 web_ui()->CallJavascriptFunction( | 792 web_ui()->CallJavascriptFunction( |
| 676 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label); | 793 "AdvancedOptions.SetupProxySettingsSection", disabled, label); |
| 677 #endif // !defined(OS_CHROMEOS) | 794 #endif // !defined(OS_CHROMEOS) |
| 678 } | 795 } |
| 679 | 796 |
| 680 void AdvancedOptionsHandler::SetupSSLConfigSettings() { | 797 void AdvancedOptionsHandler::SetupSSLConfigSettings() { |
| 681 { | 798 { |
| 682 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); | 799 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
| 683 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); | 800 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
| 684 web_ui()->CallJavascriptFunction( | 801 web_ui()->CallJavascriptFunction( |
| 685 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, | 802 "AdvancedOptions.SetCheckRevocationCheckboxState", checked, disabled); |
| 686 disabled); | |
| 687 } | 803 } |
| 688 } | 804 } |
| 689 | 805 |
| 690 } // namespace options2 | 806 } // namespace options2 |
| OLD | NEW |