| OLD | NEW |
| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 * @param {DataTransfer} dataTransfer System data transfer object. | 233 * @param {DataTransfer} dataTransfer System data transfer object. |
| 234 * @param {DirectoryEntry=} opt_destinationEntry Paste destination. | 234 * @param {DirectoryEntry=} opt_destinationEntry Paste destination. |
| 235 * @param {string=} opt_effect Desired drop/paste effect. Could be | 235 * @param {string=} opt_effect Desired drop/paste effect. Could be |
| 236 * 'move'|'copy' (default is copy). Ignored if conflicts with | 236 * 'move'|'copy' (default is copy). Ignored if conflicts with |
| 237 * |dataTransfer.effectAllowed|. | 237 * |dataTransfer.effectAllowed|. |
| 238 * @return {string} Either "copy" or "move". | 238 * @return {string} Either "copy" or "move". |
| 239 */ | 239 */ |
| 240 paste: function(dataTransfer, opt_destinationEntry, opt_effect) { | 240 paste: function(dataTransfer, opt_destinationEntry, opt_effect) { |
| 241 var sourceURLs = dataTransfer.getData('fs/sources') ? | 241 var sourceURLs = dataTransfer.getData('fs/sources') ? |
| 242 dataTransfer.getData('fs/sources').split('\n') : []; | 242 dataTransfer.getData('fs/sources').split('\n') : []; |
| 243 util.URLsToEntries(sourceURLs, function(sourceEntries) { | |
| 244 var destinationEntry = | |
| 245 opt_destinationEntry || this.currentDirectoryContentEntry; | |
| 246 // Start the pasting operation. | |
| 247 this.fileOperationManager_.paste(sourceEntries, destinationEntry, toMove); | |
| 248 }.bind(this)); | |
| 249 | |
| 250 // effectAllowed set in copy/paste handlers stay uninitialized. DnD handlers | 243 // effectAllowed set in copy/paste handlers stay uninitialized. DnD handlers |
| 251 // work fine. | 244 // work fine. |
| 252 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ? | 245 var effectAllowed = dataTransfer.effectAllowed !== 'uninitialized' ? |
| 253 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed'); | 246 dataTransfer.effectAllowed : dataTransfer.getData('fs/effectallowed'); |
| 254 var toMove = effectAllowed === 'move' || | 247 var toMove = effectAllowed === 'move' || |
| 255 (effectAllowed === 'copyMove' && opt_effect === 'move'); | 248 (effectAllowed === 'copyMove' && opt_effect === 'move'); |
| 256 | 249 |
| 250 util.URLsToEntries(sourceURLs, function(sourceEntries, failureUrls) { |
| 251 var destinationEntry = |
| 252 opt_destinationEntry || this.currentDirectoryContentEntry; |
| 253 // Start the pasting operation. |
| 254 this.fileOperationManager_.paste(sourceEntries, destinationEntry, toMove); |
| 255 |
| 256 // Publish events for failureUrls. |
| 257 for (var i = 0; i < failureUrls.length; i++) { |
| 258 var fileName = decodeURIComponent(failureUrls[i].replace(/^.+\//, '')); |
| 259 var event = new Event('source-not-found'); |
| 260 event.fileName = fileName; |
| 261 event.progressType = |
| 262 toMove ? ProgressItemType.MOVE : ProgressItemType.COPY; |
| 263 this.dispatchEvent(event); |
| 264 } |
| 265 }.bind(this)); |
| 257 return toMove ? 'move' : 'copy'; | 266 return toMove ? 'move' : 'copy'; |
| 258 }, | 267 }, |
| 259 | 268 |
| 260 /** | 269 /** |
| 261 * Preloads an image thumbnail for the specified file entry. | 270 * Preloads an image thumbnail for the specified file entry. |
| 262 * | 271 * |
| 263 * @this {FileTransferController} | 272 * @this {FileTransferController} |
| 264 * @param {Entry} entry Entry to preload a thumbnail for. | 273 * @param {Entry} entry Entry to preload a thumbnail for. |
| 265 */ | 274 */ |
| 266 preloadThumbnailImage_: function(entry) { | 275 preloadThumbnailImage_: function(entry) { |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 !event.ctrlKey) { | 934 !event.ctrlKey) { |
| 926 return 'move'; | 935 return 'move'; |
| 927 } | 936 } |
| 928 if (event.dataTransfer.effectAllowed === 'copyMove' && | 937 if (event.dataTransfer.effectAllowed === 'copyMove' && |
| 929 event.shiftKey) { | 938 event.shiftKey) { |
| 930 return 'move'; | 939 return 'move'; |
| 931 } | 940 } |
| 932 return 'copy'; | 941 return 'copy'; |
| 933 }, | 942 }, |
| 934 }; | 943 }; |
| OLD | NEW |