diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 20:01:55 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 20:01:55 +0000 |
commit | 5d5a21d42f4abb179f3692889dc4afc6e653edfb (patch) | |
tree | f8553ad542cad399076639cf1d65fc888048415a | |
parent | dd85d3925c0b9a3123526117f217ee5f8bac9e3b (diff) | |
download | chromium_src-5d5a21d42f4abb179f3692889dc4afc6e653edfb.zip chromium_src-5d5a21d42f4abb179f3692889dc4afc6e653edfb.tar.gz chromium_src-5d5a21d42f4abb179f3692889dc4afc6e653edfb.tar.bz2 |
Implement special path and mimetype check in file_manager/filesystem_api_util.
Previously, only the fixed path for Drive mount point was treated as "special",
meaning that it does not correspond to a native local path. With this CL, all
mount points with non-"NativeLocal" file system types are handled as special.
Since mimetype metadata is only available for Drive as of now, on other special
paths, the GetSpecialPathMimeType function returns success with empty mimetype.
BUG=367028
Review URL: https://codereview.chromium.org/304503007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273560 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/file_manager/filesystem_api_util.cc | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/file_manager/filesystem_api_util.cc b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc index 43e07b7..04dc1d5 100644 --- a/chrome/browser/chromeos/file_manager/filesystem_api_util.cc +++ b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc @@ -10,7 +10,13 @@ #include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_system_interface.h" #include "chrome/browser/chromeos/drive/file_system_util.h" +#include "chrome/browser/chromeos/file_manager/app_id.h" +#include "chrome/browser/chromeos/file_manager/fileapi_util.h" +#include "chrome/browser/extensions/extension_util.h" +#include "chrome/browser/profiles/profile.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/storage_partition.h" +#include "webkit/browser/fileapi/file_system_context.h" namespace file_manager { namespace util { @@ -53,8 +59,31 @@ bool IsUnderNonNativeLocalPath(Profile* profile, const base::FilePath& path) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - // TODO(kinaba): support other types of volumes besides Drive. - return drive::util::IsUnderDriveMountPoint(path); + GURL url; + if (!util::ConvertAbsoluteFilePathToFileSystemUrl( + profile, path, kFileManagerAppId, &url)) { + return false; + } + + content::StoragePartition* partition = + content::BrowserContext::GetStoragePartitionForSite( + profile, + extensions::util::GetSiteForExtensionId(kFileManagerAppId, profile)); + fileapi::FileSystemContext* context = partition->GetFileSystemContext(); + + fileapi::FileSystemURL filesystem_url = context->CrackURL(url); + if (!filesystem_url.is_valid()) + return false; + + switch (filesystem_url.type()) { + case fileapi::kFileSystemTypeNativeLocal: + case fileapi::kFileSystemTypeRestrictedNativeLocal: + return false; + default: + // The path indeed corresponds to a mount point not associated with a + // native local path. + return true; + } } void GetNonNativeLocalPathMimeType( @@ -62,8 +91,18 @@ void GetNonNativeLocalPathMimeType( const base::FilePath& path, const base::Callback<void(bool, const std::string&)>& callback) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); + DCHECK(IsUnderNonNativeLocalPath(profile, path)); + + if (!drive::util::IsUnderDriveMountPoint(path)) { + // Non-drive mount point does not have mime types as metadata. Just return + // success with empty mime type value. + content::BrowserThread::PostTask( + content::BrowserThread::UI, + FROM_HERE, + base::Bind(callback, true /* success */, std::string())); + return; + } - // TODO(kinaba): support other types of volumes besides Drive. drive::FileSystemInterface* file_system = drive::util::GetFileSystemByProfile(profile); if (!file_system) { |