 Chromium Code Reviews
 Chromium Code Reviews Issue 6770012:
  Handle the PasswordManagerAllowShowPasswords preference in the options webui.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 6770012:
  Handle the PasswordManagerAllowShowPasswords preference in the options webui.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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 | 
| 11 /** | 11 /** | 
| 12 * Creates a new passwords list item. | 12 * Creates a new passwords list item. | 
| 13 * @param {Array} entry An array of the form [url, username, password]. | 13 * @param {Array} entry An array of the form [url, username, password]. | 
| 14 * @constructor | 14 * @constructor | 
| 15 * @extends {cr.ui.ListItem} | 15 * @extends {cr.ui.ListItem} | 
| 16 */ | 16 */ | 
| 17 function PasswordListItem(entry) { | 17 function PasswordListItem(entry, showPassword) { | 
| 18 var el = cr.doc.createElement('div'); | 18 var el = cr.doc.createElement('div'); | 
| 19 el.dataItem = entry; | 19 el.dataItem = entry; | 
| 20 el.__proto__ = PasswordListItem.prototype; | 20 el.__proto__ = PasswordListItem.prototype; | 
| 21 el.showPassword = showPassword; | |
| 21 el.decorate(); | 22 el.decorate(); | 
| 22 | 23 | 
| 23 return el; | 24 return el; | 
| 24 } | 25 } | 
| 25 | 26 | 
| 26 PasswordListItem.prototype = { | 27 PasswordListItem.prototype = { | 
| 27 __proto__: DeletableItem.prototype, | 28 __proto__: DeletableItem.prototype, | 
| 28 | 29 | 
| 29 /** @inheritDoc */ | 30 /** @inheritDoc */ | 
| 30 decorate: function() { | 31 decorate: function() { | 
| 31 DeletableItem.prototype.decorate.call(this); | 32 DeletableItem.prototype.decorate.call(this); | 
| 32 | 33 | 
| 33 // The URL of the site. | 34 // The URL of the site. | 
| 34 var urlLabel = this.ownerDocument.createElement('div'); | 35 var urlLabel = this.ownerDocument.createElement('div'); | 
| 35 urlLabel.classList.add('favicon-cell'); | 36 urlLabel.classList.add('favicon-cell'); | 
| 36 urlLabel.classList.add('url'); | 37 urlLabel.classList.add('url'); | 
| 37 urlLabel.textContent = this.url; | 38 urlLabel.textContent = this.url; | 
| 38 urlLabel.style.backgroundImage = url('chrome://favicon/' + this.url); | 39 urlLabel.style.backgroundImage = url('chrome://favicon/' + this.url); | 
| 39 this.contentElement.appendChild(urlLabel); | 40 this.contentElement.appendChild(urlLabel); | 
| 40 | 41 | 
| 41 // The stored username. | 42 // The stored username. | 
| 42 var usernameLabel = this.ownerDocument.createElement('div'); | 43 var usernameLabel = this.ownerDocument.createElement('div'); | 
| 43 usernameLabel.className = 'name'; | 44 usernameLabel.className = 'name'; | 
| 44 usernameLabel.textContent = this.username; | 45 usernameLabel.textContent = this.username; | 
| 45 this.contentElement.appendChild(usernameLabel); | 46 this.contentElement.appendChild(usernameLabel); | 
| 46 | 47 | 
| 47 // The stored password. | 48 if (this.showPassword) { | 
| 
James Hawkins
2011/03/29 17:37:23
if (!this.showPassword)
  return;
^ Huge indented
 
Joao da Silva
2011/03/31 10:03:22
This has moved a couple of lines down.
 | |
| 48 var passwordInputDiv = this.ownerDocument.createElement('div'); | 49 // The stored password. | 
| 49 passwordInputDiv.className = 'password'; | 50 var passwordInputDiv = this.ownerDocument.createElement('div'); | 
| 51 passwordInputDiv.className = 'password'; | |
| 
stuartmorgan
2011/03/29 15:24:58
Having a huge blank space on the right hand side o
 
James Hawkins
2011/03/29 17:37:23
Agreed. Are we showing some sort of UI to the user
 
Joao da Silva
2011/03/31 10:03:22
Fixed. The password input div is kept, but the "sh
 
Joao da Silva
2011/03/31 10:03:22
When a preference is managed by policy there is a
 | |
| 50 | 52 | 
| 51 // The password input field. | 53 // The password input field. | 
| 52 var passwordInput = this.ownerDocument.createElement('input'); | 54 var passwordInput = this.ownerDocument.createElement('input'); | 
| 53 passwordInput.type = 'password'; | 55 passwordInput.type = 'password'; | 
| 54 passwordInput.className = 'inactive-password'; | 56 passwordInput.className = 'inactive-password'; | 
| 55 passwordInput.readOnly = true; | 57 passwordInput.readOnly = true; | 
| 56 passwordInput.value = this.password; | 58 passwordInput.value = this.password; | 
| 57 passwordInputDiv.appendChild(passwordInput); | 59 passwordInputDiv.appendChild(passwordInput); | 
| 58 | 60 | 
| 59 // The show/hide button. | 61 // The show/hide button. | 
| 60 var button = this.ownerDocument.createElement('button'); | 62 var button = this.ownerDocument.createElement('button'); | 
| 61 button.classList.add('hidden'); | 63 button.classList.add('hidden'); | 
| 62 button.classList.add('password-button'); | 64 button.classList.add('password-button'); | 
| 63 button.textContent = localStrings.getString('passwordShowButton'); | 65 button.textContent = localStrings.getString('passwordShowButton'); | 
| 64 button.addEventListener('click', this.onClick_, true); | 66 button.addEventListener('click', this.onClick_, true); | 
| 65 passwordInputDiv.appendChild(button); | 67 passwordInputDiv.appendChild(button); | 
| 66 | 68 | 
| 67 this.contentElement.appendChild(passwordInputDiv); | 69 this.contentElement.appendChild(passwordInputDiv); | 
| 70 } | |
| 68 }, | 71 }, | 
| 69 | 72 | 
| 70 /** @inheritDoc */ | 73 /** @inheritDoc */ | 
| 71 selectionChanged: function() { | 74 selectionChanged: function() { | 
| 75 if (!this.showPassword) | |
| 76 return; | |
| 
James Hawkins
2011/03/29 17:37:23
nit: Blank line after if block.
 
Joao da Silva
2011/03/31 10:03:22
Done.
 | |
| 72 var passwordInput = this.querySelector('input[type=password]'); | 77 var passwordInput = this.querySelector('input[type=password]'); | 
| 73 var textInput = this.querySelector('input[type=text]'); | 78 var textInput = this.querySelector('input[type=text]'); | 
| 74 var input = passwordInput || textInput; | 79 var input = passwordInput || textInput; | 
| 75 var button = input.nextSibling; | 80 var button = input.nextSibling; | 
| 76 if (this.selected) { | 81 if (this.selected) { | 
| 77 input.classList.remove('inactive-password'); | 82 input.classList.remove('inactive-password'); | 
| 78 button.classList.remove('hidden'); | 83 button.classList.remove('hidden'); | 
| 79 } else { | 84 } else { | 
| 80 input.classList.add('inactive-password'); | 85 input.classList.add('inactive-password'); | 
| 81 button.classList.add('hidden'); | 86 button.classList.add('hidden'); | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 * @constructor | 189 * @constructor | 
| 185 * @extends {cr.ui.List} | 190 * @extends {cr.ui.List} | 
| 186 */ | 191 */ | 
| 187 var PasswordsList = cr.ui.define('list'); | 192 var PasswordsList = cr.ui.define('list'); | 
| 188 | 193 | 
| 189 PasswordsList.prototype = { | 194 PasswordsList.prototype = { | 
| 190 __proto__: DeletableItemList.prototype, | 195 __proto__: DeletableItemList.prototype, | 
| 191 | 196 | 
| 192 /** @inheritDoc */ | 197 /** @inheritDoc */ | 
| 193 createItem: function(entry) { | 198 createItem: function(entry) { | 
| 194 return new PasswordListItem(entry); | 199 return new PasswordListItem(entry, this.showPasswords); | 
| 195 }, | 200 }, | 
| 196 | 201 | 
| 197 /** @inheritDoc */ | 202 /** @inheritDoc */ | 
| 198 deleteItemAtIndex: function(index) { | 203 deleteItemAtIndex: function(index) { | 
| 199 PasswordManager.removeSavedPassword(index); | 204 PasswordManager.removeSavedPassword(index); | 
| 200 }, | 205 }, | 
| 201 | 206 | 
| 202 /** | 207 /** | 
| 203 * The length of the list. | 208 * The length of the list. | 
| 204 */ | 209 */ | 
| 205 get length() { | 210 get length() { | 
| 206 return this.dataModel.length; | 211 return this.dataModel.length; | 
| 207 }, | 212 }, | 
| 213 | |
| 214 showPasswords: true, | |
| 
James Hawkins
2011/03/29 17:37:23
Document.
 
James Hawkins
2011/03/29 17:37:23
s/showPasswords/showPasswords_/ since it's presuma
 
Joao da Silva
2011/03/31 10:03:22
Done.
 
Joao da Silva
2011/03/31 10:03:22
It's not private. Should a getter and setter be us
 | |
| 208 }; | 215 }; | 
| 209 | 216 | 
| 210 /** | 217 /** | 
| 211 * Create a new passwords list. | 218 * Create a new passwords list. | 
| 212 * @constructor | 219 * @constructor | 
| 213 * @extends {cr.ui.List} | 220 * @extends {cr.ui.List} | 
| 214 */ | 221 */ | 
| 215 var PasswordExceptionsList = cr.ui.define('list'); | 222 var PasswordExceptionsList = cr.ui.define('list'); | 
| 216 | 223 | 
| 217 PasswordExceptionsList.prototype = { | 224 PasswordExceptionsList.prototype = { | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 235 }, | 242 }, | 
| 236 }; | 243 }; | 
| 237 | 244 | 
| 238 return { | 245 return { | 
| 239 PasswordListItem: PasswordListItem, | 246 PasswordListItem: PasswordListItem, | 
| 240 PasswordExceptionsListItem: PasswordExceptionsListItem, | 247 PasswordExceptionsListItem: PasswordExceptionsListItem, | 
| 241 PasswordsList: PasswordsList, | 248 PasswordsList: PasswordsList, | 
| 242 PasswordExceptionsList: PasswordExceptionsList, | 249 PasswordExceptionsList: PasswordExceptionsList, | 
| 243 }; | 250 }; | 
| 244 }); | 251 }); | 
| OLD | NEW |