Commit 1ef9d382 authored by Cherie Cheung's avatar Cherie Cheung Committed by Commit Bot

ConvertPathToArcUrl: Support DriveFS via Seneschal

For ARCVM, DriveFS path will be handled by Seneschal SharePath
request. For ARC++, legacy fd passing will be kept for the time
being (b/157297349).

Bug: 147618164
Test: Files on DriveFS can be opened by an android app
Change-Id: I99e5704610d5a922a95e4c3d885b6b62d9b9a144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212114Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Cherie Cheung <cherieccy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774017}
parent 1a86dd7e
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/fileapi/external_file_url_util.h" #include "chrome/browser/chromeos/fileapi/external_file_url_util.h"
#include "chrome/browser/chromeos/fileapi/file_system_backend.h" #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
#include "chrome/browser/chromeos/guest_os/guest_os_share_path.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/smb_client/smb_service.h" #include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/chromeos/smb_client/smb_service_factory.h" #include "chrome/browser/chromeos/smb_client/smb_service_factory.h"
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
#include "chrome/browser/download/download_prefs.h" #include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "components/arc/arc_util.h"
#include "components/drive/file_system_core_util.h" #include "components/drive/file_system_core_util.h"
#include "components/user_manager/user.h" #include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
...@@ -70,6 +72,8 @@ constexpr char kArcRemovableMediaContentUrlPrefix[] = ...@@ -70,6 +72,8 @@ constexpr char kArcRemovableMediaContentUrlPrefix[] =
"content://org.chromium.arc.volumeprovider/removable/"; "content://org.chromium.arc.volumeprovider/removable/";
constexpr char kArcMyFilesContentUrlPrefix[] = constexpr char kArcMyFilesContentUrlPrefix[] =
"content://org.chromium.arc.volumeprovider/MyFiles/"; "content://org.chromium.arc.volumeprovider/MyFiles/";
constexpr char kArcDriveContentUrlPrefix[] =
"content://org.chromium.arc.volumeprovider/MyDrive/";
Profile* GetPrimaryProfile() { Profile* GetPrimaryProfile() {
if (!user_manager::UserManager::IsInitialized()) if (!user_manager::UserManager::IsInitialized())
...@@ -413,17 +417,34 @@ bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) { ...@@ -413,17 +417,34 @@ bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) {
} }
bool force_external = false; bool force_external = false;
// Force external URL for DriveFS, Crostini and smbfs. // Convert paths under DriveFS.
drive::DriveIntegrationService* integration_service = const drive::DriveIntegrationService* integration_service =
drive::util::GetIntegrationServiceByProfile(primary_profile); drive::util::GetIntegrationServiceByProfile(primary_profile);
if ((integration_service && if (integration_service &&
integration_service->GetMountPointPath().AppendRelativePath( integration_service->GetMountPointPath().AppendRelativePath(
path, &relative_path)) || path, &relative_path)) {
GetCrostiniMountDirectory(primary_profile) if (arc::IsArcVmEnabled()) {
guest_os::GuestOsSharePath::GetForProfile(primary_profile)
->SharePath(arc::kArcVmName, path, /*persist=*/false,
base::DoNothing());
*arc_url_out =
GURL(kArcDriveContentUrlPrefix)
.Resolve(net::EscapePath(relative_path.AsUTF8Unsafe()));
return true;
} else {
// TODO(b/157297349): For backward compatibility with ARC++ P, force
// external URL for DriveFS.
force_external = true;
}
}
// Force external URL for Crostini.
if (GetCrostiniMountDirectory(primary_profile)
.AppendRelativePath(path, &relative_path)) { .AppendRelativePath(path, &relative_path)) {
force_external = true; force_external = true;
} }
// Force external URL for smbfs.
chromeos::smb_client::SmbService* smb_service = chromeos::smb_client::SmbService* smb_service =
chromeos::smb_client::SmbServiceFactory::Get(primary_profile); chromeos::smb_client::SmbServiceFactory::Get(primary_profile);
if (smb_service) { if (smb_service) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
#include "components/arc/arc_service_manager.h" #include "components/arc/arc_service_manager.h"
#include "components/arc/arc_util.h"
#include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_bridge_service.h"
#include "components/arc/test/connection_holder_util.h" #include "components/arc/test/connection_holder_util.h"
#include "components/arc/test/fake_file_system_instance.h" #include "components/arc/test/fake_file_system_instance.h"
...@@ -643,7 +644,7 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_Crostini) { ...@@ -643,7 +644,7 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_Crostini) {
url); url);
} }
TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_Special) { TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_MyDriveLegacy) {
GURL url; GURL url;
EXPECT_TRUE( EXPECT_TRUE(
ConvertPathToArcUrl(drive_mount_point_.AppendASCII("a/b/c"), &url)); ConvertPathToArcUrl(drive_mount_point_.AppendASCII("a/b/c"), &url));
...@@ -657,6 +658,18 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_Special) { ...@@ -657,6 +658,18 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_Special) {
url); url);
} }
TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_MyDriveArcvm) {
auto* command_line = base::CommandLine::ForCurrentProcess();
command_line->InitFromArgv({"", "--enable-arcvm"});
EXPECT_TRUE(arc::IsArcVmEnabled());
GURL url;
EXPECT_TRUE(
ConvertPathToArcUrl(drive_mount_point_.AppendASCII("a/b/c"), &url));
EXPECT_EQ(GURL("content://org.chromium.arc.volumeprovider/"
"MyDrive/a/b/c"),
url);
}
TEST_F(FileManagerPathUtilConvertUrlTest, TEST_F(FileManagerPathUtilConvertUrlTest,
ConvertToContentUrls_InvalidMountType) { ConvertToContentUrls_InvalidMountType) {
base::RunLoop run_loop; base::RunLoop run_loop;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment