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

Unified Diff: chrome/browser/resources/file_manager/js/file_transfer_controller.js

Issue 10184005: [File Manager] Properly enable/disable Copy and Open for GData files in the offline mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
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..a120b031877727ebfcb4fb5818c7797ba37dec88 100644
--- a/chrome/browser/resources/file_manager/js/file_transfer_controller.js
+++ b/chrome/browser/resources/file_manager/js/file_transfer_controller.js
@@ -75,6 +75,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 +86,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 +265,8 @@ FileTransferController.prototype = {
},
canCopyOrDrag_: function() {
+ if (this.isOnGData && util.isOffline() && !this.allGDataFilesAvailable)
+ return false;
return this.selectedEntries_.length > 0;
},
@@ -383,6 +386,22 @@ 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.directoryModel_.getMetadataCache().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() {
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | chrome/browser/resources/file_manager/js/util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698