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

Side by Side Diff: chrome/browser/resources/settings/date_time_page/date_time_page.js

Issue 2849823003: ChromeOS: implement per-user time zone preferences. (Closed)
Patch Set: Try remove g_browser_process check Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-date-time-page' is the settings page containing date and time 7 * 'settings-date-time-page' is the settings page containing date and time
8 * settings. 8 * settings.
9 */ 9 */
10 10
(...skipping 24 matching lines...) Expand all
35 value: function() { 35 value: function() {
36 if (!loadTimeData.valueExists('timeZoneAutoDetectValueFromPolicy')) 36 if (!loadTimeData.valueExists('timeZoneAutoDetectValueFromPolicy'))
37 return settings.TimeZoneAutoDetectPolicy.NONE; 37 return settings.TimeZoneAutoDetectPolicy.NONE;
38 return loadTimeData.getBoolean('timeZoneAutoDetectValueFromPolicy') ? 38 return loadTimeData.getBoolean('timeZoneAutoDetectValueFromPolicy') ?
39 settings.TimeZoneAutoDetectPolicy.FORCED_ON : 39 settings.TimeZoneAutoDetectPolicy.FORCED_ON :
40 settings.TimeZoneAutoDetectPolicy.FORCED_OFF; 40 settings.TimeZoneAutoDetectPolicy.FORCED_OFF;
41 }, 41 },
42 }, 42 },
43 43
44 /** 44 /**
45 * Whether a policy controls the time zone auto-detect setting.
46 * @private
47 */
48 hasTimeZoneAutoDetectPolicy_: {
49 type: Boolean,
50 computed:
51 'computeHasTimeZoneAutoDetectPolicy_(timeZoneAutoDetectPolicy_)',
52 },
53
54 /**
55 * The effective time zone auto-detect setting. 45 * The effective time zone auto-detect setting.
56 * @private 46 * @private
57 */ 47 */
58 timeZoneAutoDetect_: { 48 timeZoneAutoDetect_: {
59 type: Boolean, 49 type: Boolean,
60 computed: 'computeTimeZoneAutoDetect_(' + 50 computed: 'computeTimeZoneAutoDetect_(' +
61 'timeZoneAutoDetectPolicy_,' + 51 'timeZoneAutoDetectPolicy_,' +
62 'prefs.settings.resolve_timezone_by_geolocation.value)', 52 'prefs.settings.resolve_timezone_by_geolocation.value)',
63 }, 53 },
64 54
(...skipping 19 matching lines...) Expand all
84 * @private 74 * @private
85 */ 75 */
86 canSetDateTime_: { 76 canSetDateTime_: {
87 type: Boolean, 77 type: Boolean,
88 value: false, 78 value: false,
89 }, 79 },
90 }, 80 },
91 81
92 observers: [ 82 observers: [
93 'maybeGetTimeZoneList_(' + 83 'maybeGetTimeZoneList_(' +
94 'prefs.cros.system.timezone.value, timeZoneAutoDetect_)', 84 'prefs.settings.timezone.value, timeZoneAutoDetect_)',
95 ], 85 ],
96 86
97 /** @override */ 87 /** @override */
98 attached: function() { 88 attached: function() {
99 this.addWebUIListener( 89 this.addWebUIListener(
100 'time-zone-auto-detect-policy', 90 'time-zone-auto-detect-policy',
101 this.onTimeZoneAutoDetectPolicyChanged_.bind(this)); 91 this.onTimeZoneAutoDetectPolicyChanged_.bind(this));
102 this.addWebUIListener( 92 this.addWebUIListener(
103 'can-set-date-time-changed', this.onCanSetDateTimeChanged_.bind(this)); 93 'can-set-date-time-changed', this.onCanSetDateTimeChanged_.bind(this));
104 94
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 'settings.resolve_timezone_by_geolocation', e.target.checked); 129 'settings.resolve_timezone_by_geolocation', e.target.checked);
140 }, 130 },
141 131
142 /** @private */ 132 /** @private */
143 onSetDateTimeTap_: function() { 133 onSetDateTimeTap_: function() {
144 chrome.send('showSetDateTimeUI'); 134 chrome.send('showSetDateTimeUI');
145 }, 135 },
146 136
147 /** 137 /**
148 * @param {settings.TimeZoneAutoDetectPolicy} timeZoneAutoDetectPolicy 138 * @param {settings.TimeZoneAutoDetectPolicy} timeZoneAutoDetectPolicy
149 * @return {boolean}
150 * @private
151 */
152 computeHasTimeZoneAutoDetectPolicy_: function(timeZoneAutoDetectPolicy) {
153 return timeZoneAutoDetectPolicy != settings.TimeZoneAutoDetectPolicy.NONE;
154 },
155
156 /**
157 * @param {settings.TimeZoneAutoDetectPolicy} timeZoneAutoDetectPolicy
158 * @param {boolean} prefValue Value of the geolocation pref. 139 * @param {boolean} prefValue Value of the geolocation pref.
159 * @return {boolean} Whether time zone auto-detect is enabled. 140 * @return {boolean} Whether time zone auto-detect is enabled.
160 * @private 141 * @private
161 */ 142 */
162 computeTimeZoneAutoDetect_: function(timeZoneAutoDetectPolicy, prefValue) { 143 computeTimeZoneAutoDetect_: function(timeZoneAutoDetectPolicy, prefValue) {
163 switch (timeZoneAutoDetectPolicy) { 144 switch (timeZoneAutoDetectPolicy) {
164 case settings.TimeZoneAutoDetectPolicy.NONE: 145 case settings.TimeZoneAutoDetectPolicy.NONE:
165 return prefValue; 146 return prefValue;
166 case settings.TimeZoneAutoDetectPolicy.FORCED_ON: 147 case settings.TimeZoneAutoDetectPolicy.FORCED_ON:
167 return true; 148 return true;
168 case settings.TimeZoneAutoDetectPolicy.FORCED_OFF: 149 case settings.TimeZoneAutoDetectPolicy.FORCED_OFF:
169 return false; 150 return false;
170 default: 151 default:
171 assertNotReached(); 152 assertNotReached();
172 } 153 }
173 }, 154 },
174 155
175 /** 156 /**
176 * Fetches the list of time zones if necessary. 157 * Fetches the list of time zones if necessary.
177 * @private 158 * @private
178 */ 159 */
179 maybeGetTimeZoneList_: function() { 160 maybeGetTimeZoneList_: function() {
180 // Only fetch the list once. 161 // Only fetch the list once.
181 if (this.timeZoneList_.length > 1 || !CrSettingsPrefs.isInitialized) 162 if (this.timeZoneList_.length > 1 || !CrSettingsPrefs.isInitialized)
182 return; 163 return;
183 164
184 // If auto-detect is enabled, we only need the current time zone. 165 // If auto-detect is enabled, we only need the current time zone.
185 if (this.timeZoneAutoDetect_ && 166 if (this.timeZoneAutoDetect_ &&
186 this.getPref('cros.system.timezone').value == 167 this.getPref('settings.timezone').value ==
187 this.timeZoneList_[0].value) { 168 this.timeZoneList_[0].value) {
188 return; 169 return;
189 } 170 }
190 171
191 cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this)); 172 cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this));
192 }, 173 },
193 174
194 /** 175 /**
195 * Converts the C++ response into an array of menu options. 176 * Converts the C++ response into an array of menu options.
196 * @param {!Array<!Array<string>>} timeZones C++ time zones response. 177 * @param {!Array<!Array<string>>} timeZones C++ time zones response.
197 * @private 178 * @private
198 */ 179 */
199 setTimeZoneList_: function(timeZones) { 180 setTimeZoneList_: function(timeZones) {
200 this.timeZoneList_ = timeZones.map(function(timeZonePair) { 181 this.timeZoneList_ = timeZones.map(function(timeZonePair) {
201 return { 182 return {
202 name: timeZonePair[1], 183 name: timeZonePair[1],
203 value: timeZonePair[0], 184 value: timeZonePair[0],
204 }; 185 };
205 }); 186 });
206 }, 187 },
188
189
190 /**
191 * Computes visibility of user timezone preference.
192 * @param prefUserTimezone Object pref.settings.timezone
193 * @param prefResolveValue Boolean
194 * prefs.settings.resolve_timezone_by_geolocation.value
195 * @private
196 */
197 isUserTimeZoneSelectorHidden_: function(prefUserTimezone, prefResolveValue) {
198 return (prefUserTimezone && prefUserTimezone.controlledBy != null) ||
199 (prefResolveValue == true);
200 },
207 }); 201 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698