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..977dd456804ca2f30db8c335fe8cd085d006281c 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 ? |
+ this.getPref('settings.timezone').value : |
+ this.getPref('cros.system.timezone').value)) { |
+ return; |
+ } |
} |
cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this)); |
@@ -204,4 +213,36 @@ Polymer({ |
}; |
}); |
}, |
+ |
+ /** |
+ * Computes visibility of user timezone preference. |
+ * @param prefUserTimezone Object pref.settings.timezone |
+ * @param prefResolveValue Boolean |
+ * prefs.settings.resolve_timezone_by_geolocation.value |
+ * @private |
+ */ |
+ isUserTimeZoneSelectorHidden_: function(prefUserTimezone, prefResolveValue) { |
+ return (prefUserTimezone && prefUserTimezone.controlledBy != null) || |
+ (prefResolveValue == true); |
stevenjb
2017/07/10 19:10:53
nit: () not needed for ==
Alexander Alekseev
2017/07/14 03:32:47
Done.
|
+ }, |
+ |
+ /** |
+ * Observer of this.prefs.cros.flags.per_user_timezone_enabled.value . |
+ * If it becomes disabled, adds legacy observer. |
+ * @private |
+ */ |
+ onPerUserTimezoneEnabledChanged_: function() { |
+ if (this.nonPerUserTimezoneSeen_) |
+ return; |
+ |
+ if (!this.getPref('cros.flags.per_user_timezone_enabled').value) { |
stevenjb
2017/07/10 19:10:53
invert and early exit
Alexander Alekseev
2017/07/14 03:32:47
Done.
|
+ this.nonPerUserTimezoneSeen_ = true; |
+ // This is polymer private API, but we could probably remove this method |
+ // before switching to polymer 2.0 . |
+ this['_addComplexObserverEffect'].call( |
+ this, |
+ 'maybeGetTimeZoneList_(' + |
+ 'prefs.cros.system.timezone.value, timeZoneAutoDetect_)'); |
+ } |
+ }, |
}); |