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

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

Issue 10119007: [File Manager]Disable "Copy" command if selection contains dimmed GData files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed debugging code 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_manager.js
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js
index 256ad2de5cfeab1bbb05e04dc6d7c0a017dc716c..1163e927b85186faa4db0e26694600822cb2184c 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -2215,6 +2215,7 @@ FileManager.prototype = {
directoryCount: 0,
bytes: 0,
showBytes: false,
+ allGDataFilesPresent: this.isOnGData(),
iconType: null,
indexes: this.currentList_.selectionModel.selectedIndexes
};
@@ -2232,6 +2233,7 @@ FileManager.prototype = {
var fileCount = 0;
var byteCount = 0;
var pendingFiles = [];
+ var pendingGDataFiles = [];
var thumbnailCount = 0;
var thumbnailLoaded = -1;
var forcedShowTimeout = null;
@@ -2305,8 +2307,21 @@ FileManager.prototype = {
selection.bytes += entry.cachedSize_;
selection.showBytes |= this.getFileType(entry).type != 'hosted';
}
+
+ // Only keep checking if allGDataFilesPresent is not already false.
+ if (selection.allGDataFilesPresent) {
+ if (!('gdata_' in entry)) {
+ pendingGDataFiles.push(entry);
+ } else {
+ selection.allGDataFilesPresent =
+ FileManager.isAvaliableOffline_(entry.gdata_);
+ }
+ }
} else {
selection.directoryCount += 1;
+ // We cannot afford checking every file under this directory so
+ // we conservatively assume that some files are not present.
+ selection.allGDataFilesPresent = false;
}
}
@@ -2316,6 +2331,15 @@ FileManager.prototype = {
forcedShowTimeout = setTimeout(showThumbnails, 100);
onThumbnailLoaded();
+ if (this.fileTransferController_) {
+ this.fileTransferController_.selectionAvailable = false;
+ }
+
+ function maybeFireSummarized() {
+ if (pendingFiles.length == 0 && pendingGDataFiles.length == 0)
+ self.dispatchEvent(new cr.Event('selection-summarized'));
+ }
+
function cacheNextFile(fileEntry) {
if (fileEntry) {
// We're careful to modify the 'selection', rather than 'self.selection'
@@ -2328,7 +2352,21 @@ FileManager.prototype = {
if (pendingFiles.length) {
cacheEntryDateAndSize(pendingFiles.pop(), cacheNextFile);
} else {
- self.dispatchEvent(new cr.Event('selection-summarized'));
+ maybeFireSummarized();
+ }
+ }
+
+ function cacheNextGDataFile(fileEntry) {
+ // If selection.allGDataFilesPresent is already false we stop checking.
+ if (selection.allGDataFilesPresent && fileEntry) {
+ selection.allGDataFilesPresent =
+ FileManager.isAvaliableOffline_(fileEntry.gdata_);
+ }
+ if (selection.allGDataFilesPresent && pendingGDataFiles.length) {
+ cacheGDataProps(pendingGDataFiles.pop(), cacheNextGDataFile);
+ } else {
+ pendingGDataFiles = [];
+ maybeFireSummarized();
}
}
@@ -2347,6 +2385,8 @@ FileManager.prototype = {
}
cacheNextFile();
+ if (selection.allGDataFilesPresent)
+ cacheNextGDataFile();
};
/**
@@ -2695,6 +2735,16 @@ FileManager.prototype = {
return this.isOnGData() && this.isOffline();
};
+ /**
+ * Check if all the files in the current selection are available. The only
+ * case when files might be not available is when the selection contains
+ * uncached GData files and the browser is offline.
+ * @return {boolean} True if all files in the current selection are available.
+ */
+ FileManager.prototype.isSelectionAvailable = function() {
+ return !this.isOnGDataOffline() || this.selection.allGDataFilesPresent;
+ };
+
FileManager.prototype.isOnReadonlyDirectory = function() {
return this.directoryModel_.readonly;
};
@@ -3233,6 +3283,12 @@ FileManager.prototype = {
if (!selection.showBytes) text = text.substring(0, text.lastIndexOf(','));
}
this.previewSummary_.textContent = text;
+
+ this.updateOkButton_();
+ if (this.fileTransferController_) {
+ this.fileTransferController_.selectionAvailable =
+ this.isSelectionAvailable();
+ }
};
/**
@@ -3378,11 +3434,13 @@ FileManager.prototype = {
selectable = this.selection.directoryCount == 1 &&
this.selection.fileCount == 0;
} else if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE) {
- selectable = (this.selection.directoryCount == 0 &&
+ selectable = (this.isSelectionAvailable() &&
+ this.selection.directoryCount == 0 &&
this.selection.fileCount == 1);
} else if (this.dialogType_ ==
FileManager.DialogType.SELECT_OPEN_MULTI_FILE) {
- selectable = (this.selection.directoryCount == 0 &&
+ selectable = (this.isSelectionAvailable() &&
+ this.selection.directoryCount == 0 &&
this.selection.fileCount >= 1);
} else if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
if (this.isOnReadonlyDirectory()) {

Powered by Google App Engine
This is Rietveld 408576698