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

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

Issue 2479973002: MD Settings: clarify "controlled by" logic (Closed)
Patch Set: merge Created 4 years, 1 month 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 674
675 if (ShouldShowMultiProfilesUserList()) 675 if (ShouldShowMultiProfilesUserList())
676 values->Set("profilesInfo", GetProfilesInfoList().release()); 676 values->Set("profilesInfo", GetProfilesInfoList().release());
677 677
678 // Profile deletion is not allowed for any users using Metro mode. 678 // Profile deletion is not allowed for any users using Metro mode.
679 bool allow_deletion = true; 679 bool allow_deletion = true;
680 #if defined(USE_ASH) 680 #if defined(USE_ASH)
681 allow_deletion = allow_deletion && !ash::WmShell::HasInstance(); 681 allow_deletion = allow_deletion && !ash::WmShell::HasInstance();
682 #endif 682 #endif
683 values->SetBoolean("allowProfileDeletion", allow_deletion); 683 values->SetBoolean("allowProfileDeletion", allow_deletion);
684 684 values->SetBoolean("profileIsGuest", profile->IsOffTheRecord());
685 values->SetBoolean("profileIsGuest", 685 values->SetBoolean("profileIsSupervised", profile->IsSupervised());
686 Profile::FromWebUI(web_ui())->IsOffTheRecord());
687
688 values->SetBoolean("profileIsSupervised",
689 Profile::FromWebUI(web_ui())->IsSupervised());
690 686
691 #if !defined(OS_CHROMEOS) 687 #if !defined(OS_CHROMEOS)
692 values->SetBoolean( 688 values->SetBoolean(
693 "gpuEnabledAtStart", 689 "gpuEnabledAtStart",
694 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref()); 690 g_browser_process->gpu_mode_manager()->initial_gpu_mode_pref());
695 #endif 691 #endif
696 692
697 #if defined(OS_CHROMEOS) 693 #if defined(OS_CHROMEOS)
698 values->SetBoolean("cupsPrintEnabled", 694 values->SetBoolean("cupsPrintEnabled",
699 base::CommandLine::ForCurrentProcess()->HasSwitch( 695 base::CommandLine::ForCurrentProcess()->HasSwitch(
700 ::switches::kEnableNativeCups)); 696 ::switches::kEnableNativeCups));
701 values->SetString("cupsPrintLearnMoreURL", 697 values->SetString("cupsPrintLearnMoreURL",
702 chrome::kChromeUIMdCupsSettingsURL); 698 chrome::kChromeUIMdCupsSettingsURL);
703 #endif // defined(OS_CHROMEOS) 699 #endif // defined(OS_CHROMEOS)
704 700
705 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) 701 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
706 values->SetBoolean("cloudPrintHideNotificationsCheckbox", 702 values->SetBoolean("cloudPrintHideNotificationsCheckbox",
707 !cloud_print::PrivetNotificationService::IsEnabled()); 703 !cloud_print::PrivetNotificationService::IsEnabled());
708 #endif 704 #endif
709 705
710 values->SetBoolean("cloudPrintShowMDnsOptions", 706 values->SetBoolean("cloudPrintShowMDnsOptions",
711 cloud_print_mdns_ui_enabled_); 707 cloud_print_mdns_ui_enabled_);
712 708
713 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL); 709 values->SetString("cloudPrintLearnMoreURL", chrome::kCloudPrintLearnMoreURL);
714 710
715 values->SetString("languagesLearnMoreURL", 711 values->SetString("languagesLearnMoreURL",
716 chrome::kLanguageSettingsLearnMoreUrl); 712 chrome::kLanguageSettingsLearnMoreUrl);
717 713
718 values->SetBoolean( 714 values->SetBoolean(
719 "easyUnlockAllowed", 715 "easyUnlockAllowed", EasyUnlockService::Get(profile)->IsAllowed());
720 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsAllowed());
721 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl); 716 values->SetString("easyUnlockLearnMoreURL", chrome::kEasyUnlockLearnMoreUrl);
722 values->SetBoolean("easyUnlockProximityDetectionAllowed", 717 values->SetBoolean("easyUnlockProximityDetectionAllowed",
723 base::CommandLine::ForCurrentProcess()->HasSwitch( 718 base::CommandLine::ForCurrentProcess()->HasSwitch(
724 proximity_auth::switches::kEnableProximityDetection)); 719 proximity_auth::switches::kEnableProximityDetection));
725 720
726 #if defined(OS_CHROMEOS) 721 #if defined(OS_CHROMEOS)
727 RegisterTitle(values, "thirdPartyImeConfirmOverlay", 722 RegisterTitle(values, "thirdPartyImeConfirmOverlay",
728 IDS_OPTIONS_SETTINGS_LANGUAGES_THIRD_PARTY_WARNING_TITLE); 723 IDS_OPTIONS_SETTINGS_LANGUAGES_THIRD_PARTY_WARNING_TITLE);
729 values->SetBoolean("usingNewProfilesUI", false); 724 values->SetBoolean("usingNewProfilesUI", false);
730 #else 725 #else
731 values->SetBoolean("usingNewProfilesUI", true); 726 values->SetBoolean("usingNewProfilesUI", true);
732 #endif 727 #endif
733 728
734 values->SetBoolean("showSetDefault", ShouldShowSetDefaultBrowser()); 729 values->SetBoolean("showSetDefault", ShouldShowSetDefaultBrowser());
735 730
736 values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings()); 731 values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings());
737 732
738 #if defined(OS_CHROMEOS) 733 #if defined(OS_CHROMEOS)
739 values->SetBoolean( 734 values->SetBoolean(
740 "showWakeOnWifi", 735 "showWakeOnWifi",
741 chromeos::WakeOnWifiManager::Get()->WakeOnWifiSupported() && 736 chromeos::WakeOnWifiManager::Get()->WakeOnWifiSupported() &&
742 chromeos::switches::WakeOnWifiEnabled()); 737 chromeos::switches::WakeOnWifiEnabled());
743 values->SetBoolean("enableTimeZoneTrackingOption", 738 values->SetBoolean("enableTimeZoneTrackingOption",
744 !chromeos::system::HasSystemTimezonePolicy()); 739 !chromeos::system::HasSystemTimezonePolicy());
745 values->SetBoolean("resolveTimezoneByGeolocationInitialValue", 740 values->SetBoolean("resolveTimezoneByGeolocationInitialValue",
746 Profile::FromWebUI(web_ui())->GetPrefs()->GetBoolean( 741 profile->GetPrefs()->GetBoolean(prefs::kResolveTimezoneByGeolocation));
747 prefs::kResolveTimezoneByGeolocation));
748 values->SetBoolean("enableLanguageOptionsImeMenu", 742 values->SetBoolean("enableLanguageOptionsImeMenu",
749 base::FeatureList::IsEnabled(features::kOptInImeMenu)); 743 base::FeatureList::IsEnabled(features::kOptInImeMenu));
750 values->SetBoolean( 744 values->SetBoolean(
751 "enableExperimentalAccessibilityFeatures", 745 "enableExperimentalAccessibilityFeatures",
752 base::CommandLine::ForCurrentProcess()->HasSwitch( 746 base::CommandLine::ForCurrentProcess()->HasSwitch(
753 chromeos::switches::kEnableExperimentalAccessibilityFeatures)); 747 chromeos::switches::kEnableExperimentalAccessibilityFeatures));
754 748
755 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get(); 749 chromeos::CrosSettings* cros_settings = chromeos::CrosSettings::Get();
756 bool allow_bluetooth = true; 750 bool allow_bluetooth = true;
757 cros_settings->GetBoolean(chromeos::kAllowBluetooth, &allow_bluetooth); 751 cros_settings->GetBoolean(chromeos::kAllowBluetooth, &allow_bluetooth);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 content::NotificationService::AllSources()); 1000 content::NotificationService::AllSources());
1007 #endif 1001 #endif
1008 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 1002 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
1009 content::Source<ThemeService>( 1003 content::Source<ThemeService>(
1010 ThemeServiceFactory::GetForProfile(profile))); 1004 ThemeServiceFactory::GetForProfile(profile)));
1011 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, 1005 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED,
1012 content::Source<Profile>(profile)); 1006 content::Source<Profile>(profile));
1013 AddTemplateUrlServiceObserver(); 1007 AddTemplateUrlServiceObserver();
1014 1008
1015 #if defined(OS_WIN) 1009 #if defined(OS_WIN)
1016 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->AddObserver(this); 1010 ExtensionRegistry::Get(profile)->AddObserver(this);
1017 #endif 1011 #endif
1018 1012
1019 // No preferences below this point may be modified by guest profiles. 1013 // No preferences below this point may be modified by guest profiles.
1020 if (Profile::FromWebUI(web_ui())->IsGuestSession()) 1014 if (profile->IsGuestSession())
1021 return; 1015 return;
1022 1016
1023 auto_open_files_.Init( 1017 auto_open_files_.Init(
1024 prefs::kDownloadExtensionsToOpen, prefs, 1018 prefs::kDownloadExtensionsToOpen, prefs,
1025 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, 1019 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes,
1026 base::Unretained(this))); 1020 base::Unretained(this)));
1027 profile_pref_registrar_.Init(prefs); 1021 profile_pref_registrar_.Init(prefs);
1028 profile_pref_registrar_.Add( 1022 profile_pref_registrar_.Add(
1029 prefs::kNetworkPredictionOptions, 1023 prefs::kNetworkPredictionOptions,
1030 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, 1024 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1166
1173 OnSystemTimezoneAutomaticDetectionPolicyChanged(); 1167 OnSystemTimezoneAutomaticDetectionPolicyChanged();
1174 #endif 1168 #endif
1175 } 1169 }
1176 1170
1177 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { 1171 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() {
1178 #if defined(OS_CHROMEOS) 1172 #if defined(OS_CHROMEOS)
1179 // We're always the default browser on ChromeOS. 1173 // We're always the default browser on ChromeOS.
1180 return false; 1174 return false;
1181 #else 1175 #else
1182 Profile* profile = Profile::FromWebUI(web_ui()); 1176 return !Profile::FromWebUI(web_ui())->IsGuestSession();
1183 return !profile->IsGuestSession();
1184 #endif 1177 #endif
1185 } 1178 }
1186 1179
1187 bool BrowserOptionsHandler::ShouldShowMultiProfilesUserList() { 1180 bool BrowserOptionsHandler::ShouldShowMultiProfilesUserList() {
1188 #if defined(OS_CHROMEOS) 1181 #if defined(OS_CHROMEOS)
1189 // On Chrome OS we use different UI for multi-profiles. 1182 // On Chrome OS we use different UI for multi-profiles.
1190 return false; 1183 return false;
1191 #else 1184 #else
1192 Profile* profile = Profile::FromWebUI(web_ui()); 1185 if (Profile::FromWebUI(web_ui())->IsGuestSession())
1193 if (profile->IsGuestSession())
1194 return false; 1186 return false;
1195 return profiles::IsMultipleProfilesEnabled(); 1187 return profiles::IsMultipleProfilesEnabled();
1196 #endif 1188 #endif
1197 } 1189 }
1198 1190
1199 bool BrowserOptionsHandler::ShouldAllowAdvancedSettings() { 1191 bool BrowserOptionsHandler::ShouldAllowAdvancedSettings() {
1200 #if defined(OS_CHROMEOS) 1192 #if defined(OS_CHROMEOS)
1201 // ChromeOS handles guest-mode restrictions in a different manner. 1193 // ChromeOS handles guest-mode restrictions in a different manner.
1202 return true; 1194 return true;
1203 #else 1195 #else
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 void BrowserOptionsHandler::SetupEasyUnlock() { 2157 void BrowserOptionsHandler::SetupEasyUnlock() {
2166 base::FundamentalValue is_enabled( 2158 base::FundamentalValue is_enabled(
2167 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); 2159 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled());
2168 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", 2160 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock",
2169 is_enabled); 2161 is_enabled);
2170 } 2162 }
2171 2163
2172 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { 2164 void BrowserOptionsHandler::SetupExtensionControlledIndicators() {
2173 base::DictionaryValue extension_controlled; 2165 base::DictionaryValue extension_controlled;
2174 2166
2167 Profile* profile = Profile::FromWebUI(web_ui());
2168
2175 // Check if an extension is overriding the Search Engine. 2169 // Check if an extension is overriding the Search Engine.
2176 const extensions::Extension* extension = 2170 const extensions::Extension* extension =
2177 extensions::GetExtensionOverridingSearchEngine( 2171 extensions::GetExtensionOverridingSearchEngine(profile);
2178 Profile::FromWebUI(web_ui()));
2179 AppendExtensionData("searchEngine", extension, &extension_controlled); 2172 AppendExtensionData("searchEngine", extension, &extension_controlled);
2180 2173
2181 // Check if an extension is overriding the Home page. 2174 // Check if an extension is overriding the Home page.
2182 extension = extensions::GetExtensionOverridingHomepage( 2175 extension = extensions::GetExtensionOverridingHomepage(profile);
2183 Profile::FromWebUI(web_ui()));
2184 AppendExtensionData("homePage", extension, &extension_controlled); 2176 AppendExtensionData("homePage", extension, &extension_controlled);
2185 2177
2186 // Check if an extension is overriding the Startup pages. 2178 // Check if an extension is overriding the Startup pages.
2187 extension = extensions::GetExtensionOverridingStartupPages( 2179 extension = extensions::GetExtensionOverridingStartupPages(profile);
2188 Profile::FromWebUI(web_ui()));
2189 AppendExtensionData("startUpPage", extension, &extension_controlled); 2180 AppendExtensionData("startUpPage", extension, &extension_controlled);
2190 2181
2191 // Check if an extension is overriding the NTP page. 2182 // Check if an extension is overriding the NTP page.
2192 GURL ntp_url(chrome::kChromeUINewTabURL); 2183 extension = extensions::GetExtensionOverridingNewTabPage(profile);
2193 bool ignored_param;
2194 extension = NULL;
2195 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary(
2196 &ntp_url,
2197 web_ui()->GetWebContents()->GetBrowserContext(),
2198 &ignored_param);
2199 if (ntp_url.SchemeIs("chrome-extension")) {
2200 using extensions::ExtensionRegistry;
2201 ExtensionRegistry* registry = ExtensionRegistry::Get(
2202 Profile::FromWebUI(web_ui()));
2203 extension = registry->GetExtensionById(ntp_url.host(),
2204 ExtensionRegistry::ENABLED);
2205 }
2206 AppendExtensionData("newTabPage", extension, &extension_controlled); 2184 AppendExtensionData("newTabPage", extension, &extension_controlled);
2207 2185
2208 // Check if an extension is overwriting the proxy setting. 2186 // Check if an extension is overwriting the proxy setting.
2209 extension = extensions::GetExtensionOverridingProxy( 2187 extension = extensions::GetExtensionOverridingProxy(profile);
2210 Profile::FromWebUI(web_ui()));
2211 AppendExtensionData("proxy", extension, &extension_controlled); 2188 AppendExtensionData("proxy", extension, &extension_controlled);
2212 2189
2213 web_ui()->CallJavascriptFunctionUnsafe( 2190 web_ui()->CallJavascriptFunctionUnsafe(
2214 "BrowserOptions.toggleExtensionIndicators", extension_controlled); 2191 "BrowserOptions.toggleExtensionIndicators", extension_controlled);
2215 } 2192 }
2216 2193
2217 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { 2194 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() {
2218 // As the metrics and crash reporting checkbox only exists for official builds 2195 // As the metrics and crash reporting checkbox only exists for official builds
2219 // it doesn't need to be set up for non-official builds. 2196 // it doesn't need to be set up for non-official builds.
2220 #if defined(GOOGLE_CHROME_BUILD) 2197 #if defined(GOOGLE_CHROME_BUILD)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 2277
2301 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { 2278 bool BrowserOptionsHandler::IsDeviceOwnerProfile() {
2302 #if defined(OS_CHROMEOS) 2279 #if defined(OS_CHROMEOS)
2303 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); 2280 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
2304 #else 2281 #else
2305 return true; 2282 return true;
2306 #endif 2283 #endif
2307 } 2284 }
2308 2285
2309 } // namespace options 2286 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698