Chromium Code Reviews| Index: ui/file_manager/file_manager/foreground/js/file_transfer_controller.js |
| diff --git a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js |
| index 13edd5f6f45ab2c948d5411f1f7fdc101883b1e1..f2c18a2329e6f6fc2db16433417b49b00597d58a 100644 |
| --- a/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js |
| +++ b/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js |
| @@ -21,6 +21,7 @@ var DRAG_AND_DROP_GLOBAL_DATA = '__drag_and_drop_global_data'; |
| * @param {VolumeManagerWrapper} volumeManager Volume manager instance. |
| * @param {MultiProfileShareDialog} multiProfileShareDialog Share dialog to be |
| * used to share files from another profile. |
| + * @param {ProgressCenter} progressCenter To notify starting copy operation. |
| * @constructor |
| */ |
| function FileTransferController(doc, |
| @@ -28,13 +29,15 @@ function FileTransferController(doc, |
| metadataCache, |
| directoryModel, |
| volumeManager, |
| - multiProfileShareDialog) { |
| + multiProfileShareDialog, |
| + progressCenter) { |
| this.document_ = doc; |
| this.fileOperationManager_ = fileOperationManager; |
| this.metadataCache_ = metadataCache; |
| this.directoryModel_ = directoryModel; |
| this.volumeManager_ = volumeManager; |
| this.multiProfileShareDialog_ = multiProfileShareDialog; |
| + this.progressCenter_ = progressCenter; |
| this.directoryModel_.getFileList().addEventListener( |
| 'change', function(event) { |
| @@ -47,6 +50,12 @@ function FileTransferController(doc, |
| this.onSelectionChanged_.bind(this)); |
| /** |
| + * The array of pending task id. |
|
hirono
2014/09/17 03:33:20
id -> ID?
http://eow.alc.co.jp/search?q=id
iseki
2014/09/17 04:08:48
Done.
|
| + * @type {Array.<string>} |
| + */ |
| + this.pendingTaskIds = []; |
| + |
| + /** |
| * Promise to be fulfilled with the thumbnail image of selected file in drag |
| * operation. Used if only one element is selected. |
| * @type {Promise} |
| @@ -75,6 +84,13 @@ function FileTransferController(doc, |
| * @private |
| */ |
| this.touching_ = false; |
| + |
| + /** |
| + * Task id counter. |
|
hirono
2014/09/17 03:33:20
id -> ID?
iseki
2014/09/17 04:08:47
Done.
|
| + * @type {number} |
| + * @private |
| + */ |
| + this.taskIdCounter_ = 0; |
| } |
| /** |
| @@ -333,11 +349,18 @@ FileTransferController.prototype = { |
| opt_destinationEntry || this.currentDirectoryContentEntry; |
| var entries; |
| var failureUrls; |
| + var taskId = this.generateTaskId_(); |
| util.URLsToEntries(sourceURLs). |
| then(function(result) { |
| + this.pendingTaskIds.push(taskId); |
| entries = result.entries; |
| failureUrls = result.failureUrls; |
| + var item = new ProgressCenterItem(); |
| + item.id = taskId; |
| + item.type = ProgressItemType.COPY; |
| + item.message = strf('COPY_FILE_NAME', result.entries[0].name || ''); |
|
hirono
2014/09/17 03:33:20
Please use IDS_FILE_BROWSER_COPY_ITEMS_REMAINING f
iseki
2014/09/17 04:08:47
Done.
|
| + this.progressCenter_.updateItem(item); |
| // Check if cross share is needed or not. |
| return this.getMultiProfileShareEntries_(entries); |
| }.bind(this)). |
| @@ -369,7 +392,8 @@ FileTransferController.prototype = { |
| then(function() { |
| // Start the pasting operation. |
| this.fileOperationManager_.paste( |
| - entries, destinationEntry, toMove); |
| + entries, destinationEntry, toMove, taskId); |
| + this.pendingTaskIds.splice(this.pendingTaskIds.indexOf(taskId), 1); |
| // Publish events for failureUrls. |
| for (var i = 0; i < failureUrls.length; i++) { |
| @@ -1068,4 +1092,14 @@ FileTransferController.prototype = { |
| } |
| return 'copy'; |
| }, |
| + |
| + /** |
| + * Generates new task ID. |
| + * |
| + * @return {string} New task ID. |
| + * @private |
| + */ |
| + generateTaskId_: function() { |
| + return 'paste-from-transfer-controller' + this.taskIdCounter_++; |
|
hirono
2014/09/17 03:33:20
If the app opens multiple windows, each window gen
iseki
2014/09/17 04:08:48
Done.
|
| + }, |
| }; |