1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 cr.define('options', function() {
6 /** @const */ var List = cr.ui.List;
7 /** @const */ var ListItem = cr.ui.ListItem;
10 * Creates a new list item for the origin's data.
11 * @param {!Object} origin Data used to create the origin list item.
13 * @extends {cr.ui.ListItem}
15 function OriginListItem(origin) {
16 var el = cr.doc.createElement('div');
17 el.origin_ = origin.origin;
18 el.usage_ = origin.usage;
19 el.usageString_ = origin.usageString;
20 el.readableName_ = origin.readableName;
21 el.__proto__ = OriginListItem.prototype;
26 OriginListItem.prototype = {
27 __proto__: ListItem.prototype,
30 decorate: function() {
31 ListItem.prototype.decorate.call(this);
33 this.className = 'deletable-item origin-list-item';
34 this.contentElement_ = this.ownerDocument.createElement('div');
35 this.appendChild(this.contentElement_);
37 var titleEl = this.ownerDocument.createElement('div');
38 titleEl.className = 'title favicon-cell weaktrl';
39 titleEl.textContent = this.readableName_;
40 titleEl.originPattern = this.origin_;
41 titleEl.style.backgroundImage = getFaviconImageSet(this.origin_);
42 this.contentElement_.appendChild(titleEl);
44 this.contentElement_.onclick = function() {
45 chrome.send('maybeShowEditPage', [titleEl.originPattern]);
48 if (this.usageString_) {
49 var usageEl = this.ownerDocument.createElement('span');
50 usageEl.className = 'local-storage-usage';
51 usageEl.textContent = this.usageString_;
52 this.appendChild(usageEl);
59 * @extends {cr.ui.List}
61 var OriginList = cr.ui.define('list');
63 OriginList.prototype = {
64 __proto__: List.prototype,
68 * @param {!Object} entry
70 createItem: function(entry) {
71 return new OriginListItem(entry);
76 OriginListItem: OriginListItem,
77 OriginList: OriginList,