diff options
author | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-04 02:21:56 +0000 |
---|---|---|
committer | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-04 02:21:56 +0000 |
commit | b5c53f634287096fb3aa2a368591caf4a7cd4809 (patch) | |
tree | b450430e3b23ca9233e69a0c7ecbdc5de4c8b832 | |
parent | 5387fdd7cd0897297984ca90cdfdf444a9a509f2 (diff) | |
download | chromium_src-b5c53f634287096fb3aa2a368591caf4a7cd4809.zip chromium_src-b5c53f634287096fb3aa2a368591caf4a7cd4809.tar.gz chromium_src-b5c53f634287096fb3aa2a368591caf4a7cd4809.tar.bz2 |
Use volumeId instead of mountPath in fileBrowserPrivate.removeMount()
Since mountPath is being deprecated, this patch makes the removeMount() use volumeId. This significantly simplifies the code.
TEST=Tested manually with an archive.
BUG=316077
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=248147
R=benwells@chromium.org, kinaba@chromium.org
Review URL: https://codereview.chromium.org/135183013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248666 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 18 insertions, 44 deletions
diff --git a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_apitest.cc b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_apitest.cc index c775829..6f27fb3 100644 --- a/chrome/browser/chromeos/extensions/file_manager/file_browser_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/file_manager/file_browser_private_apitest.cc @@ -240,7 +240,7 @@ IN_PROC_BROWSER_TEST_F(FileBrowserPrivateApiTest, Mount) { // We will call fileBrowserPrivate.unmountVolume once. To test that method, we // check that UnmountPath is really called with the same value. - EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath(_, _, _)) + EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath(_, _, _)) .Times(0); EXPECT_CALL(*disk_mount_manager_mock_, UnmountPath( diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_mount.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_mount.cc index a21407a..c22bdf2 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_mount.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_mount.cc @@ -90,42 +90,32 @@ bool FileBrowserPrivateRemoveMountFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(params); drive::util::Log(logging::LOG_INFO, - "%s[%d] called. (mount_path: '%s')", + "%s[%d] called. (veolume_id: '%s')", name().c_str(), request_id(), - params->mount_path.c_str()); + params->volume_id.c_str()); set_log_on_completion(true); - std::vector<GURL> file_paths; - file_paths.push_back(GURL(params->mount_path)); - file_manager::util::GetSelectedFileInfo( - render_view_host(), - GetProfile(), - file_paths, - file_manager::util::NEED_LOCAL_PATH_FOR_OPENING, - base::Bind( - &FileBrowserPrivateRemoveMountFunction::GetSelectedFileInfoResponse, - this)); - return true; -} - -void FileBrowserPrivateRemoveMountFunction::GetSelectedFileInfoResponse( - const std::vector<ui::SelectedFileInfo>& files) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + using file_manager::VolumeManager; + using file_manager::VolumeInfo; + VolumeManager* volume_manager = VolumeManager::Get(GetProfile()); + if (!volume_manager) + return false; - if (files.size() != 1) { - SendResponse(false); - return; - } + VolumeInfo volume_info; + if (!volume_manager->FindVolumeInfoById(params->volume_id, &volume_info)) + return false; // TODO(tbarzic): Send response when callback is received, it would make more // sense than remembering issued unmount requests in file manager and showing // errors for them when MountCompleted event is received. DiskMountManager::GetInstance()->UnmountPath( - files[0].local_path.value(), + volume_info.mount_path.value(), chromeos::UNMOUNT_OPTIONS_NONE, DiskMountManager::UnmountPathCallback()); + SendResponse(true); + return true; } bool FileBrowserPrivateGetVolumeMetadataListFunction::RunImpl() { diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_mount.h b/chrome/browser/chromeos/extensions/file_manager/private_api_mount.h index db84b45..2109734 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_mount.h +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_mount.h @@ -53,11 +53,6 @@ class FileBrowserPrivateRemoveMountFunction // AsyncExtensionFunction overrides. virtual bool RunImpl() OVERRIDE; - - private: - // A callback method to handle the result of GetSelectedFileInfo. - void GetSelectedFileInfoResponse( - const std::vector<ui::SelectedFileInfo>& files); }; // Implements chrome.fileBrowserPrivate.getVolumeMetadataList method. diff --git a/chrome/browser/resources/file_manager/background/js/volume_manager.js b/chrome/browser/resources/file_manager/background/js/volume_manager.js index 8a8b9f2..574459e 100644 --- a/chrome/browser/resources/file_manager/background/js/volume_manager.js +++ b/chrome/browser/resources/file_manager/background/js/volume_manager.js @@ -629,8 +629,7 @@ VolumeManager.prototype.mountArchive = function( VolumeManager.prototype.unmount = function(volumeInfo, successCallback, errorCallback) { - chrome.fileBrowserPrivate.removeMount( - util.makeFilesystemUrl(volumeInfo.mountPath)); + chrome.fileBrowserPrivate.removeMount(volumeInfo.volumeId); var requestKey = this.makeRequestKey_('unmount', volumeInfo.volumeId); this.startRequest_(requestKey, successCallback, errorCallback); }; diff --git a/chrome/common/extensions/api/file_browser_private.idl b/chrome/common/extensions/api/file_browser_private.idl index f6a4f6a..ea99906 100644 --- a/chrome/common/extensions/api/file_browser_private.idl +++ b/chrome/common/extensions/api/file_browser_private.idl @@ -585,8 +585,8 @@ interface Functions { static void addMount(DOMString source, AddMountCallback callback); // Unmounts a mounted resource. - // |mountPath| A path of the mount. - static void removeMount(DOMString mountPath); + // |volumeId| An ID of the volume. + static void removeMount(DOMString volumeId); // Get the list of mounted volumes. // |callback| diff --git a/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js b/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js index 6f845a9..620fb21 100644 --- a/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js +++ b/chrome/test/data/extensions/api_test/file_browser/mount_test/test.js @@ -114,19 +114,9 @@ function validateObject(received, expected, name) { return true; } -function createFileUrl(fileName) { - var testExtensionId = 'ddammdhioacbehjngdmkjcjbnfginlla'; - var fileUrl = 'filesystem:chrome-extension://' + testExtensionId + - '/external/' + fileName; - return fileUrl; -} - chrome.test.runTests([ function removeMount() { - // The ID of this extension. - var fileUrl = createFileUrl('archive/archive_mount_path'); - - chrome.fileBrowserPrivate.removeMount(fileUrl); + chrome.fileBrowserPrivate.removeMount('archive:archive_mount_path'); // We actually check this one on C++ side. If MountLibrary.RemoveMount // doesn't get called, test will fail. |