Chromium Code Reviews| Index: chrome/browser/chromeos/file_manager/filesystem_api_util.cc |
| diff --git a/chrome/browser/chromeos/file_manager/filesystem_api_util.cc b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc |
| index aa6f9bec6df342afe5b867a1d5423055ac8db6d6..51752828042aab0936d0160f171f75fadbc0450c 100644 |
| --- a/chrome/browser/chromeos/file_manager/filesystem_api_util.cc |
| +++ b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/callback.h" |
| #include "base/files/file.h" |
| #include "base/files/file_path.h" |
| +#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.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" |
| @@ -16,6 +17,9 @@ |
| #include "chrome/browser/chromeos/file_system_provider/provided_file_system_interface.h" |
| #include "chrome/browser/extensions/extension_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "components/arc/arc_bridge_service.h" |
| +#include "components/arc/arc_service_manager.h" |
| +#include "components/arc/common/file_system.mojom.h" |
| #include "components/drive/chromeos/file_system_interface.h" |
| #include "components/drive/file_errors.h" |
| #include "components/drive/file_system_core_util.h" |
| @@ -59,6 +63,19 @@ void GetMimeTypeAfterGetMetadataForProvidedFileSystem( |
| callback.Run(true, *metadata->mime_type); |
| } |
| +// Helper function used to implement GetNonNativeLocalPathMimeType. It passes |
| +// the returned mime type to the callback. |
| +void GetMimeTypeAfterGetMimeTypeForArcContentFileSystem( |
| + const base::Callback<void(bool, const std::string&)>& callback, |
| + const base::Optional<std::string>& mime_type) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + if (mime_type.has_value()) { |
| + callback.Run(true, mime_type.value()); |
| + } else { |
| + callback.Run(false, std::string()); |
| + } |
| +} |
| + |
| // Helper function to converts a callback that takes boolean value to that takes |
| // File::Error, by regarding FILE_OK as the only successful value. |
| void BoolCallbackAsFileErrorCallback( |
| @@ -183,6 +200,24 @@ void GetNonNativeLocalPathMimeType( |
| return; |
| } |
| + if (base::FilePath(arc::kContentFileSystemMountPointPath).IsParent(path)) { |
| + GURL arc_url = arc::PathToArcUrl(path); |
| + auto* file_system_instance = ARC_GET_INSTANCE_FOR_METHOD( |
|
Shuhei Takahashi (google)
2017/05/30 09:30:17
Please add ArcFileSystemOperationRunner::GetMimeTy
hashimoto
2017/05/30 10:51:23
Ugh, I totally forgot about that deferring feature
|
| + arc::ArcServiceManager::Get()->arc_bridge_service()->file_system(), |
| + GetMimeType); |
| + if (!file_system_instance) { |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::UI, FROM_HERE, |
| + base::Bind(callback, false, std::string())); |
| + return; |
| + } |
| + file_system_instance->GetMimeType( |
| + arc_url.spec(), |
| + base::Bind(&GetMimeTypeAfterGetMimeTypeForArcContentFileSystem, |
| + callback)); |
| + return; |
| + } |
| + |
| // We don't have a way to obtain metadata other than drive and FSP. Returns an |
| // error with empty MIME type, that leads fallback guessing mime type from |
| // file extensions. |