Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / origin_resources_list.js
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.
4
5 cr.define('options', function() {
6   /** @const */ List = cr.ui.List;
7   /** @const */ ListItem = cr.ui.ListItem;
8
9   /**
10    * Creates a new list item for the origin's data.
11    * @param {!Object} origin Data used to create the origin list item.
12    */
13   function OriginListItem(origin) {
14     var el = cr.doc.createElement('div');
15     el.origin_ = origin.origin;
16     el.usage_ = origin.usage;
17     el.usageString_ = origin.usageString;
18     el.__proto__ = OriginListItem.prototype;
19     el.decorate();
20     return el;
21   }
22
23   OriginListItem.prototype = {
24     __proto__: ListItem.prototype,
25
26     /** @override */
27     decorate: function() {
28       ListItem.prototype.decorate.call(this);
29
30       this.className = 'deletable-item origin-list-item';
31       this.contentElement_ = this.ownerDocument.createElement('div');
32       this.appendChild(this.contentElement_);
33
34       var titleEl = this.ownerDocument.createElement('div');
35       titleEl.className = 'title favicon-cell weaktrl';
36       titleEl.textContent = this.origin_;
37       titleEl.style.backgroundImage = getFaviconImageSet(this.origin_);
38       this.contentElement_.appendChild(titleEl);
39
40       if (this.usageString_) {
41         var usageEl = this.ownerDocument.createElement('span');
42         usageEl.className = 'local-storage-usage';
43         usageEl.textContent = this.usageString_;
44         this.appendChild(usageEl);
45       }
46     }
47   };
48
49   var OriginList = cr.ui.define('list');
50
51   OriginList.prototype = {
52     __proto__: List.prototype,
53
54     /** @override */
55     createItem: function(entry) {
56       return new OriginListItem(entry);
57     },
58   };
59
60   return {
61     OriginListItem: OriginListItem,
62     OriginList: OriginList,
63   };
64 });