| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 cr.define('options.passwordManager', function() { | 5 cr.define('options.passwordManager', function() { |
| 6 const ArrayDataModel = cr.ui.ArrayDataModel; | 6 const ArrayDataModel = cr.ui.ArrayDataModel; |
| 7 const DeletableItemList = options.DeletableItemList; | 7 const DeletableItemList = options.DeletableItemList; |
| 8 const DeletableItem = options.DeletableItem; | 8 const DeletableItem = options.DeletableItem; |
| 9 const List = cr.ui.List; | 9 const List = cr.ui.List; |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 PasswordListItem.prototype = { | 26 PasswordListItem.prototype = { |
| 27 __proto__: DeletableItem.prototype, | 27 __proto__: DeletableItem.prototype, |
| 28 | 28 |
| 29 /** @inheritDoc */ | 29 /** @inheritDoc */ |
| 30 decorate: function() { | 30 decorate: function() { |
| 31 DeletableItem.prototype.decorate.call(this); | 31 DeletableItem.prototype.decorate.call(this); |
| 32 | 32 |
| 33 // The URL of the site. | 33 // The URL of the site. |
| 34 var urlLabel = this.ownerDocument.createElement('div'); | 34 var urlLabel = this.ownerDocument.createElement('div'); |
| 35 urlLabel.className = 'url'; | |
| 36 urlLabel.classList.add('favicon-cell'); | 35 urlLabel.classList.add('favicon-cell'); |
| 36 urlLabel.classList.add('url'); |
| 37 urlLabel.textContent = this.url; | 37 urlLabel.textContent = this.url; |
| 38 urlLabel.style.backgroundImage = url('chrome://favicon/' + this.url); | 38 urlLabel.style.backgroundImage = url('chrome://favicon/' + this.url); |
| 39 this.contentElement.appendChild(urlLabel); | 39 this.contentElement.appendChild(urlLabel); |
| 40 | 40 |
| 41 // The stored username. | 41 // The stored username. |
| 42 var usernameLabel = this.ownerDocument.createElement('div'); | 42 var usernameLabel = this.ownerDocument.createElement('div'); |
| 43 usernameLabel.className = 'name'; | 43 usernameLabel.className = 'name'; |
| 44 usernameLabel.textContent = this.username; | 44 usernameLabel.textContent = this.username; |
| 45 this.contentElement.appendChild(usernameLabel); | 45 this.contentElement.appendChild(usernameLabel); |
| 46 | 46 |
| 47 // The stored password. | 47 // The stored password. |
| 48 var passwordInputDiv = this.ownerDocument.createElement('div'); | 48 var passwordInputDiv = this.ownerDocument.createElement('div'); |
| 49 passwordInputDiv.className = 'password'; | 49 passwordInputDiv.className = 'password'; |
| 50 | 50 |
| 51 // The password input field. | 51 // The password input field. |
| 52 var passwordInput = this.ownerDocument.createElement('input'); | 52 var passwordInput = this.ownerDocument.createElement('input'); |
| 53 passwordInput.type = 'password'; |
| 53 passwordInput.className = 'inactive-password'; | 54 passwordInput.className = 'inactive-password'; |
| 54 passwordInput.readOnly = true; | 55 passwordInput.readOnly = true; |
| 55 passwordInput.type = 'password'; | |
| 56 passwordInput.value = this.password; | 56 passwordInput.value = this.password; |
| 57 passwordInputDiv.appendChild(passwordInput); | 57 passwordInputDiv.appendChild(passwordInput); |
| 58 | 58 |
| 59 // The show/hide button. | 59 // The show/hide button. |
| 60 var buttonSpan = this.ownerDocument.createElement('span'); | 60 var button = this.ownerDocument.createElement('button'); |
| 61 buttonSpan.className = 'hidden'; | 61 button.classList.add('hidden'); |
| 62 buttonSpan.addEventListener('click', this.onClick_, true); | 62 button.classList.add('password-button'); |
| 63 passwordInputDiv.appendChild(buttonSpan); | 63 button.textContent = localStrings.getString('passwordShowButton'); |
| 64 button.addEventListener('click', this.onClick_, true); |
| 65 passwordInputDiv.appendChild(button); |
| 64 | 66 |
| 65 this.contentElement.appendChild(passwordInputDiv); | 67 this.contentElement.appendChild(passwordInputDiv); |
| 66 }, | 68 }, |
| 67 | 69 |
| 68 /** @inheritDoc */ | 70 /** @inheritDoc */ |
| 69 selectionChanged: function() { | 71 selectionChanged: function() { |
| 70 var passwordInput = this.querySelector('input[type=password]'); | 72 var passwordInput = this.querySelector('input[type=password]'); |
| 71 var textInput = this.querySelector('input[type=text]'); | 73 var textInput = this.querySelector('input[type=text]'); |
| 72 var input = passwordInput || textInput; | 74 var input = passwordInput || textInput; |
| 73 var buttonSpan = input.nextSibling; | 75 var button = input.nextSibling; |
| 74 if (this.selected) { | 76 if (this.selected) { |
| 75 input.classList.remove('inactive-password'); | 77 input.classList.remove('inactive-password'); |
| 76 buttonSpan.classList.remove('hidden'); | 78 button.classList.remove('hidden'); |
| 77 } else { | 79 } else { |
| 78 input.classList.add('inactive-password'); | 80 input.classList.add('inactive-password'); |
| 79 buttonSpan.classList.add('hidden'); | 81 button.classList.add('hidden'); |
| 80 } | 82 } |
| 81 }, | 83 }, |
| 82 | 84 |
| 83 /** | 85 /** |
| 84 * On-click event handler. Swaps the type of the input field from password | 86 * On-click event handler. Swaps the type of the input field from password |
| 85 * to text and back. | 87 * to text and back. |
| 86 * @private | 88 * @private |
| 87 */ | 89 */ |
| 88 onClick_: function(event) { | 90 onClick_: function(event) { |
| 89 // The password is the input element previous to the button span. | 91 // The password is the input element previous to the button. |
| 90 var buttonSpan = event.currentTarget; | 92 var button = event.currentTarget; |
| 91 var passwordInput = buttonSpan.previousSibling; | 93 var passwordInput = button.previousSibling; |
| 92 var type = passwordInput.type; | 94 if (passwordInput.type == 'password') { |
| 93 passwordInput.type = type == 'password' ? 'text' : 'password'; | 95 passwordInput.type = 'text'; |
| 96 button.textContent = localStrings.getString('passwordHideButton'); |
| 97 } else { |
| 98 passwordInput.type = 'password'; |
| 99 button.textContent = localStrings.getString('passwordShowButton'); |
| 100 } |
| 94 }, | 101 }, |
| 95 | 102 |
| 96 /** | 103 /** |
| 97 * Get and set the URL for the entry. | 104 * Get and set the URL for the entry. |
| 98 * @type {string} | 105 * @type {string} |
| 99 */ | 106 */ |
| 100 get url() { | 107 get url() { |
| 101 return this.dataItem[0]; | 108 return this.dataItem[0]; |
| 102 }, | 109 }, |
| 103 set url(url) { | 110 set url(url) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 }, | 235 }, |
| 229 }; | 236 }; |
| 230 | 237 |
| 231 return { | 238 return { |
| 232 PasswordListItem: PasswordListItem, | 239 PasswordListItem: PasswordListItem, |
| 233 PasswordExceptionsListItem: PasswordExceptionsListItem, | 240 PasswordExceptionsListItem: PasswordExceptionsListItem, |
| 234 PasswordsList: PasswordsList, | 241 PasswordsList: PasswordsList, |
| 235 PasswordExceptionsList: PasswordExceptionsList, | 242 PasswordExceptionsList: PasswordExceptionsList, |
| 236 }; | 243 }; |
| 237 }); | 244 }); |
| OLD | NEW |