Chromium Code Reviews| 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'; | 35 urlLabel.className = 'favicon-cell url'; |
|
stuartmorgan
2011/01/21 00:05:05
Two classList.add lines instead?
James Hawkins
2011/01/21 00:34:51
Done.
| |
| 36 urlLabel.classList.add('favicon-cell'); | |
| 37 urlLabel.textContent = this.url; | 36 urlLabel.textContent = this.url; |
| 38 urlLabel.style.backgroundImage = url('chrome://favicon/' + this.url); | 37 urlLabel.style.backgroundImage = url('chrome://favicon/' + this.url); |
| 39 this.contentElement.appendChild(urlLabel); | 38 this.contentElement.appendChild(urlLabel); |
| 40 | 39 |
| 41 // The stored username. | 40 // The stored username. |
| 42 var usernameLabel = this.ownerDocument.createElement('div'); | 41 var usernameLabel = this.ownerDocument.createElement('div'); |
| 43 usernameLabel.className = 'name'; | 42 usernameLabel.className = 'name'; |
| 44 usernameLabel.textContent = this.username; | 43 usernameLabel.textContent = this.username; |
| 45 this.contentElement.appendChild(usernameLabel); | 44 this.contentElement.appendChild(usernameLabel); |
| 46 | 45 |
| 47 // The stored password. | 46 // The stored password. |
| 48 var passwordInputDiv = this.ownerDocument.createElement('div'); | 47 var passwordInputDiv = this.ownerDocument.createElement('div'); |
| 49 passwordInputDiv.className = 'password'; | 48 passwordInputDiv.className = 'password'; |
| 50 | 49 |
| 51 // The password input field. | 50 // The password input field. |
| 52 var passwordInput = this.ownerDocument.createElement('input'); | 51 var passwordInput = this.ownerDocument.createElement('input'); |
| 52 passwordInput.type = 'password'; | |
| 53 passwordInput.className = 'inactive-password'; | 53 passwordInput.className = 'inactive-password'; |
| 54 passwordInput.readOnly = true; | 54 passwordInput.readOnly = true; |
| 55 passwordInput.type = 'password'; | |
| 56 passwordInput.value = this.password; | 55 passwordInput.value = this.password; |
| 57 passwordInputDiv.appendChild(passwordInput); | 56 passwordInputDiv.appendChild(passwordInput); |
| 58 | 57 |
| 59 // The show/hide button. | 58 // The show/hide button. |
| 60 var buttonSpan = this.ownerDocument.createElement('span'); | 59 var button = this.ownerDocument.createElement('button'); |
| 61 buttonSpan.className = 'hidden'; | 60 button.className = 'hidden password-button'; |
|
stuartmorgan
2011/01/21 00:05:05
Same
James Hawkins
2011/01/21 00:34:51
Done.
| |
| 62 buttonSpan.addEventListener('click', this.onClick_, true); | 61 button.textContent = localStrings.getString('passwordShowButton'); |
| 63 passwordInputDiv.appendChild(buttonSpan); | 62 button.addEventListener('click', this.onClick_, true); |
| 63 passwordInputDiv.appendChild(button); | |
| 64 | 64 |
| 65 this.contentElement.appendChild(passwordInputDiv); | 65 this.contentElement.appendChild(passwordInputDiv); |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 /** @inheritDoc */ | 68 /** @inheritDoc */ |
| 69 selectionChanged: function() { | 69 selectionChanged: function() { |
| 70 var passwordInput = this.querySelector('input[type=password]'); | 70 var passwordInput = this.querySelector('input[type=password]'); |
| 71 var textInput = this.querySelector('input[type=text]'); | 71 var textInput = this.querySelector('input[type=text]'); |
| 72 var input = passwordInput || textInput; | 72 var input = passwordInput || textInput; |
| 73 var buttonSpan = input.nextSibling; | 73 var button = input.nextSibling; |
| 74 if (this.selected) { | 74 if (this.selected) { |
| 75 input.classList.remove('inactive-password'); | 75 input.classList.remove('inactive-password'); |
| 76 buttonSpan.classList.remove('hidden'); | 76 button.classList.remove('hidden'); |
| 77 } else { | 77 } else { |
| 78 input.classList.add('inactive-password'); | 78 input.classList.add('inactive-password'); |
| 79 buttonSpan.classList.add('hidden'); | 79 button.classList.add('hidden'); |
| 80 } | 80 } |
| 81 }, | 81 }, |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * On-click event handler. Swaps the type of the input field from password | 84 * On-click event handler. Swaps the type of the input field from password |
| 85 * to text and back. | 85 * to text and back. |
| 86 * @private | 86 * @private |
| 87 */ | 87 */ |
| 88 onClick_: function(event) { | 88 onClick_: function(event) { |
| 89 // The password is the input element previous to the button span. | 89 // The password is the input element previous to the button. |
| 90 var buttonSpan = event.currentTarget; | 90 var button = event.currentTarget; |
| 91 var passwordInput = buttonSpan.previousSibling; | 91 var passwordInput = button.previousSibling; |
| 92 var type = passwordInput.type; | 92 if (passwordInput.type == 'password') { |
| 93 passwordInput.type = type == 'password' ? 'text' : 'password'; | 93 passwordInput.type = 'text'; |
| 94 button.textContent = localStrings.getString('passwordHideButton'); | |
| 95 } else { | |
| 96 passwordInput.type = 'password'; | |
| 97 button.textContent = localStrings.getString('passwordShowButton'); | |
| 98 } | |
| 94 }, | 99 }, |
| 95 | 100 |
| 96 /** | 101 /** |
| 97 * Get and set the URL for the entry. | 102 * Get and set the URL for the entry. |
| 98 * @type {string} | 103 * @type {string} |
| 99 */ | 104 */ |
| 100 get url() { | 105 get url() { |
| 101 return this.dataItem[0]; | 106 return this.dataItem[0]; |
| 102 }, | 107 }, |
| 103 set url(url) { | 108 set url(url) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 }, | 233 }, |
| 229 }; | 234 }; |
| 230 | 235 |
| 231 return { | 236 return { |
| 232 PasswordListItem: PasswordListItem, | 237 PasswordListItem: PasswordListItem, |
| 233 PasswordExceptionsListItem: PasswordExceptionsListItem, | 238 PasswordExceptionsListItem: PasswordExceptionsListItem, |
| 234 PasswordsList: PasswordsList, | 239 PasswordsList: PasswordsList, |
| 235 PasswordExceptionsList: PasswordExceptionsList, | 240 PasswordExceptionsList: PasswordExceptionsList, |
| 236 }; | 241 }; |
| 237 }); | 242 }); |
| OLD | NEW |