| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 IDS_HOTWORD_CONFIRM_BUBBLE_TITLE); | 592 IDS_HOTWORD_CONFIRM_BUBBLE_TITLE); |
| 593 values->SetString("hotwordManageAudioHistoryURL", | 593 values->SetString("hotwordManageAudioHistoryURL", |
| 594 chrome::kManageAudioHistoryURL); | 594 chrome::kManageAudioHistoryURL); |
| 595 base::string16 supervised_user_dashboard = | 595 base::string16 supervised_user_dashboard = |
| 596 base::ASCIIToUTF16(chrome::kLegacySupervisedUserManagementURL); | 596 base::ASCIIToUTF16(chrome::kLegacySupervisedUserManagementURL); |
| 597 values->SetString("profilesSupervisedDashboardTip", | 597 values->SetString("profilesSupervisedDashboardTip", |
| 598 l10n_util::GetStringFUTF16( | 598 l10n_util::GetStringFUTF16( |
| 599 IDS_PROFILES_LEGACY_SUPERVISED_USER_DASHBOARD_TIP, | 599 IDS_PROFILES_LEGACY_SUPERVISED_USER_DASHBOARD_TIP, |
| 600 supervised_user_dashboard)); | 600 supervised_user_dashboard)); |
| 601 | 601 |
| 602 Profile* profile = Profile::FromWebUI(web_ui()); |
| 603 |
| 602 #if defined(OS_CHROMEOS) | 604 #if defined(OS_CHROMEOS) |
| 603 Profile* profile = Profile::FromWebUI(web_ui()); | |
| 604 std::string username = profile->GetProfileUserName(); | 605 std::string username = profile->GetProfileUserName(); |
| 605 if (username.empty()) { | 606 if (username.empty()) { |
| 606 const user_manager::User* user = | 607 const user_manager::User* user = |
| 607 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 608 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 608 if (user && (user->GetType() != user_manager::USER_TYPE_GUEST)) | 609 if (user && (user->GetType() != user_manager::USER_TYPE_GUEST)) |
| 609 username = user->GetAccountId().GetUserEmail(); | 610 username = user->GetAccountId().GetUserEmail(); |
| 610 } | 611 } |
| 611 if (!username.empty()) | 612 if (!username.empty()) |
| 612 username = gaia::SanitizeEmail(gaia::CanonicalizeEmail(username)); | 613 username = gaia::SanitizeEmail(gaia::CanonicalizeEmail(username)); |
| 613 | 614 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 670 |
| 670 if (ShouldShowMultiProfilesUserList()) | 671 if (ShouldShowMultiProfilesUserList()) |
| 671 values->Set("profilesInfo", GetProfilesInfoList().release()); | 672 values->Set("profilesInfo", GetProfilesInfoList().release()); |
| 672 | 673 |
| 673 // Profile deletion is not allowed for any users using Metro mode. | 674 // Profile deletion is not allowed for any users using Metro mode. |
| 674 bool allow_deletion = true; | 675 bool allow_deletion = true; |
| 675 #if defined(USE_ASH) | 676 #if defined(USE_ASH) |
| 676 allow_deletion = allow_deletion && !ash::WmShell::HasInstance(); | 677 allow_deletion = allow_deletion && !ash::WmShell::HasInstance(); |
| 677 #endif | 678 #endif |
| 678 values->SetBoolean("allowProfileDeletion", allow_deletion); | 679 values->SetBoolean("allowProfileDeletion", allow_deletion); |
| 679 | 680 values->SetBoolean("profileIsGuest", profile->IsOffTheRecord()); |
| 680 values->SetBoolean("profileIsGuest", | 681 values->SetBoolean("profileIsSupervised", profile->IsSupervised()); |
| 681 Profile::FromWebUI(web_ui())->IsOffTheRecord()); | |
| 682 | |
| 683 values->SetBoolean("profileIsSupervised", | |
| 684 Profile::FromWebUI(web_ui())->IsSupervised()); | |
| 685 | 682 |
| 686 #if !defined(OS_CHROMEOS) | 683 #if !defined(OS_CHROMEOS) |
| 687 values->SetBoolean( | 684 values->SetBoolean( |
| 688 "gpuEnabledAtStart", | 685 "gpuEnabledAtStart", |
| 689 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); | 686 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); |
| 690 #endif | 687 #endif |
| 691 | 688 |
| 692 #if defined(OS_CHROMEOS) | 689 #if defined(OS_CHROMEOS) |
| 693 values->SetBoolean("cupsPrintEnabled", | 690 values->SetBoolean("cupsPrintEnabled", |
| 694 base::CommandLine::ForCurrentProcess()->HasSwitch( | 691 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 695 ::switches::kEnableNativeCups)); | 692 ::switches::kEnableNativeCups)); |
| 696 values->SetString("cupsPrintLearnMoreURL", | 693 values->SetString("cupsPrintLearnMoreURL", |
| 697 chrome::kChromeUIMdCupsSettingsURL); | 694 chrome::kChromeUIMdCupsSettingsURL); |
| 698 #endif // defined(OS_CHROMEOS) | 695 #endif // defined(OS_CHROMEOS) |
| 699 | 696 |
| 700 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) | 697 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) |
| 701 values->SetBoolean("cloudPrintHideNotificationsCheckbox", | 698 values->SetBoolean("cloudPrintHideNotificationsCheckbox", |
| 702 !cloud_print::PrivetNotificationService::IsEnabled()); | 699 !cloud_print::PrivetNotificationService::IsEnabled()); |
| 703 #endif | 700 #endif |
| 704 | 701 |
| 705 values->SetBoolean("cloudPrintShowMDnsOptions", | 702 values->SetBoolean("cloudPrintShowMDnsOptions", |
| 706 cloud_print_mdns_ui_enabled_); | 703 cloud_print_mdns_ui_enabled_); |
| 707 | 704 |
| 708 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL); | 705 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL); |
| 709 | 706 |
| 710 values->SetString("languagesLearnMoreURL", | 707 values->SetString("languagesLearnMoreURL", |
| 711 chrome::kLanguageSettingsLearnMoreUrl); | 708 chrome::kLanguageSettingsLearnMoreUrl); |
| 712 | 709 |
| 713 values->SetBoolean( | 710 values->SetBoolean( |
| 714 "easyUnlockAllowed", | 711 "easyUnlockAllowed", EasyUnlockService::Get(profile)->IsAllowed()); |
| 715 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsAllowed()); | |
| 716 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl); | 712 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl); |
| 717 values->SetBoolean("easyUnlockProximityDetectionAllowed", | 713 values->SetBoolean("easyUnlockProximityDetectionAllowed", |
| 718 base::CommandLine::ForCurrentProcess()->HasSwitch( | 714 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 719 proximity_auth::switches::kEnableProximityDetection)); | 715 proximity_auth::switches::kEnableProximityDetection)); |
| 720 | 716 |
| 721 #if defined(OS_CHROMEOS) | 717 #if defined(OS_CHROMEOS) |
| 722 RegisterTitle(values, "thirdPartyImeConfirmOverlay", | 718 RegisterTitle(values, "thirdPartyImeConfirmOverlay", |
| 723 IDS_OPTIONS_SETTINGS_LANGUAGES_THIRD_PARTY_WARNING_TITLE); | 719 IDS_OPTIONS_SETTINGS_LANGUAGES_THIRD_PARTY_WARNING_TITLE); |
| 724 values->SetBoolean("usingNewProfilesUI", false); | 720 values->SetBoolean("usingNewProfilesUI", false); |
| 725 #else | 721 #else |
| 726 values->SetBoolean("usingNewProfilesUI", true); | 722 values->SetBoolean("usingNewProfilesUI", true); |
| 727 #endif | 723 #endif |
| 728 | 724 |
| 729 values->SetBoolean("showSetDefault", ShouldShowSetDefaultBrowser()); | 725 values->SetBoolean("showSetDefault", ShouldShowSetDefaultBrowser()); |
| 730 | 726 |
| 731 values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings()); | 727 values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings()); |
| 732 | 728 |
| 733 #if defined(OS_CHROMEOS) | 729 #if defined(OS_CHROMEOS) |
| 734 values->SetBoolean( | 730 values->SetBoolean( |
| 735 "showWakeOnWifi", | 731 "showWakeOnWifi", |
| 736 chromeos::WakeOnWifiManager::Get()->WakeOnWifiSupported() && | 732 chromeos::WakeOnWifiManager::Get()->WakeOnWifiSupported() && |
| 737 chromeos::switches::WakeOnWifiEnabled()); | 733 chromeos::switches::WakeOnWifiEnabled()); |
| 738 values->SetBoolean("enableTimeZoneTrackingOption", | 734 values->SetBoolean("enableTimeZoneTrackingOption", |
| 739 !chromeos::system::HasSystemTimezonePolicy()); | 735 !chromeos::system::HasSystemTimezonePolicy()); |
| 740 values->SetBoolean("resolveTimezoneByGeolocationInitialValue", | 736 values->SetBoolean("resolveTimezoneByGeolocationInitialValue", |
| 741 Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean( | 737 profile->GetPrefs()->GetBoolean(prefs::kResolveTimezoneByGeolocation)); |
| 742 prefs::kResolveTimezoneByGeolocation)); | |
| 743 values->SetBoolean("enableLanguageOptionsImeMenu", | 738 values->SetBoolean("enableLanguageOptionsImeMenu", |
| 744 base::FeatureList::IsEnabled(features::kOptInImeMenu)); | 739 base::FeatureList::IsEnabled(features::kOptInImeMenu)); |
| 745 values->SetBoolean( | 740 values->SetBoolean( |
| 746 "enableExperimentalAccessibilityFeatures", | 741 "enableExperimentalAccessibilityFeatures", |
| 747 base::CommandLine::ForCurrentProcess()->HasSwitch( | 742 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 748 chromeos::switches::kEnableExperimentalAccessibilityFeatures)); | 743 chromeos::switches::kEnableExperimentalAccessibilityFeatures)); |
| 749 | 744 |
| 750 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); | 745 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); |
| 751 bool allow_bluetooth = true; | 746 bool allow_bluetooth = true; |
| 752 cros_settings->GetBoolean(chromeos::kAllowBluetooth, &allow_bluetooth); | 747 cros_settings->GetBoolean(chromeos::kAllowBluetooth, &allow_bluetooth); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 content::NotificationService::AllSources()); | 991 content::NotificationService::AllSources()); |
| 997 #endif | 992 #endif |
| 998 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 993 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 999 content::Source<ThemeService>( | 994 content::Source<ThemeService>( |
| 1000 ThemeServiceFactory::GetForProfile(profile))); | 995 ThemeServiceFactory::GetForProfile(profile))); |
| 1001 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 996 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 1002 content::Source<Profile>(profile)); | 997 content::Source<Profile>(profile)); |
| 1003 AddTemplateUrlServiceObserver(); | 998 AddTemplateUrlServiceObserver(); |
| 1004 | 999 |
| 1005 #if defined(OS_WIN) | 1000 #if defined(OS_WIN) |
| 1006 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->AddObserver(this); | 1001 ExtensionRegistry::Get(profile)->AddObserver(this); |
| 1007 #endif | 1002 #endif |
| 1008 | 1003 |
| 1009 // No preferences below this point may be modified by guest profiles. | 1004 // No preferences below this point may be modified by guest profiles. |
| 1010 if (Profile::FromWebUI(web_ui())->IsGuestSession()) | 1005 if (profile->IsGuestSession()) |
| 1011 return; | 1006 return; |
| 1012 | 1007 |
| 1013 auto_open_files_.Init( | 1008 auto_open_files_.Init( |
| 1014 prefs::kDownloadExtensionsToOpen, prefs, | 1009 prefs::kDownloadExtensionsToOpen, prefs, |
| 1015 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, | 1010 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, |
| 1016 base::Unretained(this))); | 1011 base::Unretained(this))); |
| 1017 profile_pref_registrar_.Init(prefs); | 1012 profile_pref_registrar_.Init(prefs); |
| 1018 profile_pref_registrar_.Add( | 1013 profile_pref_registrar_.Add( |
| 1019 prefs::kNetworkPredictionOptions, | 1014 prefs::kNetworkPredictionOptions, |
| 1020 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, | 1015 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 | 1147 |
| 1153 OnSystemTimezoneAutomaticDetectionPolicyChanged(); | 1148 OnSystemTimezoneAutomaticDetectionPolicyChanged(); |
| 1154 #endif | 1149 #endif |
| 1155 } | 1150 } |
| 1156 | 1151 |
| 1157 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { | 1152 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { |
| 1158 #if defined(OS_CHROMEOS) | 1153 #if defined(OS_CHROMEOS) |
| 1159 // We're always the default browser on ChromeOS. | 1154 // We're always the default browser on ChromeOS. |
| 1160 return false; | 1155 return false; |
| 1161 #else | 1156 #else |
| 1162 Profile* profile = Profile::FromWebUI(web_ui()); | 1157 return !Profile::FromWebUI(web_ui())->IsGuestSession(); |
| 1163 return !profile->IsGuestSession(); | |
| 1164 #endif | 1158 #endif |
| 1165 } | 1159 } |
| 1166 | 1160 |
| 1167 bool BrowserOptionsHandler::ShouldShowMultiProfilesUserList() { | 1161 bool BrowserOptionsHandler::ShouldShowMultiProfilesUserList() { |
| 1168 #if defined(OS_CHROMEOS) | 1162 #if defined(OS_CHROMEOS) |
| 1169 // On Chrome OS we use different UI for multi-profiles. | 1163 // On Chrome OS we use different UI for multi-profiles. |
| 1170 return false; | 1164 return false; |
| 1171 #else | 1165 #else |
| 1172 Profile* profile = Profile::FromWebUI(web_ui()); | 1166 if (Profile::FromWebUI(web_ui())->IsGuestSession()) |
| 1173 if (profile->IsGuestSession()) | |
| 1174 return false; | 1167 return false; |
| 1175 return profiles::IsMultipleProfilesEnabled(); | 1168 return profiles::IsMultipleProfilesEnabled(); |
| 1176 #endif | 1169 #endif |
| 1177 } | 1170 } |
| 1178 | 1171 |
| 1179 bool BrowserOptionsHandler::ShouldAllowAdvancedSettings() { | 1172 bool BrowserOptionsHandler::ShouldAllowAdvancedSettings() { |
| 1180 #if defined(OS_CHROMEOS) | 1173 #if defined(OS_CHROMEOS) |
| 1181 // ChromeOS handles guest-mode restrictions in a different manner. | 1174 // ChromeOS handles guest-mode restrictions in a different manner. |
| 1182 return true; | 1175 return true; |
| 1183 #else | 1176 #else |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2145 void BrowserOptionsHandler::SetupEasyUnlock() { | 2138 void BrowserOptionsHandler::SetupEasyUnlock() { |
| 2146 base::FundamentalValue is_enabled( | 2139 base::FundamentalValue is_enabled( |
| 2147 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); | 2140 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); |
| 2148 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", | 2141 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", |
| 2149 is_enabled); | 2142 is_enabled); |
| 2150 } | 2143 } |
| 2151 | 2144 |
| 2152 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { | 2145 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { |
| 2153 base::DictionaryValue extension_controlled; | 2146 base::DictionaryValue extension_controlled; |
| 2154 | 2147 |
| 2148 Profile* profile = Profile::FromWebUI(web_ui()); |
| 2149 |
| 2155 // Check if an extension is overriding the Search Engine. | 2150 // Check if an extension is overriding the Search Engine. |
| 2156 const extensions::Extension* extension = | 2151 const extensions::Extension* extension = |
| 2157 extensions::GetExtensionOverridingSearchEngine( | 2152 extensions::GetExtensionOverridingSearchEngine(profile); |
| 2158 Profile::FromWebUI(web_ui())); | |
| 2159 AppendExtensionData("searchEngine", extension, &extension_controlled); | 2153 AppendExtensionData("searchEngine", extension, &extension_controlled); |
| 2160 | 2154 |
| 2161 // Check if an extension is overriding the Home page. | 2155 // Check if an extension is overriding the Home page. |
| 2162 extension = extensions::GetExtensionOverridingHomepage( | 2156 extension = extensions::GetExtensionOverridingHomepage(profile); |
| 2163 Profile::FromWebUI(web_ui())); | |
| 2164 AppendExtensionData("homePage", extension, &extension_controlled); | 2157 AppendExtensionData("homePage", extension, &extension_controlled); |
| 2165 | 2158 |
| 2166 // Check if an extension is overriding the Startup pages. | 2159 // Check if an extension is overriding the Startup pages. |
| 2167 extension = extensions::GetExtensionOverridingStartupPages( | 2160 extension = extensions::GetExtensionOverridingStartupPages(profile); |
| 2168 Profile::FromWebUI(web_ui())); | |
| 2169 AppendExtensionData("startUpPage", extension, &extension_controlled); | 2161 AppendExtensionData("startUpPage", extension, &extension_controlled); |
| 2170 | 2162 |
| 2171 // Check if an extension is overriding the NTP page. | 2163 // Check if an extension is overriding the NTP page. |
| 2172 GURL ntp_url(chrome::kChromeUINewTabURL); | 2164 extension = extensions::GetExtensionOverridingNewTabPage(profile); |
| 2173 bool ignored_param; | |
| 2174 extension = NULL; | |
| 2175 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | |
| 2176 &ntp_url, | |
| 2177 web_ui()->GetWebContents()->GetBrowserContext(), | |
| 2178 &ignored_param); | |
| 2179 if (ntp_url.SchemeIs("chrome-extension")) { | |
| 2180 using extensions::ExtensionRegistry; | |
| 2181 ExtensionRegistry* registry = ExtensionRegistry::Get( | |
| 2182 Profile::FromWebUI(web_ui())); | |
| 2183 extension = registry->GetExtensionById(ntp_url.host(), | |
| 2184 ExtensionRegistry::ENABLED); | |
| 2185 } | |
| 2186 AppendExtensionData("newTabPage", extension, &extension_controlled); | 2165 AppendExtensionData("newTabPage", extension, &extension_controlled); |
| 2187 | 2166 |
| 2188 // Check if an extension is overwriting the proxy setting. | 2167 // Check if an extension is overwriting the proxy setting. |
| 2189 extension = extensions::GetExtensionOverridingProxy( | 2168 extension = extensions::GetExtensionOverridingProxy(profile); |
| 2190 Profile::FromWebUI(web_ui())); | |
| 2191 AppendExtensionData("proxy", extension, &extension_controlled); | 2169 AppendExtensionData("proxy", extension, &extension_controlled); |
| 2192 | 2170 |
| 2193 web_ui()->CallJavascriptFunctionUnsafe( | 2171 web_ui()->CallJavascriptFunctionUnsafe( |
| 2194 "BrowserOptions.toggleExtensionIndicators", extension_controlled); | 2172 "BrowserOptions.toggleExtensionIndicators", extension_controlled); |
| 2195 } | 2173 } |
| 2196 | 2174 |
| 2197 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { | 2175 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { |
| 2198 // As the metrics and crash reporting checkbox only exists for official builds | 2176 // As the metrics and crash reporting checkbox only exists for official builds |
| 2199 // it doesn't need to be set up for non-official builds. | 2177 // it doesn't need to be set up for non-official builds. |
| 2200 #if defined(GOOGLE_CHROME_BUILD) | 2178 #if defined(GOOGLE_CHROME_BUILD) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 | 2242 |
| 2265 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { | 2243 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { |
| 2266 #if defined(OS_CHROMEOS) | 2244 #if defined(OS_CHROMEOS) |
| 2267 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | 2245 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); |
| 2268 #else | 2246 #else |
| 2269 return true; | 2247 return true; |
| 2270 #endif | 2248 #endif |
| 2271 } | 2249 } |
| 2272 | 2250 |
| 2273 } // namespace options | 2251 } // namespace options |
| OLD | NEW |