Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6882)

Unified Diff: chrome/browser/resources/shared/js/chromeos/butter_bar.js

Issue 10916149: (NOT FOR FINAL REVIEW)Refactor butter_bar.js for wallpaper manager and file manager to use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/shared/images/close_bar.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/shared/js/chromeos/butter_bar.js
diff --git a/chrome/browser/resources/file_manager/js/butter_bar.js b/chrome/browser/resources/shared/js/chromeos/butter_bar.js
similarity index 58%
rename from chrome/browser/resources/file_manager/js/butter_bar.js
rename to chrome/browser/resources/shared/js/chromeos/butter_bar.js
index dcbb37f3750e170e517e08e94364125f9bf86fb2..87ed9f526b258cec5688916198da86b855c9ab67 100644
--- a/chrome/browser/resources/file_manager/js/butter_bar.js
+++ b/chrome/browser/resources/shared/js/chromeos/butter_bar.js
@@ -10,23 +10,18 @@
var MINIMUM_BUTTER_DISPLAY_TIME_MS = 1300;
/**
- * Butter bar is shown on top of the file list and is used to show the copy
- * progress and other messages.
+ * Butter bar is shown on top of the document and is used to show the progress
+ * and other messages.
* @constructor
- * @param {HTMLElement} dialogDom FileManager top-level div.
- * @param {FileCopyManagerWrapper} copyManager The copy manager.
+ * @param {HTMLElement} dialogDom Document top-level div.
*/
-function ButterBar(dialogDom, copyManager) {
+function ButterBar(dialogDom) {
this.dialogDom_ = dialogDom;
this.butter_ = this.dialogDom_.querySelector('#butter-bar');
this.document_ = this.butter_.ownerDocument;
- this.copyManager_ = copyManager;
this.hideTimeout_ = null;
this.showTimeout_ = null;
this.lastShowTime_ = 0;
-
- this.copyManager_.addEventListener('copy-progress',
- this.onCopyProgress_.bind(this));
}
/**
@@ -45,7 +40,7 @@ ButterBar.prototype.isError_ = function() {
return this.butter_.classList.contains('error');
};
- /**
+/**
* Show butter bar.
* @param {string} message The message to be shown.
* @param {object} opt_options Options: 'actions', 'progress', 'timeout'.
@@ -181,100 +176,3 @@ ButterBar.prototype.clearHideTimeout_ = function() {
this.hideTimeout_ = null;
}
};
-
-/**
- * @private
- * @return {string?} The type of operation.
- */
-ButterBar.prototype.transferType_ = function() {
- var progress = this.progress_;
- if (!progress ||
- progress.pendingMoves === 0 && progress.pendingCopies === 0)
- return 'TRANSFER';
-
- if (progress.pendingMoves > 0) {
- if (progress.pendingCopies > 0)
- return 'TRANSFER';
- return 'MOVE';
- }
-
- return 'COPY';
-};
-
-/**
- * Set up butter bar for showing copy progress.
- * @private
- */
-ButterBar.prototype.showProgress_ = function() {
- this.progress_ = this.copyManager_.getStatus();
- var options = {progress: this.progress_.percentage, actions: {}, timeout: 0};
-
- var type = this.transferType_();
- var progressString = (this.progress_.pendingItems === 1) ?
- strf(type + '_FILE_NAME', this.progress_.filename) :
- strf(type + '_ITEMS_REMAINING', this.progress_.pendingItems);
-
- if (this.isVisible_()) {
- this.update_(progressString, options);
- } else {
- options.actions[str('CANCEL_LABEL')] =
- this.copyManager_.requestCancel.bind(this.copyManager_);
- this.show(progressString, options);
- }
-};
-
-/**
- * 'copy-progress' event handler. Show progress or an appropriate message.
- * @private
- * @param {cr.Event} event A 'copy-progress' event from FileCopyManager.
- */
-ButterBar.prototype.onCopyProgress_ = function(event) {
- if (event.reason != 'PROGRESS')
- this.clearShowTimeout_();
-
- switch (event.reason) {
- case 'BEGIN':
- this.showTimeout_ = setTimeout(function() {
- this.showTimeout_ = null;
- this.showProgress_();
- }.bind(this), 500);
- break;
-
- case 'PROGRESS':
- this.showProgress_();
- break;
-
- case 'SUCCESS':
- this.hide_();
- break;
-
- case 'CANCELLED':
- this.show(str(this.transferType_() + '_CANCELLED'), {timeout: 1000});
- break;
-
- case 'ERROR':
- if (event.error.reason === 'TARGET_EXISTS') {
- var name = event.error.data.name;
- if (event.error.data.isDirectory)
- name += '/';
- this.showError_(strf(this.transferType_() +
- '_TARGET_EXISTS_ERROR', name));
- } else if (event.error.reason === 'FILESYSTEM_ERROR') {
- if (event.error.data.toGDrive &&
- event.error.data.code === FileError.QUOTA_EXCEEDED_ERR) {
- // The alert will be shown in FileManager.onCopyProgress_.
- this.hide_();
- } else {
- this.showError_(strf(this.transferType_() + '_FILESYSTEM_ERROR',
- util.getFileErrorString(event.error.data.code)));
- }
- } else {
- this.showError_(strf(this.transferType_() + '_UNEXPECTED_ERROR',
- event.error));
- }
- break;
-
- default:
- console.log('Unknown "copy-progress" event reason: ' + event.reason);
- }
-};
« no previous file with comments | « chrome/browser/resources/shared/images/close_bar.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698