 Chromium Code Reviews
 Chromium Code Reviews Issue 6034005:
  DOMUI: Implement the new-style Autofill options page.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 6034005:
  DOMUI: Implement the new-style Autofill options page.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: chrome/browser/resources/options/autofill_options_list.js | 
| diff --git a/chrome/browser/resources/options/autofill_options_list.js b/chrome/browser/resources/options/autofill_options_list.js | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..01713e9d9b0da6dded0d05ad086c95d8429d460e | 
| --- /dev/null | 
| +++ b/chrome/browser/resources/options/autofill_options_list.js | 
| @@ -0,0 +1,102 @@ | 
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +cr.define('options.autoFillOptions', function() { | 
| + const ArrayDataModel = cr.ui.ArrayDataModel; | 
| + const DeletableItemList = options.DeletableItemList; | 
| + const DeletableItem = options.DeletableItem; | 
| + const List = cr.ui.List; | 
| + | 
| + /** | 
| + * Creates a new AutoFill list item. | 
| + * @param {Array} entry An array of the form [guid, label]. | 
| + * @constructor | 
| + * @extends {cr.ui.ListItem} | 
| + */ | 
| + function AutoFillListItem(entry) { | 
| + var el = cr.doc.createElement('div'); | 
| + el.dataItem = entry; | 
| 
arv (Not doing code reviews)
2010/12/22 18:14:07
How about storing guid and label simple value prop
 
James Hawkins
2010/12/22 21:22:31
Done.
 | 
| + el.__proto__ = AutoFillListItem.prototype; | 
| + el.decorate(); | 
| + | 
| + return el; | 
| + } | 
| + | 
| + AutoFillListItem.prototype = { | 
| + __proto__: DeletableItem.prototype, | 
| + | 
| + /** @inheritDoc */ | 
| + decorate: function() { | 
| + DeletableItem.prototype.decorate.call(this); | 
| + | 
| + // The stored label. | 
| + var label = this.ownerDocument.createElement('div'); | 
| + label.className = 'autofill-list-item'; | 
| + label.textContent = this.label; | 
| + this.contentElement.appendChild(label); | 
| + }, | 
| + | 
| + /** | 
| + * Get and set the GUID for the entry. | 
| + * @type {string} | 
| + */ | 
| + get guid() { | 
| + return this.dataItem[0]; | 
| + }, | 
| + set guid(guid) { | 
| + this.dataItem[0] = guid; | 
| + }, | 
| + | 
| + /** | 
| + * Get and set the label for the entry. | 
| + * @type {string} | 
| + */ | 
| + get label() { | 
| + return this.dataItem[1]; | 
| + }, | 
| + set label(label) { | 
| + this.dataItem[1] = label; | 
| + }, | 
| + }; | 
| + | 
| + /** | 
| + * Create a new AutoFill list. | 
| + * @constructor | 
| + * @extends {cr.ui.List} | 
| + */ | 
| + var AutoFillList = cr.ui.define('list'); | 
| + | 
| + AutoFillList.prototype = { | 
| + __proto__: DeletableItemList.prototype, | 
| + | 
| + /** @inheritDoc */ | 
| + createItem: function(entry) { | 
| + return new AutoFillListItem(entry); | 
| + }, | 
| + | 
| + /** @inheritDoc */ | 
| + activateItemAtIndex: function(index) { | 
| + var item = this.getListItemByIndex(index); | 
| 
arv (Not doing code reviews)
2010/12/22 18:14:07
Shouldn't this be going through the dataModel?
 
James Hawkins
2010/12/22 21:22:31
Done.
 | 
| + AutoFillOptions.loadProfileEditor(item.guid); | 
| + }, | 
| + | 
| + /** @inheritDoc */ | 
| + deleteItemAtIndex: function(index) { | 
| + var item = this.getListItemByIndex(index); | 
| 
arv (Not doing code reviews)
2010/12/22 18:14:07
same here
 
James Hawkins
2010/12/22 21:22:31
Done.
 | 
| + AutoFillOptions.removeAutoFillProfile(item.guid); | 
| + }, | 
| + | 
| + /** | 
| + * The length of the list. | 
| + */ | 
| + get length() { | 
| 
arv (Not doing code reviews)
2010/12/22 18:14:07
What is this used for?
 
James Hawkins
2010/12/22 21:22:31
Copy/pasted from another implementation. Removed.
 | 
| + return this.dataModel.length; | 
| + }, | 
| + }; | 
| + | 
| + return { | 
| + AutoFillListItem: AutoFillListItem, | 
| + AutoFillList: AutoFillList, | 
| + }; | 
| +}); |