| 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 |
| 11 * updates the setModes binding. | 11 * updates the setModes binding. |
| 12 * | 12 * |
| 13 * The setModes binding is a wrapper around chrome.quickUnlockPrivate.setModes | 13 * The setModes binding is a wrapper around chrome.quickUnlockPrivate.setModes |
| 14 * which has a prebound account password. The account password by itself is not | 14 * which has a prebound account password. The account password by itself is not |
| 15 * available for other elements to access. | 15 * available for other elements to access. |
| 16 * | 16 * |
| 17 * Example: | 17 * Example: |
| 18 * | 18 * |
| 19 * <settings-password-prompt-dialog | 19 * <settings-password-prompt-dialog |
| 20 * id="passwordPrompt" | 20 * id="passwordPrompt" |
| 21 * set-modes="[[setModes]]"> | 21 * set-modes="[[setModes]]"> |
| 22 * </settings-password-prompt-dialog> | 22 * </settings-password-prompt-dialog> |
| 23 * | 23 * |
| 24 * this.$.passwordPrompt.open() | 24 * this.$.passwordPrompt.open() |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 (function() { | 27 (function() { |
| 28 'use strict'; | 28 'use strict'; |
| 29 | 29 |
| 30 /** @const */ var PASSWORD_ACTIVE_DURATION_MS = 10 * 60 * 1000; // Ten minutes. | 30 /** @const */ var PASSWORD_ACTIVE_DURATION_MS = 10 * 60 * 1000; // Ten minutes. |
| 31 | 31 |
| 32 Polymer({ | 32 Polymer({ |
| 33 is: 'settings-password-prompt-dialog', | 33 is: 'settings-password-prompt-dialog', |
| 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. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 }.bind(this); | 149 }.bind(this); |
| 150 | 150 |
| 151 function clearSetModes() { | 151 function clearSetModes() { |
| 152 // Reset the password so that any cached references to this.setModes | 152 // Reset the password so that any cached references to this.setModes |
| 153 // will fail. | 153 // will fail. |
| 154 password = ''; | 154 password = ''; |
| 155 this.setModes = null; | 155 this.setModes = null; |
| 156 } | 156 } |
| 157 | 157 |
| 158 this.clearAccountPasswordTimeout_ = setTimeout( | 158 this.clearAccountPasswordTimeout_ = setTimeout( |
| 159 clearSetModes.bind(this), this.passwordActiveDurationMs_); | 159 clearSetModes.bind(this), this.passwordActiveDurationMs_); |
| 160 | 160 |
| 161 // Clear stored password state and close the dialog. | 161 // Clear stored password state and close the dialog. |
| 162 this.password_ = ''; | 162 this.password_ = ''; |
| 163 if (this.$.dialog.open) | 163 if (this.$.dialog.open) |
| 164 this.$.dialog.close(); | 164 this.$.dialog.close(); |
| 165 | 165 |
| 166 this.writeUma_(LockScreenProgress.ENTER_PASSWORD_CORRECTLY); | 166 this.writeUma_(LockScreenProgress.ENTER_PASSWORD_CORRECTLY); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 190 this.quickUnlockPrivate_.getActiveModes(function(modes) { | 190 this.quickUnlockPrivate_.getActiveModes(function(modes) { |
| 191 var credentials = | 191 var credentials = |
| 192 /** @type {!Array<string>} */ (Array(modes.length).fill('')); | 192 /** @type {!Array<string>} */ (Array(modes.length).fill('')); |
| 193 this.quickUnlockPrivate_.setModes( | 193 this.quickUnlockPrivate_.setModes( |
| 194 this.password_, modes, credentials, onCheck); | 194 this.password_, modes, credentials, onCheck); |
| 195 }.bind(this)); | 195 }.bind(this)); |
| 196 } | 196 } |
| 197 }); | 197 }); |
| 198 | 198 |
| 199 })(); | 199 })(); |
| OLD | NEW |