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

Side by Side Diff: ui/file_manager/file_manager/foreground/js/file_transfer_controller.js

Issue 571343002: Add notification before getMultiProfileShareEntries_. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
OLDNEW
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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Global (placed in the window object) variable name to hold internal 8 * Global (placed in the window object) variable name to hold internal
9 * file dragging information. Needed to show visual feedback while dragging 9 * file dragging information. Needed to show visual feedback while dragging
10 * since DataTransfer object is in protected state. Reachable from other 10 * since DataTransfer object is in protected state. Reachable from other
11 * file manager instances. 11 * file manager instances.
12 */ 12 */
13 var DRAG_AND_DROP_GLOBAL_DATA = '__drag_and_drop_global_data'; 13 var DRAG_AND_DROP_GLOBAL_DATA = '__drag_and_drop_global_data';
14 14
15 /** 15 /**
16 * @param {HTMLDocument} doc Owning document. 16 * @param {HTMLDocument} doc Owning document.
17 * @param {FileOperationManager} fileOperationManager File operation manager 17 * @param {FileOperationManager} fileOperationManager File operation manager
18 * instance. 18 * instance.
19 * @param {MetadataCache} metadataCache Metadata cache service. 19 * @param {MetadataCache} metadataCache Metadata cache service.
20 * @param {DirectoryModel} directoryModel Directory model instance. 20 * @param {DirectoryModel} directoryModel Directory model instance.
21 * @param {VolumeManagerWrapper} volumeManager Volume manager instance. 21 * @param {VolumeManagerWrapper} volumeManager Volume manager instance.
22 * @param {MultiProfileShareDialog} multiProfileShareDialog Share dialog to be 22 * @param {MultiProfileShareDialog} multiProfileShareDialog Share dialog to be
23 * used to share files from another profile. 23 * used to share files from another profile.
hirono 2014/09/16 08:12:56 Please update JSDoc.
iseki 2014/09/16 08:44:21 Done.
24 * @constructor 24 * @constructor
25 */ 25 */
26 function FileTransferController(doc, 26 function FileTransferController(doc,
27 fileOperationManager, 27 fileOperationManager,
28 metadataCache, 28 metadataCache,
29 directoryModel, 29 directoryModel,
30 volumeManager, 30 volumeManager,
31 multiProfileShareDialog) { 31 multiProfileShareDialog,
32 progressCenter) {
32 this.document_ = doc; 33 this.document_ = doc;
33 this.fileOperationManager_ = fileOperationManager; 34 this.fileOperationManager_ = fileOperationManager;
34 this.metadataCache_ = metadataCache; 35 this.metadataCache_ = metadataCache;
35 this.directoryModel_ = directoryModel; 36 this.directoryModel_ = directoryModel;
36 this.volumeManager_ = volumeManager; 37 this.volumeManager_ = volumeManager;
37 this.multiProfileShareDialog_ = multiProfileShareDialog; 38 this.multiProfileShareDialog_ = multiProfileShareDialog;
39 this.progressCenter_ = progressCenter;
38 40
39 this.directoryModel_.getFileList().addEventListener( 41 this.directoryModel_.getFileList().addEventListener(
40 'change', function(event) { 42 'change', function(event) {
41 if (this.directoryModel_.getFileListSelection(). 43 if (this.directoryModel_.getFileListSelection().
42 getIndexSelected(event.index)) { 44 getIndexSelected(event.index)) {
43 this.onSelectionChanged_(); 45 this.onSelectionChanged_();
44 } 46 }
45 }.bind(this)); 47 }.bind(this));
46 this.directoryModel_.getFileListSelection().addEventListener('change', 48 this.directoryModel_.getFileListSelection().addEventListener('change',
47 this.onSelectionChanged_.bind(this)); 49 this.onSelectionChanged_.bind(this));
48 50
49 /** 51 /**
52 * The array of pending task id.
53 * @type {Array.<string>}
54 */
55 this.pendingTaskId = [];
hirono 2014/09/16 08:12:56 nit: pendingTaskIDs ?
iseki 2014/09/16 08:44:21 Done.
56
57 /**
50 * Promise to be fulfilled with the thumbnail image of selected file in drag 58 * Promise to be fulfilled with the thumbnail image of selected file in drag
51 * operation. Used if only one element is selected. 59 * operation. Used if only one element is selected.
52 * @type {Promise} 60 * @type {Promise}
53 * @private 61 * @private
54 */ 62 */
55 this.preloadedThumbnailImagePromise_ = null; 63 this.preloadedThumbnailImagePromise_ = null;
56 64
57 /** 65 /**
58 * File objects for selected files. 66 * File objects for selected files.
59 * 67 *
60 * @type {Array.<File>} 68 * @type {Array.<File>}
61 * @private 69 * @private
62 */ 70 */
63 this.selectedFileObjects_ = []; 71 this.selectedFileObjects_ = [];
64 72
65 /** 73 /**
66 * Drag selector. 74 * Drag selector.
67 * @type {DragSelector} 75 * @type {DragSelector}
68 * @private 76 * @private
69 */ 77 */
70 this.dragSelector_ = new DragSelector(); 78 this.dragSelector_ = new DragSelector();
71 79
72 /** 80 /**
73 * Whether a user is touching the device or not. 81 * Whether a user is touching the device or not.
74 * @type {boolean} 82 * @type {boolean}
75 * @private 83 * @private
76 */ 84 */
77 this.touching_ = false; 85 this.touching_ = false;
86
87 /**
88 * Task id counter.
89 * @type {int}
hirono 2014/09/16 08:12:56 We don't use int. Instead, please use number.
iseki 2014/09/16 08:44:21 Done.
90 * @private
91 */
92 this.taskIdCounter_ = 0;
78 } 93 }
79 94
80 /** 95 /**
81 * Size of drag thumbnail for image files. 96 * Size of drag thumbnail for image files.
82 * 97 *
83 * @type {number} 98 * @type {number}
84 * @const 99 * @const
85 * @private 100 * @private
86 */ 101 */
87 FileTransferController.DRAG_THUMBNAIL_SIZE_ = 64; 102 FileTransferController.DRAG_THUMBNAIL_SIZE_ = 64;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // work fine. 341 // work fine.
327 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ? 342 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ?
328 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed'); 343 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed');
329 var toMove = util.isDropEffectAllowed(effectAllowed, 'move') && 344 var toMove = util.isDropEffectAllowed(effectAllowed, 'move') &&
330 (!util.isDropEffectAllowed(effectAllowed, 'copy') || 345 (!util.isDropEffectAllowed(effectAllowed, 'copy') ||
331 opt_effect === 'move'); 346 opt_effect === 'move');
332 var destinationEntry = 347 var destinationEntry =
333 opt_destinationEntry || this.currentDirectoryContentEntry; 348 opt_destinationEntry || this.currentDirectoryContentEntry;
334 var entries; 349 var entries;
335 var failureUrls; 350 var failureUrls;
351 var taskId = this.generateTaskId_();
336 352
337 util.URLsToEntries(sourceURLs). 353 util.URLsToEntries(sourceURLs).
338 then(function(result) { 354 then(function(result) {
355 this.pendingTaskId.push(taskId);
339 entries = result.entries; 356 entries = result.entries;
340 failureUrls = result.failureUrls; 357 failureUrls = result.failureUrls;
358 var item = new ProgressCenterItem();
359 item.id = taskId;
360 item.type = ProgressItemType.COPY;
361 item.message = strf('CHECK_FILES_ARE_SHARED');
362 this.progressCenter_.updateItem(item);
341 // Check if cross share is needed or not. 363 // Check if cross share is needed or not.
342 return this.getMultiProfileShareEntries_(entries); 364 return this.getMultiProfileShareEntries_(entries);
343 }.bind(this)). 365 }.bind(this)).
344 then(function(shareEntries) { 366 then(function(shareEntries) {
345 if (shareEntries.length === 0) 367 if (shareEntries.length === 0)
346 return; 368 return;
347 return this.multiProfileShareDialog_.show(shareEntries.length > 1). 369 return this.multiProfileShareDialog_.show(shareEntries.length > 1).
348 then(function(dialogResult) { 370 then(function(dialogResult) {
349 if (dialogResult === 'cancel') 371 if (dialogResult === 'cancel')
350 return Promise.reject('ABORT'); 372 return Promise.reject('ABORT');
(...skipping 11 matching lines...) Expand all
362 fulfill(); 384 fulfill();
363 }); 385 });
364 }).then(requestDriveShare.bind(null, index + 1)); 386 }).then(requestDriveShare.bind(null, index + 1));
365 }; 387 };
366 return requestDriveShare(0); 388 return requestDriveShare(0);
367 }); 389 });
368 }.bind(this)). 390 }.bind(this)).
369 then(function() { 391 then(function() {
370 // Start the pasting operation. 392 // Start the pasting operation.
371 this.fileOperationManager_.paste( 393 this.fileOperationManager_.paste(
372 entries, destinationEntry, toMove); 394 entries, destinationEntry, toMove, taskId);
395 this.pendingTaskId.splice(this.pendingTaskId.find(taskId), 1);
hirono 2014/09/16 08:12:56 Array does not have 'find' method.
iseki 2014/09/16 08:44:21 Done.
373 396
374 // Publish events for failureUrls. 397 // Publish events for failureUrls.
375 for (var i = 0; i < failureUrls.length; i++) { 398 for (var i = 0; i < failureUrls.length; i++) {
376 var fileName = 399 var fileName =
377 decodeURIComponent(failureUrls[i].replace(/^.+\//, '')); 400 decodeURIComponent(failureUrls[i].replace(/^.+\//, ''));
378 var event = new Event('source-not-found'); 401 var event = new Event('source-not-found');
379 event.fileName = fileName; 402 event.fileName = fileName;
380 event.progressType = 403 event.progressType =
381 toMove ? ProgressItemType.MOVE : ProgressItemType.COPY; 404 toMove ? ProgressItemType.MOVE : ProgressItemType.COPY;
382 this.dispatchEvent(event); 405 this.dispatchEvent(event);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 destinationLocationInfo.volumeInfo.fileSystem.root.toURL() && 1084 destinationLocationInfo.volumeInfo.fileSystem.root.toURL() &&
1062 !event.ctrlKey) { 1085 !event.ctrlKey) {
1063 return 'move'; 1086 return 'move';
1064 } 1087 }
1065 if (event.shiftKey) { 1088 if (event.shiftKey) {
1066 return 'move'; 1089 return 'move';
1067 } 1090 }
1068 } 1091 }
1069 return 'copy'; 1092 return 'copy';
1070 }, 1093 },
1094
1095 /**
1096 * Generates new task ID.
1097 *
1098 * @return {string} New task ID.
1099 * @private
1100 */
1101 generateTaskId_: function() {
1102 return 'file-operation-from-transfer-controller' + this.taskIdCounter_++;
1103 },
1071 }; 1104 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698