From 2ca7c971186207ce362fd3f7f60ecb9b5bc3973a Mon Sep 17 00:00:00 2001 From: "hidehiko@chromium.org" Date: Tue, 17 Sep 2013 20:29:10 +0000 Subject: [PATCH] Remove 'drive-enabled-status-changed' event. Now, Drive's mounting state, including enable/disable state is managed by DriveIntegrationService via VolumeManager in C++. So we don't need to track it in Files.app in most cases. This is the first CL to clean up js-code. BUG=268817 TEST=Ran browser_tests --gtest_filter="*FileSystemExtensionApiTest*:*FileManagerBrowserTest*:*FileBrowserPrivateApiTest*" and tested manually. Review URL: https://chromiumcodereview.appspot.com/23465019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223674 0039d316-1c4b-4281-b951-d872f2087c98 --- .../resources/file_manager/js/directory_model.js | 39 ++++++---------------- .../resources/file_manager/js/volume_manager.js | 6 ++-- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js index 0d21e1f60510..f2ec7eb5c02b 100644 --- a/chrome/browser/resources/file_manager/js/directory_model.js +++ b/chrome/browser/resources/file_manager/js/directory_model.js @@ -213,9 +213,6 @@ DirectoryModel.prototype.start = function() { 'drive-status-changed', this.taskQueue_.run.bind( this.taskQueue_, this.onDriveStatusChanged_.bind(this))); - this.volumeManager_.addEventListener( - 'drive-enabled-status-changed', - this.onDriveEnabledStatusChanged_.bind(this)); this.taskQueue_.run(this.updateRoots_.bind(this)); }; @@ -234,27 +231,6 @@ DirectoryModel.prototype.getFileList = function() { }; /** - * Called when the drive enable status is changed. - * @param {cr.Event} event Event object for the status change. - * @private - */ -DirectoryModel.prototype.onDriveEnabledStatusChanged_ = function(event) { - this.taskQueue_.run(function(callback) { - // TODO(hidehiko): This should be moved to VolumeManager, when rootsList - // is moved to there. - this.taskQueue_.run(this.updateRoots_.bind(this)); - - if (!event.enabled && - PathUtil.isDriveBasedPath(this.getCurrentDirEntry().fullPath)) { - // Currently, this is on Drive's directory, but Drive file system is - // disabled. So, move back to the default directory. - this.changeDirectory(PathUtil.DEFAULT_DIRECTORY); - } - callback(); - }.bind(this)); -}; - -/** * Sort the file list. * @param {string} sortField Sort field. * @param {string} sortDirection "asc" or "desc". @@ -1203,12 +1179,17 @@ DirectoryModel.prototype.isDriveMounted = function() { */ DirectoryModel.prototype.onMountChanged_ = function(callback) { this.updateRoots_(function() { - var rootType = this.getCurrentRootType(); - - if ((rootType == RootType.ARCHIVE || rootType == RootType.REMOVABLE) && - !this.volumeManager_.isMounted(this.getCurrentRootPath())) { + var rootPath = this.getCurrentRootPath(); + // Reduce to the DRIVE root path, if necessary. + if (rootPath == RootDirectory.DRIVE_OFFLINE || + rootPath == RootDirectory.DRIVE_SHARED_WITH_ME || + rootPath == RootDirectory.DRIVE_RECENT) + rootPath = RootDirectory.DRIVE; + + // When the volume where we are is unmounted, fallback to + // DEFAULT_DIRECTORY. + if (!this.volumeManager_.isMounted(rootPath)) this.changeDirectory(PathUtil.DEFAULT_DIRECTORY); - } callback(); }.bind(this)); diff --git a/chrome/browser/resources/file_manager/js/volume_manager.js b/chrome/browser/resources/file_manager/js/volume_manager.js index b8950e1fdca9..0756ca02d80c 100644 --- a/chrome/browser/resources/file_manager/js/volume_manager.js +++ b/chrome/browser/resources/file_manager/js/volume_manager.js @@ -465,6 +465,8 @@ VolumeManager.getInstance = function(callback) { * Enables/disables Drive file system. Dispatches * 'drive-enabled-status-changed' event, when the enabled state is actually * changed. + * TODO(hidehiko): Enable/Disable of drive based on preference is managed by + * backend (C++) layer. Remove this. * @param {boolean} enabled True if Drive file system is enabled. */ VolumeManager.prototype.setDriveEnabled = function(enabled) { @@ -475,10 +477,6 @@ VolumeManager.prototype.setDriveEnabled = function(enabled) { // When drive is enabled, start to mount. if (enabled) this.mountDrive(function() {}, function() {}); - - var e = new cr.Event('drive-enabled-status-changed'); - e.enabled = enabled; - this.dispatchEvent(e); }; /** -- 2.11.4.GIT