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 // Setting the src of an img to an empty string can crash the browser, so we | 5 // Setting the src of an img to an empty string can crash the browser, so we |
6 // use an empty 1x1 gif instead. | 6 // use an empty 1x1 gif instead. |
7 | 7 |
8 /** | 8 /** |
9 * FileManager constructor. | 9 * FileManager constructor. |
10 * | 10 * |
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2186 // been summarized. See the 'computeNextFile' logic below. | 2186 // been summarized. See the 'computeNextFile' logic below. |
2187 pendingFiles.push(entry); | 2187 pendingFiles.push(entry); |
2188 continue; | 2188 continue; |
2189 } else { | 2189 } else { |
2190 selection.bytes += entry.cachedSize_; | 2190 selection.bytes += entry.cachedSize_; |
2191 } | 2191 } |
2192 // File object must be prepeared in advance for clipboard operations | 2192 // File object must be prepeared in advance for clipboard operations |
2193 // (copy, paste and drag). Clipboard object closes for write after | 2193 // (copy, paste and drag). Clipboard object closes for write after |
2194 // returning control from that handlers so they may not have | 2194 // returning control from that handlers so they may not have |
2195 // asynchronous operations. | 2195 // asynchronous operations. |
2196 // TODO(serya): Put file objects into the clipboard. | |
2197 if (!this.isOnGData()) { | 2196 if (!this.isOnGData()) { |
2198 entry.file(function(f) { | 2197 entry.file(function(f) { |
2199 selection.files.push(f); | 2198 selection.files.push(f); |
2200 }); | 2199 }); |
2201 } | 2200 } |
2202 } else { | 2201 } else { |
2203 selection.directoryCount += 1; | 2202 selection.directoryCount += 1; |
2204 } | 2203 } |
2205 } | 2204 } |
2206 | 2205 |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3129 else | 3128 else |
3130 files += entry.fullPath + '\n'; | 3129 files += entry.fullPath + '\n'; |
3131 } | 3130 } |
3132 | 3131 |
3133 clipboard.setData('fs/isCut', isCut.toString()); | 3132 clipboard.setData('fs/isCut', isCut.toString()); |
3134 clipboard.setData('fs/sourceDir', | 3133 clipboard.setData('fs/sourceDir', |
3135 this.directoryModel_.currentEntry.fullPath); | 3134 this.directoryModel_.currentEntry.fullPath); |
3136 clipboard.setData('fs/sourceOnGData', this.isOnGData()); | 3135 clipboard.setData('fs/sourceOnGData', this.isOnGData()); |
3137 clipboard.setData('fs/directories', directories); | 3136 clipboard.setData('fs/directories', directories); |
3138 clipboard.setData('fs/files', files); | 3137 clipboard.setData('fs/files', files); |
3138 | |
3139 var files = this.selection.files; | |
3140 for(var i = 0, entry; i < files.length; i++) { | |
dgozman
2012/03/26 14:48:54
|entry| is not used
SeRya
2012/03/26 14:51:33
Done.
| |
3141 clipboard.items.add(files[i]); | |
3142 } | |
3139 } | 3143 } |
3140 | 3144 |
3141 FileManager.prototype.onCopy_ = function(event) { | 3145 FileManager.prototype.onCopy_ = function(event) { |
3142 if (!this.selection || this.selection.totalCount == 0) | 3146 if (!this.selection || this.selection.totalCount == 0) |
3143 return; | 3147 return; |
3144 | 3148 |
3145 event.preventDefault(); | 3149 event.preventDefault(); |
3146 this.cutOrCopyToClipboard_(event.clipboardData, false); | 3150 this.cutOrCopyToClipboard_(event.clipboardData, false); |
3147 | 3151 |
3148 this.blinkSelection(); | 3152 this.blinkSelection(); |
3149 }; | 3153 }; |
3150 | 3154 |
3151 FileManager.prototype.onCut_ = function(event) { | 3155 FileManager.prototype.onCut_ = function(event) { |
3152 if (!this.selection || this.selection.totalCount == 0 || | 3156 if (!this.selection || this.selection.totalCount == 0 || |
3153 this.commands_['cut'].disabled) | 3157 this.commands_['cut'].disabled) |
3154 return; | 3158 return; |
3155 | 3159 |
3156 event.preventDefault(); | 3160 event.preventDefault(); |
3157 this.cutOrCopyToClipboard_(event.clipboardData, true); | 3161 this.cutOrCopyToClipboard_(event.clipboardData, true); |
3158 | 3162 |
3159 this.blinkSelection(); | 3163 this.blinkSelection(); |
3160 }; | 3164 }; |
3161 | 3165 |
3162 FileManager.prototype.onPaste_ = function(event) { | 3166 FileManager.prototype.onPaste_ = function(event) { |
3167 if (!event.clipboardData.getData('fs/isCut')) | |
dgozman
2012/03/26 14:48:54
Add a comment about this check.
SeRya
2012/03/26 14:51:33
Done.
| |
3168 return; | |
3163 event.preventDefault(); | 3169 event.preventDefault(); |
3164 this.pasteFromClipboard_(event.clipboardData); | 3170 this.pasteFromClipboard_(event.clipboardData); |
3165 }; | 3171 }; |
3166 | 3172 |
3167 /** | 3173 /** |
3168 * Queue up a file copy operation based on the current system clipboard. | 3174 * Queue up a file copy operation based on the current system clipboard. |
3169 */ | 3175 */ |
3170 FileManager.prototype.pasteFromClipboard_ = function(clipboard) { | 3176 FileManager.prototype.pasteFromClipboard_ = function(clipboard) { |
3171 if (!event.clipboardData.getData('fs/isCut')) | |
3172 return; | |
3173 | |
3174 var operationInfo = { | 3177 var operationInfo = { |
3175 isCut: clipboard.getData('fs/isCut'), | 3178 isCut: clipboard.getData('fs/isCut'), |
3176 sourceDir: clipboard.getData('fs/sourceDir'), | 3179 sourceDir: clipboard.getData('fs/sourceDir'), |
3177 sourceOnGData: clipboard.getData('fs/sourceOnGData'), | 3180 sourceOnGData: clipboard.getData('fs/sourceOnGData'), |
3178 directories: clipboard.getData('fs/directories'), | 3181 directories: clipboard.getData('fs/directories'), |
3179 files: clipboard.getData('fs/files') | 3182 files: clipboard.getData('fs/files') |
3180 }; | 3183 }; |
3181 | 3184 |
3182 // If both source and target are on GData, FileCopyManager uses | 3185 // If both source and target are on GData, FileCopyManager uses |
3183 // FileEntry.copyTo() / FileEntry.moveTo() to copy / move files. | 3186 // FileEntry.copyTo() / FileEntry.moveTo() to copy / move files. |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4342 }); | 4345 }); |
4343 }, onError); | 4346 }, onError); |
4344 | 4347 |
4345 function onError(err) { | 4348 function onError(err) { |
4346 console.log('Error while checking free space: ' + err); | 4349 console.log('Error while checking free space: ' + err); |
4347 setTimeout(doCheck, 1000 * 60); | 4350 setTimeout(doCheck, 1000 * 60); |
4348 } | 4351 } |
4349 } | 4352 } |
4350 } | 4353 } |
4351 })(); | 4354 })(); |
OLD | NEW |