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 | 10 |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 base::Unretained(this))); | 1006 base::Unretained(this))); |
1007 policy_registrar_->Observe( | 1007 policy_registrar_->Observe( |
1008 policy::key::kWallpaperImage, | 1008 policy::key::kWallpaperImage, |
1009 base::Bind(&BrowserOptionsHandler::OnWallpaperPolicyChanged, | 1009 base::Bind(&BrowserOptionsHandler::OnWallpaperPolicyChanged, |
1010 base::Unretained(this))); | 1010 base::Unretained(this))); |
1011 } | 1011 } |
1012 chromeos::CrosSettings::Get()->AddSettingsObserver( | 1012 chromeos::CrosSettings::Get()->AddSettingsObserver( |
1013 chromeos::kSystemTimezonePolicy, | 1013 chromeos::kSystemTimezonePolicy, |
1014 base::Bind(&BrowserOptionsHandler::OnSystemTimezonePolicyChanged, | 1014 base::Bind(&BrowserOptionsHandler::OnSystemTimezonePolicyChanged, |
1015 weak_ptr_factory_.GetWeakPtr())); | 1015 weak_ptr_factory_.GetWeakPtr())); |
1016 local_state_pref_change_registrar_.Init(g_browser_process->local_state()); | |
1017 local_state_pref_change_registrar_.Add( | |
1018 prefs::kSystemTimezoneAutomaticDetectionPolicy, | |
1019 base::Bind(&BrowserOptionsHandler:: | |
1020 OnSystemTimezoneAutomaticDetectionPolicyChanged, | |
1021 base::Unretained(this))); | |
1022 | |
1023 #else // !defined(OS_CHROMEOS) | 1016 #else // !defined(OS_CHROMEOS) |
1024 profile_pref_registrar_.Add( | 1017 profile_pref_registrar_.Add( |
1025 proxy_config::prefs::kProxy, | 1018 proxy_config::prefs::kProxy, |
1026 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, | 1019 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, |
1027 base::Unretained(this))); | 1020 base::Unretained(this))); |
1028 #endif // !defined(OS_CHROMEOS) | 1021 #endif // !defined(OS_CHROMEOS) |
1029 } | 1022 } |
1030 | 1023 |
1031 void BrowserOptionsHandler::InitializePage() { | 1024 void BrowserOptionsHandler::InitializePage() { |
1032 page_initialized_ = true; | 1025 page_initialized_ = true; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 OnConsumerManagementStatusChanged(); | 1074 OnConsumerManagementStatusChanged(); |
1082 consumer_management->AddObserver(this); | 1075 consumer_management->AddObserver(this); |
1083 } | 1076 } |
1084 | 1077 |
1085 if (!arc::ArcBridgeService::GetEnabled( | 1078 if (!arc::ArcBridgeService::GetEnabled( |
1086 base::CommandLine::ForCurrentProcess()) || | 1079 base::CommandLine::ForCurrentProcess()) || |
1087 arc::ArcAuthService::IsOptInVerificationDisabled() || | 1080 arc::ArcAuthService::IsOptInVerificationDisabled() || |
1088 profile->IsLegacySupervised()) { | 1081 profile->IsLegacySupervised()) { |
1089 web_ui()->CallJavascriptFunction("BrowserOptions.hideAndroidAppsSection"); | 1082 web_ui()->CallJavascriptFunction("BrowserOptions.hideAndroidAppsSection"); |
1090 } | 1083 } |
1091 OnSystemTimezoneAutomaticDetectionPolicyChanged(); | |
1092 #endif | 1084 #endif |
1093 } | 1085 } |
1094 | 1086 |
1095 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { | 1087 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { |
1096 #if defined(OS_CHROMEOS) | 1088 #if defined(OS_CHROMEOS) |
1097 // We're always the default browser on ChromeOS. | 1089 // We're always the default browser on ChromeOS. |
1098 return false; | 1090 return false; |
1099 #else | 1091 #else |
1100 Profile* profile = Profile::FromWebUI(web_ui()); | 1092 Profile* profile = Profile::FromWebUI(web_ui()); |
1101 return !profile->IsGuestSession(); | 1093 return !profile->IsGuestSession(); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { | 1433 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { |
1442 web_ui()->CallJavascriptFunction("BrowserOptions.setWallpaperManaged", | 1434 web_ui()->CallJavascriptFunction("BrowserOptions.setWallpaperManaged", |
1443 base::FundamentalValue(managed)); | 1435 base::FundamentalValue(managed)); |
1444 } | 1436 } |
1445 | 1437 |
1446 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { | 1438 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { |
1447 web_ui()->CallJavascriptFunction( | 1439 web_ui()->CallJavascriptFunction( |
1448 "BrowserOptions.setSystemTimezoneManaged", | 1440 "BrowserOptions.setSystemTimezoneManaged", |
1449 base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy())); | 1441 base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy())); |
1450 } | 1442 } |
1451 | |
1452 void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() { | |
1453 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1454 chromeos::switches::kEnableSystemTimezoneAutomaticDetectionPolicy)) { | |
1455 return; | |
1456 } | |
1457 | |
1458 PrefService* prefs = g_browser_process->local_state(); | |
1459 const bool is_managed = prefs->IsManagedPreference( | |
1460 prefs::kSystemTimezoneAutomaticDetectionPolicy); | |
1461 const int value = | |
1462 prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); | |
1463 web_ui()->CallJavascriptFunction( | |
1464 "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged", | |
1465 base::FundamentalValue(is_managed), base::FundamentalValue(value)); | |
1466 } | |
1467 #endif | 1443 #endif |
1468 | 1444 |
1469 scoped_ptr<base::DictionaryValue> | 1445 scoped_ptr<base::DictionaryValue> |
1470 BrowserOptionsHandler::GetSyncStateDictionary() { | 1446 BrowserOptionsHandler::GetSyncStateDictionary() { |
1471 // The items which are to be written into |sync_status| are also described in | 1447 // The items which are to be written into |sync_status| are also described in |
1472 // chrome/browser/resources/options/browser_options.js in @typedef | 1448 // chrome/browser/resources/options/browser_options.js in @typedef |
1473 // for SyncStatus. Please update it whenever you add or remove any keys here. | 1449 // for SyncStatus. Please update it whenever you add or remove any keys here. |
1474 scoped_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); | 1450 scoped_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); |
1475 Profile* profile = Profile::FromWebUI(web_ui()); | 1451 Profile* profile = Profile::FromWebUI(web_ui()); |
1476 if (profile->IsGuestSession()) { | 1452 if (profile->IsGuestSession()) { |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 | 2142 |
2167 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { | 2143 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { |
2168 #if defined(OS_CHROMEOS) | 2144 #if defined(OS_CHROMEOS) |
2169 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | 2145 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); |
2170 #else | 2146 #else |
2171 return true; | 2147 return true; |
2172 #endif | 2148 #endif |
2173 } | 2149 } |
2174 | 2150 |
2175 } // namespace options | 2151 } // namespace options |
OLD | NEW |