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

Unified Diff: chrome/browser/resources/file_manager/js/file_manager.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_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 247988fe2a40ce58b2417fd6727ce0fcef5d8afd..9e7d3c7435905eefd364dbd02d13890f0d8e5444 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -542,7 +542,8 @@ FileManager.prototype = {
this.directoryModel_.fileListSelection,
GridItem.bind(null, this),
this.copyManager_,
- this.directoryModel_);
+ this.directoryModel_,
+ this.commands_);
controller.attachDragSource(this.table_.list);
controller.attachDropTarget(this.table_.list);
controller.attachDragSource(this.grid_);
@@ -1906,7 +1907,7 @@ FileManager.prototype = {
if (entry.gdata_.isHosted) {
listItem.classList.add('gdata-hosted');
}
- if (entry.isDirectory || FileManager.isAvaliableOffline_(entry.gdata_)) {
+ if (entry.isDirectory || FileType.isAvaliableOffline_(entry.gdata_)) {
listItem.classList.add('gdata-present');
}
}.bind(this));
@@ -2038,7 +2039,7 @@ FileManager.prototype = {
FileManager.prototype.displayDateInDiv_ = function(div, filesystemProps) {
if (!filesystemProps) return;
- if (this.directoryModel_.isSystemDirectoy &&
+ if (this.directoryModel_.isSystemDirectory &&
filesystemProps.modificationTime.getTime() == 0) {
// Mount points for FAT volumes have this time associated with them.
// We'd rather display nothing than this bogus date.
@@ -2151,6 +2152,7 @@ FileManager.prototype = {
directoryCount: 0,
bytes: 0,
showBytes: false,
+ allGDataFilesPresent: false,
iconType: null,
indexes: this.currentList_.selectionModel.selectedIndexes
};
@@ -2265,6 +2267,14 @@ FileManager.prototype = {
this.dispatchEvent(new cr.Event('selection-summarized'));
}.bind(this));
+
+ if (this.isOnGData()) {
+ FileType.checkOfflineAvailability(
+ selection.entries, selection.urls, function(result) {
+ selection.allGDataFilesPresent = result;
+ this.updateOkButton_();
+ }.bind(this));
+ }
};
/**
@@ -2386,8 +2396,7 @@ FileManager.prototype = {
FileManager.prototype.isOnGData = function() {
- return this.directoryModel_ &&
- this.directoryModel_.rootPath == '/' + DirectoryModel.GDATA_DIRECTORY;
+ return this.directoryModel_.isOnGData;
};
FileManager.prototype.getMetadataProvider = function() {
@@ -2574,18 +2583,17 @@ FileManager.prototype = {
FileManager.prototype.executeIfAvailable_ = function(urls, callback) {
if (this.isOnGDataOffline()) {
- chrome.fileBrowserPrivate.getGDataFileProperties(urls, function(props) {
- for (var i = 0; i != props.length; i++) {
- if (!FileManager.isAvaliableOffline_(props[i])) {
- this.alert.showHtml(
- str('OFFLINE_HEADER'),
- strf(
- urls.length == 1 ?
- 'OFFLINE_MESSAGE' :
- 'OFFLINE_MESSAGE_PLURAL',
- str('OFFLINE_COLUMN_LABEL')));
- return;
- }
+ FileType.checkOfflineAvailability(
+ null /* entries */, urls, function(result) {
+ if (!result) {
+ this.alert.showHtml(
+ str('OFFLINE_HEADER'),
+ strf(
+ urls.length == 1 ?
+ 'OFFLINE_MESSAGE' :
+ 'OFFLINE_MESSAGE_PLURAL',
+ str('OFFLINE_COLUMN_LABEL')));
+ return;
}
callback(urls);
}.bind(this));
@@ -2594,10 +2602,6 @@ FileManager.prototype = {
}
};
- FileManager.isAvaliableOffline_ = function(gdata) {
- return gdata.isPresent && !gdata.isHosted;
- };
-
FileManager.prototype.isOffline = function() {
return !navigator.onLine;
};
@@ -2611,6 +2615,7 @@ FileManager.prototype = {
this.dialogContainer_.removeAttribute('offline');
}
this.directoryModel_.offline = this.isOffline();
+ this.updateOkButton_();
};
FileManager.prototype.isOnGDataOffline = function() {
@@ -3288,18 +3293,32 @@ FileManager.prototype = {
this.updateSelectAllCheckboxState_(selectAllCheckbox);
};
+ /**
+ * 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.updateOkButton_ = function(event) {
var selectable;
- if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) {
+ if (!this.selection) {
+ selectable = false;
+ } else if (this.dialogType_ == FileManager.DialogType.SELECT_FOLDER) {
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