OLD | NEW |
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 /** | 9 /** |
10 * @param {!downloads.ThrottledIconLoader} iconLoader | 10 * @param {!downloads.ThrottledIconLoader} iconLoader |
(...skipping 17 matching lines...) Expand all Loading... |
28 readyPromise: { | 28 readyPromise: { |
29 type: Object, | 29 type: Object, |
30 value: function() { | 30 value: function() { |
31 return new Promise(function(resolve, reject) { | 31 return new Promise(function(resolve, reject) { |
32 this.resolveReadyPromise_ = resolve; | 32 this.resolveReadyPromise_ = resolve; |
33 }.bind(this)); | 33 }.bind(this)); |
34 }, | 34 }, |
35 }, | 35 }, |
36 | 36 |
37 scrollbarWidth: { | 37 scrollbarWidth: { |
| 38 observer: 'onScrollbarWidthChange_', |
38 type: Number, | 39 type: Number, |
39 value: 0, | 40 value: 0, |
40 observer: 'onScrollbarWidthChange_', | |
41 }, | 41 }, |
42 | 42 |
43 completelyOnDisk_: { | 43 completelyOnDisk_: { |
| 44 computed: 'computeCompletelyOnDisk_(' + |
| 45 'data_.state, data_.file_externally_removed)', |
44 type: Boolean, | 46 type: Boolean, |
45 value: true, | 47 value: true, |
46 computed: 'computeCompletelyOnDisk_(' + | |
47 'data_.state, data_.file_externally_removed)', | |
48 }, | 48 }, |
49 | 49 |
50 i18n_: { | 50 i18n_: { |
| 51 readOnly: true, |
51 type: Object, | 52 type: Object, |
52 value: function() { | 53 value: function() { |
53 return { | 54 return { |
54 cancel: loadTimeData.getString('controlCancel'), | 55 cancel: loadTimeData.getString('controlCancel'), |
| 56 discard: loadTimeData.getString('dangerDiscard'), |
55 pause: loadTimeData.getString('controlPause'), | 57 pause: loadTimeData.getString('controlPause'), |
| 58 remove: loadTimeData.getString('controlRemoveFromList'), |
56 resume: loadTimeData.getString('controlResume'), | 59 resume: loadTimeData.getString('controlResume'), |
| 60 restore: loadTimeData.getString('dangerRestore'), |
57 retry: loadTimeData.getString('controlRetry'), | 61 retry: loadTimeData.getString('controlRetry'), |
| 62 save: loadTimeData.getString('dangerSave'), |
58 show: loadTimeData.getString('controlShowInFolder'), | 63 show: loadTimeData.getString('controlShowInFolder'), |
59 }; | 64 }; |
60 }, | 65 }, |
61 readOnly: true, | |
62 }, | 66 }, |
63 | 67 |
64 isDangerous_: { | 68 isDangerous_: { |
| 69 computed: 'computeIsDangerous_(data_.state)', |
65 type: Boolean, | 70 type: Boolean, |
66 value: false, | 71 value: false, |
67 computed: 'computeIsDangerous_(data_.state)', | |
68 }, | 72 }, |
69 | 73 |
70 isInProgress_: { | 74 isInProgress_: { |
| 75 computed: 'computeIsInProgress_(data_.state)', |
71 type: Boolean, | 76 type: Boolean, |
72 value: false, | 77 value: false, |
73 computed: 'computeIsInProgress_(data_.state)', | |
74 }, | 78 }, |
75 | 79 |
76 showCancel_: { | 80 showCancel_: { |
| 81 computed: 'computeShowCancel_(data_.state)', |
77 type: Boolean, | 82 type: Boolean, |
78 value: false, | 83 value: false, |
79 computed: 'computeShowCancel_(data_.state)', | |
80 }, | 84 }, |
81 | 85 |
82 showProgress_: { | 86 showProgress_: { |
| 87 computed: 'computeShowProgress_(showCancel_, data_.percent)', |
83 type: Boolean, | 88 type: Boolean, |
84 value: false, | 89 value: false, |
85 computed: 'computeShowProgress_(showCancel_, data_.percent)', | |
86 }, | 90 }, |
87 | 91 |
88 /** Only set when |isDangerous| is true. */ | 92 isMalware_: { |
89 isMalware_: Boolean, | 93 computed: 'computeIsMalware_(isDangerous_, data_.danger_type)', |
| 94 type: Boolean, |
| 95 value: false, |
| 96 }, |
90 | 97 |
91 // TODO(dbeam): move all properties to |data_|. | 98 // TODO(dbeam): move all properties to |data_|. |
92 data_: { | 99 data_: { |
93 type: Object, | 100 type: Object, |
94 value: function() { return {}; }, | 101 value: function() { return {}; }, |
95 }, | 102 }, |
96 }, | 103 }, |
97 | 104 |
98 ready: function() { | 105 ready: function() { |
99 this.content = this.$.content; | 106 this.content = this.$.content; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 154 |
148 // Status goes in the "tag" (next to the file name) if there's no file. | 155 // Status goes in the "tag" (next to the file name) if there's no file. |
149 this.ensureTextIs_(this.$.description, isActive ? description : ''); | 156 this.ensureTextIs_(this.$.description, isActive ? description : ''); |
150 this.ensureTextIs_(this.$.tag, isActive ? '' : description); | 157 this.ensureTextIs_(this.$.tag, isActive ? '' : description); |
151 | 158 |
152 this.$.content.classList.toggle('show-progress', this.showProgress_); | 159 this.$.content.classList.toggle('show-progress', this.showProgress_); |
153 | 160 |
154 var hideRemove; | 161 var hideRemove; |
155 | 162 |
156 if (this.isDangerous_) { | 163 if (this.isDangerous_) { |
157 this.isMalware_ = | |
158 data.danger_type == downloads.DangerType.DANGEROUS_CONTENT || | |
159 data.danger_type == downloads.DangerType.DANGEROUS_HOST || | |
160 data.danger_type == downloads.DangerType.DANGEROUS_URL || | |
161 data.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED; | |
162 hideRemove = true; | 164 hideRemove = true; |
163 } else { | 165 } else { |
164 this.$['file-link'].href = data.url; | 166 this.$['file-link'].href = data.url; |
165 this.ensureTextIs_(this.$['file-link'], data.file_name); | 167 this.ensureTextIs_(this.$['file-link'], data.file_name); |
166 | 168 |
167 this.$['file-link'].hidden = !this.completelyOnDisk_; | 169 this.$['file-link'].hidden = !this.completelyOnDisk_; |
168 this.$.name.hidden = this.completelyOnDisk_; | 170 this.$.name.hidden = this.completelyOnDisk_; |
169 | 171 |
170 hideRemove = this.showCancel_ || | 172 hideRemove = this.showCancel_ || |
171 !loadTimeData.getBoolean('allowDeletingHistory'); | 173 !loadTimeData.getBoolean('allowDeletingHistory'); |
(...skipping 25 matching lines...) Expand all Loading... |
197 assert(!this.hideDate); | 199 assert(!this.hideDate); |
198 return assert(this.data_.since_string || this.data_.date_string); | 200 return assert(this.data_.since_string || this.data_.date_string); |
199 }, | 201 }, |
200 | 202 |
201 /** @private */ | 203 /** @private */ |
202 computeIsInProgress_: function() { | 204 computeIsInProgress_: function() { |
203 return this.data_.state == downloads.States.IN_PROGRESS; | 205 return this.data_.state == downloads.States.IN_PROGRESS; |
204 }, | 206 }, |
205 | 207 |
206 /** @private */ | 208 /** @private */ |
| 209 computeIsMalware_: function() { |
| 210 return this.isDangerous_ && |
| 211 (this.data_.danger_type == downloads.DangerType.DANGEROUS_CONTENT || |
| 212 this.data_.danger_type == downloads.DangerType.DANGEROUS_HOST || |
| 213 this.data_.danger_type == downloads.DangerType.DANGEROUS_URL || |
| 214 this.data_.danger_type == downloads.DangerType.POTENTIALLY_UNWANTED); |
| 215 }, |
| 216 |
| 217 /** @private */ |
207 computeIsDangerous_: function() { | 218 computeIsDangerous_: function() { |
208 return this.data_.state == downloads.States.DANGEROUS; | 219 return this.data_.state == downloads.States.DANGEROUS; |
209 }, | 220 }, |
210 | 221 |
211 /** @private */ | 222 /** @private */ |
212 computeShowCancel_: function() { | 223 computeShowCancel_: function() { |
213 return this.data_.state == downloads.States.IN_PROGRESS || | 224 return this.data_.state == downloads.States.IN_PROGRESS || |
214 this.data_.state == downloads.States.PAUSED; | 225 this.data_.state == downloads.States.PAUSED; |
215 }, | 226 }, |
216 | 227 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 }, | 366 }, |
356 | 367 |
357 /** @private */ | 368 /** @private */ |
358 onShowClick_: function() { | 369 onShowClick_: function() { |
359 this.actionService_.show(this.data_.id); | 370 this.actionService_.show(this.data_.id); |
360 }, | 371 }, |
361 }); | 372 }); |
362 | 373 |
363 return {Item: Item}; | 374 return {Item: Item}; |
364 }); | 375 }); |
OLD | NEW |