| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 5 /** |
| 6 * The minimum about of time to display the butter bar for, in ms. | 6 * The minimum about of time to display the butter bar for, in ms. |
| 7 * Justification is 1000ms for minimum display time plus 300ms for transition | 7 * Justification is 1000ms for minimum display time plus 300ms for transition |
| 8 * duration. | 8 * duration. |
| 9 */ | 9 */ |
| 10 var MINIMUM_BUTTER_DISPLAY_TIME_MS = 1300; | 10 var MINIMUM_BUTTER_DISPLAY_TIME_MS = 1300; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 this.show(loadTimeData.getString('downloadCanceled'), {timeout: 1000}); | 251 this.show(loadTimeData.getString('downloadCanceled'), {timeout: 1000}); |
| 252 this.xhr_ = null; | 252 this.xhr_ = null; |
| 253 }; | 253 }; |
| 254 | 254 |
| 255 /** | 255 /** |
| 256 * Hides butter bar when download complete. | 256 * Hides butter bar when download complete. |
| 257 * @private | 257 * @private |
| 258 * @param {Event} e A load ProgressEvent from XMLHttpRequest. | 258 * @param {Event} e A load ProgressEvent from XMLHttpRequest. |
| 259 */ | 259 */ |
| 260 ButterBar.prototype.onDownloadComplete_ = function(e) { | 260 ButterBar.prototype.onDownloadComplete_ = function(e) { |
| 261 this.hide_(); | |
| 262 this.xhr_ = null; | 261 this.xhr_ = null; |
| 263 }; | 262 }; |
| 264 | 263 |
| 265 /** | 264 /** |
| 266 * Shows error message when receiving an error event. | 265 * Shows error message when receiving an error event. |
| 267 * @private | 266 * @private |
| 268 * @param {Event} e An error ProgressEvent from XMLHttpRequest. | 267 * @param {Event} e An error ProgressEvent from XMLHttpRequest. |
| 269 */ | 268 */ |
| 270 ButterBar.prototype.onDownloadError_ = function(e) { | 269 ButterBar.prototype.onDownloadError_ = function(e) { |
| 271 this.showError_(loadTimeData.getString('downloadFailed')); | 270 this.showError_(loadTimeData.getString('downloadFailed')); |
| 272 this.xhr_ = null; | 271 this.xhr_ = null; |
| 273 }; | 272 }; |
| 274 | 273 |
| 275 /** | 274 /** |
| 276 * Calculates downloading percentage and shows downloading progress. | 275 * Calculates downloading percentage and shows downloading progress. |
| 277 * @private | 276 * @private |
| 278 * @param {Event} e A progress ProgressEvent from XMLHttpRequest. | 277 * @param {Event} e A progress ProgressEvent from XMLHttpRequest. |
| 279 */ | 278 */ |
| 280 ButterBar.prototype.onDownloadProgress_ = function(e) { | 279 ButterBar.prototype.onDownloadProgress_ = function(e) { |
| 281 if (e.lengthComputable) { | 280 if (e.lengthComputable) { |
| 282 this.percentComplete_ = e.loaded / e.total; | 281 this.percentComplete_ = e.loaded / e.total; |
| 283 } | 282 } |
| 284 this.showProgress_(); | 283 this.showProgress_(); |
| 285 }; | 284 }; |
| OLD | NEW |