Chromium Code Reviews| Index: chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.js |
| diff --git a/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.js b/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.js |
| index b992e2cc44775d6572adbec47033b42314f81dde..6d3f4a86e1d4f8e0c6d1aaa89259204cec56ae67 100644 |
| --- a/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.js |
| +++ b/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.js |
| @@ -22,19 +22,92 @@ Polymer({ |
| type: Object, |
| value: null, |
| }, |
| + |
| + password: { |
| + type: String, |
| + value: '', |
| + }, |
| + |
| + showPassword: { |
| + type: Boolean, |
| + value: false, |
| + }, |
| }, |
| /** Opens the dialog. */ |
| open: function() { |
| + this.password = ''; |
| + this.showPassword = false; |
| this.$.dialog.open(); |
| }, |
| + /** Closes the dialog. */ |
| + close: function() { |
| + this.$.dialog.close(); |
| + }, |
| + |
| + /** |
| + * Determines if the password can be shown in the UI or not. |
| + * @param {!boolean} showPassword |
| + * @param {!string} password |
|
Dan Beam
2016/03/25 03:12:55
you can remove the ! from these types: for built-i
hcarmona
2016/03/25 19:08:20
Done.
|
| + * @private |
| + */ |
| + canShowPassword_: function(showPassword, password) { |
| + return password && showPassword; |
| + }, |
| + |
| + /** |
| + * Gets the password input's type. Should be 'text' when password is visible |
| + * and 'password' when it's not. |
| + * @param {!boolean} showPassword |
| + * @param {!string} password |
| + * @private |
| + */ |
| + getPasswordInputType_: function(showPassword, password) { |
| + if (this.canShowPassword_(showPassword, password)) |
| + return 'text'; |
| + return 'password'; |
| + }, |
| + |
| /** |
| - * Creates an empty password of specified length. |
| - * @param {number} length |
| - * @return {string} password |
| + * Gets the text of the password. Will use the value of |password| unless it |
| + * cannot be shown, in which case it will be spaces. |
| + * @param {!boolean} showPassword |
| + * @param {!string} password |
| * @private |
| */ |
| - getEmptyPassword_: function(length) { return ' '.repeat(length); }, |
| + getPassword_: function(showPassword, item, password) { |
| + if (this.canShowPassword_(showPassword, password)) |
| + return password; |
| + return item ? ' '.repeat(item.numCharactersInPassword) : ''; |
| + }, |
| + |
| + /** |
| + * Handler for tapping the show/hide button. Will fire an event to request the |
| + * password for this login pair. |
| + * @private |
| + */ |
| + onTapShowPasswordButton_: function() { |
| + this.showPassword = !this.showPassword; |
| + if (this.showPassword) |
| + this.fire('show-password', this.item.loginPair); // Request the password. |
| + }, |
| + |
| + /** |
| + * Handler for tapping the 'cancel' button. Should just dismiss the dialog. |
| + * @private |
| + */ |
| + onTapCancelButton_: function() { |
| + this.close(); |
| + }, |
| + |
| + /** |
| + * Handler for tapping the save button. |
| + * @private |
| + */ |
| + onTapSaveButton_: function() { |
| + // TODO(hcarmona): what to save? |
| + this.close(); |
| + }, |
| }); |
| })(); |