Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: chrome/browser/resources/md_downloads/item.js

Issue 1375333004: MD Downloads: use <iron-list> to render download items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iron-list2
Patch Set: remove loader import Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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('downloads', function() { 5 cr.define('downloads', function() {
6 var Item = Polymer({ 6 var Item = Polymer({
7 is: 'downloads-item', 7 is: 'downloads-item',
8 8
9 /**
10 * @param {!downloads.ThrottledIconLoader} iconLoader
11 */
12 factoryImpl: function(iconLoader) {
13 /** @private {!downloads.ThrottledIconLoader} */
14 this.iconLoader_ = iconLoader;
15 },
16
17 properties: { 9 properties: {
18 data: { 10 data: {
19 type: Object, 11 type: Object,
20 }, 12 },
21 13
22 hideDate: { 14 hideDate: {
23 type: Boolean, 15 type: Boolean,
24 value: true, 16 value: true,
25 }, 17 },
26 18
27 readyPromise: {
28 type: Object,
29 value: function() {
30 return new Promise(function(resolve, reject) {
31 this.resolveReadyPromise_ = resolve;
32 }.bind(this));
33 },
34 },
35
36 completelyOnDisk_: { 19 completelyOnDisk_: {
37 computed: 'computeCompletelyOnDisk_(' + 20 computed: 'computeCompletelyOnDisk_(' +
38 'data.state, data.file_externally_removed)', 21 'data.state, data.file_externally_removed)',
39 type: Boolean, 22 type: Boolean,
40 value: true, 23 value: true,
41 }, 24 },
42 25
43 controlledBy_: { 26 controlledBy_: {
44 computed: 'computeControlledBy_(data.by_ext_id, data.by_ext_name)', 27 computed: 'computeControlledBy_(data.by_ext_id, data.by_ext_name)',
45 type: String, 28 type: String,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 computed: 'computeIsMalware_(isDangerous_, data.danger_type)', 81 computed: 'computeIsMalware_(isDangerous_, data.danger_type)',
99 type: Boolean, 82 type: Boolean,
100 value: false, 83 value: false,
101 }, 84 },
102 }, 85 },
103 86
104 observers: [ 87 observers: [
105 // TODO(dbeam): this gets called way more when I observe data.by_ext_id 88 // TODO(dbeam): this gets called way more when I observe data.by_ext_id
106 // and data.by_ext_name directly. Why? 89 // and data.by_ext_name directly. Why?
107 'observeControlledBy_(controlledBy_)', 90 'observeControlledBy_(controlledBy_)',
91 'observeIsDangerous_(isDangerous_, data.file_path)',
esprehn 2015/10/03 05:11:54 So dangerous!
Dan Beam 2015/10/04 08:27:08 Acknowledged.
108 ], 92 ],
109 93
110 ready: function() { 94 ready: function() {
111 this.content = this.$.content; 95 this.content = this.$.content;
112 this.resolveReadyPromise_();
113 },
114
115 /** @param {!downloads.Data} data */
116 update: function(data) {
117 this.data = data;
118
119 if (!this.isDangerous_) {
120 var icon = 'chrome://fileicon/' + encodeURIComponent(data.file_path);
121 this.iconLoader_.loadScaledIcon(this.$['file-icon'], icon);
122 }
123 }, 96 },
124 97
125 /** @private */ 98 /** @private */
126 computeClass_: function() { 99 computeClass_: function() {
127 var classes = []; 100 var classes = [];
128 101
129 if (this.isActive_) 102 if (this.isActive_)
130 classes.push('is-active'); 103 classes.push('is-active');
131 104
132 if (this.isDangerous_) 105 if (this.isDangerous_)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 isIndeterminate_: function() { 229 isIndeterminate_: function() {
257 return this.data.percent == -1; 230 return this.data.percent == -1;
258 }, 231 },
259 232
260 /** @private */ 233 /** @private */
261 observeControlledBy_: function() { 234 observeControlledBy_: function() {
262 this.$['controlled-by'].innerHTML = this.controlledBy_; 235 this.$['controlled-by'].innerHTML = this.controlledBy_;
263 }, 236 },
264 237
265 /** @private */ 238 /** @private */
239 observeIsDangerous_: function() {
240 if (this.data && !this.isDangerous_) {
241 var filePath = encodeURIComponent(this.data.file_path);
242 this.$['file-icon'].src = 'chrome://fileicon/' + filePath;
esprehn 2015/10/03 05:11:54 If we make our ids camel case this is prettier. No
Dan Beam 2015/10/04 08:27:08 Acknowledged.
243 }
244 },
245
246 /** @private */
266 onCancelClick_: function() { 247 onCancelClick_: function() {
267 downloads.ActionService.getInstance().cancel(this.data.id); 248 downloads.ActionService.getInstance().cancel(this.data.id);
268 }, 249 },
269 250
270 /** @private */ 251 /** @private */
271 onDiscardDangerous_: function() { 252 onDiscardDangerous_: function() {
272 downloads.ActionService.getInstance().discardDangerous(this.data.id); 253 downloads.ActionService.getInstance().discardDangerous(this.data.id);
273 }, 254 },
274 255
275 /** 256 /**
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 }, 297 },
317 298
318 /** @private */ 299 /** @private */
319 onShowClick_: function() { 300 onShowClick_: function() {
320 downloads.ActionService.getInstance().show(this.data.id); 301 downloads.ActionService.getInstance().show(this.data.id);
321 }, 302 },
322 }); 303 });
323 304
324 return {Item: Item}; 305 return {Item: Item};
325 }); 306 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/item.html ('k') | chrome/browser/resources/md_downloads/manager.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698