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/options/browser_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/app_window.h" | 10 #include "apps/app_window.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #include "ui/base/webui/web_ui_util.h" | 94 #include "ui/base/webui/web_ui_util.h" |
95 | 95 |
96 #if !defined(OS_CHROMEOS) | 96 #if !defined(OS_CHROMEOS) |
97 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" | 97 #include "chrome/browser/ui/webui/options/advanced_options_utils.h" |
98 #endif | 98 #endif |
99 | 99 |
100 #if defined(OS_CHROMEOS) | 100 #if defined(OS_CHROMEOS) |
101 #include "ash/ash_switches.h" | 101 #include "ash/ash_switches.h" |
102 #include "ash/magnifier/magnifier_constants.h" | 102 #include "ash/magnifier/magnifier_constants.h" |
103 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 103 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 104 #include "chrome/browser/chromeos/chromeos_utils.h" |
104 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h" | 105 #include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h" |
105 #include "chrome/browser/chromeos/login/user.h" | 106 #include "chrome/browser/chromeos/login/user.h" |
106 #include "chrome/browser/chromeos/login/user_manager.h" | 107 #include "chrome/browser/chromeos/login/user_manager.h" |
107 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 108 #include "chrome/browser/chromeos/login/wallpaper_manager.h" |
108 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 109 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
109 #include "chrome/browser/chromeos/settings/cros_settings.h" | 110 #include "chrome/browser/chromeos/settings/cros_settings.h" |
110 #include "chrome/browser/chromeos/system/timezone_util.h" | 111 #include "chrome/browser/chromeos/system/timezone_util.h" |
111 #include "chrome/browser/policy/profile_policy_connector.h" | 112 #include "chrome/browser/policy/profile_policy_connector.h" |
112 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 113 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
113 #include "chrome/browser/ui/browser_window.h" | 114 #include "chrome/browser/ui/browser_window.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 { "doNotTrackConfirmDisable", | 226 { "doNotTrackConfirmDisable", |
226 IDS_OPTIONS_ENABLE_DO_NOT_TRACK_BUBBLE_DISABLE }, | 227 IDS_OPTIONS_ENABLE_DO_NOT_TRACK_BUBBLE_DISABLE }, |
227 { "downloadLocationAskForSaveLocation", | 228 { "downloadLocationAskForSaveLocation", |
228 IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION }, | 229 IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION }, |
229 { "downloadLocationBrowseTitle", | 230 { "downloadLocationBrowseTitle", |
230 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE }, | 231 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE }, |
231 { "downloadLocationChangeButton", | 232 { "downloadLocationChangeButton", |
232 IDS_OPTIONS_DOWNLOADLOCATION_CHANGE_BUTTON }, | 233 IDS_OPTIONS_DOWNLOADLOCATION_CHANGE_BUTTON }, |
233 { "downloadLocationGroupName", IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME }, | 234 { "downloadLocationGroupName", IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME }, |
234 { "enableLogging", IDS_OPTIONS_ENABLE_LOGGING }, | 235 { "enableLogging", IDS_OPTIONS_ENABLE_LOGGING }, |
| 236 #if !defined(OS_CHROMEOS) |
| 237 { "easyUnlockCheckboxLabel", IDS_OPTIONS_EASY_UNLOCK_CHECKBOX_LABEL }, |
| 238 #endif |
| 239 { "easyUnlockSectionTitle", IDS_OPTIONS_EASY_UNLOCK_SECTION_TITLE }, |
| 240 { "easyUnlockSetupButton", IDS_OPTIONS_EASY_UNLOCK_SETUP_BUTTON }, |
| 241 { "easyUnlockManagement", IDS_OPTIONS_EASY_UNLOCK_MANAGEMENT }, |
235 { "fontSettingsCustomizeFontsButton", | 242 { "fontSettingsCustomizeFontsButton", |
236 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON }, | 243 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON }, |
237 { "fontSizeLabelCustom", IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM }, | 244 { "fontSizeLabelCustom", IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM }, |
238 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE }, | 245 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE }, |
239 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, | 246 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, |
240 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, | 247 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, |
241 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE }, | 248 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE }, |
242 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, | 249 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, |
243 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, | 250 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, |
244 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, | 251 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 !local_discovery::PrivetNotificationService::IsEnabled()); | 567 !local_discovery::PrivetNotificationService::IsEnabled()); |
561 #endif | 568 #endif |
562 | 569 |
563 values->SetBoolean("cloudPrintShowMDnsOptions", | 570 values->SetBoolean("cloudPrintShowMDnsOptions", |
564 cloud_print_mdns_ui_enabled_); | 571 cloud_print_mdns_ui_enabled_); |
565 | 572 |
566 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL); | 573 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL); |
567 | 574 |
568 values->SetString("languagesLearnMoreURL", | 575 values->SetString("languagesLearnMoreURL", |
569 chrome::kLanguageSettingsLearnMoreUrl); | 576 chrome::kLanguageSettingsLearnMoreUrl); |
| 577 |
| 578 values->SetBoolean( |
| 579 "easyUnlockEnabled", |
| 580 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableEasyUnlock)); |
| 581 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl); |
| 582 values->SetString("easyUnlockManagementURL", |
| 583 chrome::kEasyUnlockManagementUrl); |
| 584 #if defined(OS_CHROMEOS) |
| 585 values->SetString("easyUnlockCheckboxLabel", |
| 586 l10n_util::GetStringFUTF16( |
| 587 IDS_OPTIONS_EASY_UNLOCK_CHECKBOX_LABEL_CHROMEOS, |
| 588 chromeos::GetChromeDeviceType())); |
| 589 #endif |
570 } | 590 } |
571 | 591 |
572 #if defined(ENABLE_FULL_PRINTING) | 592 #if defined(ENABLE_FULL_PRINTING) |
573 void BrowserOptionsHandler::RegisterCloudPrintValues( | 593 void BrowserOptionsHandler::RegisterCloudPrintValues( |
574 base::DictionaryValue* values) { | 594 base::DictionaryValue* values) { |
575 values->SetString("cloudPrintOptionLabel", | 595 values->SetString("cloudPrintOptionLabel", |
576 l10n_util::GetStringFUTF16( | 596 l10n_util::GetStringFUTF16( |
577 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL, | 597 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL, |
578 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); | 598 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
579 | 599 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 #endif | 722 #endif |
703 web_ui()->RegisterMessageCallback( | 723 web_ui()->RegisterMessageCallback( |
704 "requestHotwordAvailable", | 724 "requestHotwordAvailable", |
705 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, | 725 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, |
706 base::Unretained(this))); | 726 base::Unretained(this))); |
707 | 727 |
708 web_ui()->RegisterMessageCallback( | 728 web_ui()->RegisterMessageCallback( |
709 "requestHotwordSetupRetry", | 729 "requestHotwordSetupRetry", |
710 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordSetupRetry, | 730 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordSetupRetry, |
711 base::Unretained(this))); | 731 base::Unretained(this))); |
| 732 |
| 733 web_ui()->RegisterMessageCallback( |
| 734 "launchEasyUnlockSetup", |
| 735 base::Bind(&BrowserOptionsHandler::HandleLaunchEasyUnlockSetup, |
| 736 base::Unretained(this))); |
712 } | 737 } |
713 | 738 |
714 void BrowserOptionsHandler::Uninitialize() { | 739 void BrowserOptionsHandler::Uninitialize() { |
715 registrar_.RemoveAll(); | 740 registrar_.RemoveAll(); |
716 } | 741 } |
717 | 742 |
718 void BrowserOptionsHandler::OnStateChanged() { | 743 void BrowserOptionsHandler::OnStateChanged() { |
719 UpdateSyncState(); | 744 UpdateSyncState(); |
720 } | 745 } |
721 | 746 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, | 821 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, |
797 base::Unretained(this))); | 822 base::Unretained(this))); |
798 profile_pref_registrar_.Add( | 823 profile_pref_registrar_.Add( |
799 prefs::kManagedUsers, | 824 prefs::kManagedUsers, |
800 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers, | 825 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers, |
801 base::Unretained(this))); | 826 base::Unretained(this))); |
802 profile_pref_registrar_.Add( | 827 profile_pref_registrar_.Add( |
803 prefs::kSigninAllowed, | 828 prefs::kSigninAllowed, |
804 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange, | 829 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange, |
805 base::Unretained(this))); | 830 base::Unretained(this))); |
| 831 profile_pref_registrar_.Add( |
| 832 prefs::kEasyUnlockPairing, |
| 833 base::Bind(&BrowserOptionsHandler::SetupEasyUnlock, |
| 834 base::Unretained(this))); |
806 | 835 |
807 #if defined(OS_CHROMEOS) | 836 #if defined(OS_CHROMEOS) |
808 if (!policy_registrar_) { | 837 if (!policy_registrar_) { |
809 policy_registrar_.reset(new policy::PolicyChangeRegistrar( | 838 policy_registrar_.reset(new policy::PolicyChangeRegistrar( |
810 policy::ProfilePolicyConnectorFactory::GetForProfile(profile)-> | 839 policy::ProfilePolicyConnectorFactory::GetForProfile(profile)-> |
811 policy_service(), | 840 policy_service(), |
812 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()))); | 841 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()))); |
813 policy_registrar_->Observe( | 842 policy_registrar_->Observe( |
814 policy::key::kUserAvatarImage, | 843 policy::key::kUserAvatarImage, |
815 base::Bind(&BrowserOptionsHandler::OnUserImagePolicyChanged, | 844 base::Bind(&BrowserOptionsHandler::OnUserImagePolicyChanged, |
(...skipping 20 matching lines...) Expand all Loading... |
836 OnStateChanged(); | 865 OnStateChanged(); |
837 UpdateDefaultBrowserState(); | 866 UpdateDefaultBrowserState(); |
838 | 867 |
839 SetupMetricsReportingSettingVisibility(); | 868 SetupMetricsReportingSettingVisibility(); |
840 SetupFontSizeSelector(); | 869 SetupFontSizeSelector(); |
841 SetupPageZoomSelector(); | 870 SetupPageZoomSelector(); |
842 SetupAutoOpenFileTypes(); | 871 SetupAutoOpenFileTypes(); |
843 SetupProxySettingsSection(); | 872 SetupProxySettingsSection(); |
844 SetupManageCertificatesSection(); | 873 SetupManageCertificatesSection(); |
845 SetupManagingSupervisedUsers(); | 874 SetupManagingSupervisedUsers(); |
| 875 SetupEasyUnlock(); |
846 | 876 |
847 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS) | 877 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS) |
848 if (!cloud_print_mdns_ui_enabled_) { | 878 if (!cloud_print_mdns_ui_enabled_) { |
849 if (cloud_print_connector_ui_enabled_) { | 879 if (cloud_print_connector_ui_enabled_) { |
850 SetupCloudPrintConnectorSection(); | 880 SetupCloudPrintConnectorSection(); |
851 RefreshCloudPrintStatusFromService(); | 881 RefreshCloudPrintStatusFromService(); |
852 } else { | 882 } else { |
853 RemoveCloudPrintConnectorSection(); | 883 RemoveCloudPrintConnectorSection(); |
854 } | 884 } |
855 } | 885 } |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection"); | 1602 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection"); |
1573 } else if (HotwordServiceFactory::IsHotwordAllowed(profile)) { | 1603 } else if (HotwordServiceFactory::IsHotwordAllowed(profile)) { |
1574 base::StringValue error_message(l10n_util::GetStringUTF16( | 1604 base::StringValue error_message(l10n_util::GetStringUTF16( |
1575 IDS_HOTWORD_GENERIC_ERROR_MESSAGE)); | 1605 IDS_HOTWORD_GENERIC_ERROR_MESSAGE)); |
1576 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection", | 1606 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection", |
1577 error_message); | 1607 error_message); |
1578 } | 1608 } |
1579 } | 1609 } |
1580 } | 1610 } |
1581 | 1611 |
| 1612 void BrowserOptionsHandler::HandleLaunchEasyUnlockSetup( |
| 1613 const base::ListValue* args) { |
| 1614 // TODO(tengs): launch Easy Unlock setup flow. |
| 1615 } |
| 1616 |
1582 void BrowserOptionsHandler::HandleRequestHotwordSetupRetry( | 1617 void BrowserOptionsHandler::HandleRequestHotwordSetupRetry( |
1583 const base::ListValue* args) { | 1618 const base::ListValue* args) { |
1584 // TODO(joshtrask): invoke BrowserOptions.showHotwordSection again, passing | 1619 // TODO(joshtrask): invoke BrowserOptions.showHotwordSection again, passing |
1585 // the new error message if any. | 1620 // the new error message if any. |
1586 HotwordServiceFactory::RetryHotwordExtension(Profile::FromWebUI(web_ui())); | 1621 HotwordServiceFactory::RetryHotwordExtension(Profile::FromWebUI(web_ui())); |
1587 } | 1622 } |
1588 | 1623 |
1589 #if defined(OS_CHROMEOS) | 1624 #if defined(OS_CHROMEOS) |
1590 void BrowserOptionsHandler::HandleOpenWallpaperManager( | 1625 void BrowserOptionsHandler::HandleOpenWallpaperManager( |
1591 const base::ListValue* args) { | 1626 const base::ListValue* args) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 | 1792 |
1758 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { | 1793 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { |
1759 bool has_users = !Profile::FromWebUI(web_ui())-> | 1794 bool has_users = !Profile::FromWebUI(web_ui())-> |
1760 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty(); | 1795 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty(); |
1761 base::FundamentalValue has_users_value(has_users); | 1796 base::FundamentalValue has_users_value(has_users); |
1762 web_ui()->CallJavascriptFunction( | 1797 web_ui()->CallJavascriptFunction( |
1763 "BrowserOptions.updateManagesSupervisedUsers", | 1798 "BrowserOptions.updateManagesSupervisedUsers", |
1764 has_users_value); | 1799 has_users_value); |
1765 } | 1800 } |
1766 | 1801 |
| 1802 void BrowserOptionsHandler::SetupEasyUnlock() { |
| 1803 bool has_pairing = !Profile::FromWebUI(web_ui())->GetPrefs() |
| 1804 ->GetDictionary(prefs::kEasyUnlockPairing)->empty(); |
| 1805 base::FundamentalValue has_pairing_value(has_pairing); |
| 1806 web_ui()->CallJavascriptFunction( |
| 1807 "BrowserOptions.updateEasyUnlock", |
| 1808 has_pairing_value); |
| 1809 } |
| 1810 |
1767 } // namespace options | 1811 } // namespace options |
OLD | NEW |