| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 76 * overridden for tests. |
| 77 * |
| 78 * @type {Function} |
| 79 * @private |
| 80 */ |
| 81 writeUma_: { |
| 82 type: Object, |
| 83 value: function() { return settings.recordLockScreenProgress; } |
| 84 }, |
| 85 |
| 86 /** |
| 75 * PASSWORD_ACTIVE_DURATION_MS value. May be overridden by tests. | 87 * PASSWORD_ACTIVE_DURATION_MS value. May be overridden by tests. |
| 76 * @private | 88 * @private |
| 77 */ | 89 */ |
| 78 passwordActiveDurationMs_: { | 90 passwordActiveDurationMs_: { |
| 79 type: Number, | 91 type: Number, |
| 80 value: PASSWORD_ACTIVE_DURATION_MS | 92 value: PASSWORD_ACTIVE_DURATION_MS |
| 81 }, | 93 }, |
| 82 }, | 94 }, |
| 83 | 95 |
| 84 /** | 96 /** |
| 85 * Open up the dialog. This will wait until the dialog has loaded before | 97 * Open up the dialog. This will wait until the dialog has loaded before |
| 86 * opening it. | 98 * opening it. |
| 87 */ | 99 */ |
| 88 open: function() { | 100 open: function() { |
| 89 // Wait until the dialog is attached to the DOM before trying to open it. | 101 // Wait until the dialog is attached to the DOM before trying to open it. |
| 90 var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog); | 102 var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog); |
| 91 if (!dialog.isConnected) { | 103 if (!dialog.isConnected) { |
| 92 setTimeout(this.open.bind(this)); | 104 setTimeout(this.open.bind(this)); |
| 93 return; | 105 return; |
| 94 } | 106 } |
| 95 | 107 |
| 96 if (this.$.dialog.open) | 108 if (this.$.dialog.open) |
| 97 return; | 109 return; |
| 98 | 110 |
| 111 this.writeUma_(LockScreenProgress.START_SCREEN_LOCK); |
| 99 this.$.dialog.showModal(); | 112 this.$.dialog.showModal(); |
| 100 }, | 113 }, |
| 101 | 114 |
| 102 /** @private */ | 115 /** @private */ |
| 103 onCancelTap_: function() { | 116 onCancelTap_: function() { |
| 104 if (this.$.dialog.open) | 117 if (this.$.dialog.open) |
| 105 this.$.dialog.close(); | 118 this.$.dialog.close(); |
| 106 }, | 119 }, |
| 107 | 120 |
| 108 /** | 121 /** |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 this.setModes = null; | 169 this.setModes = null; |
| 157 } | 170 } |
| 158 | 171 |
| 159 this.clearAccountPasswordTimeout_ = setTimeout( | 172 this.clearAccountPasswordTimeout_ = setTimeout( |
| 160 clearSetModes.bind(this), this.passwordActiveDurationMs_); | 173 clearSetModes.bind(this), this.passwordActiveDurationMs_); |
| 161 | 174 |
| 162 // Clear stored password state and close the dialog. | 175 // Clear stored password state and close the dialog. |
| 163 this.password_ = ''; | 176 this.password_ = ''; |
| 164 if (this.$.dialog.open) | 177 if (this.$.dialog.open) |
| 165 this.$.dialog.close(); | 178 this.$.dialog.close(); |
| 179 |
| 180 this.writeUma_(LockScreenProgress.ENTER_PASSWORD_CORRECTLY); |
| 166 } | 181 } |
| 167 } | 182 } |
| 168 | 183 |
| 169 this.checkAccountPassword_(onPasswordChecked.bind(this)); | 184 this.checkAccountPassword_(onPasswordChecked.bind(this)); |
| 170 }, | 185 }, |
| 171 | 186 |
| 172 /** @private */ | 187 /** @private */ |
| 173 onPasswordChanged_: function() { | 188 onPasswordChanged_: function() { |
| 174 this.passwordInvalid_ = false; | 189 this.passwordInvalid_ = false; |
| 175 }, | 190 }, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 189 this.quickUnlockPrivate_.getActiveModes(function(modes) { | 204 this.quickUnlockPrivate_.getActiveModes(function(modes) { |
| 190 var credentials = | 205 var credentials = |
| 191 /** @type {!Array<string>} */ (Array(modes.length).fill('')); | 206 /** @type {!Array<string>} */ (Array(modes.length).fill('')); |
| 192 this.quickUnlockPrivate_.setModes( | 207 this.quickUnlockPrivate_.setModes( |
| 193 this.password_, modes, credentials, onCheck); | 208 this.password_, modes, credentials, onCheck); |
| 194 }.bind(this)); | 209 }.bind(this)); |
| 195 } | 210 } |
| 196 }); | 211 }); |
| 197 | 212 |
| 198 })(); | 213 })(); |
| OLD | NEW |