OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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-lock-screen' allows the user to change how they unlock their | 7 * 'settings-lock-screen' allows the user to change how they unlock their |
8 * device. | 8 * device. |
9 * | 9 * |
10 * Example: | 10 * Example: |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 loadTimeData.getBoolean('easyUnlockProximityDetectionAllowed'); | 116 loadTimeData.getBoolean('easyUnlockProximityDetectionAllowed'); |
117 }, | 117 }, |
118 readOnly: true, | 118 readOnly: true, |
119 }, | 119 }, |
120 | 120 |
121 /** @private */ | 121 /** @private */ |
122 showEasyUnlockTurnOffDialog_: { | 122 showEasyUnlockTurnOffDialog_: { |
123 type: Boolean, | 123 type: Boolean, |
124 value: false, | 124 value: false, |
125 }, | 125 }, |
126 | |
127 /** @private */ | |
128 showPasswordPromptDialog_: Boolean, | |
129 | |
130 /** @private */ | |
131 showSetupPinDialog_: Boolean, | |
126 }, | 132 }, |
127 | 133 |
128 /** @private {?settings.EasyUnlockBrowserProxy} */ | 134 /** @private {?settings.EasyUnlockBrowserProxy} */ |
129 easyUnlockBrowserProxy_: null, | 135 easyUnlockBrowserProxy_: null, |
130 | 136 |
131 /** @private {?settings.FingerprintBrowserProxy} */ | 137 /** @private {?settings.FingerprintBrowserProxy} */ |
132 fingerprintBrowserProxy_: null, | 138 fingerprintBrowserProxy_: null, |
133 | 139 |
134 /** selectedUnlockType is defined in LockStateBehavior. */ | 140 /** selectedUnlockType is defined in LockStateBehavior. */ |
135 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], | 141 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], |
136 | 142 |
137 /** @override */ | 143 /** @override */ |
138 attached: function() { | 144 attached: function() { |
139 if (this.shouldAskForPassword_(settings.getCurrentRoute())) | 145 if (this.shouldAskForPassword_(settings.getCurrentRoute())) |
140 this.$.passwordPrompt.open(); | 146 this.openPasswordPromptDialog_(); |
141 | 147 |
142 this.easyUnlockBrowserProxy_ = | 148 this.easyUnlockBrowserProxy_ = |
143 settings.EasyUnlockBrowserProxyImpl.getInstance(); | 149 settings.EasyUnlockBrowserProxyImpl.getInstance(); |
144 this.fingerprintBrowserProxy_ = | 150 this.fingerprintBrowserProxy_ = |
145 settings.FingerprintBrowserProxyImpl.getInstance(); | 151 settings.FingerprintBrowserProxyImpl.getInstance(); |
146 | 152 |
147 if (this.easyUnlockAllowed_) { | 153 if (this.easyUnlockAllowed_) { |
148 this.addWebUIListener( | 154 this.addWebUIListener( |
149 'easy-unlock-enabled-status', | 155 'easy-unlock-enabled-status', |
150 this.handleEasyUnlockEnabledStatusChanged_.bind(this)); | 156 this.handleEasyUnlockEnabledStatusChanged_.bind(this)); |
(...skipping 11 matching lines...) Expand all Loading... | |
162 currentRouteChanged: function(newRoute, oldRoute) { | 168 currentRouteChanged: function(newRoute, oldRoute) { |
163 if (newRoute == settings.Route.LOCK_SCREEN && | 169 if (newRoute == settings.Route.LOCK_SCREEN && |
164 this.fingerprintUnlockEnabled_ && this.fingerprintBrowserProxy_) { | 170 this.fingerprintUnlockEnabled_ && this.fingerprintBrowserProxy_) { |
165 this.fingerprintBrowserProxy_.getNumFingerprints().then( | 171 this.fingerprintBrowserProxy_.getNumFingerprints().then( |
166 function(numFingerprints) { | 172 function(numFingerprints) { |
167 this.numFingerprints_ = numFingerprints; | 173 this.numFingerprints_ = numFingerprints; |
168 }.bind(this)); | 174 }.bind(this)); |
169 } | 175 } |
170 | 176 |
171 if (this.shouldAskForPassword_(newRoute)) { | 177 if (this.shouldAskForPassword_(newRoute)) { |
172 this.$.passwordPrompt.open(); | 178 this.openPasswordPromptDialog_(); |
173 } else if (newRoute != settings.Route.FINGERPRINT && | 179 } else if (newRoute != settings.Route.FINGERPRINT && |
174 oldRoute != settings.Route.FINGERPRINT) { | 180 oldRoute != settings.Route.FINGERPRINT) { |
175 // If the user navigated away from the lock screen settings page they will | 181 // If the user navigated away from the lock screen settings page they will |
176 // have to re-enter their password. An exception is if they are navigating | 182 // have to re-enter their password. An exception is if they are navigating |
177 // to or from the fingerprint subpage. | 183 // to or from the fingerprint subpage. |
178 this.setModes_ = undefined; | 184 this.setModes_ = undefined; |
179 } | 185 } |
180 }, | 186 }, |
181 | 187 |
182 /** | 188 /** |
183 * Called when the unlock type has changed. | 189 * Called when the unlock type has changed. |
184 * @param {!string} selected The current unlock type. | 190 * @param {!string} selected The current unlock type. |
185 * @private | 191 * @private |
186 */ | 192 */ |
187 selectedUnlockTypeChanged_: function(selected) { | 193 selectedUnlockTypeChanged_: function(selected) { |
188 if (selected == LockScreenUnlockType.VALUE_PENDING) | 194 if (selected == LockScreenUnlockType.VALUE_PENDING) |
189 return; | 195 return; |
190 | 196 |
191 if (selected != LockScreenUnlockType.PIN_PASSWORD && this.setModes_) { | 197 if (selected != LockScreenUnlockType.PIN_PASSWORD && this.setModes_) { |
192 this.setModes_.call(null, [], [], function(didSet) { | 198 this.setModes_.call(null, [], [], function(didSet) { |
193 assert(didSet, 'Failed to clear quick unlock modes'); | 199 assert(didSet, 'Failed to clear quick unlock modes'); |
194 }); | 200 }); |
195 } | 201 } |
196 }, | 202 }, |
197 | 203 |
198 /** @private */ | 204 /** @private */ |
199 onSetModesChanged_: function() { | 205 onSetModesChanged_: function() { |
200 if (this.shouldAskForPassword_(settings.getCurrentRoute())) { | 206 if (this.shouldAskForPassword_(settings.getCurrentRoute())) { |
201 this.$.setupPin.close(); | 207 this.$.setupPin.close(); |
202 this.$.passwordPrompt.open(); | 208 this.openPasswordPromptDialog_(); |
203 } | 209 } |
204 }, | 210 }, |
205 | 211 |
206 /** @private */ | 212 /** @private */ |
207 onPasswordClosed_: function() { | 213 openPasswordPromptDialog_: function() { |
208 if (!this.setModes_) | 214 this.showPasswordPromptDialog_ = true; |
209 settings.navigateTo(settings.Route.PEOPLE); | 215 this.async(function() { |
210 else | 216 var dialog = this.$$('settings-password-prompt-dialog'); |
211 cr.ui.focusWithoutInk(assert(this.$$('#unlockType'))); | 217 dialog.addEventListener('close', function() { |
212 }, | 218 this.showPasswordPromptDialog_ = false; |
213 | 219 if (!this.setModes_) |
214 /** @private */ | 220 settings.navigateToPreviousRoute(); |
215 onPinSetupDone_: function() { | 221 else |
216 this.$.setupPin.close(); | 222 cr.ui.focusWithoutInk(assert(this.$$('#unlockType'))); |
217 }, | 223 }.bind(this)); |
stevenjb
2017/06/01 17:28:24
Same here, can we use an on-close binding (and bel
sammiequon
2017/06/01 20:21:10
Done.
| |
218 | 224 }.bind(this)); |
219 /** @private */ | |
220 onSetupPinClosed_: function() { | |
221 cr.ui.focusWithoutInk(assert(this.$$('#setupPinButton'))); | |
222 }, | 225 }, |
223 | 226 |
224 /** | 227 /** |
228 * @param {!Event} e | |
229 * @private | |
230 */ | |
231 onConfigurePin_: function(e) { | |
232 e.preventDefault(); | |
233 this.writeUma_(LockScreenProgress.CHOOSE_PIN_OR_PASSWORD); | |
234 this.showSetupPinDialog_ = true; | |
235 this.async(function() { | |
236 var dialog = this.$$('settings-setup-pin-dialog'); | |
237 dialog.addEventListener('close', function() { | |
dpapad
2017/06/01 17:48:44
Same here, let's use on-close=, instead of calling
sammiequon
2017/06/01 20:21:10
Done.
| |
238 this.showSetupPinDialog_ = false; | |
239 cr.ui.focusWithoutInk(assert(this.$$('#setupPinButton'))); | |
240 }.bind(this)); | |
241 }.bind(this)); | |
242 }, | |
243 | |
244 /** | |
225 * Returns true if the setup pin section should be shown. | 245 * Returns true if the setup pin section should be shown. |
226 * @param {!string} selectedUnlockType The current unlock type. Used to let | 246 * @param {!string} selectedUnlockType The current unlock type. Used to let |
227 * Polymer know about the dependency. | 247 * Polymer know about the dependency. |
228 * @private | 248 * @private |
229 */ | 249 */ |
230 showConfigurePinButton_: function(selectedUnlockType) { | 250 showConfigurePinButton_: function(selectedUnlockType) { |
231 return selectedUnlockType === LockScreenUnlockType.PIN_PASSWORD; | 251 return selectedUnlockType === LockScreenUnlockType.PIN_PASSWORD; |
232 }, | 252 }, |
233 | 253 |
234 /** | 254 /** |
235 * @param {boolean} hasPin | 255 * @param {boolean} hasPin |
236 * @private | 256 * @private |
237 */ | 257 */ |
238 getSetupPinText_: function(hasPin) { | 258 getSetupPinText_: function(hasPin) { |
239 if (hasPin) | 259 if (hasPin) |
240 return this.i18n('lockScreenChangePinButton'); | 260 return this.i18n('lockScreenChangePinButton'); |
241 return this.i18n('lockScreenSetupPinButton'); | 261 return this.i18n('lockScreenSetupPinButton'); |
242 }, | 262 }, |
243 | 263 |
244 /** @private */ | 264 /** @private */ |
245 getDescriptionText_: function() { | 265 getDescriptionText_: function() { |
246 if (this.numFingerprints_ > 0) { | 266 if (this.numFingerprints_ > 0) { |
247 return this.i18n('lockScreenNumberFingerprints', | 267 return this.i18n('lockScreenNumberFingerprints', |
248 this.numFingerprints_.toString()); | 268 this.numFingerprints_.toString()); |
249 } | 269 } |
250 | 270 |
251 return this.i18n('lockScreenEditFingerprintsDescription'); | 271 return this.i18n('lockScreenEditFingerprintsDescription'); |
252 }, | 272 }, |
253 | 273 |
254 /** | |
255 * @param {!Event} e | |
256 * @private | |
257 */ | |
258 onConfigurePin_: function(e) { | |
259 e.preventDefault(); | |
260 this.$.setupPin.open(); | |
261 this.writeUma_(LockScreenProgress.CHOOSE_PIN_OR_PASSWORD); | |
262 }, | |
263 | |
264 /** @private */ | 274 /** @private */ |
265 onEditFingerprints_: function() { | 275 onEditFingerprints_: function() { |
266 settings.navigateTo(settings.Route.FINGERPRINT); | 276 settings.navigateTo(settings.Route.FINGERPRINT); |
267 }, | 277 }, |
268 | 278 |
269 /** | 279 /** |
270 * @param {!settings.Route} route | 280 * @param {!settings.Route} route |
271 * @return {boolean} Whether the password dialog should be shown. | 281 * @return {boolean} Whether the password dialog should be shown. |
272 * @private | 282 * @private |
273 */ | 283 */ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 /** | 333 /** |
324 * @param {boolean} easyUnlockEnabled | 334 * @param {boolean} easyUnlockEnabled |
325 * @param {boolean} proximityDetectionAllowed | 335 * @param {boolean} proximityDetectionAllowed |
326 * @private | 336 * @private |
327 */ | 337 */ |
328 getShowEasyUnlockToggle_: function( | 338 getShowEasyUnlockToggle_: function( |
329 easyUnlockEnabled, proximityDetectionAllowed) { | 339 easyUnlockEnabled, proximityDetectionAllowed) { |
330 return easyUnlockEnabled && proximityDetectionAllowed; | 340 return easyUnlockEnabled && proximityDetectionAllowed; |
331 }, | 341 }, |
332 }); | 342 }); |
OLD | NEW |