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

Unified Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 1843523002: ChromeOS: Add SystemTimezoneAutomaticDetection policy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@596690--Implement-better-timezone-detection--refactoring-before-policy
Patch Set: Rebased. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/browser_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index fa16c8440531907befa2d1d5b15d1bd07a191ce3..ef9fc77ac883ff9880f9a87a421d7fa9aa3f4bc7 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -1013,6 +1013,13 @@ void BrowserOptionsHandler::InitializeHandler() {
chromeos::kSystemTimezonePolicy,
base::Bind(&BrowserOptionsHandler::OnSystemTimezonePolicyChanged,
weak_ptr_factory_.GetWeakPtr()));
+ local_state_pref_change_registrar_.Init(g_browser_process->local_state());
+ local_state_pref_change_registrar_.Add(
+ prefs::kSystemTimezoneAutomaticDetectionPolicy,
+ base::Bind(&BrowserOptionsHandler::
+ OnSystemTimezoneAutomaticDetectionPolicyChanged,
+ base::Unretained(this)));
+
#else // !defined(OS_CHROMEOS)
profile_pref_registrar_.Add(
proxy_config::prefs::kProxy,
@@ -1081,6 +1088,7 @@ void BrowserOptionsHandler::InitializePage() {
profile->IsLegacySupervised()) {
web_ui()->CallJavascriptFunction("BrowserOptions.hideAndroidAppsSection");
}
+ OnSystemTimezoneAutomaticDetectionPolicyChanged();
#endif
}
@@ -1440,6 +1448,22 @@ void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() {
"BrowserOptions.setSystemTimezoneManaged",
base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy()));
}
+
+void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() {
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableSystemTimezoneAutomaticDetectionPolicy)) {
+ return;
+ }
+
+ PrefService* prefs = g_browser_process->local_state();
+ const bool is_managed = prefs->IsManagedPreference(
+ prefs::kSystemTimezoneAutomaticDetectionPolicy);
+ const int value =
+ prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy);
+ web_ui()->CallJavascriptFunction(
+ "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged",
+ base::FundamentalValue(is_managed), base::FundamentalValue(value));
+}
#endif
scoped_ptr<base::DictionaryValue>

Powered by Google App Engine
This is Rietveld 408576698