Chromium Code Reviews| 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..4d2dba79265683903b1d0d7ffa699632eb85bdc8 |
| --- /dev/null |
| +++ b/chrome/browser/resources/options/autofill_options_list.js |
| @@ -0,0 +1,93 @@ |
| +// 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 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 {options.DeletableItem} |
| + */ |
| + function AutoFillListItem(entry) { |
| + var el = cr.doc.createElement('div'); |
| + el.guid = entry[0]; |
| + el.label = entry[1]; |
| + 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() { |
|
arv (Not doing code reviews)
2010/12/22 23:00:35
No need for getter and setters for these since the
James Hawkins
2010/12/22 23:13:08
Done.
|
| + return this.guid; |
|
arv (Not doing code reviews)
2010/12/22 23:00:35
This will not work. It will cause infinite recursi
James Hawkins
2010/12/22 23:13:08
Done.
|
| + }, |
| + set guid(guid) { |
| + this.guid = guid; |
| + }, |
| + |
| + /** |
| + * Get and set the label for the entry. |
| + * @type {string} |
| + */ |
| + get label() { |
| + return this.label; |
| + }, |
| + set label(label) { |
| + this.label = label; |
| + }, |
| + }; |
| + |
| + /** |
| + * Create a new AutoFill list. |
| + * @constructor |
| + * @extends {options.DeletableItemList} |
| + */ |
| + var AutoFillList = cr.ui.define('list'); |
| + |
| + AutoFillList.prototype = { |
| + __proto__: DeletableItemList.prototype, |
| + |
| + /** @inheritDoc */ |
| + createItem: function(entry) { |
| + return new AutoFillListItem(entry); |
| + }, |
| + |
| + /** @inheritDoc */ |
| + activateItemAtIndex: function(index) { |
| + AutoFillOptions.loadProfileEditor(this.dataModel.item(index)[0]); |
| + }, |
| + |
| + /** @inheritDoc */ |
| + deleteItemAtIndex: function(index) { |
| + AutoFillOptions.removeAutoFillProfile(this.dataModel.item(index)[0]); |
| + }, |
| + }; |
| + |
| + return { |
| + AutoFillListItem: AutoFillListItem, |
| + AutoFillList: AutoFillList, |
| + }; |
| +}); |