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..589f790ac2176be05cace5f51e37cb7d316e920e 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 |
@@ -87,10 +87,26 @@ Polymer({ |
type: Boolean, |
value: false, |
}, |
+ |
+ /** |
+ * Boolean flag indicatined whether per-user timezone option is enabled. |
michaelpg
2017/05/30 22:21:23
"indicating"
Alexander Alekseev
2017/07/06 06:30:29
Done.
|
+ * @private |
+ */ |
+ perUserTimezoneEnabled_: { |
+ type: Boolean, |
+ value: function() { |
+ return loadTimeData.getBoolean('perUserTimezoneEnabled'); |
+ }, |
+ }, |
}, |
+ // We need two separate observers, because prefs.settings.timezone.value is |
+ // undefined when per-user timezone option is disabled, so we cannot combine |
+ // all three inputs in a single observer. |
observers: [ |
'maybeGetTimeZoneList_(' + |
+ 'prefs.settings.timezone.value, timeZoneAutoDetect_)', |
+ 'maybeGetTimeZoneList_(' + |
'prefs.cros.system.timezone.value, timeZoneAutoDetect_)', |
], |
stevenjb
2017/05/30 16:47:18
This is much cleaner, thanks!
Alexander Alekseev
2017/07/06 06:30:29
Done.
|
@@ -182,10 +198,18 @@ 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.perUserTimezoneEnabled_) { |
michaelpg
2017/05/30 22:21:23
optional: use the "if" described in the comment.
Alexander Alekseev
2017/07/06 06:30:29
Done.
|
+ if (this.timeZoneAutoDetect_ && |
+ this.getPref('settings.timezone').value == |
+ this.timeZoneList_[0].value) { |
+ return; |
+ } |
+ } else { |
+ if (this.timeZoneAutoDetect_ && |
+ this.getPref('cros.system.timezone').value == |
+ this.timeZoneList_[0].value) { |
+ return; |
+ } |
} |
cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this)); |
@@ -204,4 +228,16 @@ 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); |
+ }, |
}); |