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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 * @param {DataTransfer} dataTransfer DataTransfer from the event. | 152 * @param {DataTransfer} dataTransfer DataTransfer from the event. |
153 * @param {string} effectAllowed Value must be valid for the | 153 * @param {string} effectAllowed Value must be valid for the |
154 * |dataTransfer.effectAllowed| property ('move', 'copy', 'copyMove'). | 154 * |dataTransfer.effectAllowed| property ('move', 'copy', 'copyMove'). |
155 */ | 155 */ |
156 cutOrCopy_: function(dataTransfer, effectAllowed) { | 156 cutOrCopy_: function(dataTransfer, effectAllowed) { |
157 // Existence of the volumeInfo is checked in canXXX methods. | 157 // Existence of the volumeInfo is checked in canXXX methods. |
158 var volumeInfo = this.volumeManager_.getVolumeInfo( | 158 var volumeInfo = this.volumeManager_.getVolumeInfo( |
159 this.currentDirectoryContentEntry); | 159 this.currentDirectoryContentEntry); |
160 // Tag to check it's filemanager data. | 160 // Tag to check it's filemanager data. |
161 dataTransfer.setData('fs/tag', 'filemanager-data'); | 161 dataTransfer.setData('fs/tag', 'filemanager-data'); |
162 dataTransfer.setData('fs/sourceRootURL', volumeInfo.root.toURL()); | 162 dataTransfer.setData('fs/sourceRootURL', |
| 163 volumeInfo.fileSystem.root.toURL()); |
163 var sourceURLs = util.entriesToURLs(this.selectedEntries_); | 164 var sourceURLs = util.entriesToURLs(this.selectedEntries_); |
164 dataTransfer.setData('fs/sources', sourceURLs.join('\n')); | 165 dataTransfer.setData('fs/sources', sourceURLs.join('\n')); |
165 dataTransfer.effectAllowed = effectAllowed; | 166 dataTransfer.effectAllowed = effectAllowed; |
166 dataTransfer.setData('fs/effectallowed', effectAllowed); | 167 dataTransfer.setData('fs/effectallowed', effectAllowed); |
167 dataTransfer.setData('fs/missingFileContents', | 168 dataTransfer.setData('fs/missingFileContents', |
168 !this.isAllSelectedFilesAvailable_()); | 169 !this.isAllSelectedFilesAvailable_()); |
169 | 170 |
170 for (var i = 0; i < this.selectedFileObjects_.length; i++) { | 171 for (var i = 0; i < this.selectedFileObjects_.length; i++) { |
171 dataTransfer.items.add(this.selectedFileObjects_[i]); | 172 dataTransfer.items.add(this.selectedFileObjects_[i]); |
172 } | 173 } |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return false; | 737 return false; |
737 var destinationLocationInfo = | 738 var destinationLocationInfo = |
738 this.volumeManager_.getLocationInfo(destinationEntry); | 739 this.volumeManager_.getLocationInfo(destinationEntry); |
739 if (destinationLocationInfo.isReadOnly) | 740 if (destinationLocationInfo.isReadOnly) |
740 return false; | 741 return false; |
741 if (!dataTransfer.types || dataTransfer.types.indexOf('fs/tag') === -1) | 742 if (!dataTransfer.types || dataTransfer.types.indexOf('fs/tag') === -1) |
742 return false; // Unsupported type of content. | 743 return false; // Unsupported type of content. |
743 | 744 |
744 // Copying between different sources requires all files to be available. | 745 // Copying between different sources requires all files to be available. |
745 if (this.getSourceRootURL_(dataTransfer) !== | 746 if (this.getSourceRootURL_(dataTransfer) !== |
746 destinationLocationInfo.volumeInfo.root.toURL() && | 747 destinationLocationInfo.volumeInfo.fileSystem.root.toURL() && |
747 this.isMissingFileContents_(dataTransfer)) | 748 this.isMissingFileContents_(dataTransfer)) |
748 return false; | 749 return false; |
749 | 750 |
750 return true; | 751 return true; |
751 }, | 752 }, |
752 | 753 |
753 /** | 754 /** |
754 * Execute paste command. | 755 * Execute paste command. |
755 * | 756 * |
756 * @this {FileTransferController} | 757 * @this {FileTransferController} |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 if (!destinationLocationInfo) | 924 if (!destinationLocationInfo) |
924 return 'none'; | 925 return 'none'; |
925 if (destinationLocationInfo.isReadOnly) | 926 if (destinationLocationInfo.isReadOnly) |
926 return 'none'; | 927 return 'none'; |
927 if (event.dataTransfer.effectAllowed === 'move') | 928 if (event.dataTransfer.effectAllowed === 'move') |
928 return 'move'; | 929 return 'move'; |
929 // TODO(mtomasz): Use volumeId instead of comparing roots, as soon as | 930 // TODO(mtomasz): Use volumeId instead of comparing roots, as soon as |
930 // volumeId gets unique. | 931 // volumeId gets unique. |
931 if (event.dataTransfer.effectAllowed === 'copyMove' && | 932 if (event.dataTransfer.effectAllowed === 'copyMove' && |
932 this.getSourceRootURL_(event.dataTransfer) === | 933 this.getSourceRootURL_(event.dataTransfer) === |
933 destinationLocationInfo.volumeInfo.root.toURL() && | 934 destinationLocationInfo.volumeInfo.fileSystem.root.toURL() && |
934 !event.ctrlKey) { | 935 !event.ctrlKey) { |
935 return 'move'; | 936 return 'move'; |
936 } | 937 } |
937 if (event.dataTransfer.effectAllowed === 'copyMove' && | 938 if (event.dataTransfer.effectAllowed === 'copyMove' && |
938 event.shiftKey) { | 939 event.shiftKey) { |
939 return 'move'; | 940 return 'move'; |
940 } | 941 } |
941 return 'copy'; | 942 return 'copy'; |
942 }, | 943 }, |
943 }; | 944 }; |
OLD | NEW |