| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 data.total == this.data_.total && | 140 data.total == this.data_.total && |
| 141 data.url == this.data_.url) { | 141 data.url == this.data_.url) { |
| 142 // TODO(dbeam): remove this once data binding is fully in place. | 142 // TODO(dbeam): remove this once data binding is fully in place. |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 | 145 |
| 146 for (var key in data) { | 146 for (var key in data) { |
| 147 this.set('data_.' + key, data[key]); | 147 this.set('data_.' + key, data[key]); |
| 148 } | 148 } |
| 149 | 149 |
| 150 // TODO(dbeam): Move to a computeClass_() method + data binding. | |
| 151 this.$.content.classList.toggle('is-active', this.isActive_); | |
| 152 this.$.content.classList.toggle('dangerous', this.isDangerous_); | |
| 153 this.$.content.classList.toggle('show-progress', this.showProgress_); | |
| 154 | |
| 155 var desc = this.getDangerText_(data) || this.getStatusText_(data); | 150 var desc = this.getDangerText_(data) || this.getStatusText_(data); |
| 156 | 151 |
| 157 // Status goes in the "tag" (next to the file name) if there's no file. | 152 // Status goes in the "tag" (next to the file name) if there's no file. |
| 158 this.ensureTextIs_(this.$.description, this.isActive_ ? desc : ''); | 153 this.ensureTextIs_(this.$.description, this.isActive_ ? desc : ''); |
| 159 this.ensureTextIs_(this.$.tag, this.isActive_ ? '' : desc); | 154 this.ensureTextIs_(this.$.tag, this.isActive_ ? '' : desc); |
| 160 | 155 |
| 161 if (!this.isDangerous_) { | 156 if (!this.isDangerous_) { |
| 162 /** @const */ var controlledByExtension = data.by_ext_id && | 157 /** @const */ var controlledByExtension = data.by_ext_id && |
| 163 data.by_ext_name; | 158 data.by_ext_name; |
| 164 this.$['controlled-by'].hidden = !controlledByExtension; | 159 this.$['controlled-by'].hidden = !controlledByExtension; |
| 165 if (controlledByExtension) { | 160 if (controlledByExtension) { |
| 166 var link = this.$['controlled-by'].querySelector('a'); | 161 var link = this.$['controlled-by'].querySelector('a'); |
| 167 link.href = 'chrome://extensions#' + data.by_ext_id; | 162 link.href = 'chrome://extensions#' + data.by_ext_id; |
| 168 link.textContent = data.by_ext_name; | 163 link.textContent = data.by_ext_name; |
| 169 } | 164 } |
| 170 | 165 |
| 171 var icon = 'chrome://fileicon/' + encodeURIComponent(data.file_path); | 166 var icon = 'chrome://fileicon/' + encodeURIComponent(data.file_path); |
| 172 this.iconLoader_.loadScaledIcon(this.$['file-icon'], icon); | 167 this.iconLoader_.loadScaledIcon(this.$['file-icon'], icon); |
| 173 } | 168 } |
| 174 }, | 169 }, |
| 175 | 170 |
| 176 /** @private */ | 171 /** @private */ |
| 172 computeClass_: function() { |
| 173 var classes = []; |
| 174 |
| 175 if (this.isActive_) |
| 176 classes.push('is-active'); |
| 177 |
| 178 if (this.isDangerous_) |
| 179 classes.push('dangerous'); |
| 180 |
| 181 if (this.showProgress_) |
| 182 classes.push('show-progress'); |
| 183 |
| 184 return classes.join(' '); |
| 185 }, |
| 186 |
| 187 /** @private */ |
| 177 computeCompletelyOnDisk_: function() { | 188 computeCompletelyOnDisk_: function() { |
| 178 return this.data_.state == downloads.States.COMPLETE && | 189 return this.data_.state == downloads.States.COMPLETE && |
| 179 !this.data_.file_externally_removed; | 190 !this.data_.file_externally_removed; |
| 180 }, | 191 }, |
| 181 | 192 |
| 182 /** @private */ | 193 /** @private */ |
| 183 computeDate_: function() { | 194 computeDate_: function() { |
| 184 assert(!this.hideDate); | 195 assert(!this.hideDate); |
| 185 return assert(this.data_.since_string || this.data_.date_string); | 196 return assert(this.data_.since_string || this.data_.date_string); |
| 186 }, | 197 }, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 }, | 380 }, |
| 370 | 381 |
| 371 /** @private */ | 382 /** @private */ |
| 372 onShowClick_: function() { | 383 onShowClick_: function() { |
| 373 this.actionService_.show(this.data_.id); | 384 this.actionService_.show(this.data_.id); |
| 374 }, | 385 }, |
| 375 }); | 386 }); |
| 376 | 387 |
| 377 return {Item: Item}; | 388 return {Item: Item}; |
| 378 }); | 389 }); |
| OLD | NEW |