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 ccf4a84df57d0050c8260f3578ca6e479fc0544e..8a435cb96cf9b0c10508a61e8192adbb4c78a52d 100644 |
--- a/chrome/browser/chromeos/file_manager/filesystem_api_util.cc |
+++ b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc |
@@ -9,6 +9,9 @@ |
#include "base/callback.h" |
#include "base/files/file.h" |
#include "base/files/file_path.h" |
+#include "chrome/browser/chromeos/arc/arc_util.h" |
+#include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_url_util.h" |
+#include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.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 +19,7 @@ |
#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_service_manager.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( |
@@ -181,6 +198,23 @@ void GetNonNativeLocalPathMimeType( |
return; |
} |
+ if (arc::IsArcAllowedForProfile(profile) && |
+ base::FilePath(arc::kContentFileSystemMountPointPath).IsParent(path)) { |
+ GURL arc_url = arc::PathToArcUrl(path); |
+ auto* runner = arc::ArcServiceManager::GetGlobalService< |
+ arc::ArcFileSystemOperationRunner>(); |
+ if (!runner) { |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, FROM_HERE, |
+ base::BindOnce(callback, false, std::string())); |
+ return; |
+ } |
+ runner->GetMimeType( |
+ arc_url, 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. |