Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/browser/ui/webui/options/advanced_options_handler.cc

Issue 7649006: more changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix another typo Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/options/advanced_options_handler.h" 5 #include "chrome/browser/ui/webui/options/advanced_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 const ListValue* args) { 448 const ListValue* args) {
449 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); 449 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args));
450 bool enabled = checked_str == "true"; 450 bool enabled = checked_str == "true";
451 UserMetrics::RecordAction(enabled ? 451 UserMetrics::RecordAction(enabled ?
452 UserMetricsAction("Options_BackgroundMode_Enable") : 452 UserMetricsAction("Options_BackgroundMode_Enable") :
453 UserMetricsAction("Options_BackgroundMode_Disable")); 453 UserMetricsAction("Options_BackgroundMode_Disable"));
454 background_mode_enabled_.SetValue(enabled); 454 background_mode_enabled_.SetValue(enabled);
455 } 455 }
456 456
457 void AdvancedOptionsHandler::SetupBackgroundModeSettings() { 457 void AdvancedOptionsHandler::SetupBackgroundModeSettings() {
458 base::FundamentalValue checked(background_mode_enabled_.GetValue()); 458 base::BooleanValue checked(background_mode_enabled_.GetValue());
459 web_ui_->CallJavascriptFunction( 459 web_ui_->CallJavascriptFunction(
460 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked); 460 "options.AdvancedOptions.SetBackgroundModeCheckboxState", checked);
461 } 461 }
462 #endif 462 #endif
463 463
464 #if !defined(OS_CHROMEOS) 464 #if !defined(OS_CHROMEOS)
465 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { 465 void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) {
466 UserMetrics::RecordAction(UserMetricsAction("Options_ShowProxySettings")); 466 UserMetrics::RecordAction(UserMetricsAction("Options_ShowProxySettings"));
467 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents()); 467 AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents());
468 } 468 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 Profile* profile = Profile::FromWebUI(web_ui_); 514 Profile* profile = Profile::FromWebUI(web_ui_);
515 if (!CloudPrintProxyServiceFactory::GetForProfile(profile)) { 515 if (!CloudPrintProxyServiceFactory::GetForProfile(profile)) {
516 cloud_print_proxy_ui_enabled_ = false; 516 cloud_print_proxy_ui_enabled_ = false;
517 RemoveCloudPrintProxySection(); 517 RemoveCloudPrintProxySection();
518 return; 518 return;
519 } 519 }
520 520
521 bool cloud_print_proxy_allowed = 521 bool cloud_print_proxy_allowed =
522 !cloud_print_proxy_enabled_.IsManaged() || 522 !cloud_print_proxy_enabled_.IsManaged() ||
523 cloud_print_proxy_enabled_.GetValue(); 523 cloud_print_proxy_enabled_.GetValue();
524 base::FundamentalValue allowed(cloud_print_proxy_allowed); 524 base::BooleanValue allowed(cloud_print_proxy_allowed);
525 525
526 std::string email; 526 std::string email;
527 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && 527 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) &&
528 cloud_print_proxy_allowed) { 528 cloud_print_proxy_allowed) {
529 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); 529 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail);
530 } 530 }
531 base::FundamentalValue disabled(email.empty()); 531 base::BooleanValue disabled(email.empty());
532 532
533 string16 label_str; 533 string16 label_str;
534 if (email.empty()) { 534 if (email.empty()) {
535 label_str = l10n_util::GetStringUTF16( 535 label_str = l10n_util::GetStringUTF16(
536 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL); 536 IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL);
537 } else { 537 } else {
538 label_str = l10n_util::GetStringFUTF16( 538 label_str = l10n_util::GetStringFUTF16(
539 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_LABEL, UTF8ToUTF16(email)); 539 IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_LABEL, UTF8ToUTF16(email));
540 } 540 }
541 StringValue label(label_str); 541 StringValue label(label_str);
542 542
543 web_ui_->CallJavascriptFunction( 543 web_ui_->CallJavascriptFunction(
544 "options.AdvancedOptions.SetupCloudPrintProxySection", 544 "options.AdvancedOptions.SetupCloudPrintProxySection",
545 disabled, label, allowed); 545 disabled, label, allowed);
546 } 546 }
547 547
548 void AdvancedOptionsHandler::RemoveCloudPrintProxySection() { 548 void AdvancedOptionsHandler::RemoveCloudPrintProxySection() {
549 web_ui_->CallJavascriptFunction( 549 web_ui_->CallJavascriptFunction(
550 "options.AdvancedOptions.RemoveCloudPrintProxySection"); 550 "options.AdvancedOptions.RemoveCloudPrintProxySection");
551 } 551 }
552 552
553 #endif 553 #endif
554 554
555 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() { 555 void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() {
556 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) 556 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
557 base::FundamentalValue checked(enable_metrics_recording_.GetValue()); 557 base::BooleanValue checked(enable_metrics_recording_.GetValue());
558 base::FundamentalValue disabled(enable_metrics_recording_.IsManaged()); 558 base::BooleanValue disabled(enable_metrics_recording_.IsManaged());
559 web_ui_->CallJavascriptFunction( 559 web_ui_->CallJavascriptFunction(
560 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, 560 "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked,
561 disabled); 561 disabled);
562 #endif 562 #endif
563 } 563 }
564 564
565 void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() { 565 void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() {
566 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) 566 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS)
567 // Don't show the reporting setting if we are in the guest mode. 567 // Don't show the reporting setting if we are in the guest mode.
568 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { 568 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) {
569 base::FundamentalValue visible(false); 569 base::BooleanValue visible(false);
570 web_ui_->CallJavascriptFunction( 570 web_ui_->CallJavascriptFunction(
571 "options.AdvancedOptions.SetMetricsReportingSettingVisibility", 571 "options.AdvancedOptions.SetMetricsReportingSettingVisibility",
572 visible); 572 visible);
573 } 573 }
574 #endif 574 #endif
575 } 575 }
576 576
577 void AdvancedOptionsHandler::SetupFontSizeLabel() { 577 void AdvancedOptionsHandler::SetupFontSizeLabel() {
578 // We're only interested in integer values, so convert to int. 578 // We're only interested in integer values, so convert to int.
579 base::FundamentalValue font_size(default_font_size_.GetValue()); 579 base::NumberValue font_size(default_font_size_.GetValue());
580 web_ui_->CallJavascriptFunction( 580 web_ui_->CallJavascriptFunction(
581 "options.AdvancedOptions.SetFontSize", font_size); 581 "options.AdvancedOptions.SetFontSize", font_size);
582 } 582 }
583 583
584 void AdvancedOptionsHandler::SetupDownloadLocationPath() { 584 void AdvancedOptionsHandler::SetupDownloadLocationPath() {
585 StringValue value(default_download_location_.GetValue().value()); 585 StringValue value(default_download_location_.GetValue().value());
586 // In case allow_file_selection_dialogs_ is false, we will not display any 586 // In case allow_file_selection_dialogs_ is false, we will not display any
587 // file-selection dialogs but show an InfoBar. That is why we can disable 587 // file-selection dialogs but show an InfoBar. That is why we can disable
588 // the DownloadLocationPath-Chooser right-away. 588 // the DownloadLocationPath-Chooser right-away.
589 base::FundamentalValue disabled(default_download_location_.IsManaged() || 589 base::BooleanValue disabled(default_download_location_.IsManaged() ||
590 !allow_file_selection_dialogs_.GetValue()); 590 !allow_file_selection_dialogs_.GetValue());
591 web_ui_->CallJavascriptFunction( 591 web_ui_->CallJavascriptFunction(
592 "options.AdvancedOptions.SetDownloadLocationPath", value, disabled); 592 "options.AdvancedOptions.SetDownloadLocationPath", value, disabled);
593 } 593 }
594 594
595 void AdvancedOptionsHandler::SetupPromptForDownload() { 595 void AdvancedOptionsHandler::SetupPromptForDownload() {
596 base::FundamentalValue checked(ask_for_save_location_.GetValue()); 596 base::BooleanValue checked(ask_for_save_location_.GetValue());
597 // If either the DownloadDirectory is managed or if file-selection dialogs are 597 // If either the DownloadDirectory is managed or if file-selection dialogs are
598 // disallowed then |ask_for_save_location_| must currently be false and cannot 598 // disallowed then |ask_for_save_location_| must currently be false and cannot
599 // be changed. 599 // be changed.
600 base::FundamentalValue disabled(default_download_location_.IsManaged() || 600 base::BooleanValue disabled(default_download_location_.IsManaged() ||
601 !allow_file_selection_dialogs_.GetValue()); 601 !allow_file_selection_dialogs_.GetValue());
602 web_ui_->CallJavascriptFunction( 602 web_ui_->CallJavascriptFunction(
603 "options.AdvancedOptions.SetPromptForDownload", checked, disabled); 603 "options.AdvancedOptions.SetPromptForDownload", checked, disabled);
604 } 604 }
605 605
606 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { 606 void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() {
607 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. 607 // Set the enabled state for the AutoOpenFileTypesResetToDefault button.
608 // We enable the button if the user has any auto-open file types registered. 608 // We enable the button if the user has any auto-open file types registered.
609 DownloadManager* manager = 609 DownloadManager* manager =
610 web_ui_->tab_contents()->browser_context()->GetDownloadManager(); 610 web_ui_->tab_contents()->browser_context()->GetDownloadManager();
611 bool disabled = !(manager && manager->download_prefs()->IsAutoOpenUsed()); 611 bool disabled = !(manager && manager->download_prefs()->IsAutoOpenUsed());
612 base::FundamentalValue value(disabled); 612 base::BooleanValue value(disabled);
613 web_ui_->CallJavascriptFunction( 613 web_ui_->CallJavascriptFunction(
614 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); 614 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value);
615 } 615 }
616 616
617 void AdvancedOptionsHandler::SetupProxySettingsSection() { 617 void AdvancedOptionsHandler::SetupProxySettingsSection() {
618 // Disable the button if proxy settings are managed by a sysadmin or 618 // Disable the button if proxy settings are managed by a sysadmin or
619 // overridden by an extension. 619 // overridden by an extension.
620 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); 620 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
621 const PrefService::Preference* proxy_config = 621 const PrefService::Preference* proxy_config =
622 pref_service->FindPreference(prefs::kProxy); 622 pref_service->FindPreference(prefs::kProxy);
623 bool is_extension_controlled = (proxy_config && 623 bool is_extension_controlled = (proxy_config &&
624 proxy_config->IsExtensionControlled()); 624 proxy_config->IsExtensionControlled());
625 625
626 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || 626 base::BooleanValue disabled(proxy_prefs_->IsManaged() ||
627 is_extension_controlled); 627 is_extension_controlled);
628 628
629 // Get the appropriate info string to describe the button. 629 // Get the appropriate info string to describe the button.
630 string16 label_str; 630 string16 label_str;
631 if (is_extension_controlled) { 631 if (is_extension_controlled) {
632 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); 632 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL);
633 } else { 633 } else {
634 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, 634 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL,
635 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 635 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
636 } 636 }
637 StringValue label(label_str); 637 StringValue label(label_str);
638 638
639 web_ui_->CallJavascriptFunction( 639 web_ui_->CallJavascriptFunction(
640 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label); 640 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label);
641 } 641 }
642 642
643 void AdvancedOptionsHandler::SetupSSLConfigSettings() { 643 void AdvancedOptionsHandler::SetupSSLConfigSettings() {
644 { 644 {
645 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); 645 base::BooleanValue checked(rev_checking_enabled_.GetValue());
646 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); 646 base::BooleanValue disabled(rev_checking_enabled_.IsManaged());
647 web_ui_->CallJavascriptFunction( 647 web_ui_->CallJavascriptFunction(
648 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, 648 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked,
649 disabled); 649 disabled);
650 } 650 }
651 { 651 {
652 base::FundamentalValue checked(ssl3_enabled_.GetValue()); 652 base::BooleanValue checked(ssl3_enabled_.GetValue());
653 base::FundamentalValue disabled(ssl3_enabled_.IsManaged()); 653 base::BooleanValue disabled(ssl3_enabled_.IsManaged());
654 web_ui_->CallJavascriptFunction( 654 web_ui_->CallJavascriptFunction(
655 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled); 655 "options.AdvancedOptions.SetUseSSL3CheckboxState", checked, disabled);
656 } 656 }
657 { 657 {
658 base::FundamentalValue checked(tls1_enabled_.GetValue()); 658 base::BooleanValue checked(tls1_enabled_.GetValue());
659 base::FundamentalValue disabled(tls1_enabled_.IsManaged()); 659 base::BooleanValue disabled(tls1_enabled_.IsManaged());
660 web_ui_->CallJavascriptFunction( 660 web_ui_->CallJavascriptFunction(
661 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled); 661 "options.AdvancedOptions.SetUseTLS1CheckboxState", checked, disabled);
662 } 662 }
663 } 663 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/shown_sections_handler.cc ('k') | chrome/browser/ui/webui/options/autofill_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698