[Files] substitute Fusebox path for "mount archive"
ChromeOS' /usr/bin/mount-zip (or similar FUSE helper programs) run in a
separate process to ash-chrome and so they have to use the Fusebox
flavored base::FilePath.
In particular, this fixes "double-click in the Files app to open (mount)
a zip file served by the ODFS (One Drive File System) extension".
Bug: b:255509287
Test: Manual
Change-Id: I3950702c6af3a0d7773eb8efe191e5566ec30f10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5208290
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Josh Simmons <simmonsjosh@google.com>
Auto-Submit: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1251738}
diff --git a/chrome/browser/ash/extensions/file_manager/private_api_mount.cc b/chrome/browser/ash/extensions/file_manager/private_api_mount.cc
index fa1ea4a5..4d9e52d 100644
--- a/chrome/browser/ash/extensions/file_manager/private_api_mount.cc
+++ b/chrome/browser/ash/extensions/file_manager/private_api_mount.cc
@@ -22,6 +22,8 @@
#include "chrome/browser/ash/file_manager/file_tasks_notifier.h"
#include "chrome/browser/ash/file_manager/fileapi_util.h"
#include "chrome/browser/ash/file_manager/volume_manager.h"
+#include "chrome/browser/ash/fileapi/file_system_backend.h"
+#include "chrome/browser/ash/fusebox/fusebox_server.h"
#include "chrome/browser/ash/smb_client/smb_service.h"
#include "chrome/browser/ash/smb_client/smb_service_factory.h"
#include "chrome/browser/profiles/profile.h"
@@ -68,21 +70,21 @@
}
set_log_on_completion(true);
- path_ = file_manager::util::GetLocalPathFromURL(render_frame_host(), profile,
- GURL(params->file_url));
+ const scoped_refptr<storage::FileSystemContext> file_system_context =
+ file_manager::util::GetFileSystemContextForRenderFrameHost(
+ profile, render_frame_host());
+ const storage::FileSystemURL fs_url(
+ file_system_context->CrackURLInFirstPartyContext(GURL(params->file_url)));
+ path_ = ash::FileSystemBackend::CanHandleURL(fs_url)
+ ? (fs_url.TypeImpliesPathIsReal()
+ ? fs_url.path()
+ : fusebox::Server::SubstituteFuseboxFilePath(fs_url))
+ : base::FilePath();
if (auto* notifier =
file_manager::file_tasks::FileTasksNotifier::GetForProfile(profile)) {
- const scoped_refptr<storage::FileSystemContext> file_system_context =
- file_manager::util::GetFileSystemContextForRenderFrameHost(
- profile, render_frame_host());
-
std::vector<storage::FileSystemURL> urls;
- const storage::FileSystemURL url =
- file_system_context->CrackURLInFirstPartyContext(
- GURL(params->file_url));
- urls.push_back(url);
-
+ urls.push_back(std::move(fs_url));
notifier->NotifyFileTasks(urls);
}
@@ -155,8 +157,17 @@
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- base::FilePath path = file_manager::util::GetLocalPathFromURL(
- render_frame_host(), profile, GURL(params->file_url));
+ const scoped_refptr<storage::FileSystemContext> file_system_context =
+ file_manager::util::GetFileSystemContextForRenderFrameHost(
+ profile, render_frame_host());
+ const storage::FileSystemURL fs_url(
+ file_system_context->CrackURLInFirstPartyContext(GURL(params->file_url)));
+ base::FilePath path =
+ ash::FileSystemBackend::CanHandleURL(fs_url)
+ ? (fs_url.TypeImpliesPathIsReal()
+ ? fs_url.path()
+ : fusebox::Server::SubstituteFuseboxFilePath(fs_url))
+ : base::FilePath();
DiskMountManager* const disk_mount_manager = DiskMountManager::GetInstance();
DCHECK(disk_mount_manager);