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

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

Issue 9855024: Postpone connecting to GData even more, provide progress indication. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 2ba50c6f6d565aaa358750ce85625da077bd5980..0140af90b8c4b156c3fe1cf909a84612cb1a1444 100644
--- a/chrome/browser/resources/file_manager/js/file_manager.js
+++ b/chrome/browser/resources/file_manager/js/file_manager.js
@@ -635,6 +635,7 @@ FileManager.prototype = {
this.spinner_ = this.dialogDom_.querySelector('.spinner');
this.showSpinner_(false);
this.butter_ = this.dialogDom_.querySelector('.butter-bar');
+ this.unmountedPanel_ = this.dialogDom_.querySelector('.unmounted-panel');
cr.ui.Table.decorate(this.table_);
cr.ui.Grid.decorate(this.grid_);
@@ -800,22 +801,77 @@ FileManager.prototype = {
this.rootsList_.dataModel = this.directoryModel_.rootsList;
this.directoryModel_.updateRoots(function() {
self.rootsList_.endBatchUpdates();
- });
+ }, this.gdataMounted_);
};
- FileManager.prototype.initGData_ = function() {
+ FileManager.prototype.initGData_ = function(retry) {
dgozman 2012/03/26 16:30:21 |retry| is not a meaningful name. Does it mean we
Vladislav Kaznacheev 2012/03/27 09:25:35 changed to |dirChanged| On 2012/03/26 16:30:21, dg
+ if (this.gdataMountTimer_) // Already mounting, do nothing.
+ return;
+
+ this.initUnmountedPanel_();
+
+ this.unmountedPanel_.removeAttribute('error');
+ if (retry) {
+ // When retrying we do not hide "Retry" and "Learn more".
+ this.unmountedPanel_.setAttribute('loading', true);
+ } else {
+ // When trying on a GData directory change we want to see a clear panel.
+ this.unmountedPanel_.removeAttribute('retry');
+ this.unmountedPanel_.removeAttribute('loading');
+ setTimeout(function() {
+ if (this.gdataMountTimer_) { // Still mounting.
+ this.unmountedPanel_.setAttribute('loading', true);
+ }
+ }.bind(this), 500); // Avoid flicker if the mount is quick.
+ }
+
metrics.startInterval('Load.GData');
chrome.fileBrowserPrivate.addMount('', 'gdata', {});
- if (this.gdataMountTimer_) {
- clearTimeout(this.gdataMountTimer_);
+
+ this.gdataMountTimer_ = setTimeout(
+ this.onGDataUnreachable_.bind(this, 'GData mount timeout'),
+ 10 * 1000) ;
+ };
+
+ FileManager.prototype.onGDataUnreachable_ = function(message) {
+ console.warn(message);
+ this.gdataMountTimer_ = null;
+ if (this.isOnGData()) {
+ this.unmountedPanel_.removeAttribute('loading');
+ this.unmountedPanel_.setAttribute('error', true);
+ this.unmountedPanel_.setAttribute('retry', true);
}
- this.gdataMountTimer_ = setTimeout(function() {
- this.gdataMountTimer_ = null;
- if (this.isOnGData()) {
- // TODO(kaznacheev): show the message in the file list space.
- this.alert.show('Could not connect to GData');
- }
- }.bind(this), 10 * 1000);
+ };
+
+ FileManager.prototype.initUnmountedPanel_ = function() {
dgozman 2012/03/26 16:30:21 Consider not so generic |gdataPanel| or |gdataNotM
Vladislav Kaznacheev 2012/03/27 09:25:35 Done.
+ if (this.unmountedPanel_.firstElementChild)
+ return;
+
+ var loading = this.document_.createElement('div');
+ loading.className = 'gdata loading';
+ loading.textContent = strf('GDATA_LOADING', str('GDATA_PRODUCT_NAME'));
+ this.unmountedPanel_.appendChild(loading);
+
+ var error = this.document_.createElement('div');
+ error.className = 'gdata error';
+ error.textContent = strf('GDATA_CANNOT_REACH', str('GDATA_PRODUCT_NAME'));
+ this.unmountedPanel_.appendChild(error);
+
+ var retry = this.document_.createElement('button');
+ retry.className = 'gdata retry';
+ retry.textContent = str('GDATA_RETRY');
+ retry.onclick = this.initGData_.bind(this, true /* retry */);
+ this.unmountedPanel_.appendChild(retry);
+
+ var learnMore = this.document_.createElement('div');
+ learnMore.className = 'gdata learn-more';
+ this.unmountedPanel_.appendChild(learnMore);
+
+ var learnMoreLink = this.document_.createElement('a');
+ learnMoreLink.textContent = str('GDATA_LEARN_MORE');
+ learnMoreLink.href = 'javascript://'; // TODO: Set a proper link URL.
+ learnMoreLink.className = 'gdata learn-more';
+ learnMore.appendChild(learnMoreLink);
};
/**
@@ -2549,6 +2605,7 @@ FileManager.prototype = {
changeDirectoryTo = this.directoryModel_.rootPath;
}
} else {
+ this.onGDataUnreachable_('GData mount failed: ' + event.status);
this.gdataMounted_ = false;
this.gdataMountInfo_ = null;
}
@@ -2606,7 +2663,7 @@ FileManager.prototype = {
if (changeDirectoryTo) {
self.directoryModel_.changeDirectory(changeDirectoryTo);
}
- });
+ }, self.gdataMounted_);
});
};
@@ -3470,7 +3527,7 @@ FileManager.prototype = {
this.watchedDirectoryUrl_ = null;
}
- if (event.newDirEntry.fullPath != '/') {
+ if (event.newDirEntry.fullPath != '/' && !event.newDirEntry.unmounted) {
this.watchedDirectoryUrl_ = event.newDirEntry.toURL();
chrome.fileBrowserPrivate.addFileWatch(this.watchedDirectoryUrl_,
function(result) {
@@ -3483,11 +3540,15 @@ FileManager.prototype = {
this.updateVolumeMetadata_();
+ if (event.newDirEntry.unmounted)
+ this.dialogContainer_.setAttribute('unmounted');
+ else
+ this.dialogContainer_.removeAttribute('unmounted');
+
if (this.isOnGData()) {
this.dialogContainer_.setAttribute('gdata', true);
- if (!this.requestedGDataMount_) { // Request GData mount only once.
- this.requestedGDataMount_ = true;
- this.initGData_();
+ if (event.newDirEntry.unmounted) {
+ this.initGData_(false /* first try */);
}
} else {
this.dialogContainer_.removeAttribute('gdata');

Powered by Google App Engine
This is Rietveld 408576698