| OLD | NEW |
| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 */ | 82 */ |
| 83 timeZoneList_: { | 83 timeZoneList_: { |
| 84 type: Array, | 84 type: Array, |
| 85 value: function() { | 85 value: function() { |
| 86 return [{ | 86 return [{ |
| 87 name: loadTimeData.getString('timeZoneName'), | 87 name: loadTimeData.getString('timeZoneName'), |
| 88 value: loadTimeData.getString('timeZoneID'), | 88 value: loadTimeData.getString('timeZoneID'), |
| 89 }]; | 89 }]; |
| 90 }, | 90 }, |
| 91 }, | 91 }, |
| 92 |
| 93 /** |
| 94 * Whether date and time are settable. Normally the date and time are forced |
| 95 * by network time, so default to false to initially hide the button. |
| 96 * @private |
| 97 */ |
| 98 canSetDateTime_: { |
| 99 type: Boolean, |
| 100 value: false, |
| 101 }, |
| 92 }, | 102 }, |
| 93 | 103 |
| 94 observers: [ | 104 observers: [ |
| 95 'maybeGetTimeZoneList_(' + | 105 'maybeGetTimeZoneList_(' + |
| 96 'prefs.cros.system.timezone.value, timeZoneAutoDetect_)', | 106 'prefs.cros.system.timezone.value, timeZoneAutoDetect_)', |
| 97 ], | 107 ], |
| 98 | 108 |
| 99 attached: function() { | 109 attached: function() { |
| 100 this.addWebUIListener( | 110 this.addWebUIListener( |
| 101 'time-zone-auto-detect-policy', | 111 'time-zone-auto-detect-policy', |
| 102 this.onTimeZoneAutoDetectPolicyChanged_.bind(this)); | 112 this.onTimeZoneAutoDetectPolicyChanged_.bind(this)); |
| 113 this.addWebUIListener( |
| 114 'can-set-date-time-changed', this.onCanSetDateTimeChanged_.bind(this)); |
| 115 |
| 103 chrome.send('dateTimePageReady'); | 116 chrome.send('dateTimePageReady'); |
| 104 | |
| 105 this.maybeGetTimeZoneList_(); | 117 this.maybeGetTimeZoneList_(); |
| 106 }, | 118 }, |
| 107 | 119 |
| 108 /** | 120 /** |
| 109 * @param {boolean} managed Whether the auto-detect setting is controlled. | 121 * @param {boolean} managed Whether the auto-detect setting is controlled. |
| 110 * @param {boolean} valueFromPolicy The value of the auto-detect setting | 122 * @param {boolean} valueFromPolicy The value of the auto-detect setting |
| 111 * forced by policy. | 123 * forced by policy. |
| 112 * @private | 124 * @private |
| 113 */ | 125 */ |
| 114 onTimeZoneAutoDetectPolicyChanged_: function(managed, valueFromPolicy) { | 126 onTimeZoneAutoDetectPolicyChanged_: function(managed, valueFromPolicy) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 127 key: 'fakeTimeZonePref', | 139 key: 'fakeTimeZonePref', |
| 128 type: chrome.settingsPrivate.PrefType.NUMBER, | 140 type: chrome.settingsPrivate.PrefType.NUMBER, |
| 129 value: 0, | 141 value: 0, |
| 130 policySource: chrome.settingsPrivate.PolicySource.DEVICE_POLICY, | 142 policySource: chrome.settingsPrivate.PolicySource.DEVICE_POLICY, |
| 131 policyEnforcement: chrome.settingsPrivate.PolicyEnforcement.ENFORCED, | 143 policyEnforcement: chrome.settingsPrivate.PolicyEnforcement.ENFORCED, |
| 132 }; | 144 }; |
| 133 } | 145 } |
| 134 }, | 146 }, |
| 135 | 147 |
| 136 /** | 148 /** |
| 149 * @param {boolean} canSetDateTime Whether date and time are settable. |
| 150 * @private |
| 151 */ |
| 152 onCanSetDateTimeChanged_: function(canSetDateTime) { |
| 153 this.canSetDateTime_ = canSetDateTime; |
| 154 }, |
| 155 |
| 156 /** |
| 137 * @param {!Event} e | 157 * @param {!Event} e |
| 138 * @private | 158 * @private |
| 139 */ | 159 */ |
| 140 onTimeZoneAutoDetectCheckboxChange_: function(e) { | 160 onTimeZoneAutoDetectCheckboxChange_: function(e) { |
| 141 this.setPrefValue( | 161 this.setPrefValue( |
| 142 'settings.resolve_timezone_by_geolocation', e.target.checked); | 162 'settings.resolve_timezone_by_geolocation', e.target.checked); |
| 143 }, | 163 }, |
| 144 | 164 |
| 165 /** @private */ |
| 166 onSetDateTimeTap_: function() { |
| 167 chrome.send('showSetDateTimeUI'); |
| 168 }, |
| 169 |
| 145 /** | 170 /** |
| 146 * @param {settings.TimeZoneAutoDetectPolicy} timeZoneAutoDetectPolicy | 171 * @param {settings.TimeZoneAutoDetectPolicy} timeZoneAutoDetectPolicy |
| 147 * @return {boolean} | 172 * @return {boolean} |
| 148 * @private | 173 * @private |
| 149 */ | 174 */ |
| 150 computeHasTimeZoneAutoDetectPolicy_: function(timeZoneAutoDetectPolicy) { | 175 computeHasTimeZoneAutoDetectPolicy_: function(timeZoneAutoDetectPolicy) { |
| 151 return timeZoneAutoDetectPolicy != settings.TimeZoneAutoDetectPolicy.NONE; | 176 return timeZoneAutoDetectPolicy != settings.TimeZoneAutoDetectPolicy.NONE; |
| 152 }, | 177 }, |
| 153 | 178 |
| 154 /** | 179 /** |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 */ | 221 */ |
| 197 setTimeZoneList_: function(timeZones) { | 222 setTimeZoneList_: function(timeZones) { |
| 198 this.timeZoneList_ = timeZones.map(function(timeZonePair) { | 223 this.timeZoneList_ = timeZones.map(function(timeZonePair) { |
| 199 return { | 224 return { |
| 200 name: timeZonePair[1], | 225 name: timeZonePair[1], |
| 201 value: timeZonePair[0], | 226 value: timeZonePair[0], |
| 202 }; | 227 }; |
| 203 }); | 228 }); |
| 204 }, | 229 }, |
| 205 }); | 230 }); |
| OLD | NEW |