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 e81219931c4697431d83422b01574a33d8aa0fed..25f14ef7c771997bddae1788d965c17771935cb6 100644 |
--- a/chrome/browser/resources/file_manager/js/file_transfer_controller.js |
+++ b/chrome/browser/resources/file_manager/js/file_transfer_controller.js |
@@ -8,12 +8,14 @@ function FileTransferController(fileList, |
fileListSelection, |
dragNodeConstructor, |
copyManager, |
- directoryModel) { |
+ directoryModel, |
+ commands) { |
this.fileList_ = fileList; |
this.fileListSelection_ = fileListSelection; |
this.dragNodeConstructor_ = dragNodeConstructor; |
this.copyManager_ = copyManager; |
this.directoryModel_ = directoryModel; |
+ this.commands_ = commands; |
this.fileListSelection_.addEventListener('change', |
this.onSelectionChanged_.bind(this)); |
@@ -78,7 +80,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++) { |
@@ -254,6 +256,10 @@ FileTransferController.prototype = { |
}, |
canCopyOrDrag_: function() { |
+ if (this.isOnGData && |
+ this.directoryModel_.offline && |
+ !this.allGDataFilesAvailable) |
+ return false; |
return this.selectedEntries_.length > 0; |
}, |
@@ -371,6 +377,17 @@ 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() }); |
+ FileType.checkOfflineAvailability(entries, urls, function(result) { |
+ this.allGDataFilesAvailable = result; |
+ // |Copy| is the only menu item affected by allGDataFilesAvailable. |
+ // It could be open right now, update its UI. |
+ this.commands_['copy'].disabled = !this.canCopyOrDrag_(); |
+ }.bind(this)); |
+ } |
}, |
get currentDirectory() { |
@@ -382,7 +399,7 @@ FileTransferController.prototype = { |
}, |
get isOnGData() { |
- return this.directoryModel_.rootType == DirectoryModel.RootType.GDATA; |
+ return this.directoryModel_.isOnGData; |
}, |
notify_: function(eventName) { |