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

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: 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 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) {
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | chrome/browser/resources/file_manager/js/file_type.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698