Index: chrome/browser/resources/settings/date_time_page/date_time_page.js |
diff --git a/chrome/browser/resources/settings/date_time_page/date_time_page.js b/chrome/browser/resources/settings/date_time_page/date_time_page.js |
index 3b004f22eabfd72b0a33f42437fe37b9ca52e093..ef37894763604b37d0a7b6a052b2c531189e41aa 100644 |
--- a/chrome/browser/resources/settings/date_time_page/date_time_page.js |
+++ b/chrome/browser/resources/settings/date_time_page/date_time_page.js |
@@ -90,7 +90,9 @@ Polymer({ |
}, |
observers: [ |
- 'maybeGetTimeZoneList_(' + |
+ 'maybeGetTimeZoneListPerUser_(' + |
+ 'prefs.settings.timezone.value, timeZoneAutoDetect_)', |
+ 'maybeGetTimeZoneListPerSystem_(' + |
'prefs.cros.system.timezone.value, timeZoneAutoDetect_)', |
], |
@@ -174,23 +176,53 @@ Polymer({ |
/** |
* Fetches the list of time zones if necessary. |
+ * @param {boolean=} perUserTimeZoneMode Expected value of per-user time zone. |
* @private |
*/ |
- maybeGetTimeZoneList_: function() { |
+ maybeGetTimeZoneList_: function(perUserTimeZoneMode) { |
+ if (typeof(perUserTimeZoneMode) !== 'undefined') { |
+ /* This method is called as observer. Skip if if current mode does not |
+ * match expected. |
+ */ |
+ if (perUserTimeZoneMode != |
+ this.getPref('cros.flags.per_user_timezone_enabled').value) { |
+ return; |
+ } |
+ } |
// Only fetch the list once. |
if (this.timeZoneList_.length > 1 || !CrSettingsPrefs.isInitialized) |
return; |
// If auto-detect is enabled, we only need the current time zone. |
- if (this.timeZoneAutoDetect_ && |
- this.getPref('cros.system.timezone').value == |
- this.timeZoneList_[0].value) { |
- return; |
+ if (this.timeZoneAutoDetect_) { |
+ var isPerUserTimezone = |
+ this.getPref('cros.flags.per_user_timezone_enabled').value; |
+ if (this.timeZoneList_[0].value == |
+ (isPerUserTimezone ? this.getPref('settings.timezone').value : |
+ this.getPref('cros.system.timezone').value)) { |
+ return; |
+ } |
} |
cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this)); |
}, |
+ /** |
+ * Prefs observer for Per-user time zone enabled mode. |
+ * @private |
+ */ |
+ maybeGetTimeZoneListPerUser_: function() { |
+ this.maybeGetTimeZoneList_(true); |
+ }, |
+ |
+ /** |
+ * Prefs observer for Per-user time zone disabled mode. |
+ * @private |
+ */ |
+ maybeGetTimeZoneListPerSystem_: function() { |
+ this.maybeGetTimeZoneList_(false); |
+ }, |
+ |
/** |
* Converts the C++ response into an array of menu options. |
* @param {!Array<!Array<string>>} timeZones C++ time zones response. |
@@ -204,4 +236,17 @@ Polymer({ |
}; |
}); |
}, |
+ |
+ /** |
+ * Computes visibility of user timezone preference. |
+ * @param {?chrome.settingsPrivate.PrefObject} prefUserTimezone |
+ * pref.settings.timezone |
+ * @param {boolean} prefResolveValue |
+ * prefs.settings.resolve_timezone_by_geolocation.value |
+ * @private |
+ */ |
+ isUserTimeZoneSelectorHidden_: function(prefUserTimezone, prefResolveValue) { |
+ return (prefUserTimezone && prefUserTimezone.controlledBy != null) || |
+ prefResolveValue; |
+ }, |
}); |