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..38b6a725db4660a5e91eabfbdd06b111fdb49605 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 |
@@ -91,9 +91,15 @@ Polymer({ |
observers: [ |
'maybeGetTimeZoneList_(' + |
- 'prefs.cros.system.timezone.value, timeZoneAutoDetect_)', |
+ 'prefs.settings.timezone.value, timeZoneAutoDetect_)', |
+ 'onPerUserTimezoneEnabledChanged_(' + |
+ 'prefs.cros.flags.per_user_timezone_enabled.value)', |
], |
+ // True if !prefs.cros.flags.per_user_timezone_enabled.value has been |
+ // acknowledged. |
+ nonPerUserTimezoneSeen_: false, |
+ |
/** @override */ |
attached: function() { |
this.addWebUIListener( |
@@ -182,10 +188,13 @@ Polymer({ |
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_) { |
+ if (this.timeZoneList_[0].value == |
+ (this.getPref('cros.flags.per_user_timezone_enabled').value ? |
michaelpg
2017/07/17 18:17:05
nit: maybe split this out into a separate variable
Alexander Alekseev
2017/07/20 00:30:54
Done.
|
+ this.getPref('settings.timezone').value : |
+ this.getPref('cros.system.timezone').value)) { |
+ return; |
+ } |
} |
cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this)); |
@@ -204,4 +213,37 @@ Polymer({ |
}; |
}); |
}, |
+ |
+ /** |
+ * Computes visibility of user timezone preference. |
+ * @param prefUserTimezone Object pref.settings.timezone |
michaelpg
2017/07/17 18:17:05
@param {?Pref} prefUserTimezone pref.settings.time
Alexander Alekseev
2017/07/20 00:30:53
Done.
|
+ * @param prefResolveValue Boolean |
michaelpg
2017/07/17 18:17:05
@param {boolean} prefResolveValue
Alexander Alekseev
2017/07/20 00:30:53
Done.
|
+ * prefs.settings.resolve_timezone_by_geolocation.value |
+ * @private |
+ */ |
+ isUserTimeZoneSelectorHidden_: function(prefUserTimezone, prefResolveValue) { |
+ return (prefUserTimezone && prefUserTimezone.controlledBy != null) || |
+ prefResolveValue == true; |
michaelpg
2017/07/17 18:17:04
nit: no need for the equality test here, prefResol
Alexander Alekseev
2017/07/20 00:30:53
Done.
|
+ }, |
+ |
+ /** |
+ * Observer of this.prefs.cros.flags.per_user_timezone_enabled.value . |
michaelpg
2017/07/17 18:17:05
nit: remove space before period
Alexander Alekseev
2017/07/20 00:30:54
Done.
|
+ * If it becomes disabled, adds legacy observer. |
+ * @private |
+ */ |
+ onPerUserTimezoneEnabledChanged_: function() { |
+ if (this.nonPerUserTimezoneSeen_) |
+ return; |
+ |
+ if (this.getPref('cros.flags.per_user_timezone_enabled').value) |
+ return; |
+ |
+ this.nonPerUserTimezoneSeen_ = true; |
+ // This is polymer private API, but we could probably remove this method |
+ // before switching to polymer 2.0 . |
michaelpg
2017/07/17 18:17:05
ditto
Alexander Alekseev
2017/07/20 00:30:53
Done.
|
+ this['_addComplexObserverEffect'].call( |
michaelpg
2017/07/17 18:17:05
This looks really scary. Can we just add this as a
Alexander Alekseev
2017/07/20 00:30:53
Done.
|
+ this, |
+ 'maybeGetTimeZoneList_(' + |
+ 'prefs.cros.system.timezone.value, timeZoneAutoDetect_)'); |
+ }, |
}); |