diff options
author | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-24 17:44:04 +0000 |
---|---|---|
committer | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-24 17:44:04 +0000 |
commit | 99a310275f66b8bf40b01bc74278d4ca188304fe (patch) | |
tree | d406c5e38ab0e22937c050b09151921262a06b39 | |
parent | 0383374756931ed340b1f2e10af20246dcbf95dd (diff) | |
download | chromium_src-99a310275f66b8bf40b01bc74278d4ca188304fe.zip chromium_src-99a310275f66b8bf40b01bc74278d4ca188304fe.tar.gz chromium_src-99a310275f66b8bf40b01bc74278d4ca188304fe.tar.bz2 |
Display the stub Drive implementation in Offline, when nothing is cached.
When a user launches Chrome OS for the first time in the offline mode, then the C++ side of Drive integration will return an error when trying to access Drive contents, since nothing is cached, and nothing can't be fetched due to lack of connection. This patch shows the empty Drive (stub) in this case. If the promo is available, then it will be displayed over the list.
Along the way, the promo has been cleaned up - the redundant space has been removed (after V1).
TEST=Launch Chrome OS on a new profile, without network. Click on Drive.
BUG=253464, 253470
Review URL: https://chromiumcodereview.appspot.com/17591009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208232 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 22 insertions, 6 deletions
diff --git a/chrome/browser/resources/file_manager/css/drive_welcome.css b/chrome/browser/resources/file_manager/css/drive_welcome.css index 8f4332c..a3c5ddb 100644 --- a/chrome/browser/resources/file_manager/css/drive_welcome.css +++ b/chrome/browser/resources/file_manager/css/drive_welcome.css @@ -125,7 +125,7 @@ left: 0; position: absolute; right: 0; - top: 28px; /* Leave room for the file list header. */ + top: 0; } .dialog-container:not([drive-welcome='page']) .drive-welcome.page { @@ -139,7 +139,6 @@ .drive-welcome.page .drive-welcome-wrapper { -webkit-box-align: center; -webkit-box-orient: vertical; - background-position: 0 50px; background-size: 520px 173px; bottom: 0; display: -webkit-box; diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js index 8780e0e..7520201 100644 --- a/chrome/browser/resources/file_manager/js/directory_model.js +++ b/chrome/browser/resources/file_manager/js/directory_model.js @@ -803,12 +803,13 @@ DirectoryModel.prototype.changeDirectory = function(path, opt_errorCallback) { /** * Resolves absolute directory path. Handles Drive stub. If the drive is * mounting, callbacks will be called after the mount is completed. + * * @param {string} path Path to the directory. * @param {function(DirectoryEntry} successCallback Success callback. * @param {function(FileError} errorCallback Error callback. */ -DirectoryModel.prototype.resolveDirectory = function(path, successCallback, - errorCallback) { +DirectoryModel.prototype.resolveDirectory = function( + path, successCallback, errorCallback) { if (PathUtil.getRootType(path) == RootType.DRIVE) { var driveStatus = this.volumeManager_.getDriveStatus(); if (!this.isDriveMounted() && @@ -826,8 +827,24 @@ DirectoryModel.prototype.resolveDirectory = function(path, successCallback, return; } + var onError = function(error) { + // Handle the special case, when in offline mode, and there are no cached + // contents on the C++ side. In such case, let's display the stub. + // The INVALID_STATE_ERR error code is returned from the drive filesystem + // in such situation. + // + // TODO(mtomasz, hashimoto): Consider rewriting this logic. + // crbug.com/253464. + if (PathUtil.getRootType(path) == RootType.DRIVE && + error.code == FileError.INVALID_STATE_ERR) { + successCallback(DirectoryModel.fakeDriveEntry_); + return; + } + errorCallback(error); + }.bind(this); + this.root_.getDirectory(path, {create: false}, - successCallback, errorCallback); + successCallback, onError); }; /** diff --git a/chrome/browser/resources/file_manager/js/sidebar.js b/chrome/browser/resources/file_manager/js/sidebar.js index f38c7a1..3b9053d 100644 --- a/chrome/browser/resources/file_manager/js/sidebar.js +++ b/chrome/browser/resources/file_manager/js/sidebar.js @@ -181,7 +181,7 @@ DirectoryTreeUtil.updateSubDirectories = function( DirectoryTreeUtil.updateSubDirectories( item, dm, successCallback, opt_errorCallback); }, - opt_errorCallback); + opt_errorCallback || function() {}); return; } |