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

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

Issue 290653002: Files.app: Add 'link' to the allowed effects in dataTransfer objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/file_manager/file_manager/common/js/util.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 this.onPaste_.bind(this)); 158 this.onPaste_.bind(this));
159 this.copyCommand_ = this.document_.querySelector('command#copy'); 159 this.copyCommand_ = this.document_.querySelector('command#copy');
160 }, 160 },
161 161
162 /** 162 /**
163 * Write the current selection to system clipboard. 163 * Write the current selection to system clipboard.
164 * 164 *
165 * @this {FileTransferController} 165 * @this {FileTransferController}
166 * @param {DataTransfer} dataTransfer DataTransfer from the event. 166 * @param {DataTransfer} dataTransfer DataTransfer from the event.
167 * @param {string} effectAllowed Value must be valid for the 167 * @param {string} effectAllowed Value must be valid for the
168 * |dataTransfer.effectAllowed| property ('move', 'copy', 'copyMove'). 168 * |dataTransfer.effectAllowed| property.
169 */ 169 */
170 cutOrCopy_: function(dataTransfer, effectAllowed) { 170 cutOrCopy_: function(dataTransfer, effectAllowed) {
171 // Existence of the volumeInfo is checked in canXXX methods. 171 // Existence of the volumeInfo is checked in canXXX methods.
172 var volumeInfo = this.volumeManager_.getVolumeInfo( 172 var volumeInfo = this.volumeManager_.getVolumeInfo(
173 this.currentDirectoryContentEntry); 173 this.currentDirectoryContentEntry);
174 // Tag to check it's filemanager data. 174 // Tag to check it's filemanager data.
175 dataTransfer.setData('fs/tag', 'filemanager-data'); 175 dataTransfer.setData('fs/tag', 'filemanager-data');
176 dataTransfer.setData('fs/sourceRootURL', 176 dataTransfer.setData('fs/sourceRootURL',
177 volumeInfo.fileSystem.root.toURL()); 177 volumeInfo.fileSystem.root.toURL());
178 var sourceURLs = util.entriesToURLs(this.selectedEntries_); 178 var sourceURLs = util.entriesToURLs(this.selectedEntries_);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 * |dataTransfer.effectAllowed|. 322 * |dataTransfer.effectAllowed|.
323 * @return {string} Either "copy" or "move". 323 * @return {string} Either "copy" or "move".
324 */ 324 */
325 paste: function(dataTransfer, opt_destinationEntry, opt_effect) { 325 paste: function(dataTransfer, opt_destinationEntry, opt_effect) {
326 var sourceURLs = dataTransfer.getData('fs/sources') ? 326 var sourceURLs = dataTransfer.getData('fs/sources') ?
327 dataTransfer.getData('fs/sources').split('\n') : []; 327 dataTransfer.getData('fs/sources').split('\n') : [];
328 // effectAllowed set in copy/paste handlers stay uninitialized. DnD handlers 328 // effectAllowed set in copy/paste handlers stay uninitialized. DnD handlers
329 // work fine. 329 // work fine.
330 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ? 330 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ?
331 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed'); 331 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed');
332 var toMove = effectAllowed === 'move' || 332 var toMove = util.isDropEffectAllowed(effectAllowed, 'move') &&
333 (effectAllowed === 'copyMove' && opt_effect === 'move'); 333 (!util.isDropEffectAllowed(effectAllowed, 'copy') ||
334 opt_effect === 'move');
334 var destinationEntry = 335 var destinationEntry =
335 opt_destinationEntry || this.currentDirectoryContentEntry; 336 opt_destinationEntry || this.currentDirectoryContentEntry;
336 var entries; 337 var entries;
337 var failureUrls; 338 var failureUrls;
338 339
339 util.URLsToEntries(sourceURLs). 340 util.URLsToEntries(sourceURLs).
340 then(function(result) { 341 then(function(result) {
341 entries = result.entries; 342 entries = result.entries;
342 failureUrls = result.failureUrls; 343 failureUrls = result.failureUrls;
343 // Check if cross share is needed or not. 344 // Check if cross share is needed or not.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (!this.selectedEntries_.length) { 483 if (!this.selectedEntries_.length) {
483 event.preventDefault(); 484 event.preventDefault();
484 return; 485 return;
485 } 486 }
486 487
487 var dt = event.dataTransfer; 488 var dt = event.dataTransfer;
488 var canCopy = this.canCopyOrDrag_(dt); 489 var canCopy = this.canCopyOrDrag_(dt);
489 var canCut = this.canCutOrDrag_(dt); 490 var canCut = this.canCutOrDrag_(dt);
490 if (canCopy || canCut) { 491 if (canCopy || canCut) {
491 if (canCopy && canCut) { 492 if (canCopy && canCut) {
492 this.cutOrCopy_(dt, 'copyMove'); 493 this.cutOrCopy_(dt, 'all');
493 } else if (canCopy) { 494 } else if (canCopy) {
494 this.cutOrCopy_(dt, 'copy'); 495 this.cutOrCopy_(dt, 'copyLink');
495 } else { 496 } else {
496 this.cutOrCopy_(dt, 'move'); 497 this.cutOrCopy_(dt, 'move');
497 } 498 }
498 } else { 499 } else {
499 event.preventDefault(); 500 event.preventDefault();
500 return; 501 return;
501 } 502 }
502 503
503 var dragThumbnail = this.renderThumbnail_(); 504 var dragThumbnail = this.renderThumbnail_();
504 dt.setDragImage(dragThumbnail, 1000, 1000); 505 dt.setDragImage(dragThumbnail, 1000, 1000);
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 */ 1041 */
1041 selectDropEffect_: function(event, destinationEntry) { 1042 selectDropEffect_: function(event, destinationEntry) {
1042 if (!destinationEntry) 1043 if (!destinationEntry)
1043 return 'none'; 1044 return 'none';
1044 var destinationLocationInfo = 1045 var destinationLocationInfo =
1045 this.volumeManager_.getLocationInfo(destinationEntry); 1046 this.volumeManager_.getLocationInfo(destinationEntry);
1046 if (!destinationLocationInfo) 1047 if (!destinationLocationInfo)
1047 return 'none'; 1048 return 'none';
1048 if (destinationLocationInfo.isReadOnly) 1049 if (destinationLocationInfo.isReadOnly)
1049 return 'none'; 1050 return 'none';
1050 if (event.dataTransfer.effectAllowed === 'move') 1051 if (util.isDropEffectAllowed(event.dataTransfer.effectAllowed, 'move')) {
1051 return 'move'; 1052 if (!util.isDropEffectAllowed(event.dataTransfer.effectAllowed, 'copy'))
1052 // TODO(mtomasz): Use volumeId instead of comparing roots, as soon as 1053 return 'move';
1053 // volumeId gets unique. 1054 // TODO(mtomasz): Use volumeId instead of comparing roots, as soon as
1054 if (event.dataTransfer.effectAllowed === 'copyMove' && 1055 // volumeId gets unique.
1055 this.getSourceRootURL_(event.dataTransfer) === 1056 if (this.getSourceRootURL_(event.dataTransfer) ===
1056 destinationLocationInfo.volumeInfo.fileSystem.root.toURL() && 1057 destinationLocationInfo.volumeInfo.fileSystem.root.toURL() &&
1057 !event.ctrlKey) { 1058 !event.ctrlKey) {
1058 return 'move'; 1059 return 'move';
1059 } 1060 }
1060 if (event.dataTransfer.effectAllowed === 'copyMove' && 1061 if (event.shiftKey) {
1061 event.shiftKey) { 1062 return 'move';
1062 return 'move'; 1063 }
1063 } 1064 }
1064 return 'copy'; 1065 return 'copy';
1065 }, 1066 },
1066 }; 1067 };
OLDNEW
« no previous file with comments | « ui/file_manager/file_manager/common/js/util.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698