| 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-password-prompt-dialog' shows a dialog which asks for the user to | 8 * 'settings-password-prompt-dialog' shows a dialog which asks for the user to |
| 9 * enter their password. It validates the password is correct. Once the user has | 9 * enter their password. It validates the password is correct. Once the user has |
| 10 * entered their account password, the page fires an 'authenticated' event and | 10 * entered their account password, the page fires an 'authenticated' event and |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 properties: { | 35 properties: { |
| 36 /** | 36 /** |
| 37 * A wrapper around chrome.quickUnlockPrivate.setModes with the account | 37 * A wrapper around chrome.quickUnlockPrivate.setModes with the account |
| 38 * password already supplied. If this is null, the authentication screen | 38 * password already supplied. If this is null, the authentication screen |
| 39 * needs to be redisplayed. This property will be cleared after | 39 * needs to be redisplayed. This property will be cleared after |
| 40 * |this.passwordActiveDurationMs_| milliseconds. | 40 * |this.passwordActiveDurationMs_| milliseconds. |
| 41 */ | 41 */ |
| 42 setModes: { | 42 setModes: { |
| 43 type: Object, | 43 type: Object, |
| 44 notify: true | 44 notify: true, |
| 45 }, | 45 }, |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * The actual value of the password field. This is cleared whenever the | 48 * The actual value of the password field. This is cleared whenever the |
| 49 * authentication screen is not displayed so that the user's password is not | 49 * authentication screen is not displayed so that the user's password is not |
| 50 * easily available to an attacker. The actual password is stored as an | 50 * easily available to an attacker. The actual password is stored as an |
| 51 * captured closure variable inside of setModes. | 51 * captured closure variable inside of setModes. |
| 52 * @private | 52 * @private |
| 53 */ | 53 */ |
| 54 password_: { | 54 password_: { |
| 55 type: String, | 55 type: String, |
| 56 observer: 'onPasswordChanged_' | 56 observer: 'onPasswordChanged_', |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Helper property which marks password as valid/invalid. | 60 * Helper property which marks password as valid/invalid. |
| 61 * @private | 61 * @private |
| 62 */ | 62 */ |
| 63 passwordInvalid_: Boolean, | 63 passwordInvalid_: Boolean, |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests. | 66 * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests. |
| 67 * @private | 67 * @private |
| 68 */ | 68 */ |
| 69 quickUnlockPrivate_: { | 69 quickUnlockPrivate_: { |
| 70 type: Object, | 70 type: Object, |
| 71 value: chrome.quickUnlockPrivate | 71 value: chrome.quickUnlockPrivate, |
| 72 }, | 72 }, |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * writeUma_ is a function that handles writing uma stats. It may be | 75 * writeUma_ is a function that handles writing uma stats. It may be |
| 76 * overridden for tests. | 76 * overridden for tests. |
| 77 * | 77 * |
| 78 * @type {Function} | 78 * @type {Function} |
| 79 * @private | 79 * @private |
| 80 */ | 80 */ |
| 81 writeUma_: { | 81 writeUma_: { |
| 82 type: Object, | 82 type: Object, |
| 83 value: function() { return settings.recordLockScreenProgress; } | 83 value: function() { |
| 84 return settings.recordLockScreenProgress; |
| 85 } |
| 84 }, | 86 }, |
| 85 | 87 |
| 86 /** | 88 /** |
| 87 * PASSWORD_ACTIVE_DURATION_MS value. May be overridden by tests. | 89 * PASSWORD_ACTIVE_DURATION_MS value. May be overridden by tests. |
| 88 * @private | 90 * @private |
| 89 */ | 91 */ |
| 90 passwordActiveDurationMs_: { | 92 passwordActiveDurationMs_: { |
| 91 type: Number, | 93 type: Number, |
| 92 value: PASSWORD_ACTIVE_DURATION_MS | 94 value: PASSWORD_ACTIVE_DURATION_MS, |
| 93 }, | 95 }, |
| 94 }, | 96 }, |
| 95 | 97 |
| 98 /** @override */ |
| 99 attached: function() { |
| 100 this.async(function() { |
| 101 this.$.passwordInput.focus(); |
| 102 }.bind(this)); |
| 103 }, |
| 104 |
| 96 /** | 105 /** |
| 97 * Open up the dialog. This will wait until the dialog has loaded before | 106 * Open up the dialog. This will wait until the dialog has loaded before |
| 98 * opening it. | 107 * opening it. |
| 99 */ | 108 */ |
| 100 open: function() { | 109 open: function() { |
| 101 // Wait until the dialog is attached to the DOM before trying to open it. | 110 // Wait until the dialog is attached to the DOM before trying to open it. |
| 102 var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog); | 111 var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog); |
| 103 if (!dialog.isConnected) { | 112 if (!dialog.isConnected) { |
| 104 setTimeout(this.open.bind(this)); | 113 setTimeout(this.open.bind(this)); |
| 105 return; | 114 return; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 onPasswordChanged_: function() { | 191 onPasswordChanged_: function() { |
| 183 this.passwordInvalid_ = false; | 192 this.passwordInvalid_ = false; |
| 184 }, | 193 }, |
| 185 | 194 |
| 186 /** @private */ | 195 /** @private */ |
| 187 enableConfirm_: function() { | 196 enableConfirm_: function() { |
| 188 return !!this.password_ && !this.passwordInvalid_; | 197 return !!this.password_ && !this.passwordInvalid_; |
| 189 }, | 198 }, |
| 190 | 199 |
| 191 /** | 200 /** |
| 192 * Helper method that checks if the current password is valid. | 201 * Helper method that checks if the current password is valid. |
| 193 * @param {function(boolean):void} onCheck | 202 * @param {function(boolean):void} onCheck |
| 194 */ | 203 */ |
| 195 checkAccountPassword_: function(onCheck) { | 204 checkAccountPassword_: function(onCheck) { |
| 196 // We check the account password by trying to update the active set of quick | 205 // We check the account password by trying to update the active set of quick |
| 197 // unlock modes without changing any credentials. | 206 // unlock modes without changing any credentials. |
| 198 this.quickUnlockPrivate_.getActiveModes(function(modes) { | 207 this.quickUnlockPrivate_.getActiveModes(function(modes) { |
| 199 var credentials = | 208 var credentials = |
| 200 /** @type {!Array<string>} */ (Array(modes.length).fill('')); | 209 /** @type {!Array<string>} */ (Array(modes.length).fill('')); |
| 201 this.quickUnlockPrivate_.setModes( | 210 this.quickUnlockPrivate_.setModes( |
| 202 this.password_, modes, credentials, onCheck); | 211 this.password_, modes, credentials, onCheck); |
| 203 }.bind(this)); | 212 }.bind(this)); |
| 204 } | 213 } |
| 205 }); | 214 }); |
| 206 | 215 |
| 207 })(); | 216 })(); |
| OLD | NEW |