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 /** | 5 /** |
6 * Global (placed in the window object) variable name to hold internal | 6 * Global (placed in the window object) variable name to hold internal |
7 * file dragging information. Needed to show visual feedback while dragging | 7 * file dragging information. Needed to show visual feedback while dragging |
8 * since DataTransfer object is in protected state. Reachable from other | 8 * since DataTransfer object is in protected state. Reachable from other |
9 * file manager instances. | 9 * file manager instances. |
10 */ | 10 */ |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1254 doc.addEventListener(command, handler); | 1254 doc.addEventListener(command, handler); |
1255 doc.execCommand(command); | 1255 doc.execCommand(command); |
1256 doc.removeEventListener(command, handler); | 1256 doc.removeEventListener(command, handler); |
1257 }; | 1257 }; |
1258 | 1258 |
1259 /** | 1259 /** |
1260 * @private | 1260 * @private |
1261 */ | 1261 */ |
1262 FileTransferController.prototype.onFileSelectionChanged_ = function() { | 1262 FileTransferController.prototype.onFileSelectionChanged_ = function() { |
1263 this.preloadedThumbnailImagePromise_ = null; | 1263 this.preloadedThumbnailImagePromise_ = null; |
1264 this.selectedAsyncData_ = {}; | |
fukino
2017/04/26 03:11:33
We should clear objects in selectedAsyncData_ if t
tetsui2
2017/04/26 03:37:04
Every time a file is copied, both onFileSelectionC
fukino
2017/04/26 03:49:17
I didn't mean that we should clear the selectedAsy
tetsui2
2017/04/26 06:47:42
Done.
| |
1265 }; | 1264 }; |
1266 | 1265 |
1267 /** | 1266 /** |
1268 * @private | 1267 * @private |
1269 */ | 1268 */ |
1270 FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() { | 1269 FileTransferController.prototype.onFileSelectionChangedThrottled_ = function() { |
1271 var entries = this.selectionHandler_.selection.entries; | 1270 var entries = this.selectionHandler_.selection.entries; |
1272 var asyncData = this.selectedAsyncData_; | 1271 var asyncData = this.selectedAsyncData_; |
1273 var fileEntries = []; | 1272 var fileEntries = []; |
1274 for (var i = 0; i < entries.length; i++) { | 1273 for (var i = 0; i < entries.length; i++) { |
1275 if (entries[i].isFile) | 1274 if (entries[i].isFile) |
1276 fileEntries.push(entries[i]); | 1275 fileEntries.push(entries[i]); |
1277 asyncData[entries[i].toURL()] = {externalFileUrl: '', file: null}; | 1276 if (!(entries[i].toURL() in asyncData)) { |
1277 asyncData[entries[i].toURL()] = {externalFileUrl: '', file: null}; | |
1278 } | |
1278 } | 1279 } |
1279 var containsDirectory = this.selectionHandler_.selection.directoryCount > 0; | 1280 var containsDirectory = this.selectionHandler_.selection.directoryCount > 0; |
1280 | 1281 |
1281 // File object must be prepeared in advance for clipboard operations | 1282 // File object must be prepeared in advance for clipboard operations |
1282 // (copy, paste and drag). DataTransfer object closes for write after | 1283 // (copy, paste and drag). DataTransfer object closes for write after |
1283 // returning control from that handlers so they may not have | 1284 // returning control from that handlers so they may not have |
1284 // asynchronous operations. | 1285 // asynchronous operations. |
1285 if (!containsDirectory) { | 1286 if (!containsDirectory) { |
1286 for (var i = 0; i < fileEntries.length; i++) { | 1287 for (var i = 0; i < fileEntries.length; i++) { |
1287 (function(fileEntry) { | 1288 (function(fileEntry) { |
1288 fileEntry.file(function(file) { | 1289 if (!asyncData[fileEntry.toURL()]) { |
1289 asyncData[fileEntry.toURL()].file = file; | 1290 fileEntry.file(function(file) { |
1290 }); | 1291 asyncData[fileEntry.toURL()].file = file; |
1292 }); | |
1293 } | |
1291 })(fileEntries[i]); | 1294 })(fileEntries[i]); |
1292 } | 1295 } |
1293 } | 1296 } |
1294 | 1297 |
1295 if (entries.length === 1) { | 1298 if (entries.length === 1) { |
1296 // For single selection, the dragged element is created in advance, | 1299 // For single selection, the dragged element is created in advance, |
1297 // otherwise an image may not be loaded at the time the 'dragstart' event | 1300 // otherwise an image may not be loaded at the time the 'dragstart' event |
1298 // comes. | 1301 // comes. |
1299 this.preloadThumbnailImage_(entries[0]); | 1302 this.preloadThumbnailImage_(entries[0]); |
1300 } | 1303 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1386 listItems.push(listItem); | 1389 listItems.push(listItem); |
1387 } | 1390 } |
1388 } | 1391 } |
1389 | 1392 |
1390 setTimeout(function() { | 1393 setTimeout(function() { |
1391 for (var i = 0; i < listItems.length; i++) { | 1394 for (var i = 0; i < listItems.length; i++) { |
1392 listItems[i].classList.remove('blink'); | 1395 listItems[i].classList.remove('blink'); |
1393 } | 1396 } |
1394 }, 100); | 1397 }, 100); |
1395 }; | 1398 }; |
OLD | NEW |