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-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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 * opening it. | 83 * opening it. |
| 84 */ | 84 */ |
| 85 open: function() { | 85 open: function() { |
| 86 // Wait until the dialog is attached to the DOM before trying to open it. | 86 // Wait until the dialog is attached to the DOM before trying to open it. |
| 87 var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog); | 87 var dialog = /** @type {{isConnected: boolean}} */ (this.$.dialog); |
| 88 if (!dialog.isConnected) { | 88 if (!dialog.isConnected) { |
| 89 setTimeout(this.open.bind(this)); | 89 setTimeout(this.open.bind(this)); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 | 92 |
| 93 if (this.$.dialog.open) | |
| 94 return; | |
| 95 | |
| 93 this.$.dialog.showModal(); | 96 this.$.dialog.showModal(); |
| 94 }, | 97 }, |
| 95 | 98 |
| 96 /** Close the dialog. */ | 99 /** Close the dialog. */ |
| 97 close: function() { | 100 close: function() { |
|
tommycli
2016/08/25 23:13:32
This is never called from outside this class right
jdufault
2016/08/25 23:25:24
Done.
| |
| 98 if (this.$.dialog.open) | 101 if (this.$.dialog.open) |
| 99 this.$.dialog.close(); | 102 this.$.dialog.close(); |
| 100 | 103 |
| 101 this.password_ = ''; | 104 this.password_ = ''; |
| 102 }, | 105 }, |
| 103 | 106 |
| 104 /** Cancel the password prompt. */ | 107 /** @private */ |
| 105 cancel: function() { | 108 onKeydown_: function(e) { |
| 106 if (this.$.dialog.open) | 109 if (e.key == 'Enter') |
| 107 this.$.dialog.cancel(); | 110 this.checkPassword_(); |
| 108 | |
| 109 // We bind setModes_ in an on-change event, so when the user hits cancel | |
| 110 // after they enter their valid password we may have authenticated them. | |
| 111 this.setModes_ = undefined; | |
|
tommycli
2016/08/25 23:13:32
We don't care about clearing setModes_ anymore in
jdufault
2016/08/25 23:25:24
Right, the on-change event binding has been remove
| |
| 112 }, | 111 }, |
| 113 | 112 |
| 114 /** | 113 /** |
| 115 * Run the account password check. | 114 * Run the account password check. |
| 116 * @private | 115 * @private |
| 117 */ | 116 */ |
| 118 checkPassword_: function() { | 117 checkPassword_: function() { |
| 119 clearTimeout(this.clearAccountPasswordTimeout_); | 118 clearTimeout(this.clearAccountPasswordTimeout_); |
| 120 | 119 |
| 121 // The user might have started entering a password and then deleted it all. | 120 // The user might have started entering a password and then deleted it all. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 this.passwordInvalid_ = false; | 161 this.passwordInvalid_ = false; |
| 163 }, | 162 }, |
| 164 | 163 |
| 165 /** @private */ | 164 /** @private */ |
| 166 enableConfirm_: function() { | 165 enableConfirm_: function() { |
| 167 return !!this.password_ && !this.passwordInvalid_; | 166 return !!this.password_ && !this.passwordInvalid_; |
| 168 } | 167 } |
| 169 }); | 168 }); |
| 170 | 169 |
| 171 })(); | 170 })(); |
| OLD | NEW |