0

Remove ExternalFileSystemBackend which is only used in ChromeOS

ExternalFileSystemBackend and FileSystemContext::external_backend() is
only used in ChromeOS, so the interface can be deleted, and
storage::FileSystemContext::external_backend() is moved to
ash::FileSystemBackend::Get().

Bug: 257279
Bug: b/293534917
Change-Id: Id6667b4f48f13319f5af08a6aa1ca8dda30de530
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4745222
Reviewed-by: Toni Barzic <tbarzic@chromium.org>
Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1180139}
This commit is contained in:
Joel Hockey
2023-08-07 06:01:24 +00:00
committed by Chromium LUCI CQ
parent bd36172103
commit d096e5402f
20 changed files with 111 additions and 127 deletions

@ -18,6 +18,7 @@
#include "chrome/browser/ash/file_manager/io_task.h"
#include "chrome/browser/ash/file_manager/path_util.h"
#include "chrome/browser/ash/file_manager/volume_manager_factory.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/ash/components/disks/fake_disk_mount_manager.h"
#include "content/public/test/browser_task_environment.h"
@ -25,7 +26,6 @@
#include "extensions/browser/test_event_router.h"
#include "extensions/common/extension.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/browser/test/test_file_system_context.h"
#include "testing/gmock/include/gmock/gmock.h"
@ -141,13 +141,12 @@ class FileManagerEventRouterTest : public testing::Test {
storage::kFileSystemTypeLocal, storage::FileSystemMountOption(),
temp_dir_.GetPath());
file_manager::util::GetFileSystemContextForSourceURL(
profile_.get(), GURL("chrome-extension://abc"))
->external_backend()
->GrantFileAccessToOrigin(
url::Origin::Create(GURL("chrome-extension://abc")),
base::FilePath(file_manager::util::GetDownloadsMountPointName(
profile_.get())));
auto* context = file_manager::util::GetFileSystemContextForSourceURL(
profile_.get(), GURL("chrome-extension://abc"));
ash::FileSystemBackend::Get(*context)->GrantFileAccessToOrigin(
url::Origin::Create(GURL("chrome-extension://abc")),
base::FilePath(
file_manager::util::GetDownloadsMountPointName(profile_.get())));
}
const io_task::EntryStatus CreateSuccessfulEntryStatusForFileName(

@ -32,6 +32,7 @@
#include "chrome/browser/ash/file_manager/volume_manager.h"
#include "chrome/browser/ash/file_system_provider/icon_set.h"
#include "chrome/browser/ash/file_system_provider/provided_file_system_info.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/ash/policy/dlp/dlp_files_controller_ash.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/policy/dlp/dlp_rules_manager.h"
@ -58,7 +59,6 @@
#include "extensions/common/install_warning.h"
#include "google_apis/common/test_util.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
using ::testing::_;
using ::testing::ReturnRef;
@ -809,12 +809,14 @@ IN_PROC_BROWSER_TEST_F(FileManagerPrivateApiDlpTest, DlpBlockCopy) {
auto* file_system_context =
file_manager::util::GetFileManagerFileSystemContext(browser()->profile());
file_system_context->external_backend()->GrantFileAccessToOrigin(
url::Origin::Create(
GURL("chrome-extension://"
"pkplfbidichfdicaijlchgnapepdginl/")), // Testing
// extension
base::FilePath(base::StrCat({kLocalMountPointName, "/", kTestFileName})));
ash::FileSystemBackend::Get(*file_system_context)
->GrantFileAccessToOrigin(
url::Origin::Create(
GURL("chrome-extension://"
"pkplfbidichfdicaijlchgnapepdginl/")), // Testing
// extension
base::FilePath(
base::StrCat({kLocalMountPointName, "/", kTestFileName})));
storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
"drivefs-delayed_mount_2", storage::kFileSystemTypeDriveFs,

@ -9,11 +9,11 @@
#include "base/strings/string_number_conversions.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/extensions/chrome_extension_function_details.h"
#include "chrome/common/extensions/api/file_manager_private_internal.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/storage_partition.h"
#include "storage/browser/file_system/file_system_backend.h"
namespace extensions {
@ -54,8 +54,7 @@ FileManagerPrivateInternalGetVolumeRootFunction::Run() {
scoped_refptr<storage::FileSystemContext> file_system_context =
render_frame_host()->GetStoragePartition()->GetFileSystemContext();
DCHECK(file_system_context.get());
storage::ExternalFileSystemBackend* const backend =
file_system_context->external_backend();
auto* const backend = ash::FileSystemBackend::Get(*file_system_context);
DCHECK(backend);
file_manager::util::FileDefinition fd;
if (!backend->GetVirtualPath(volume->mount_path(), &fd.virtual_path)) {

@ -333,8 +333,7 @@ ExtensionFunction::ResponseAction FileManagerPrivateGrantAccessFunction::Run() {
file_manager::util::GetFileSystemContextForRenderFrameHost(
Profile::FromBrowserContext(browser_context()), render_frame_host());
storage::ExternalFileSystemBackend* const backend =
file_system_context->external_backend();
auto* const backend = ash::FileSystemBackend::Get(*file_system_context);
DCHECK(backend);
const std::vector<Profile*>& profiles =
@ -1197,8 +1196,8 @@ FileManagerPrivateInternalResolveIsolatedEntriesFunction::Run() {
profile, render_frame_host());
DCHECK(file_system_context.get());
const storage::ExternalFileSystemBackend* external_backend =
file_system_context->external_backend();
const auto* external_backend =
ash::FileSystemBackend::Get(*file_system_context);
DCHECK(external_backend);
file_manager::util::FileDefinitionList file_definition_list;

@ -133,8 +133,7 @@ FileBrowserHandlerExecutor::SetupFileAccessPermissions(
const std::vector<FileSystemURL>& file_urls) {
DCHECK(handler_extension.get());
storage::ExternalFileSystemBackend* backend =
file_system_context_handler->external_backend();
auto* backend = ash::FileSystemBackend::Get(*file_system_context_handler);
std::unique_ptr<FileDefinitionList> file_definition_list(
new FileDefinitionList);

@ -18,6 +18,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ash/file_manager/app_id.h"
#include "chrome/browser/ash/file_manager/filesystem_api_util.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
@ -28,7 +29,6 @@
#include "content/public/common/url_utils.h"
#include "extensions/browser/extension_util.h"
#include "google_apis/common/task_util.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/isolated_context.h"
#include "storage/browser/file_system/open_file_system_mode.h"
@ -242,7 +242,8 @@ void OnConvertFileDefinitionDone(
bool IsUnderNonNativeLocalPath(const storage::FileSystemContext& context,
const base::FilePath& file_path) {
base::FilePath virtual_path;
if (!context.external_backend()->GetVirtualPath(file_path, &virtual_path)) {
if (!ash::FileSystemBackend::Get(context)->GetVirtualPath(file_path,
&virtual_path)) {
return false;
}
@ -298,7 +299,7 @@ class ConvertSelectedFileInfoListToFileChooserFileInfoListImpl {
// Non-native file without a snapshot file.
base::FilePath virtual_path;
if (!context->external_backend()->GetVirtualPath(
if (!ash::FileSystemBackend::Get(*context)->GetVirtualPath(
selected_info_list[i].file_path, &virtual_path)) {
NotifyError(std::move(lifetime));
return;
@ -554,8 +555,8 @@ bool ConvertAbsoluteFilePathToRelativeFileSystemPath(
const GURL& source_url,
const base::FilePath& absolute_path,
base::FilePath* virtual_path) {
storage::ExternalFileSystemBackend* backend =
GetFileSystemContextForSourceURL(profile, source_url)->external_backend();
auto* backend = ash::FileSystemBackend::Get(
*GetFileSystemContextForSourceURL(profile, source_url));
if (!backend) {
return false;
}
@ -631,8 +632,7 @@ void CheckIfDirectoryExists(
storage::FileSystemOperationRunner::StatusCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
storage::ExternalFileSystemBackend* const backend =
file_system_context->external_backend();
auto* const backend = ash::FileSystemBackend::Get(*file_system_context);
DCHECK(backend);
const storage::FileSystemURL internal_url =
backend->CreateInternalURL(file_system_context.get(), directory_path);
@ -651,8 +651,7 @@ void GetMetadataForPath(
storage::FileSystemOperationRunner::GetMetadataCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
storage::ExternalFileSystemBackend* const backend =
file_system_context->external_backend();
auto* const backend = ash::FileSystemBackend::Get(*file_system_context);
DCHECK(backend);
const storage::FileSystemURL internal_url =
backend->CreateInternalURL(file_system_context.get(), entry_path);

@ -18,6 +18,7 @@
#include "chrome/browser/ash/file_system_provider/fake_provided_file_system.h"
#include "chrome/browser/ash/file_system_provider/service.h"
#include "chrome/browser/ash/file_system_provider/service_factory.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
@ -25,7 +26,6 @@
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/browser/test/async_file_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -66,8 +66,8 @@ class TempFileSystem {
// Grant the test extension the ability to access the just created
// file system.
file_system_context_->external_backend()->GrantFileAccessToOrigin(
origin_, base::FilePath(name_));
ash::FileSystemBackend::Get(*file_system_context_)
->GrantFileAccessToOrigin(origin_, base::FilePath(name_));
return true;
}
@ -530,7 +530,7 @@ TEST_F(FileManagerFileAPIUtilTest, GenerateUnusedFilenameFileSystemProvider) {
ASSERT_TRUE(context);
// Make sure we can access the filesystem from the above origin.
context->external_backend()->GrantFileAccessToOrigin(
ash::FileSystemBackend::Get(*context)->GrantFileAccessToOrigin(
url::Origin::Create(GURL(origin)), base::FilePath(mount_point_name));
const storage::ExternalMountPoints* const mount_points =

@ -26,6 +26,7 @@
#include "chrome/browser/ash/file_manager/fileapi_util.h"
#include "chrome/browser/ash/file_system_provider/mount_path_util.h"
#include "chrome/browser/ash/file_system_provider/provided_file_system_interface.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "components/drive/file_errors.h"
@ -35,7 +36,6 @@
#include "content/public/browser/storage_partition.h"
#include "google_apis/common/task_util.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "url/gurl.h"
@ -365,8 +365,7 @@ void PrepareNonNativeLocalFileForWritableApp(
scoped_refptr<storage::FileSystemContext> const file_system_context =
GetFileManagerFileSystemContext(profile);
DCHECK(file_system_context);
storage::ExternalFileSystemBackend* const backend =
file_system_context->external_backend();
auto* const backend = ash::FileSystemBackend::Get(*file_system_context);
DCHECK(backend);
const storage::FileSystemURL internal_url =
backend->CreateInternalURL(file_system_context.get(), path);

@ -9,6 +9,7 @@
#include "base/functional/bind.h"
#include "chrome/browser/ash/file_manager/fileapi_util.h"
#include "chrome/browser/ash/fileapi/external_file_url_util.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "content/public/browser/browser_task_traits.h"
@ -19,7 +20,6 @@
#include "net/http/http_request_headers.h"
#include "net/http/http_util.h"
#include "storage/browser/file_system/file_stream_reader.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/isolated_context.h"
#include "url/gurl.h"
@ -206,10 +206,11 @@ void ExternalFileResolver::OnHelperResultObtained(
// Check if the entry has a redirect URL.
file_system_context_ = std::move(file_system_context);
file_system_context_->external_backend()->GetRedirectURLForContents(
isolated_file_system_.url,
base::BindOnce(&ExternalFileResolver::OnRedirectURLObtained,
weak_ptr_factory_.GetWeakPtr()));
ash::FileSystemBackend::Get(*file_system_context_)
->GetRedirectURLForContents(
isolated_file_system_.url,
base::BindOnce(&ExternalFileResolver::OnRedirectURLObtained,
weak_ptr_factory_.GetWeakPtr()));
}
void ExternalFileResolver::OnRedirectURLObtained(const GURL& redirect_url) {

@ -14,6 +14,7 @@
#include "chrome/browser/ash/file_manager/path_util.h"
#include "chrome/browser/ash/fileapi/file_change_service_factory.h"
#include "chrome/browser/ash/fileapi/file_change_service_observer.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile_manager.h"
@ -23,7 +24,6 @@
#include "mojo/public/cpp/system/string_data_source.h"
#include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_operation_runner.h"
#include "storage/browser/test/async_file_test_helper.h"
@ -112,8 +112,9 @@ class TempFileSystem {
name_, storage::kFileSystemTypeLocal,
storage::FileSystemMountOption(), temp_dir_.GetPath()));
GetFileSystemContext(profile_)->external_backend()->GrantFileAccessToOrigin(
file_manager::util::GetFilesAppOrigin(), base::FilePath(name_));
ash::FileSystemBackend::Get(*GetFileSystemContext(profile_))
->GrantFileAccessToOrigin(file_manager::util::GetFilesAppOrigin(),
base::FilePath(name_));
}
// Synchronously creates the file specified by `url`.

@ -19,6 +19,7 @@
#include "base/task/thread_pool.h"
#include "chrome/browser/ash/arc/fileapi/arc_documents_provider_util.h"
#include "chrome/browser/ash/fileapi/file_access_permissions.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/ash/fileapi/file_system_backend_delegate.h"
#include "chrome/browser/ash/fileapi/observable_file_system_operation_impl.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
@ -93,6 +94,13 @@ FileSystemBackend::FileSystemBackend(
FileSystemBackend::~FileSystemBackend() {}
// static
FileSystemBackend* FileSystemBackend::Get(
const storage::FileSystemContext& context) {
return static_cast<FileSystemBackend*>(
context.GetFileSystemBackend(storage::kFileSystemTypeExternal));
}
void FileSystemBackend::AddSystemMountPoints() {
// RegisterFileSystem() is no-op if the mount point with the same name
// already exists, hence it's safe to call without checking if a mount

@ -63,7 +63,7 @@ constexpr char kSystemMountNameRemovable[] = "removable";
//
// Other mounts are also registered by VolumeManager for MyFiles, Drive, VMs
// (crostini, arc, etc), Android Document Providers, fileSystemProviders, etc.
class FileSystemBackend : public storage::ExternalFileSystemBackend {
class FileSystemBackend : public storage::FileSystemBackend {
public:
using storage::FileSystemBackend::ResolveURLCallback;
@ -85,6 +85,9 @@ class FileSystemBackend : public storage::ExternalFileSystemBackend {
~FileSystemBackend() override;
// Gets the ChromeOS FileSystemBackend.
static FileSystemBackend* Get(const storage::FileSystemContext& context);
// Adds system mount points, such as "archive", and "removable". This
// function is no-op if these mount points are already present.
void AddSystemMountPoints();
@ -94,6 +97,40 @@ class FileSystemBackend : public storage::ExternalFileSystemBackend {
// This could be called on any threads.
static bool CanHandleURL(const storage::FileSystemURL& url);
// Returns true if |url| is allowed to be accessed.
// This is supposed to perform ExternalFileSystem-specific security
// checks.
bool IsAccessAllowed(const storage::FileSystemURL& url) const;
// Returns the list of top level directories that are exposed by this
// provider. This list is used to set appropriate child process file access
// permissions.
std::vector<base::FilePath> GetRootDirectories() const;
// Grants access to |virtual_path| from |origin| URL.
void GrantFileAccessToOrigin(const url::Origin& origin,
const base::FilePath& virtual_path);
// Revokes file access from origin identified with |origin|.
void RevokeAccessForOrigin(const url::Origin& origin);
// Gets virtual path by known filesystem path. Returns false when filesystem
// path is not exposed by this provider.
bool GetVirtualPath(const base::FilePath& file_system_path,
base::FilePath* virtual_path) const;
// Gets a redirect URL for contents. e.g. Google Drive URL for hosted
// documents. Returns empty URL if the entry does not have the redirect URL.
void GetRedirectURLForContents(const storage::FileSystemURL& url,
storage::URLCallback callback) const;
// Creates an internal File System URL for performing internal operations such
// as confirming if a file or a directory exist before granting the final
// permission to the entry. The path must be an absolute path.
storage::FileSystemURL CreateInternalURL(
storage::FileSystemContext* context,
const base::FilePath& entry_path) const;
// storage::FileSystemBackend overrides.
bool CanHandleType(storage::FileSystemType type) const override;
void Initialize(storage::FileSystemContext* context) override;
@ -134,20 +171,6 @@ class FileSystemBackend : public storage::ExternalFileSystemBackend {
const storage::AccessObserverList* GetAccessObservers(
storage::FileSystemType type) const override;
// storage::ExternalFileSystemBackend overrides.
bool IsAccessAllowed(const storage::FileSystemURL& url) const override;
std::vector<base::FilePath> GetRootDirectories() const override;
void GrantFileAccessToOrigin(const url::Origin& origin,
const base::FilePath& virtual_path) override;
void RevokeAccessForOrigin(const url::Origin& origin) override;
bool GetVirtualPath(const base::FilePath& filesystem_path,
base::FilePath* virtual_path) const override;
void GetRedirectURLForContents(const storage::FileSystemURL& url,
storage::URLCallback callback) const override;
storage::FileSystemURL CreateInternalURL(
storage::FileSystemContext* context,
const base::FilePath& entry_path) const override;
private:
const AccountId account_id_;

@ -20,6 +20,7 @@
#include "base/types/expected.h"
#include "chrome/browser/ash/file_manager/fileapi_util.h"
#include "chrome/browser/ash/file_manager/path_util.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/ash/fusebox/fusebox_copy_to_fd.h"
#include "chrome/browser/ash/fusebox/fusebox_errno.h"
#include "chrome/browser/ash/fusebox/fusebox_read_writer.h"
@ -30,7 +31,6 @@
#include "storage/browser/file_system/async_file_util.h"
#include "storage/browser/file_system/copy_or_move_hook_delegate.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/common/file_system/file_system_util.h"
#include "third_party/cros_system_api/dbus/fusebox/dbus-constants.h"
@ -177,7 +177,7 @@ base::expected<Parsed, ParseError> ParseFileSystemURL(
return base::unexpected(ParseError(ENOENT));
}
if (!fs_context->external_backend()->CanHandleType(fs_url.type())) {
if (!ash::FileSystemBackend::Get(*fs_context)->CanHandleType(fs_url.type())) {
LOG(ERROR) << "Backend cannot handle "
<< storage::GetFileSystemTypeString(fs_url.type());
return base::unexpected(ParseError(EINVAL));
@ -1439,8 +1439,9 @@ void Server::ReplyToMakeTempDir(base::ScopedTempDir scoped_temp_dir,
const blink::StorageKey storage_key =
blink::StorageKey::CreateFromStringForTesting(
"http://fusebox-server.example.com");
fs_context->external_backend()->GrantFileAccessToOrigin(
storage_key.origin(), base::FilePath(mount_name));
ash::FileSystemBackend::Get(*fs_context)
->GrantFileAccessToOrigin(storage_key.origin(),
base::FilePath(mount_name));
storage::FileSystemURL fs_url =
mount_points->CreateExternalFileSystemURL(storage_key, mount_name, {});

@ -12,6 +12,7 @@
#include "base/functional/callback.h"
#include "base/path_service.h"
#include "chrome/browser/ash/file_manager/volume_manager.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/child_process_security_policy.h"
@ -25,7 +26,6 @@
#include "extensions/browser/extension_util.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/browser/file_system/isolated_context.h"
@ -91,8 +91,7 @@ void OnConsentReceived(content::BrowserContext* browser_context,
scoped_refptr<storage::FileSystemContext> file_system_context =
util::GetStoragePartitionForExtensionId(origin.host(), browser_context)
->GetFileSystemContext();
storage::ExternalFileSystemBackend* const backend =
file_system_context->external_backend();
auto* const backend = ash::FileSystemBackend::Get(*file_system_context);
DCHECK(backend);
base::FilePath virtual_path;
@ -225,8 +224,7 @@ void ChromeFileSystemDelegateAsh::RequestFileSystem(
scoped_refptr<storage::FileSystemContext> file_system_context =
util::GetStoragePartitionForExtensionId(extension.id(), browser_context)
->GetFileSystemContext();
storage::ExternalFileSystemBackend* const backend =
file_system_context->external_backend();
auto* const backend = ash::FileSystemBackend::Get(*file_system_context);
DCHECK(backend);
base::FilePath virtual_path;

@ -125,8 +125,8 @@
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/system/sys_info.h"
#include "chrome/browser/ash/extensions/install_limiter.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#endif
@ -1215,9 +1215,9 @@ void ExtensionService::PostDeactivateExtension(
storage::FileSystemContext* filesystem_context =
util::GetStoragePartitionForExtensionId(extension->id(), profile_)
->GetFileSystemContext();
if (filesystem_context && filesystem_context->external_backend()) {
filesystem_context->external_backend()->RevokeAccessForOrigin(
extension->origin());
if (filesystem_context && ash::FileSystemBackend::Get(*filesystem_context)) {
ash::FileSystemBackend::Get(*filesystem_context)
->RevokeAccessForOrigin(extension->origin());
}
#endif

@ -9,8 +9,8 @@
#include "chrome/browser/ash/file_manager/fileapi_util.h"
#include "chrome/browser/ash/file_manager/path_util.h"
#include "chrome/browser/ash/file_manager/volume_manager_factory.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
namespace ash {
@ -57,8 +57,8 @@ void ScopedTestMountPoint::Mount(Profile* profile) {
storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
name_, file_system_type_, storage::FileSystemMountOption(),
temp_dir_.GetPath());
file_manager::util::GetFileManagerFileSystemContext(profile)
->external_backend()
ash::FileSystemBackend::Get(
*file_manager::util::GetFileManagerFileSystemContext(profile))
->GrantFileAccessToOrigin(file_manager::util::GetFilesAppOrigin(),
base::FilePath(name_));
if (file_manager::VolumeManager::Get(profile_)) {

@ -14,6 +14,7 @@
#include "chrome/browser/ash/file_manager/fileapi_util.h"
#include "chrome/browser/ash/file_manager/open_util.h"
#include "chrome/browser/ash/file_manager/volume_manager.h"
#include "chrome/browser/ash/fileapi/file_system_backend.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
@ -21,7 +22,6 @@
#include "content/public/test/browser_test.h"
#include "extensions/common/extension.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "url/origin.h"
@ -61,9 +61,9 @@ class ScopedExternalMountPoint {
temp_dir_.GetPath());
GURL image_loader_url = extensions::Extension::GetBaseURLFromExtensionId(
file_manager::kImageLoaderExtensionId);
file_manager::util::GetFileSystemContextForSourceURL(profile,
image_loader_url)
->external_backend()
ash::FileSystemBackend::Get(
*file_manager::util::GetFileSystemContextForSourceURL(profile,
image_loader_url))
->GrantFileAccessToOrigin(url::Origin::Create(image_loader_url),
base::FilePath(name_));
}

@ -164,39 +164,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileSystemBackend {
FileSystemType type) const = 0;
};
// An interface to control external file system access permissions.
// TODO(satorux): Move this out of 'storage/browser/fileapi'. crbug.com/257279
class ExternalFileSystemBackend : public FileSystemBackend {
public:
// Returns true if |url| is allowed to be accessed.
// This is supposed to perform ExternalFileSystem-specific security
// checks.
virtual bool IsAccessAllowed(const FileSystemURL& url) const = 0;
// Returns the list of top level directories that are exposed by this
// provider. This list is used to set appropriate child process file access
// permissions.
virtual std::vector<base::FilePath> GetRootDirectories() const = 0;
// Grants access to |virtual_path| from |origin| URL.
virtual void GrantFileAccessToOrigin(const url::Origin& origin,
const base::FilePath& virtual_path) = 0;
// Revokes file access from origin identified with |origin|.
virtual void RevokeAccessForOrigin(const url::Origin& origin) = 0;
// Gets virtual path by known filesystem path. Returns false when filesystem
// path is not exposed by this provider.
virtual bool GetVirtualPath(const base::FilePath& file_system_path,
base::FilePath* virtual_path) const = 0;
// Gets a redirect URL for contents. e.g. Google Drive URL for hosted
// documents. Returns empty URL if the entry does not have the redirect URL.
virtual void GetRedirectURLForContents(const FileSystemURL& url,
URLCallback callback) const = 0;
// Creates an internal File System URL for performing internal operations such
// as confirming if a file or a directory exist before granting the final
// permission to the entry. The path must be an absolute path.
virtual FileSystemURL CreateInternalURL(
FileSystemContext* context,
const base::FilePath& entry_path) const = 0;
};
} // namespace storage
#endif // STORAGE_BROWSER_FILE_SYSTEM_FILE_SYSTEM_BACKEND_H_

@ -422,11 +422,6 @@ std::vector<FileSystemType> FileSystemContext::GetFileSystemTypes() const {
return types;
}
ExternalFileSystemBackend* FileSystemContext::external_backend() const {
return static_cast<ExternalFileSystemBackend*>(
GetFileSystemBackend(kFileSystemTypeExternal));
}
void FileSystemContext::OpenFileSystem(
const blink::StorageKey& storage_key,
const absl::optional<storage::BucketLocator>& bucket,

@ -54,7 +54,6 @@ namespace storage {
class AsyncFileUtil;
class CopyOrMoveFileValidatorFactory;
class ExternalFileSystemBackend;
class ExternalMountPoints;
class FileStreamReader;
class FileStreamWriter;
@ -210,11 +209,6 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) FileSystemContext
// Returns all registered filesystem types.
std::vector<FileSystemType> GetFileSystemTypes() const;
// Returns a FileSystemBackend instance for external filesystem
// type, which is used only by chromeos for now. This is equivalent to
// calling GetFileSystemBackend(kFileSystemTypeExternal).
ExternalFileSystemBackend* external_backend() const;
// Used for OpenFileSystem.
using OpenFileSystemCallback =
base::OnceCallback<void(const FileSystemURL& root_url,