Chromium Code Reviews| 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 * | 7 * |
| 8 * 'settings-quick-unlock-authenticate' shows a password input prompt to the | 8 * 'settings-quick-unlock-authenticate' shows a password input prompt to the |
| 9 * user. It validates the password is correct. Once the user has entered their | 9 * user. It validates the password is correct. Once the user has entered their |
| 10 * account password, the page navigates to the quick unlock setup methods page. | 10 * account password, the page navigates to the quick unlock setup methods page. |
| 11 * | 11 * |
| 12 * This element provides a wrapper around chrome.quickUnlockPrivate.setModes | 12 * This element provides a wrapper around chrome.quickUnlockPrivate.setModes |
| 13 * which has a prebound account password (the |set-modes| property). The account | 13 * which has a prebound account password (the |set-modes| property). The account |
| 14 * password by itself is not available for other elements to access. | 14 * password by itself is not available for other elements to access. |
| 15 * | 15 * |
| 16 * Example: | 16 * Example: |
| 17 * | 17 * |
| 18 * <settings-quick-unlock-authenticate | 18 * <settings-quick-unlock-authenticate |
| 19 * set-modes="[[setModes]]" | 19 * set-modes="[[setModes]]" |
| 20 * current-route="{{currentRoute}}" | |
| 21 * profile-name="[[profileName_]]"> | 20 * profile-name="[[profileName_]]"> |
|
Dan Beam
2016/08/05 18:25:18
nit: example indent off ;)
tommycli
2016/08/05 18:54:05
Done.
| |
| 22 * </settings-quick-unlock-authenticate> | 21 * </settings-quick-unlock-authenticate> |
| 23 */ | 22 */ |
| 24 | 23 |
| 25 (function() { | 24 (function() { |
| 26 'use strict'; | 25 'use strict'; |
| 27 | 26 |
| 28 /** @const */ var PASSWORD_ACTIVE_DURATION_MS = 10 * 60 * 1000; // Ten minutes. | 27 /** @const */ var PASSWORD_ACTIVE_DURATION_MS = 10 * 60 * 1000; // Ten minutes. |
| 29 /** @const */ var AUTOSUBMIT_DELAY_MS = 500; // .5 seconds | 28 /** @const */ var AUTOSUBMIT_DELAY_MS = 500; // .5 seconds |
| 30 | 29 |
| 31 /** | 30 /** |
| 32 * Helper method that checks if |password| is valid. | 31 * Helper method that checks if |password| is valid. |
| 33 * @param {string} password | 32 * @param {string} password |
| 34 * @param {function(boolean):void} onCheck | 33 * @param {function(boolean):void} onCheck |
| 35 */ | 34 */ |
| 36 function checkAccountPassword_(password, onCheck) { | 35 function checkAccountPassword_(password, onCheck) { |
| 37 // We check the account password by trying to update the active set of quick | 36 // We check the account password by trying to update the active set of quick |
| 38 // unlock modes without changing any credentials. | 37 // unlock modes without changing any credentials. |
| 39 chrome.quickUnlockPrivate.getActiveModes(function(modes) { | 38 chrome.quickUnlockPrivate.getActiveModes(function(modes) { |
| 40 var credentials = | 39 var credentials = |
| 41 /** @type {!Array<string>} */ (Array(modes.length).fill('')); | 40 /** @type {!Array<string>} */ (Array(modes.length).fill('')); |
| 42 chrome.quickUnlockPrivate.setModes(password, modes, credentials, onCheck); | 41 chrome.quickUnlockPrivate.setModes(password, modes, credentials, onCheck); |
| 43 }); | 42 }); |
| 44 } | 43 } |
| 45 | 44 |
| 46 Polymer({ | 45 Polymer({ |
| 47 is: 'settings-quick-unlock-authenticate', | 46 is: 'settings-quick-unlock-authenticate', |
| 48 | 47 |
| 48 behavior: [settings.RouteObserverBehavior], | |
| 49 | |
| 49 properties: { | 50 properties: { |
| 50 /** @type {!settings.Route} */ | |
| 51 currentRoute: { | |
| 52 type: Object, | |
| 53 observer: 'onRouteChanged_', | |
| 54 }, | |
| 55 | |
| 56 /** | 51 /** |
| 57 * A wrapper around chrome.quickUnlockPrivate.setModes with the account | 52 * A wrapper around chrome.quickUnlockPrivate.setModes with the account |
| 58 * password already supplied. If this is null, the authentication screen | 53 * password already supplied. If this is null, the authentication screen |
| 59 * needs to be redisplayed. This property will be cleared after | 54 * needs to be redisplayed. This property will be cleared after |
| 60 * PASSWORD_ACTIVE_DURATION_MS milliseconds. | 55 * PASSWORD_ACTIVE_DURATION_MS milliseconds. |
| 61 */ | 56 */ |
| 62 setModes: { | 57 setModes: { |
| 63 type: Object, | 58 type: Object, |
| 64 notify: true | 59 notify: true |
| 65 }, | 60 }, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 78 */ | 73 */ |
| 79 password_: String, | 74 password_: String, |
| 80 | 75 |
| 81 /** | 76 /** |
| 82 * Helper property which marks password as valid/invalid. | 77 * Helper property which marks password as valid/invalid. |
| 83 * @private | 78 * @private |
| 84 */ | 79 */ |
| 85 passwordInvalid_: Boolean | 80 passwordInvalid_: Boolean |
| 86 }, | 81 }, |
| 87 | 82 |
| 88 /** @private */ | 83 /** @protected */ |
| 89 onRouteChanged_: function(currentRoute) { | 84 currentRouteChanged: function() { |
| 90 // Clear local state if this screen is not active so if this screen shows | 85 // Clear local state if this screen is not active so if this screen shows |
| 91 // up again the user will get a fresh UI. | 86 // up again the user will get a fresh UI. |
| 92 if (this.currentRoute != settings.Route.QUICK_UNLOCK_AUTHENTICATE) { | 87 if (settings.getCurrentRoute() == settings.Route.QUICK_UNLOCK_AUTHENTICATE) |
| 93 this.password_ = ''; | 88 return; |
| 94 this.passwordInvalid_ = false; | 89 |
| 95 } | 90 this.password_ = ''; |
| 91 this.passwordInvalid_ = false; | |
| 96 }, | 92 }, |
| 97 | 93 |
| 98 /** | 94 /** |
| 99 * Start or restart a timer to check the account password and move past the | 95 * Start or restart a timer to check the account password and move past the |
| 100 * authentication screen. | 96 * authentication screen. |
| 101 * @private | 97 * @private |
| 102 */ | 98 */ |
| 103 startDelayedPasswordCheck_: function() { | 99 startDelayedPasswordCheck_: function() { |
| 104 clearTimeout(this.delayedPasswordCheckTimeout_); | 100 clearTimeout(this.delayedPasswordCheckTimeout_); |
| 105 this.delayedPasswordCheckTimeout_ = | 101 this.delayedPasswordCheckTimeout_ = |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 146 |
| 151 settings.navigateTo(settings.Route.QUICK_UNLOCK_CHOOSE_METHOD); | 147 settings.navigateTo(settings.Route.QUICK_UNLOCK_CHOOSE_METHOD); |
| 152 } | 148 } |
| 153 } | 149 } |
| 154 | 150 |
| 155 checkAccountPassword_(this.password_, onPasswordChecked.bind(this)); | 151 checkAccountPassword_(this.password_, onPasswordChecked.bind(this)); |
| 156 } | 152 } |
| 157 }); | 153 }); |
| 158 | 154 |
| 159 })(); | 155 })(); |
| OLD | NEW |