| 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 /** | 6 /** |
| 7 * Creates and updates the DOM representation for a download. | 7 * Creates and updates the DOM representation for a download. |
| 8 * @param {!downloads.ThrottledIconLoader} iconLoader | 8 * @param {!downloads.ThrottledIconLoader} iconLoader |
| 9 * @constructor | 9 * @constructor |
| 10 */ | 10 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 this.save_ = this.queryRequired_('.save'); | 21 this.save_ = this.queryRequired_('.save'); |
| 22 this.backgroundProgress_ = this.queryRequired_('.progress.background'); | 22 this.backgroundProgress_ = this.queryRequired_('.progress.background'); |
| 23 this.foregroundProgress_ = /** @type !HTMLCanvasElement */( | 23 this.foregroundProgress_ = /** @type !HTMLCanvasElement */( |
| 24 this.queryRequired_('canvas.progress')); | 24 this.queryRequired_('canvas.progress')); |
| 25 this.safeImg_ = /** @type !HTMLImageElement */( | 25 this.safeImg_ = /** @type !HTMLImageElement */( |
| 26 this.queryRequired_('.safe img')); | 26 this.queryRequired_('.safe img')); |
| 27 this.fileName_ = this.queryRequired_('span.name'); | 27 this.fileName_ = this.queryRequired_('span.name'); |
| 28 this.fileLink_ = this.queryRequired_('[is="action-link"].name'); | 28 this.fileLink_ = this.queryRequired_('[is="action-link"].name'); |
| 29 this.status_ = this.queryRequired_('.status'); | 29 this.status_ = this.queryRequired_('.status'); |
| 30 this.srcUrl_ = this.queryRequired_('.src-url'); | 30 this.srcUrl_ = this.queryRequired_('.src-url'); |
| 31 this.show_ = this.queryRequired_('.show'); | 31 this.showInFolder_ = this.queryRequired_('.show-in-folder'); |
| 32 this.retry_ = this.queryRequired_('.retry'); | 32 this.retry_ = this.queryRequired_('.retry'); |
| 33 this.pause_ = this.queryRequired_('.pause'); | 33 this.pause_ = this.queryRequired_('.pause'); |
| 34 this.resume_ = this.queryRequired_('.resume'); | 34 this.resume_ = this.queryRequired_('.resume'); |
| 35 this.safeRemove_ = this.queryRequired_('.safe .remove'); | 35 this.safeRemove_ = this.queryRequired_('.safe .remove'); |
| 36 this.cancel_ = this.queryRequired_('.cancel'); | 36 this.cancel_ = this.queryRequired_('.cancel'); |
| 37 this.controlledBy_ = this.queryRequired_('.controlled-by'); | 37 this.controlledBy_ = this.queryRequired_('.controlled-by'); |
| 38 | 38 |
| 39 this.dangerous_ = this.queryRequired_('.dangerous'); | 39 this.dangerous_ = this.queryRequired_('.dangerous'); |
| 40 this.dangerImg_ = /** @type {!HTMLImageElement} */( | 40 this.dangerImg_ = /** @type {!HTMLImageElement} */( |
| 41 this.queryRequired_('.dangerous img')); | 41 this.queryRequired_('.dangerous img')); |
| 42 this.description_ = this.queryRequired_('.description'); | 42 this.description_ = this.queryRequired_('.description'); |
| 43 this.malwareControls_ = this.queryRequired_('.dangerous .controls'); | 43 this.malwareControls_ = this.queryRequired_('.dangerous .controls'); |
| 44 this.restore_ = this.queryRequired_('.restore'); | 44 this.restore_ = this.queryRequired_('.restore'); |
| 45 this.dangerRemove_ = this.queryRequired_('.dangerous .remove'); | 45 this.dangerRemove_ = this.queryRequired_('.dangerous .remove'); |
| 46 this.save_ = this.queryRequired_('.save'); | 46 this.save_ = this.queryRequired_('.save'); |
| 47 this.discard_ = this.queryRequired_('.discard'); | 47 this.discard_ = this.queryRequired_('.discard'); |
| 48 | 48 |
| 49 // Event handlers (bound once on creation). | 49 // Event handlers (bound once on creation). |
| 50 this.safe_.ondragstart = this.onSafeDragstart_.bind(this); | 50 this.safe_.ondragstart = this.onSafeDragstart_.bind(this); |
| 51 this.fileLink_.onclick = this.onFileLinkClick_.bind(this); | 51 this.fileLink_.onclick = this.onFileLinkClick_.bind(this); |
| 52 this.show_.onclick = this.onShowClick_.bind(this); | 52 this.showInFolder_.onclick = this.onShowInFolderClick_.bind(this); |
| 53 this.pause_.onclick = this.onPauseClick_.bind(this); | 53 this.pause_.onclick = this.onPauseClick_.bind(this); |
| 54 this.resume_.onclick = this.onResumeClick_.bind(this); | 54 this.resume_.onclick = this.onResumeClick_.bind(this); |
| 55 this.safeRemove_.onclick = this.onSafeRemoveClick_.bind(this); | 55 this.safeRemove_.onclick = this.onSafeRemoveClick_.bind(this); |
| 56 this.cancel_.onclick = this.onCancelClick_.bind(this); | 56 this.cancel_.onclick = this.onCancelClick_.bind(this); |
| 57 this.restore_.onclick = this.onRestoreClick_.bind(this); | 57 this.restore_.onclick = this.onRestoreClick_.bind(this); |
| 58 this.save_.onclick = this.onSaveClick_.bind(this); | 58 this.save_.onclick = this.onSaveClick_.bind(this); |
| 59 this.dangerRemove_.onclick = this.onDangerRemoveClick_.bind(this); | 59 this.dangerRemove_.onclick = this.onDangerRemoveClick_.bind(this); |
| 60 this.discard_.onclick = this.onDiscardClick_.bind(this); | 60 this.discard_.onclick = this.onDiscardClick_.bind(this); |
| 61 } | 61 } |
| 62 | 62 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 this.fileLink_.href = data.url; | 169 this.fileLink_.href = data.url; |
| 170 this.ensureTextIs_(this.fileLink_, data.file_name); | 170 this.ensureTextIs_(this.fileLink_, data.file_name); |
| 171 this.fileLink_.hidden = !completelyOnDisk; | 171 this.fileLink_.hidden = !completelyOnDisk; |
| 172 | 172 |
| 173 /** @const */ var isInterrupted = | 173 /** @const */ var isInterrupted = |
| 174 data.state == downloads.States.INTERRUPTED; | 174 data.state == downloads.States.INTERRUPTED; |
| 175 this.fileName_.classList.toggle('interrupted', isInterrupted); | 175 this.fileName_.classList.toggle('interrupted', isInterrupted); |
| 176 this.ensureTextIs_(this.fileName_, data.file_name); | 176 this.ensureTextIs_(this.fileName_, data.file_name); |
| 177 this.fileName_.hidden = completelyOnDisk; | 177 this.fileName_.hidden = completelyOnDisk; |
| 178 | 178 |
| 179 this.show_.hidden = !completelyOnDisk; | 179 this.showInFolder_.hidden = !completelyOnDisk; |
| 180 | 180 |
| 181 this.retry_.href = data.url; | 181 this.retry_.href = data.url; |
| 182 this.retry_.hidden = !data.retry; | 182 this.retry_.hidden = !data.retry; |
| 183 | 183 |
| 184 this.pause_.hidden = !isInProgress; | 184 this.pause_.hidden = !isInProgress; |
| 185 | 185 |
| 186 this.resume_.hidden = !data.resume; | 186 this.resume_.hidden = !data.resume; |
| 187 | 187 |
| 188 /** @const */ var isPaused = data.state == downloads.States.PAUSED; | 188 /** @const */ var isPaused = data.state == downloads.States.PAUSED; |
| 189 /** @const */ var showCancel = isPaused || isInProgress; | 189 /** @const */ var showCancel = isPaused || isInProgress; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 /** | 339 /** |
| 340 * @param {Event} e | 340 * @param {Event} e |
| 341 * @private | 341 * @private |
| 342 */ | 342 */ |
| 343 onFileLinkClick_: function(e) { | 343 onFileLinkClick_: function(e) { |
| 344 e.preventDefault(); | 344 e.preventDefault(); |
| 345 chrome.send('openFile', [this.id_]); | 345 chrome.send('openFile', [this.id_]); |
| 346 }, | 346 }, |
| 347 | 347 |
| 348 /** @private */ | 348 /** @private */ |
| 349 onShowClick_: function() { | 349 onShowInFolderClick_: function() { |
| 350 chrome.send('show', [this.id_]); | 350 chrome.send('showInFolder', [this.id_]); |
| 351 }, | 351 }, |
| 352 | 352 |
| 353 /** @private */ | 353 /** @private */ |
| 354 onPauseClick_: function() { | 354 onPauseClick_: function() { |
| 355 chrome.send('pause', [this.id_]); | 355 chrome.send('pause', [this.id_]); |
| 356 }, | 356 }, |
| 357 | 357 |
| 358 /** @private */ | 358 /** @private */ |
| 359 onResumeClick_: function() { | 359 onResumeClick_: function() { |
| 360 chrome.send('resume', [this.id_]); | 360 chrome.send('resume', [this.id_]); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 386 }, | 386 }, |
| 387 | 387 |
| 388 /** @private */ | 388 /** @private */ |
| 389 onDiscardClick_: function() { | 389 onDiscardClick_: function() { |
| 390 chrome.send('discardDangerous', [this.id_]); | 390 chrome.send('discardDangerous', [this.id_]); |
| 391 }, | 391 }, |
| 392 }; | 392 }; |
| 393 | 393 |
| 394 return {ItemView: ItemView}; | 394 return {ItemView: ItemView}; |
| 395 }); | 395 }); |
| OLD | NEW |