Commit af5540d2 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Remove legacy drive code from chrome/browser/chromeos/file_manager

Bug: 1003238
Change-Id: I829684e1b9959948c3deb70649ce590aac6347c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877500
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarSergei Datsenko <dats@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710203}
parent 50ab1e95
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.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/app_id.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h" #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chrome/browser/chromeos/file_manager/open_with_browser.h" #include "chrome/browser/chromeos/file_manager/open_with_browser.h"
...@@ -227,9 +226,6 @@ FileBrowserHandlerExecutor::SetupFileAccessPermissions( ...@@ -227,9 +226,6 @@ FileBrowserHandlerExecutor::SetupFileAccessPermissions(
base::FilePath local_path = url.path(); base::FilePath local_path = url.path();
base::FilePath virtual_path = url.virtual_path(); base::FilePath virtual_path = url.virtual_path();
const bool is_drive_file = url.type() == storage::kFileSystemTypeDrive;
DCHECK(!is_drive_file || drive::util::IsUnderDriveMountPoint(local_path));
const bool is_native_file = const bool is_native_file =
url.type() == storage::kFileSystemTypeNativeLocal || url.type() == storage::kFileSystemTypeNativeLocal ||
url.type() == storage::kFileSystemTypeRestrictedNativeLocal; url.type() == storage::kFileSystemTypeRestrictedNativeLocal;
......
...@@ -531,9 +531,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) { ...@@ -531,9 +531,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) {
// Find apps for a "text/plain" file. Foo.app and Bar.app should be found. // Find apps for a "text/plain" file. Foo.app and Bar.app should be found.
std::vector<extensions::EntryInfo> entries; std::vector<extensions::EntryInfo> entries;
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.txt"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.txt"),
"text/plain", false); "text/plain", false);
std::vector<FullTaskDescriptor> tasks; std::vector<FullTaskDescriptor> tasks;
FindFileHandlerTasks(&test_profile_, entries, &tasks); FindFileHandlerTasks(&test_profile_, entries, &tasks);
...@@ -550,12 +550,12 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) { ...@@ -550,12 +550,12 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTasks) {
// Find apps for "text/plain" and "text/html" files. Only Foo.app should be // Find apps for "text/plain" and "text/html" files. Only Foo.app should be
// found. // found.
entries.clear(); entries.clear();
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.txt"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.txt"),
"text/plain", false); "text/plain", false);
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.html"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.html"),
"text/html", false); "text/html", false);
tasks.clear(); tasks.clear();
FindFileHandlerTasks(&test_profile_, entries, &tasks); FindFileHandlerTasks(&test_profile_, entries, &tasks);
ASSERT_EQ(1U, tasks.size()); ASSERT_EQ(1U, tasks.size());
...@@ -615,9 +615,9 @@ TEST_F(FileManagerFileTasksComplexTest, ...@@ -615,9 +615,9 @@ TEST_F(FileManagerFileTasksComplexTest,
std::vector<FullTaskDescriptor> tasks; std::vector<FullTaskDescriptor> tasks;
std::vector<extensions::EntryInfo> entries; std::vector<extensions::EntryInfo> entries;
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.csv"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.csv"),
"text/csv", false); "text/csv", false);
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures({blink::features::kNativeFileSystemAPI, scoped_feature_list.InitWithFeatures({blink::features::kNativeFileSystemAPI,
...@@ -781,9 +781,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks) { ...@@ -781,9 +781,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks) {
// Find apps for "foo.txt". All apps should be found. // Find apps for "foo.txt". All apps should be found.
std::vector<extensions::EntryInfo> entries; std::vector<extensions::EntryInfo> entries;
std::vector<GURL> file_urls; std::vector<GURL> file_urls;
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.txt"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.txt"),
"text/plain", false); "text/plain", false);
file_urls.emplace_back("filesystem:chrome-extension://id/dir/foo.txt"); file_urls.emplace_back("filesystem:chrome-extension://id/dir/foo.txt");
std::vector<FullTaskDescriptor> tasks; std::vector<FullTaskDescriptor> tasks;
...@@ -860,9 +860,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) { ...@@ -860,9 +860,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindAllTypesOfTasks_GoogleDocument) {
// should be found. // should be found.
std::vector<extensions::EntryInfo> entries; std::vector<extensions::EntryInfo> entries;
std::vector<GURL> file_urls; std::vector<GURL> file_urls;
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.gdoc"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.gdoc"),
"application/vnd.google-apps.document", false); "application/vnd.google-apps.document", false);
file_urls.emplace_back("filesystem:chrome-extension://id/dir/foo.gdoc"); file_urls.emplace_back("filesystem:chrome-extension://id/dir/foo.gdoc");
std::vector<FullTaskDescriptor> tasks; std::vector<FullTaskDescriptor> tasks;
...@@ -1005,9 +1005,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) { ...@@ -1005,9 +1005,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) {
// Test case with .txt file // Test case with .txt file
std::vector<extensions::EntryInfo> txt_entries; std::vector<extensions::EntryInfo> txt_entries;
txt_entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) txt_entries.emplace_back(
.AppendASCII("foo.txt"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.txt"),
"text/plain", false); "text/plain", false);
std::vector<FullTaskDescriptor> txt_result; std::vector<FullTaskDescriptor> txt_result;
FindFileHandlerTasks(&test_profile_, txt_entries, &txt_result); FindFileHandlerTasks(&test_profile_, txt_entries, &txt_result);
EXPECT_EQ(4U, txt_result.size()); EXPECT_EQ(4U, txt_result.size());
...@@ -1026,9 +1026,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) { ...@@ -1026,9 +1026,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) {
// Test case with .jpg file // Test case with .jpg file
std::vector<extensions::EntryInfo> jpg_entries; std::vector<extensions::EntryInfo> jpg_entries;
jpg_entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) jpg_entries.emplace_back(
.AppendASCII("foo.jpg"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.jpg"),
"image/jpeg", false); "image/jpeg", false);
std::vector<FullTaskDescriptor> jpg_result; std::vector<FullTaskDescriptor> jpg_result;
FindFileHandlerTasks(&test_profile_, jpg_entries, &jpg_result); FindFileHandlerTasks(&test_profile_, jpg_entries, &jpg_result);
EXPECT_EQ(3U, jpg_result.size()); EXPECT_EQ(3U, jpg_result.size());
...@@ -1046,8 +1046,8 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) { ...@@ -1046,8 +1046,8 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Generic) {
// Test case with directories. // Test case with directories.
std::vector<extensions::EntryInfo> dir_entries; std::vector<extensions::EntryInfo> dir_entries;
dir_entries.emplace_back( dir_entries.emplace_back(
drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII("dir"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("dir"), "",
"", true); true);
std::vector<FullTaskDescriptor> dir_result; std::vector<FullTaskDescriptor> dir_result;
FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result); FindFileHandlerTasks(&test_profile_, dir_entries, &dir_result);
ASSERT_EQ(1U, dir_result.size()); ASSERT_EQ(1U, dir_result.size());
...@@ -1133,9 +1133,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) { ...@@ -1133,9 +1133,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) {
// but only one ADD_TO that is not a generic handler will be taken into // but only one ADD_TO that is not a generic handler will be taken into
// account, even though there are 2 ADD_TO matches for "text/plain". // account, even though there are 2 ADD_TO matches for "text/plain".
std::vector<extensions::EntryInfo> entries; std::vector<extensions::EntryInfo> entries;
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.txt"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.txt"),
"text/plain", false); "text/plain", false);
std::vector<FullTaskDescriptor> tasks; std::vector<FullTaskDescriptor> tasks;
FindFileHandlerTasks(&test_profile_, entries, &tasks); FindFileHandlerTasks(&test_profile_, entries, &tasks);
...@@ -1159,9 +1159,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) { ...@@ -1159,9 +1159,9 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) {
// ADD_TO that is a good match will be taken into account, even though there // ADD_TO that is a good match will be taken into account, even though there
// are 3 ADD_TO matches for "text/html". // are 3 ADD_TO matches for "text/html".
entries.clear(); entries.clear();
entries.emplace_back(drive::util::GetDriveMountPointPath(&test_profile_) entries.emplace_back(
.AppendASCII("foo.html"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("foo.html"),
"text/html", false); "text/html", false);
tasks.clear(); tasks.clear();
FindFileHandlerTasks(&test_profile_, entries, &tasks); FindFileHandlerTasks(&test_profile_, entries, &tasks);
...@@ -1177,8 +1177,8 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) { ...@@ -1177,8 +1177,8 @@ TEST_F(FileManagerFileTasksComplexTest, FindFileHandlerTask_Verbs) {
// Foo.app with only PACK_WITH should be found. // Foo.app with only PACK_WITH should be found.
entries.clear(); entries.clear();
entries.emplace_back( entries.emplace_back(
drive::util::GetDriveMountPointPath(&test_profile_).AppendASCII("dir"), util::GetMyFilesFolderForProfile(&test_profile_).AppendASCII("dir"), "",
"", true); true);
tasks.clear(); tasks.clear();
FindFileHandlerTasks(&test_profile_, entries, &tasks); FindFileHandlerTasks(&test_profile_, entries, &tasks);
......
...@@ -13,11 +13,9 @@ ...@@ -13,11 +13,9 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h" #include "base/task/post_task.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/app_id.h"
#include "chrome/browser/chromeos/file_manager/filesystem_api_util.h" #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/drive/file_system_core_util.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
...@@ -471,34 +469,6 @@ storage::FileSystemContext* GetFileSystemContextForRenderFrameHost( ...@@ -471,34 +469,6 @@ storage::FileSystemContext* GetFileSystemContextForRenderFrameHost(
GetFileSystemContext(); GetFileSystemContext();
} }
base::FilePath ConvertDrivePathToRelativeFileSystemPath(
Profile* profile,
const std::string& extension_id,
const base::FilePath& drive_path) {
// "/special/drive-xxx"
base::FilePath path = drive::util::GetDriveMountPointPath(profile);
// appended with (|drive_path| - "drive").
drive::util::GetDriveGrandRootPath().AppendRelativePath(drive_path, &path);
base::FilePath relative_path;
ConvertAbsoluteFilePathToRelativeFileSystemPath(profile,
extension_id,
path,
&relative_path);
return relative_path;
}
GURL ConvertDrivePathToFileSystemUrl(Profile* profile,
const base::FilePath& drive_path,
const std::string& extension_id) {
const base::FilePath relative_path =
ConvertDrivePathToRelativeFileSystemPath(profile, extension_id,
drive_path);
if (relative_path.empty())
return GURL();
return ConvertRelativeFilePathToFileSystemUrl(relative_path, extension_id);
}
bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile, bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile,
const base::FilePath& absolute_path, const base::FilePath& absolute_path,
const std::string& extension_id, const std::string& extension_id,
......
...@@ -99,22 +99,7 @@ storage::FileSystemContext* GetFileSystemContextForRenderFrameHost( ...@@ -99,22 +99,7 @@ storage::FileSystemContext* GetFileSystemContextForRenderFrameHost(
Profile* profile, Profile* profile,
content::RenderFrameHost* render_frame_host); content::RenderFrameHost* render_frame_host);
// Converts DrivePath (e.g., "drive/root", which always starts with the fixed // Converts AbsolutePath (e.g., "/media/removable/foo" or
// "drive" directory) to a RelativeFileSystemPathrelative (e.g.,
// "drive-xxx/root/foo". which starts from the "mount point" in the FileSystem
// API that may be distinguished for each profile by the appended "xxx" part.)
base::FilePath ConvertDrivePathToRelativeFileSystemPath(
Profile* profile,
const std::string& extension_id,
const base::FilePath& drive_path);
// Converts DrivePath to FileSystem URL.
// E.g., "drive/root" to filesystem://id/external/drive-xxx/root.
GURL ConvertDrivePathToFileSystemUrl(Profile* profile,
const base::FilePath& drive_path,
const std::string& extension_id);
// Converts AbsolutePath (e.g., "/special/drive-xxx/root" or
// "/home/chronos/u-xxx/Downloads") into filesystem URL. Returns false // "/home/chronos/u-xxx/Downloads") into filesystem URL. Returns false
// if |absolute_path| is not managed by the external filesystem provider. // if |absolute_path| is not managed by the external filesystem provider.
bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile, bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile,
...@@ -123,7 +108,7 @@ bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile, ...@@ -123,7 +108,7 @@ bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile,
GURL* url); GURL* url);
// Converts AbsolutePath into RelativeFileSystemPath (e.g., // Converts AbsolutePath into RelativeFileSystemPath (e.g.,
// "/special/drive-xxx/root/foo" => "drive-xxx/root/foo".) Returns false if // "/media/removable/foo/bar" => "removable/foo/bar".) Returns false if
// |absolute_path| is not managed by the external filesystem provider. // |absolute_path| is not managed by the external filesystem provider.
bool ConvertAbsoluteFilePathToRelativeFileSystemPath( bool ConvertAbsoluteFilePathToRelativeFileSystemPath(
Profile* profile, Profile* profile,
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "chrome/browser/extensions/extension_util.h" #include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "components/arc/arc_service_manager.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_errors.h"
#include "components/drive/file_system_core_util.h" #include "components/drive/file_system_core_util.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
...@@ -38,22 +37,6 @@ namespace file_manager { ...@@ -38,22 +37,6 @@ namespace file_manager {
namespace util { namespace util {
namespace { namespace {
// Helper function used to implement GetNonNativeLocalPathMimeType. It extracts
// the mime type from the passed Drive resource entry.
void GetMimeTypeAfterGetResourceEntryForDrive(
base::OnceCallback<void(const base::Optional<std::string>&)> callback,
drive::FileError error,
std::unique_ptr<drive::ResourceEntry> entry) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (error != drive::FILE_ERROR_OK || !entry->has_file_specific_info() ||
entry->file_specific_info().content_mime_type().empty()) {
std::move(callback).Run(base::nullopt);
return;
}
std::move(callback).Run(entry->file_specific_info().content_mime_type());
}
void GetMimeTypeAfterGetMetadata( void GetMimeTypeAfterGetMetadata(
base::OnceCallback<void(const base::Optional<std::string>&)> callback, base::OnceCallback<void(const base::Optional<std::string>&)> callback,
drive::FileError error, drive::FileError error,
...@@ -196,14 +179,6 @@ void GetNonNativeLocalPathMimeType( ...@@ -196,14 +179,6 @@ void GetNonNativeLocalPathMimeType(
if (drive_integration_service && if (drive_integration_service &&
drive_integration_service->GetRelativeDrivePath(path, drive_integration_service->GetRelativeDrivePath(path,
&drive_relative_path)) { &drive_relative_path)) {
if (drive::FileSystemInterface* file_system =
drive_integration_service->file_system()) {
file_system->GetResourceEntry(
drive::util::ExtractDrivePath(path),
base::BindOnce(&GetMimeTypeAfterGetResourceEntryForDrive,
std::move(callback)));
return;
}
if (auto* drivefs = drive_integration_service->GetDriveFsInterface()) { if (auto* drivefs = drive_integration_service->GetDriveFsInterface()) {
drivefs->GetMetadata( drivefs->GetMetadata(
drive_relative_path, drive_relative_path,
......
...@@ -375,7 +375,7 @@ bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) { ...@@ -375,7 +375,7 @@ bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) {
bool force_external = false; bool force_external = false;
// Force external URL for DriveFS and Crostini. // Force external URL for DriveFS and Crostini.
drive::DriveIntegrationService* integration_service = drive::DriveIntegrationService* integration_service =
drive::util::GetIntegrationServiceByProfile(primary_profile); drive::DriveIntegrationServiceFactory::FindForProfile(primary_profile);
if ((integration_service && if ((integration_service &&
integration_service->GetMountPointPath().AppendRelativePath( integration_service->GetMountPointPath().AppendRelativePath(
path, &relative_path)) || path, &relative_path)) ||
......
...@@ -114,9 +114,9 @@ void ConvertToContentUrls( ...@@ -114,9 +114,9 @@ void ConvertToContentUrls(
// Replacements: // Replacements:
// * /home/chronos/user/Downloads => Downloads // * /home/chronos/user/Downloads => Downloads
// * /home/chronos/u-<hash>/Downloads => Downloads // * /home/chronos/u-<hash>/Downloads => Downloads
// * /special/drive-<hash>/root => Google Drive // * /media/fuse/drivefs-<hash>/root => Google Drive
// * /special/drive-<hash>/team_drives => Team Drives // * /media/fuse/drivefs-<hash>/team_drives => Team Drives
// * /special/drive-<hash>/Computers => Computers // * /media/fuse/drivefs-<hash>/Computers => Computers
// * /run/arc/sdcard/write/emulated/0 => Play files // * /run/arc/sdcard/write/emulated/0 => Play files
// * /media/fuse/crostini_<hash>_termina_penguin => Linux files // * /media/fuse/crostini_<hash>_termina_penguin => Linux files
// * '/' with ' \u203a ' (angled quote sign) for display purposes. // * '/' with ' \u203a ' (angled quote sign) for display purposes.
......
...@@ -533,6 +533,8 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test { ...@@ -533,6 +533,8 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test {
profile_manager_->CreateTestingProfile("user@gmail.com"); profile_manager_->CreateTestingProfile("user@gmail.com");
ASSERT_TRUE(primary_profile); ASSERT_TRUE(primary_profile);
ASSERT_TRUE(profile_manager_->CreateTestingProfile("user2@gmail.com")); ASSERT_TRUE(profile_manager_->CreateTestingProfile("user2@gmail.com"));
primary_profile->GetPrefs()->SetString(drive::prefs::kDriveFsProfileSalt,
"a");
// Set up an Arc service manager with a fake file system. // Set up an Arc service manager with a fake file system.
arc_service_manager_ = std::make_unique<arc::ArcServiceManager>(); arc_service_manager_ = std::make_unique<arc::ArcServiceManager>();
...@@ -549,10 +551,12 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test { ...@@ -549,10 +551,12 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test {
// Add a drive mount point for the primary profile. // Add a drive mount point for the primary profile.
storage::ExternalMountPoints* mount_points = storage::ExternalMountPoints* mount_points =
storage::ExternalMountPoints::GetSystemInstance(); storage::ExternalMountPoints::GetSystemInstance();
drive_mount_point_ = drive::util::GetDriveMountPointPath(primary_profile); drive::DriveIntegrationService* integration_service =
drive::DriveIntegrationServiceFactory::GetForProfile(primary_profile);
drive_mount_point_ = integration_service->GetMountPointPath();
mount_points->RegisterFileSystem( mount_points->RegisterFileSystem(
drive_mount_point_.BaseName().AsUTF8Unsafe(), drive_mount_point_.BaseName().AsUTF8Unsafe(),
storage::kFileSystemTypeDrive, storage::FileSystemMountOption(), storage::kFileSystemTypeNativeLocal, storage::FileSystemMountOption(),
drive_mount_point_); drive_mount_point_);
// Add a crostini mount point for the primary profile. // Add a crostini mount point for the primary profile.
...@@ -651,7 +655,8 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_Special) { ...@@ -651,7 +655,8 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertPathToArcUrl_Special) {
// - creating externalfile: URL from the path // - creating externalfile: URL from the path
// - encoding the URL to Chrome content provider URL // - encoding the URL to Chrome content provider URL
EXPECT_EQ(GURL("content://org.chromium.arc.chromecontentprovider/" EXPECT_EQ(GURL("content://org.chromium.arc.chromecontentprovider/"
"externalfile%3Adrive-user%252540gmail.com-hash%2Fa%2Fb%2Fc"), "externalfile%3Adrivefs-b1f44746e7144c3caafeacaa8bb5c569%2Fa"
"%2Fb%2Fc"),
url); url);
} }
...@@ -777,8 +782,8 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertToContentUrls_Special) { ...@@ -777,8 +782,8 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertToContentUrls_Special) {
run_loop->Quit(); run_loop->Quit();
ASSERT_EQ(1U, urls.size()); ASSERT_EQ(1U, urls.size());
EXPECT_EQ(GURL("content://org.chromium.arc.chromecontentprovider/" EXPECT_EQ(GURL("content://org.chromium.arc.chromecontentprovider/"
"externalfile%3Adrive-user%252540gmail.com-hash%2Fa%" "externalfile%3Adrivefs-b1f44746e7144c3caafeacaa8bb5"
"2Fb%2Fc"), "c569%2Fa%2Fb%2Fc"),
urls[0]); urls[0]);
}, },
&run_loop)); &run_loop));
...@@ -891,8 +896,8 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertToContentUrls_MultipleUrls) { ...@@ -891,8 +896,8 @@ TEST_F(FileManagerPathUtilConvertUrlTest, ConvertToContentUrls_MultipleUrls) {
"removable/a/b/c"), "removable/a/b/c"),
urls[1]); urls[1]);
EXPECT_EQ(GURL("content://org.chromium.arc.chromecontentprovider/" EXPECT_EQ(GURL("content://org.chromium.arc.chromecontentprovider/"
"externalfile%3Adrive-user%252540gmail.com-hash%2Fa%" "externalfile%3Adrivefs-b1f44746e7144c3caafeacaa8bb5"
"2Fb%2Fc"), "c569%2Fa%2Fb%2Fc"),
urls[2]); urls[2]);
EXPECT_EQ( EXPECT_EQ(
GURL("content://org.chromium.arc.file_system.fileprovider/" GURL("content://org.chromium.arc.file_system.fileprovider/"
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "chromeos/disks/disk.h" #include "chromeos/disks/disk.h"
#include "chromeos/disks/disk_mount_manager.h" #include "chromeos/disks/disk_mount_manager.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/storage_monitor/storage_monitor.h" #include "components/storage_monitor/storage_monitor.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -890,24 +889,7 @@ void VolumeManager::OnMountEvent( ...@@ -890,24 +889,7 @@ void VolumeManager::OnMountEvent(
const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) { const chromeos::disks::DiskMountManager::MountPointInfo& mount_info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
switch (mount_info.mount_type) { switch (mount_info.mount_type) {
case chromeos::MOUNT_TYPE_ARCHIVE: { case chromeos::MOUNT_TYPE_ARCHIVE:
// If the file is not mounted now, tell it to drive file system so that
// it can handle file caching correctly.
// Note that drive file system knows if the file is managed by drive file
// system or not, so here we report all paths.
if ((event == chromeos::disks::DiskMountManager::MOUNTING &&
error_code != chromeos::MOUNT_ERROR_NONE) ||
(event == chromeos::disks::DiskMountManager::UNMOUNTING &&
error_code == chromeos::MOUNT_ERROR_NONE)) {
drive::FileSystemInterface* const file_system =
drive::util::GetFileSystemByProfile(profile_);
if (file_system) {
file_system->MarkCacheFileAsUnmounted(
base::FilePath(mount_info.source_path), base::DoNothing());
}
}
FALLTHROUGH;
}
case chromeos::MOUNT_TYPE_DEVICE: { case chromeos::MOUNT_TYPE_DEVICE: {
// Notify a mounting/unmounting event to observers. // Notify a mounting/unmounting event to observers.
const chromeos::disks::Disk* const disk = const chromeos::disks::Disk* const disk =
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include <vector> #include <vector>
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/file_tasks.h" #include "chrome/browser/chromeos/file_manager/file_tasks.h"
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/test/test_app_registrar.h" #include "chrome/browser/web_applications/test/test_app_registrar.h"
...@@ -69,7 +69,7 @@ TEST_F(WebFileTasksTest, WebAppFileHandlingCanBeDisabled) { ...@@ -69,7 +69,7 @@ TEST_F(WebFileTasksTest, WebAppFileHandlingCanBeDisabled) {
std::vector<extensions::EntryInfo> entries; std::vector<extensions::EntryInfo> entries;
entries.emplace_back( entries.emplace_back(
drive::util::GetDriveMountPointPath(profile()).AppendASCII("foo.csv"), util::GetMyFilesFolderForProfile(profile()).AppendASCII("foo.csv"),
"text/csv", false); "text/csv", false);
std::vector<FullTaskDescriptor> tasks; std::vector<FullTaskDescriptor> tasks;
...@@ -123,7 +123,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) { ...@@ -123,7 +123,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) {
// Find apps for a "text/plain" file. Both Foo and Bar should be found. // Find apps for a "text/plain" file. Both Foo and Bar should be found.
std::vector<extensions::EntryInfo> entries; std::vector<extensions::EntryInfo> entries;
entries.emplace_back( entries.emplace_back(
drive::util::GetDriveMountPointPath(profile()).AppendASCII("foo.txt"), util::GetMyFilesFolderForProfile(profile()).AppendASCII("foo.txt"),
"text/plain", false); "text/plain", false);
std::vector<FullTaskDescriptor> tasks; std::vector<FullTaskDescriptor> tasks;
...@@ -137,7 +137,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) { ...@@ -137,7 +137,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) {
// Add a "text/html" file. Only Foo should be found. // Add a "text/html" file. Only Foo should be found.
entries.emplace_back( entries.emplace_back(
drive::util::GetDriveMountPointPath(profile()).AppendASCII("foo.html"), util::GetMyFilesFolderForProfile(profile()).AppendASCII("foo.html"),
"text/html", false); "text/html", false);
tasks.clear(); tasks.clear();
FindWebTasks(profile(), entries, &tasks); FindWebTasks(profile(), entries, &tasks);
...@@ -147,7 +147,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) { ...@@ -147,7 +147,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTasks) {
// Add an "image/png" file. No tasks should be found. // Add an "image/png" file. No tasks should be found.
entries.emplace_back( entries.emplace_back(
drive::util::GetDriveMountPointPath(profile()).AppendASCII("foo.png"), util::GetMyFilesFolderForProfile(profile()).AppendASCII("foo.png"),
"image/png", false); "image/png", false);
tasks.clear(); tasks.clear();
FindWebTasks(profile(), entries, &tasks); FindWebTasks(profile(), entries, &tasks);
...@@ -196,7 +196,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTask_Generic) { ...@@ -196,7 +196,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTask_Generic) {
// All apps should be able to handle ".txt" files. // All apps should be able to handle ".txt" files.
entries.emplace_back( entries.emplace_back(
drive::util::GetDriveMountPointPath(profile()).AppendASCII("foo.txt"), util::GetMyFilesFolderForProfile(profile()).AppendASCII("foo.txt"),
"text/plain", false); "text/plain", false);
FindWebTasks(profile(), entries, &tasks); FindWebTasks(profile(), entries, &tasks);
// Ensure stable order. // Ensure stable order.
...@@ -221,7 +221,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTask_Generic) { ...@@ -221,7 +221,7 @@ TEST_F(WebFileTasksTest, FindWebFileHandlerTask_Generic) {
// Every app but Bar should be able to handle jpegs. // Every app but Bar should be able to handle jpegs.
entries.emplace_back( entries.emplace_back(
drive::util::GetDriveMountPointPath(profile()).AppendASCII("foo.jpg"), util::GetMyFilesFolderForProfile(profile()).AppendASCII("foo.jpg"),
"image/jpeg", false); "image/jpeg", false);
FindWebTasks(profile(), entries, &tasks); FindWebTasks(profile(), entries, &tasks);
// Ensure stable order., // Ensure stable order.,
......
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