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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 9809021: Dragging files into external apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review fixes. Created 8 years, 9 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 | « no previous file | 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 // 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
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
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; i < files.length; i++) {
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 // Check that the data copied by ourselves.
3168 if (!event.clipboardData.getData('fs/isCut'))
3169 return;
3163 event.preventDefault(); 3170 event.preventDefault();
3164 this.pasteFromClipboard_(event.clipboardData); 3171 this.pasteFromClipboard_(event.clipboardData);
3165 }; 3172 };
3166 3173
3167 /** 3174 /**
3168 * Queue up a file copy operation based on the current system clipboard. 3175 * Queue up a file copy operation based on the current system clipboard.
3169 */ 3176 */
3170 FileManager.prototype.pasteFromClipboard_ = function(clipboard) { 3177 FileManager.prototype.pasteFromClipboard_ = function(clipboard) {
3171 if (!event.clipboardData.getData('fs/isCut'))
3172 return;
3173
3174 var operationInfo = { 3178 var operationInfo = {
3175 isCut: clipboard.getData('fs/isCut'), 3179 isCut: clipboard.getData('fs/isCut'),
3176 sourceDir: clipboard.getData('fs/sourceDir'), 3180 sourceDir: clipboard.getData('fs/sourceDir'),
3177 sourceOnGData: clipboard.getData('fs/sourceOnGData'), 3181 sourceOnGData: clipboard.getData('fs/sourceOnGData'),
3178 directories: clipboard.getData('fs/directories'), 3182 directories: clipboard.getData('fs/directories'),
3179 files: clipboard.getData('fs/files') 3183 files: clipboard.getData('fs/files')
3180 }; 3184 };
3181 3185
3182 // If both source and target are on GData, FileCopyManager uses 3186 // If both source and target are on GData, FileCopyManager uses
3183 // FileEntry.copyTo() / FileEntry.moveTo() to copy / move files. 3187 // FileEntry.copyTo() / FileEntry.moveTo() to copy / move files.
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 }); 4346 });
4343 }, onError); 4347 }, onError);
4344 4348
4345 function onError(err) { 4349 function onError(err) {
4346 console.log('Error while checking free space: ' + err); 4350 console.log('Error while checking free space: ' + err);
4347 setTimeout(doCheck, 1000 * 60); 4351 setTimeout(doCheck, 1000 * 60);
4348 } 4352 }
4349 } 4353 }
4350 } 4354 }
4351 })(); 4355 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698