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

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

Issue 197313007: Add Easy Unlock options to chrome://settings behind a flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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) 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "chrome/browser/ui/options/options_util.h" 64 #include "chrome/browser/ui/options/options_util.h"
65 #include "chrome/browser/ui/webui/favicon_source.h" 65 #include "chrome/browser/ui/webui/favicon_source.h"
66 #include "chrome/browser/ui/webui/options/options_handlers_helper.h" 66 #include "chrome/browser/ui/webui/options/options_handlers_helper.h"
67 #include "chrome/common/chrome_constants.h" 67 #include "chrome/common/chrome_constants.h"
68 #include "chrome/common/chrome_paths.h" 68 #include "chrome/common/chrome_paths.h"
69 #include "chrome/common/chrome_switches.h" 69 #include "chrome/common/chrome_switches.h"
70 #include "chrome/common/net/url_fixer_upper.h" 70 #include "chrome/common/net/url_fixer_upper.h"
71 #include "chrome/common/pref_names.h" 71 #include "chrome/common/pref_names.h"
72 #include "chrome/common/url_constants.h" 72 #include "chrome/common/url_constants.h"
73 #include "chromeos/chromeos_switches.h" 73 #include "chromeos/chromeos_switches.h"
74 #include "chromeos/chromeos_utils.h"
74 #include "content/public/browser/browser_thread.h" 75 #include "content/public/browser/browser_thread.h"
75 #include "content/public/browser/download_manager.h" 76 #include "content/public/browser/download_manager.h"
76 #include "content/public/browser/navigation_controller.h" 77 #include "content/public/browser/navigation_controller.h"
77 #include "content/public/browser/notification_details.h" 78 #include "content/public/browser/notification_details.h"
78 #include "content/public/browser/notification_service.h" 79 #include "content/public/browser/notification_service.h"
79 #include "content/public/browser/notification_source.h" 80 #include "content/public/browser/notification_source.h"
80 #include "content/public/browser/notification_types.h" 81 #include "content/public/browser/notification_types.h"
81 #include "content/public/browser/url_data_source.h" 82 #include "content/public/browser/url_data_source.h"
82 #include "content/public/browser/user_metrics.h" 83 #include "content/public/browser/user_metrics.h"
83 #include "content/public/browser/web_contents.h" 84 #include "content/public/browser/web_contents.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 { "doNotTrackConfirmDisable", 225 { "doNotTrackConfirmDisable",
225 IDS_OPTIONS_ENABLE_DO_NOT_TRACK_BUBBLE_DISABLE }, 226 IDS_OPTIONS_ENABLE_DO_NOT_TRACK_BUBBLE_DISABLE },
226 { "downloadLocationAskForSaveLocation", 227 { "downloadLocationAskForSaveLocation",
227 IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION }, 228 IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION },
228 { "downloadLocationBrowseTitle", 229 { "downloadLocationBrowseTitle",
229 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE }, 230 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE },
230 { "downloadLocationChangeButton", 231 { "downloadLocationChangeButton",
231 IDS_OPTIONS_DOWNLOADLOCATION_CHANGE_BUTTON }, 232 IDS_OPTIONS_DOWNLOADLOCATION_CHANGE_BUTTON },
232 { "downloadLocationGroupName", IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME }, 233 { "downloadLocationGroupName", IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME },
233 { "enableLogging", IDS_OPTIONS_ENABLE_LOGGING }, 234 { "enableLogging", IDS_OPTIONS_ENABLE_LOGGING },
235 #if !defined(OS_CHROMEOS)
236 { "easyUnlockCheckboxLabel", IDS_OPTIONS_EASY_UNLOCK_CHECKBOX_LABEL },
237 #endif
238 { "easyUnlockSectionTitle", IDS_OPTIONS_EASY_UNLOCK_SECTION_TITLE },
239 { "easyUnlockSetupButton", IDS_OPTIONS_EASY_UNLOCK_SETUP_BUTTON },
240 { "easyUnlockManagement", IDS_OPTIONS_EASY_UNLOCK_MANAGEMENT },
234 { "fontSettingsCustomizeFontsButton", 241 { "fontSettingsCustomizeFontsButton",
235 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON }, 242 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON },
236 { "fontSizeLabelCustom", IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM }, 243 { "fontSizeLabelCustom", IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM },
237 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE }, 244 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE },
238 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, 245 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM },
239 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, 246 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL },
240 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE }, 247 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE },
241 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, 248 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL },
242 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, 249 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS },
243 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP }, 250 { "homePageNtp", IDS_OPTIONS_HOMEPAGE_NTP },
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 !local_discovery::PrivetNotificationService::IsEnabled()); 565 !local_discovery::PrivetNotificationService::IsEnabled());
559 #endif 566 #endif
560 567
561 values->SetBoolean("cloudPrintShowMDnsOptions", 568 values->SetBoolean("cloudPrintShowMDnsOptions",
562 cloud_print_mdns_ui_enabled_); 569 cloud_print_mdns_ui_enabled_);
563 570
564 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL); 571 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL);
565 572
566 values->SetString("languagesLearnMoreURL", 573 values->SetString("languagesLearnMoreURL",
567 chrome::kLanguageSettingsLearnMoreUrl); 574 chrome::kLanguageSettingsLearnMoreUrl);
575
576 values->SetBoolean(
577 "easyUnlockEnabled",
578 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableEasyUnlock));
579 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl);
580 values->SetString("easyUnlockManagementURL",
581 chrome::kEasyUnlockManagementUrl);
582 #if defined(OS_CHROMEOS)
583 values->SetString("easyUnlockCheckboxLabel",
xiyuan 2014/03/15 00:54:56 nit: wrong indent
Tim Song 2014/03/17 19:12:07 Done.
584 l10n_util::GetStringFUTF16(
585 IDS_OPTIONS_EASY_UNLOCK_CHECKBOX_LABEL_CHROMEOS,
586 base::UTF8ToUTF16(chromeos::GetChromeDeviceType())));
587 #endif
568 } 588 }
569 589
570 #if defined(ENABLE_FULL_PRINTING) 590 #if defined(ENABLE_FULL_PRINTING)
571 void BrowserOptionsHandler::RegisterCloudPrintValues( 591 void BrowserOptionsHandler::RegisterCloudPrintValues(
572 base::DictionaryValue* values) { 592 base::DictionaryValue* values) {
573 values->SetString("cloudPrintOptionLabel", 593 values->SetString("cloudPrintOptionLabel",
574 l10n_util::GetStringFUTF16( 594 l10n_util::GetStringFUTF16(
575 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL, 595 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL,
576 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); 596 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)));
577 597
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 web_ui()->RegisterMessageCallback( 715 web_ui()->RegisterMessageCallback(
696 "showCloudPrintDevicesPage", 716 "showCloudPrintDevicesPage",
697 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage, 717 base::Bind(&BrowserOptionsHandler::ShowCloudPrintDevicesPage,
698 base::Unretained(this))); 718 base::Unretained(this)));
699 } 719 }
700 #endif 720 #endif
701 web_ui()->RegisterMessageCallback( 721 web_ui()->RegisterMessageCallback(
702 "requestHotwordAvailable", 722 "requestHotwordAvailable",
703 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable, 723 base::Bind(&BrowserOptionsHandler::HandleRequestHotwordAvailable,
704 base::Unretained(this))); 724 base::Unretained(this)));
725
726 web_ui()->RegisterMessageCallback(
727 "setupEasyUnlock",
728 base::Bind(&BrowserOptionsHandler::HandleLaunchEasyUnlockSetup,
729 base::Unretained(this)));
705 } 730 }
706 731
707 void BrowserOptionsHandler::Uninitialize() { 732 void BrowserOptionsHandler::Uninitialize() {
708 registrar_.RemoveAll(); 733 registrar_.RemoveAll();
709 } 734 }
710 735
711 void BrowserOptionsHandler::OnStateChanged() { 736 void BrowserOptionsHandler::OnStateChanged() {
712 UpdateSyncState(); 737 UpdateSyncState();
713 } 738 }
714 739
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, 814 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector,
790 base::Unretained(this))); 815 base::Unretained(this)));
791 profile_pref_registrar_.Add( 816 profile_pref_registrar_.Add(
792 prefs::kManagedUsers, 817 prefs::kManagedUsers,
793 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers, 818 base::Bind(&BrowserOptionsHandler::SetupManagingSupervisedUsers,
794 base::Unretained(this))); 819 base::Unretained(this)));
795 profile_pref_registrar_.Add( 820 profile_pref_registrar_.Add(
796 prefs::kSigninAllowed, 821 prefs::kSigninAllowed,
797 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange, 822 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange,
798 base::Unretained(this))); 823 base::Unretained(this)));
824 profile_pref_registrar_.Add(
825 prefs::kEasyUnlockPairing,
826 base::Bind(&BrowserOptionsHandler::SetupEasyUnlock,
827 base::Unretained(this)));
799 828
800 #if defined(OS_CHROMEOS) 829 #if defined(OS_CHROMEOS)
801 if (!policy_registrar_) { 830 if (!policy_registrar_) {
802 policy_registrar_.reset(new policy::PolicyChangeRegistrar( 831 policy_registrar_.reset(new policy::PolicyChangeRegistrar(
803 policy::ProfilePolicyConnectorFactory::GetForProfile(profile)-> 832 policy::ProfilePolicyConnectorFactory::GetForProfile(profile)->
804 policy_service(), 833 policy_service(),
805 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string()))); 834 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())));
806 policy_registrar_->Observe( 835 policy_registrar_->Observe(
807 policy::key::kUserAvatarImage, 836 policy::key::kUserAvatarImage,
808 base::Bind(&BrowserOptionsHandler::OnUserImagePolicyChanged, 837 base::Bind(&BrowserOptionsHandler::OnUserImagePolicyChanged,
(...skipping 16 matching lines...) Expand all
825 OnStateChanged(); 854 OnStateChanged();
826 UpdateDefaultBrowserState(); 855 UpdateDefaultBrowserState();
827 856
828 SetupMetricsReportingSettingVisibility(); 857 SetupMetricsReportingSettingVisibility();
829 SetupFontSizeSelector(); 858 SetupFontSizeSelector();
830 SetupPageZoomSelector(); 859 SetupPageZoomSelector();
831 SetupAutoOpenFileTypes(); 860 SetupAutoOpenFileTypes();
832 SetupProxySettingsSection(); 861 SetupProxySettingsSection();
833 SetupManageCertificatesSection(); 862 SetupManageCertificatesSection();
834 SetupManagingSupervisedUsers(); 863 SetupManagingSupervisedUsers();
864 SetupEasyUnlock();
835 865
836 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS) 866 #if defined(ENABLE_FULL_PRINTING) && !defined(OS_CHROMEOS)
837 if (!cloud_print_mdns_ui_enabled_) { 867 if (!cloud_print_mdns_ui_enabled_) {
838 if (cloud_print_connector_ui_enabled_) { 868 if (cloud_print_connector_ui_enabled_) {
839 SetupCloudPrintConnectorSection(); 869 SetupCloudPrintConnectorSection();
840 RefreshCloudPrintStatusFromService(); 870 RefreshCloudPrintStatusFromService();
841 } else { 871 } else {
842 RemoveCloudPrintConnectorSection(); 872 RemoveCloudPrintConnectorSection();
843 } 873 }
844 } 874 }
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 void BrowserOptionsHandler::HandleRequestHotwordAvailable( 1567 void BrowserOptionsHandler::HandleRequestHotwordAvailable(
1538 const base::ListValue* args) { 1568 const base::ListValue* args) {
1539 Profile* profile = Profile::FromWebUI(web_ui()); 1569 Profile* profile = Profile::FromWebUI(web_ui());
1540 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger"); 1570 std::string group = base::FieldTrialList::FindFullName("VoiceTrigger");
1541 if (group != "" && group != "Disabled" && 1571 if (group != "" && group != "Disabled" &&
1542 HotwordServiceFactory::IsServiceAvailable(profile)) { 1572 HotwordServiceFactory::IsServiceAvailable(profile)) {
1543 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection"); 1573 web_ui()->CallJavascriptFunction("BrowserOptions.showHotwordSection");
1544 } 1574 }
1545 } 1575 }
1546 1576
1577 void BrowserOptionsHandler::HandleLaunchEasyUnlockSetup(
1578 const base::ListValue* args) {
1579 // TODO(tengs): launch Easy Unlock setup flow.
1580 }
1581
1547 #if defined(OS_CHROMEOS) 1582 #if defined(OS_CHROMEOS)
1548 void BrowserOptionsHandler::HandleOpenWallpaperManager( 1583 void BrowserOptionsHandler::HandleOpenWallpaperManager(
1549 const base::ListValue* args) { 1584 const base::ListValue* args) {
1550 wallpaper_manager_util::OpenWallpaperManager(); 1585 wallpaper_manager_util::OpenWallpaperManager();
1551 } 1586 }
1552 1587
1553 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( 1588 void BrowserOptionsHandler::VirtualKeyboardChangeCallback(
1554 const base::ListValue* args) { 1589 const base::ListValue* args) {
1555 bool enabled = false; 1590 bool enabled = false;
1556 args->GetBoolean(0, &enabled); 1591 args->GetBoolean(0, &enabled);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 1750
1716 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { 1751 void BrowserOptionsHandler::SetupManagingSupervisedUsers() {
1717 bool has_users = !Profile::FromWebUI(web_ui())-> 1752 bool has_users = !Profile::FromWebUI(web_ui())->
1718 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty(); 1753 GetPrefs()->GetDictionary(prefs::kManagedUsers)->empty();
1719 base::FundamentalValue has_users_value(has_users); 1754 base::FundamentalValue has_users_value(has_users);
1720 web_ui()->CallJavascriptFunction( 1755 web_ui()->CallJavascriptFunction(
1721 "BrowserOptions.updateManagesSupervisedUsers", 1756 "BrowserOptions.updateManagesSupervisedUsers",
1722 has_users_value); 1757 has_users_value);
1723 } 1758 }
1724 1759
1760 void BrowserOptionsHandler::SetupEasyUnlock() {
1761 bool has_pairing = !Profile::FromWebUI(web_ui())->GetPrefs()
1762 ->GetDictionary(prefs::kEasyUnlockPairing)->empty();
1763 base::FundamentalValue has_pairing_value(has_pairing);
1764 web_ui()->CallJavascriptFunction(
1765 "BrowserOptions.updateEasyUnlock",
1766 has_pairing_value);
1767 }
1768
1725 } // namespace options 1769 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698