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

Unified Diff: chrome/browser/resources/options/browser_options.js

Issue 1241453005: ChromeOS: Time zone setting dropdown should be grayed out once we enable the Automatically resolve … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert updateTimezoneSectionState_() method to argumentless. Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/options/browser_options.js
diff --git a/chrome/browser/resources/options/browser_options.js b/chrome/browser/resources/options/browser_options.js
index 5ee926d1a48f50bc89b7540dcac159484c5c2853..9fdddfba55810b520275987a1017d63690ff665a 100644
--- a/chrome/browser/resources/options/browser_options.js
+++ b/chrome/browser/resources/options/browser_options.js
@@ -109,6 +109,18 @@ cr.define('options', function() {
*/
initializationComplete_: false,
+ /**
+ * Current status of "Resolve Timezone by Geolocation" checkbox.
+ * @private {boolean}
+ */
+ resolveTimezoneByGeolocation_: false,
+
+ /**
+ * True if system timezone is managed by policy.
+ * @private {boolean}
+ */
+ systemTimezoneIsManaged_: false,
+
/** @override */
initializePage: function() {
Page.prototype.initializePage.call(this);
@@ -407,9 +419,12 @@ cr.define('options', function() {
// Timezone
if (loadTimeData.getBoolean('enableTimeZoneTrackingOption')) {
$('resolve-timezone-by-geolocation-selection').hidden = false;
- this.setSystemTimezoneManaged_(false);
- $('timezone-value-select').disabled = loadTimeData.getBoolean(
+ this.resolveTimezoneByGeolocation_ = loadTimeData.getBoolean(
'resolveTimezoneByGeolocationInitialValue');
+ this.updateTimezoneSectionState_();
+ Preferences.getInstance().addEventListener(
+ 'settings.resolve_timezone_by_geolocation',
+ this.onResolveTimezoneByGeolocationChanged_.bind(this));
}
}
@@ -1652,26 +1667,44 @@ cr.define('options', function() {
},
/**
+ * This enables or disables dependent settings in timezone section.
+ * @private
+ */
+ updateTimezoneSectionState_: function() {
+ if (this.systemTimezoneIsManaged_) {
+ $('resolve-timezone-by-geolocation-selection').disabled = true;
+ $('resolve-timezone-by-geolocation').onclick = function(event) {};
+ } else {
+ this.enableElementIfPossible_(
+ getRequiredElement('resolve-timezone-by-geolocation-selection'));
+ $('resolve-timezone-by-geolocation').onclick = function(event) {
+ $('timezone-value-select').disabled = event.currentTarget.checked;
+ };
+ $('timezone-value-select').disabled =
+ this.resolveTimezoneByGeolocation_;
+ }
+ },
+
+ /**
* This is called from chromium code when system timezone "managed" state
* is changed. Enables or disables dependent settings.
* @param {boolean} managed Is true when system Timezone is managed by
* enterprise policy. False otherwize.
*/
setSystemTimezoneManaged_: function(managed) {
- if (loadTimeData.getBoolean('enableTimeZoneTrackingOption')) {
- if (managed) {
- $('resolve-timezone-by-geolocation-selection').disabled = true;
- $('resolve-timezone-by-geolocation').onclick = function(event) {};
- } else {
- this.enableElementIfPossible_(
- getRequiredElement('resolve-timezone-by-geolocation-selection'));
- $('resolve-timezone-by-geolocation').onclick = function(event) {
- $('timezone-value-select').disabled = event.currentTarget.checked;
- };
- $('timezone-value-select').disabled =
- $('resolve-timezone-by-geolocation').checked;
- }
- }
+ this.systemTimezoneIsManaged_ = managed;
+ this.updateTimezoneSectionState_();
+ },
+
+ /**
+ * This is Preferences event listener, which is called when
+ * kResolveTimezoneByGeolocation preference is changed.
+ * Enables or disables dependent settings.
+ * @param {Event} value New preference state.
+ */
+ onResolveTimezoneByGeolocationChanged_: function(value) {
+ this.resolveTimezoneByGeolocation_ = value.value.value;
+ this.updateTimezoneSectionState_();
},
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698