From cae35362d0eb16d27adeb8a07786b52152d68e55 Mon Sep 17 00:00:00 2001 From: mtomasz Date: Mon, 2 Nov 2015 19:06:44 -0800 Subject: Fix code style for pasting in Files app. TEST=All current tests pass. BUG=None Review URL: https://codereview.chromium.org/1398963002 Cr-Commit-Position: refs/heads/master@{#357520} --- .../foreground/js/file_transfer_controller.js | 64 ++++++++++++---------- 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'ui') 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 f47f6ad..eb9eda8 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 @@ -529,6 +529,7 @@ FileTransferController.prototype.paste = /** @type {DirectoryEntry} */ (this.directoryModel_.getCurrentDirEntry()); var entries = []; var failureUrls; + var shareEntries; var taskId = this.fileOperationManager_.generateTaskId(); FileTransferController.URLsToEntriesWithAccess(sourceURLs) @@ -575,43 +576,46 @@ FileTransferController.prototype.paste = }.bind(this)) .then( /** - * @param {!Array} shareEntries + * @param {!Array} inShareEntries * @this {FileTransferController} - * @return {!Promise>|undefined} + * @return {!Promise>} */ - function(shareEntries) { + function(inShareEntries) { + shareEntries = inShareEntries; if (shareEntries.length === 0) - return; + return Promise.resolve(null); return this.multiProfileShareDialog_. - showMultiProfileShareDialog(shareEntries.length > 1).then( - /** - * @param {string} dialogResult - * @return {!Promise|undefined} - */ - function(dialogResult) { - if (dialogResult === 'cancel') - return Promise.reject('ABORT'); - // Do cross share. - // TODO(hirono): Make the loop cancellable. - var requestDriveShare = function(index) { - if (index >= shareEntries.length) - return; - return new Promise(function(fulfill) { - chrome.fileManagerPrivate.requestDriveShare( - shareEntries[index], - dialogResult, - function() { - // TODO(hirono): Check chrome.runtime.lastError - // here. - fulfill(undefined); - }); - }).then(requestDriveShare.bind(null, index + 1)); - }; - return requestDriveShare(0); - }); + showMultiProfileShareDialog(shareEntries.length > 1); }.bind(this)) .then( /** + * @param {?string} dialogResult + * @return {!Promise|undefined} + */ + function(dialogResult) { + if (dialogResult === null) + return; // No dialog was shown, skip this step. + if (dialogResult === 'cancel') + return Promise.reject('ABORT'); + // Do cross share. + // TODO(hirono): Make the loop cancellable. + var requestDriveShare = function(index) { + if (index >= shareEntries.length) + return; + return new Promise(function(fulfill) { + chrome.fileManagerPrivate.requestDriveShare( + shareEntries[index], + assert(dialogResult), + function() { + // TODO(hirono): Check chrome.runtime.lastError here. + fulfill(); + }); + }).then(requestDriveShare.bind(null, index + 1)); + }; + return requestDriveShare(0); + }) + .then( + /** * @this {FileTransferController} */ function() { -- cgit v1.1