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

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

Issue 571453002: Correct indentation, JSDoc, etc... to comply with closure linter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made it more strict. 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
(...skipping 19 matching lines...) Expand all
30 volumeManager, 30 volumeManager,
31 multiProfileShareDialog) { 31 multiProfileShareDialog) {
32 this.document_ = doc; 32 this.document_ = doc;
33 this.fileOperationManager_ = fileOperationManager; 33 this.fileOperationManager_ = fileOperationManager;
34 this.metadataCache_ = metadataCache; 34 this.metadataCache_ = metadataCache;
35 this.directoryModel_ = directoryModel; 35 this.directoryModel_ = directoryModel;
36 this.volumeManager_ = volumeManager; 36 this.volumeManager_ = volumeManager;
37 this.multiProfileShareDialog_ = multiProfileShareDialog; 37 this.multiProfileShareDialog_ = multiProfileShareDialog;
38 38
39 this.directoryModel_.getFileList().addEventListener( 39 this.directoryModel_.getFileList().addEventListener(
40 'change', function(event) { 40 'change', function(event) {
yoshiki 2014/09/16 00:49:08 nit: new line for function?
fukino 2014/09/17 05:17:26 Done.
41 if (this.directoryModel_.getFileListSelection(). 41 if (this.directoryModel_.getFileListSelection().
42 getIndexSelected(event.index)) { 42 getIndexSelected(event.index)) {
43 this.onSelectionChanged_(); 43 this.onSelectionChanged_();
44 } 44 }
45 }.bind(this)); 45 }.bind(this));
46 this.directoryModel_.getFileListSelection().addEventListener('change', 46 this.directoryModel_.getFileListSelection().addEventListener('change',
47 this.onSelectionChanged_.bind(this)); 47 this.onSelectionChanged_.bind(this));
48 48
49 /** 49 /**
50 * Promise to be fulfilled with the thumbnail image of selected file in drag 50 * Promise to be fulfilled with the thumbnail image of selected file in drag
51 * operation. Used if only one element is selected. 51 * operation. Used if only one element is selected.
52 * @type {Promise} 52 * @type {Promise}
53 * @private 53 * @private
54 */ 54 */
55 this.preloadedThumbnailImagePromise_ = null; 55 this.preloadedThumbnailImagePromise_ = null;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return Promise.all(promises).then(concatArrays); 259 return Promise.all(promises).then(concatArrays);
260 }; 260 };
261 261
262 // Check all file entries and keeps only those need sharing operation. 262 // Check all file entries and keeps only those need sharing operation.
263 var processFileEntries = function(entries) { 263 var processFileEntries = function(entries) {
264 return new Promise(function(callback) { 264 return new Promise(function(callback) {
265 // TODO(mtomasz): Move conversion from entry to url to custom bindings. 265 // TODO(mtomasz): Move conversion from entry to url to custom bindings.
266 // crbug.com/345527. 266 // crbug.com/345527.
267 var urls = util.entriesToURLs(entries); 267 var urls = util.entriesToURLs(entries);
268 chrome.fileManagerPrivate.getEntryProperties(urls, callback); 268 chrome.fileManagerPrivate.getEntryProperties(urls, callback);
269 }). 269 }).then(function(metadatas) {
270 then(function(metadatas) {
271 return entries.filter(function(entry, i) { 270 return entries.filter(function(entry, i) {
272 var metadata = metadatas[i]; 271 var metadata = metadatas[i];
273 return metadata && metadata.isHosted && !metadata.sharedWithMe; 272 return metadata && metadata.isHosted && !metadata.sharedWithMe;
274 }); 273 });
275 }); 274 });
276 }; 275 };
277 276
278 // Check child entries. 277 // Check child entries.
279 var processDirectoryEntry = function(entry) { 278 var processDirectoryEntry = function(entry) {
280 return readEntries(entry.createReader()); 279 return readEntries(entry.createReader());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ? 326 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ?
328 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed'); 327 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed');
329 var toMove = util.isDropEffectAllowed(effectAllowed, 'move') && 328 var toMove = util.isDropEffectAllowed(effectAllowed, 'move') &&
330 (!util.isDropEffectAllowed(effectAllowed, 'copy') || 329 (!util.isDropEffectAllowed(effectAllowed, 'copy') ||
331 opt_effect === 'move'); 330 opt_effect === 'move');
332 var destinationEntry = 331 var destinationEntry =
333 opt_destinationEntry || this.currentDirectoryContentEntry; 332 opt_destinationEntry || this.currentDirectoryContentEntry;
334 var entries; 333 var entries;
335 var failureUrls; 334 var failureUrls;
336 335
337 util.URLsToEntries(sourceURLs). 336 util.URLsToEntries(sourceURLs).then(function(result) {
338 then(function(result) {
339 entries = result.entries; 337 entries = result.entries;
340 failureUrls = result.failureUrls; 338 failureUrls = result.failureUrls;
341 // Check if cross share is needed or not. 339 // Check if cross share is needed or not.
342 return this.getMultiProfileShareEntries_(entries); 340 return this.getMultiProfileShareEntries_(entries);
343 }.bind(this)). 341 }.bind(this)).then(function(shareEntries) {
344 then(function(shareEntries) {
345 if (shareEntries.length === 0) 342 if (shareEntries.length === 0)
346 return; 343 return;
347 return this.multiProfileShareDialog_.show(shareEntries.length > 1). 344 return this.multiProfileShareDialog_.show(shareEntries.length > 1).
348 then(function(dialogResult) { 345 then(function(dialogResult) {
349 if (dialogResult === 'cancel') 346 if (dialogResult === 'cancel')
350 return Promise.reject('ABORT'); 347 return Promise.reject('ABORT');
351 // Do cross share. 348 // Do cross share.
352 // TODO(hirono): Make the loop cancellable. 349 // TODO(hirono): Make the loop cancellable.
353 var requestDriveShare = function(index) { 350 var requestDriveShare = function(index) {
354 if (index >= shareEntries.length) 351 if (index >= shareEntries.length)
355 return; 352 return;
356 return new Promise(function(fulfill) { 353 return new Promise(function(fulfill) {
357 chrome.fileManagerPrivate.requestDriveShare( 354 chrome.fileManagerPrivate.requestDriveShare(
358 shareEntries[index].toURL(), 355 shareEntries[index].toURL(),
359 dialogResult, 356 dialogResult,
360 function() { 357 function() {
361 // TODO(hirono): Check chrome.runtime.lastError here. 358 // TODO(hirono): Check chrome.runtime.lastError here.
362 fulfill(); 359 fulfill();
363 }); 360 });
364 }).then(requestDriveShare.bind(null, index + 1)); 361 }).then(requestDriveShare.bind(null, index + 1));
365 }; 362 };
366 return requestDriveShare(0); 363 return requestDriveShare(0);
367 }); 364 });
368 }.bind(this)). 365 }.bind(this)).then(function() {
369 then(function() {
370 // Start the pasting operation. 366 // Start the pasting operation.
371 this.fileOperationManager_.paste( 367 this.fileOperationManager_.paste(
372 entries, destinationEntry, toMove); 368 entries, destinationEntry, toMove);
373 369
374 // Publish events for failureUrls. 370 // Publish events for failureUrls.
375 for (var i = 0; i < failureUrls.length; i++) { 371 for (var i = 0; i < failureUrls.length; i++) {
376 var fileName = 372 var fileName =
377 decodeURIComponent(failureUrls[i].replace(/^.+\//, '')); 373 decodeURIComponent(failureUrls[i].replace(/^.+\//, ''));
378 var event = new Event('source-not-found'); 374 var event = new Event('source-not-found');
379 event.fileName = fileName; 375 event.fileName = fileName;
380 event.progressType = 376 event.progressType =
381 toMove ? ProgressItemType.MOVE : ProgressItemType.COPY; 377 toMove ? ProgressItemType.MOVE : ProgressItemType.COPY;
382 this.dispatchEvent(event); 378 this.dispatchEvent(event);
383 } 379 }
384 }.bind(this)). 380 }.bind(this)).catch(function(error) {
385 catch(function(error) {
386 if (error !== 'ABORT') 381 if (error !== 'ABORT')
387 console.error(error.stack ? error.stack : error); 382 console.error(error.stack ? error.stack : error);
388 }); 383 });
389 return toMove ? 'move' : 'copy'; 384 return toMove ? 'move' : 'copy';
390 }, 385 },
391 386
392 /** 387 /**
393 * Preloads an image thumbnail for the specified file entry. 388 * Preloads an image thumbnail for the specified file entry.
394 * 389 *
395 * @this {FileTransferController} 390 * @this {FileTransferController}
396 * @param {Entry} entry Entry to preload a thumbnail for. 391 * @param {Entry} entry Entry to preload a thumbnail for.
397 */ 392 */
398 preloadThumbnailImage_: function(entry) { 393 preloadThumbnailImage_: function(entry) {
399 var metadataPromise = new Promise(function(fulfill, reject) { 394 var metadataPromise = new Promise(function(fulfill, reject) {
400 this.metadataCache_.getOne(entry, 395 this.metadataCache_.getOne(
401 'thumbnail|filesystem', 396 entry, 'thumbnail|filesystem', function(metadata) {
yoshiki 2014/09/16 00:49:08 nit: new line for function?
fukino 2014/09/17 05:17:26 Done.
402 function(metadata) { 397 if (metadata)
403 if (metadata) 398 fulfill(metadata);
404 fulfill(metadata); 399 else
405 else 400 reject('Failed to fetch metadata.');
406 reject('Failed to fetch metadata.'); 401 });
407 });
408 }.bind(this)); 402 }.bind(this));
409 403
410 var imagePromise = metadataPromise.then(function(metadata) { 404 var imagePromise = metadataPromise.then(function(metadata) {
411 return new Promise(function(fulfill, reject) { 405 return new Promise(function(fulfill, reject) {
412 var loader = new ThumbnailLoader( 406 var loader = new ThumbnailLoader(
413 entry, ThumbnailLoader.LoaderType.Image, metadata); 407 entry, ThumbnailLoader.LoaderType.Image, metadata);
414 loader.loadDetachedImage(function(result) { 408 loader.loadDetachedImage(function(result) {
415 if (result) 409 if (result)
416 fulfill(loader.getImage()); 410 fulfill(loader.getImage());
417 }); 411 });
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } else { 525 } else {
532 event.preventDefault(); 526 event.preventDefault();
533 return; 527 return;
534 } 528 }
535 529
536 var dragThumbnail = this.renderThumbnail_(); 530 var dragThumbnail = this.renderThumbnail_();
537 dt.setDragImage(dragThumbnail, 0, 0); 531 dt.setDragImage(dragThumbnail, 0, 0);
538 532
539 window[DRAG_AND_DROP_GLOBAL_DATA] = { 533 window[DRAG_AND_DROP_GLOBAL_DATA] = {
540 sourceRootURL: dt.getData('fs/sourceRootURL'), 534 sourceRootURL: dt.getData('fs/sourceRootURL'),
541 missingFileContents: dt.getData('fs/missingFileContents'), 535 missingFileContents: dt.getData('fs/missingFileContents')
542 }; 536 };
543 }, 537 },
544 538
545 /** 539 /**
546 * @this {FileTransferController} 540 * @this {FileTransferController}
547 * @param {cr.ui.List} list Drop target list. 541 * @param {cr.ui.List} list Drop target list.
548 * @param {Event} event A dragend event of DOM. 542 * @param {Event} event A dragend event of DOM.
549 */ 543 */
550 onDragEnd_: function(list, event) { 544 onDragEnd_: function(list, event) {
551 // TODO(fukino): This is workaround for crbug.com/373125. 545 // TODO(fukino): This is workaround for crbug.com/373125.
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 !event.ctrlKey) { 1056 !event.ctrlKey) {
1063 return 'move'; 1057 return 'move';
1064 } 1058 }
1065 if (event.shiftKey) { 1059 if (event.shiftKey) {
1066 return 'move'; 1060 return 'move';
1067 } 1061 }
1068 } 1062 }
1069 return 'copy'; 1063 return 'copy';
1070 }, 1064 },
1071 }; 1065 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698