| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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]. When |
| 14 * the list has been filtered, a fourth element [index] may be present. |
| 14 * @constructor | 15 * @constructor |
| 15 * @extends {cr.ui.ListItem} | 16 * @extends {cr.ui.ListItem} |
| 16 */ | 17 */ |
| 17 function PasswordListItem(entry, showPasswords) { | 18 function PasswordListItem(entry, showPasswords) { |
| 18 var el = cr.doc.createElement('div'); | 19 var el = cr.doc.createElement('div'); |
| 19 el.dataItem = entry; | 20 el.dataItem = entry; |
| 20 el.__proto__ = PasswordListItem.prototype; | 21 el.__proto__ = PasswordListItem.prototype; |
| 21 el.decorate(showPasswords); | 22 el.decorate(showPasswords); |
| 22 | 23 |
| 23 return el; | 24 return el; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 this.redraw(); | 223 this.redraw(); |
| 223 }, | 224 }, |
| 224 | 225 |
| 225 /** @inheritDoc */ | 226 /** @inheritDoc */ |
| 226 createItem: function(entry) { | 227 createItem: function(entry) { |
| 227 return new PasswordListItem(entry, this.showPasswords_); | 228 return new PasswordListItem(entry, this.showPasswords_); |
| 228 }, | 229 }, |
| 229 | 230 |
| 230 /** @inheritDoc */ | 231 /** @inheritDoc */ |
| 231 deleteItemAtIndex: function(index) { | 232 deleteItemAtIndex: function(index) { |
| 233 var item = this.dataModel.item(index); |
| 234 if (item && item.length > 3) { |
| 235 // The fourth element, if present, is the original index to delete. |
| 236 index = item[3]; |
| 237 } |
| 232 PasswordManager.removeSavedPassword(index); | 238 PasswordManager.removeSavedPassword(index); |
| 233 }, | 239 }, |
| 234 | 240 |
| 235 /** | 241 /** |
| 236 * The length of the list. | 242 * The length of the list. |
| 237 */ | 243 */ |
| 238 get length() { | 244 get length() { |
| 239 return this.dataModel.length; | 245 return this.dataModel.length; |
| 240 }, | 246 }, |
| 241 }; | 247 }; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 268 }, | 274 }, |
| 269 }; | 275 }; |
| 270 | 276 |
| 271 return { | 277 return { |
| 272 PasswordListItem: PasswordListItem, | 278 PasswordListItem: PasswordListItem, |
| 273 PasswordExceptionsListItem: PasswordExceptionsListItem, | 279 PasswordExceptionsListItem: PasswordExceptionsListItem, |
| 274 PasswordsList: PasswordsList, | 280 PasswordsList: PasswordsList, |
| 275 PasswordExceptionsList: PasswordExceptionsList, | 281 PasswordExceptionsList: PasswordExceptionsList, |
| 276 }; | 282 }; |
| 277 }); | 283 }); |
| OLD | NEW |