| 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 properties: { | 9 properties: { |
| 10 data: { | 10 data: { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 if (this.showProgress_) | 100 if (this.showProgress_) |
| 101 classes.push('show-progress'); | 101 classes.push('show-progress'); |
| 102 | 102 |
| 103 return classes.join(' '); | 103 return classes.join(' '); |
| 104 }, | 104 }, |
| 105 | 105 |
| 106 /** @private */ | 106 /** @private */ |
| 107 computeCompletelyOnDisk_: function() { | 107 computeCompletelyOnDisk_: function() { |
| 108 return this.data.state == downloads.States.COMPLETE && | 108 return this.data.state == downloads.States.COMPLETE && |
| 109 !this.data.file_externally_removed; | 109 !this.data.file_externally_removed; |
| 110 }, | 110 }, |
| 111 | 111 |
| 112 /** @private */ | 112 /** @private */ |
| 113 computeControlledBy_: function() { | 113 computeControlledBy_: function() { |
| 114 if (!this.data.by_ext_id || !this.data.by_ext_name) | 114 if (!this.data.by_ext_id || !this.data.by_ext_name) |
| 115 return ''; | 115 return ''; |
| 116 | 116 |
| 117 var url = 'chrome://extensions#' + this.data.by_ext_id; | 117 var url = 'chrome://extensions#' + this.data.by_ext_id; |
| 118 var name = this.data.by_ext_name; | 118 var name = this.data.by_ext_name; |
| 119 return loadTimeData.getStringF('controlledByUrl', url, HTMLEscape(name)); | 119 return loadTimeData.getStringF('controlledByUrl', url, HTMLEscape(name)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 134 | 134 |
| 135 /** @private */ | 135 /** @private */ |
| 136 computeDescription_: function() { | 136 computeDescription_: function() { |
| 137 var data = this.data; | 137 var data = this.data; |
| 138 | 138 |
| 139 switch (data.state) { | 139 switch (data.state) { |
| 140 case downloads.States.DANGEROUS: | 140 case downloads.States.DANGEROUS: |
| 141 var fileName = data.file_name; | 141 var fileName = data.file_name; |
| 142 switch (data.danger_type) { | 142 switch (data.danger_type) { |
| 143 case downloads.DangerType.DANGEROUS_FILE: | 143 case downloads.DangerType.DANGEROUS_FILE: |
| 144 return loadTimeData.getString('dangerFileDesc'); | 144 return loadTimeData.getString('dangerFileDesc'); |
| 145 | 145 |
| 146 case downloads.DangerType.DANGEROUS_URL: | 146 case downloads.DangerType.DANGEROUS_URL: |
| 147 case downloads.DangerType.DANGEROUS_CONTENT: | 147 case downloads.DangerType.DANGEROUS_CONTENT: |
| 148 case downloads.DangerType.DANGEROUS_HOST: | 148 case downloads.DangerType.DANGEROUS_HOST: |
| 149 return loadTimeData.getString('dangerDownloadDesc'); | 149 return loadTimeData.getString('dangerDownloadDesc'); |
| 150 | 150 |
| 151 case downloads.DangerType.UNCOMMON_CONTENT: | 151 case downloads.DangerType.UNCOMMON_CONTENT: |
| 152 return loadTimeData.getString('dangerUncommonDesc'); | 152 return loadTimeData.getString('dangerUncommonDesc'); |
| 153 | 153 |
| 154 case downloads.DangerType.POTENTIALLY_UNWANTED: | 154 case downloads.DangerType.POTENTIALLY_UNWANTED: |
| 155 return loadTimeData.getString('dangerSettingsDesc'); | 155 return loadTimeData.getString('dangerSettingsDesc'); |
| 156 } | 156 } |
| 157 break; | 157 break; |
| 158 | 158 |
| 159 case downloads.States.IN_PROGRESS: | 159 case downloads.States.IN_PROGRESS: |
| 160 case downloads.States.PAUSED: // Fallthrough. | 160 case downloads.States.PAUSED: // Fallthrough. |
| 161 return data.progress_status_text; | 161 return data.progress_status_text; |
| 162 } | 162 } |
| 163 | 163 |
| 164 return ''; | 164 return ''; |
| 165 }, | 165 }, |
| 166 | 166 |
| 167 /** @private */ | 167 /** @private */ |
| 168 computeIsActive_: function() { | 168 computeIsActive_: function() { |
| 169 return this.data.state != downloads.States.CANCELLED && | 169 return this.data.state != downloads.States.CANCELLED && |
| 170 this.data.state != downloads.States.INTERRUPTED && | 170 this.data.state != downloads.States.INTERRUPTED && |
| 171 !this.data.file_externally_removed; | 171 !this.data.file_externally_removed; |
| 172 }, | 172 }, |
| 173 | 173 |
| 174 /** @private */ | 174 /** @private */ |
| 175 computeIsDangerous_: function() { | 175 computeIsDangerous_: function() { |
| 176 return this.data.state == downloads.States.DANGEROUS; | 176 return this.data.state == downloads.States.DANGEROUS; |
| 177 }, | 177 }, |
| 178 | 178 |
| 179 /** @private */ | 179 /** @private */ |
| 180 computeIsInProgress_: function() { | 180 computeIsInProgress_: function() { |
| 181 return this.data.state == downloads.States.IN_PROGRESS; | 181 return this.data.state == downloads.States.IN_PROGRESS; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 202 /** @private */ | 202 /** @private */ |
| 203 computeRemoveStyle_: function() { | 203 computeRemoveStyle_: function() { |
| 204 var canDelete = loadTimeData.getBoolean('allowDeletingHistory'); | 204 var canDelete = loadTimeData.getBoolean('allowDeletingHistory'); |
| 205 var hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete; | 205 var hideRemove = this.isDangerous_ || this.showCancel_ || !canDelete; |
| 206 return hideRemove ? 'visibility: hidden' : ''; | 206 return hideRemove ? 'visibility: hidden' : ''; |
| 207 }, | 207 }, |
| 208 | 208 |
| 209 /** @private */ | 209 /** @private */ |
| 210 computeShowCancel_: function() { | 210 computeShowCancel_: function() { |
| 211 return this.data.state == downloads.States.IN_PROGRESS || | 211 return this.data.state == downloads.States.IN_PROGRESS || |
| 212 this.data.state == downloads.States.PAUSED; | 212 this.data.state == downloads.States.PAUSED; |
| 213 }, | 213 }, |
| 214 | 214 |
| 215 /** @private */ | 215 /** @private */ |
| 216 computeShowProgress_: function() { | 216 computeShowProgress_: function() { |
| 217 return this.showCancel_ && this.data.percent >= -1; | 217 return this.showCancel_ && this.data.percent >= -1; |
| 218 }, | 218 }, |
| 219 | 219 |
| 220 /** @private */ | 220 /** @private */ |
| 221 computeTag_: function() { | 221 computeTag_: function() { |
| 222 switch (this.data.state) { | 222 switch (this.data.state) { |
| 223 case downloads.States.CANCELLED: | 223 case downloads.States.CANCELLED: |
| 224 return loadTimeData.getString('statusCancelled'); | 224 return loadTimeData.getString('statusCancelled'); |
| 225 | 225 |
| 226 case downloads.States.INTERRUPTED: | 226 case downloads.States.INTERRUPTED: |
| 227 return this.data.last_reason_text; | 227 return this.data.last_reason_text; |
| 228 | 228 |
| 229 case downloads.States.COMPLETE: | 229 case downloads.States.COMPLETE: |
| 230 return this.data.file_externally_removed ? | 230 return this.data.file_externally_removed ? |
| 231 loadTimeData.getString('statusRemoved') : ''; | 231 loadTimeData.getString('statusRemoved') : |
| 232 ''; |
| 232 } | 233 } |
| 233 | 234 |
| 234 return ''; | 235 return ''; |
| 235 }, | 236 }, |
| 236 | 237 |
| 237 /** @private */ | 238 /** @private */ |
| 238 isIndeterminate_: function() { | 239 isIndeterminate_: function() { |
| 239 return this.data.percent == -1; | 240 return this.data.percent == -1; |
| 240 }, | 241 }, |
| 241 | 242 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 }, | 312 }, |
| 312 | 313 |
| 313 /** @private */ | 314 /** @private */ |
| 314 onShowTap_: function() { | 315 onShowTap_: function() { |
| 315 downloads.ActionService.getInstance().show(this.data.id); | 316 downloads.ActionService.getInstance().show(this.data.id); |
| 316 }, | 317 }, |
| 317 }); | 318 }); |
| 318 | 319 |
| 319 return {Item: Item}; | 320 return {Item: Item}; |
| 320 }); | 321 }); |
| OLD | NEW |