Index: chrome/browser/resources/file_manager/js/file_transfer_controller.js |
diff --git a/chrome/browser/resources/file_manager/js/file_transfer_controller.js b/chrome/browser/resources/file_manager/js/file_transfer_controller.js |
index efdd7f1c68cccc2722ffd472919a48fd5bd8e045..7fc98aeaef716d51be8f24b5ac61b9929c0476e7 100644 |
--- a/chrome/browser/resources/file_manager/js/file_transfer_controller.js |
+++ b/chrome/browser/resources/file_manager/js/file_transfer_controller.js |
@@ -11,12 +11,14 @@ function FileTransferController(fileList, |
fileListSelection, |
dragNodeConstructor, |
copyManager, |
- directoryModel) { |
+ directoryModel, |
+ metadataCache) { |
this.fileList_ = fileList; |
this.fileListSelection_ = fileListSelection; |
this.dragNodeConstructor_ = dragNodeConstructor; |
this.copyManager_ = copyManager; |
this.directoryModel_ = directoryModel; |
+ this.metadataCache_ = metadataCache; |
SeRya
2012/04/25 13:50:36
The parameter list tends to get huge. I't prefer a
|
this.fileListSelection_.addEventListener('change', |
this.onSelectionChanged_.bind(this)); |
@@ -75,6 +77,7 @@ FileTransferController.prototype = { |
doc.addEventListener('cut', this.onCut_.bind(this)); |
doc.addEventListener('beforepaste', this.onBeforePaste_.bind(this)); |
doc.addEventListener('paste', this.onPaste_.bind(this)); |
+ this.copyCommand_ = doc.querySelector('command#copy'); |
}, |
/** |
@@ -85,7 +88,7 @@ FileTransferController.prototype = { |
* |dataTransfer.effectAllowed| property ('move', 'copy', 'copyMove'). |
*/ |
cutOrCopy: function(dataTransfer, effectAllowed) { |
- var directories = []; |
+ var directories = []; |
var files = []; |
var entries = this.selectedEntries_; |
for (var i = 0; i < entries.length; i++) { |
@@ -264,6 +267,8 @@ FileTransferController.prototype = { |
}, |
canCopyOrDrag_: function() { |
+ if (this.isOnGData && util.isOffline() && !this.allGDataFilesAvailable) |
+ return false; |
return this.selectedEntries_.length > 0; |
}, |
@@ -383,6 +388,21 @@ FileTransferController.prototype = { |
if (dragNodes.length < MAX_DRAG_THUMBAIL_COUNT) |
dragNodes.push(new this.dragNodeConstructor_(entries[i])); |
} |
+ |
+ if (this.isOnGData) { |
+ this.allGDataFilesAvailable = false; |
+ var urls = entries.map(function(e) { return e.toURL() }); |
+ this.metadataCache_.get(urls, 'gdata', function(props) { |
+ // We consider directories not available offline for the purposes of |
+ // file transfer since we cannot afford to recursive traversal. |
+ this.allGDataFilesAvailable = |
+ entries.filter(function(e) {return e.isDirectory}).length == 0 && |
+ props.filter(function(p) {return !p.availableOffline}).length == 0; |
+ // |Copy| is the only menu item affected by allGDataFilesAvailable. |
+ // It could be open right now, update its UI. |
+ this.copyCommand_.disabled = !this.canCopyOrDrag_(); |
+ }.bind(this)); |
+ } |
}, |
get currentDirectory() { |