Commit 53f411e5 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Remove DriveFS feature flag in C++ code

The legacy drive sync client is being deleted in favour of switching to
DriveFS, so remove the feature flag and clean up code using the flag.

Bug: 1002339
Change-Id: I51035d863569d484748a22dd6b07b5aaf26a7057
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1797943
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697086}
parent e26adffa
...@@ -654,12 +654,10 @@ DriveIntegrationService::DriveIntegrationService( ...@@ -654,12 +654,10 @@ DriveIntegrationService::DriveIntegrationService(
cache_root_directory_(!test_cache_root.empty() cache_root_directory_(!test_cache_root.empty()
? test_cache_root ? test_cache_root
: util::GetCacheRootPath(profile)), : util::GetCacheRootPath(profile)),
drivefs_holder_(base::FeatureList::IsEnabled(chromeos::features::kDriveFs) drivefs_holder_(std::make_unique<DriveFsHolder>(
? std::make_unique<DriveFsHolder>( profile_,
profile_, this,
this, std::move(test_drivefs_mojo_listener_factory))),
std::move(test_drivefs_mojo_listener_factory))
: nullptr),
preference_watcher_(preference_watcher), preference_watcher_(preference_watcher),
power_manager_observer_(this) { power_manager_observer_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
......
...@@ -573,21 +573,7 @@ FileManagerPrivateGetSizeStatsFunction::Run() { ...@@ -573,21 +573,7 @@ FileManagerPrivateGetSizeStatsFunction::Run() {
if (!volume.get()) if (!volume.get())
return RespondNow(Error("Volume not found")); return RespondNow(Error("Volume not found"));
if (volume->type() == file_manager::VOLUME_TYPE_GOOGLE_DRIVE && if (volume->type() == file_manager::VOLUME_TYPE_MTP) {
!base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
drive::FileSystemInterface* file_system =
drive::util::GetFileSystemByProfile(chrome_details.GetProfile());
if (!file_system) {
// |file_system| is NULL if Drive is disabled.
// If stats couldn't be gotten for drive, result should be left
// undefined. See comments in GetDriveAvailableSpaceCallback().
return RespondNow(NoArguments());
}
file_system->GetAvailableSpace(base::BindOnce(
&FileManagerPrivateGetSizeStatsFunction::OnGetDriveAvailableSpace,
this));
} else if (volume->type() == file_manager::VOLUME_TYPE_MTP) {
// Resolve storage_name. // Resolve storage_name.
storage_monitor::StorageMonitor* storage_monitor = storage_monitor::StorageMonitor* storage_monitor =
storage_monitor::StorageMonitor::GetInstance(); storage_monitor::StorageMonitor::GetInstance();
......
...@@ -102,12 +102,7 @@ class FakeSelectFileDialog : public ui::SelectFileDialog { ...@@ -102,12 +102,7 @@ class FakeSelectFileDialog : public ui::SelectFileDialog {
const base::FilePath::StringType& default_extension, const base::FilePath::StringType& default_extension,
gfx::NativeWindow owning_window, gfx::NativeWindow owning_window,
void* params) override { void* params) override {
listener_->FileSelected( listener_->FileSelected(drivefs_root_.Append("root/test_dir"), 0, nullptr);
(base::FeatureList::IsEnabled(chromeos::features::kDriveFs)
? drivefs_root_
: base::FilePath("/special/drive-user"))
.Append("root/test_dir"),
0, nullptr);
} }
bool IsRunning(gfx::NativeWindow owning_window) const override { bool IsRunning(gfx::NativeWindow owning_window) const override {
...@@ -657,30 +652,6 @@ class MultiProfileDriveFileSystemExtensionApiTest : ...@@ -657,30 +652,6 @@ class MultiProfileDriveFileSystemExtensionApiTest :
drivefs_helper->CreateFakeDriveFsListenerFactory()); drivefs_helper->CreateFakeDriveFsListenerFactory());
} }
void AddTestHostedDocuments() {
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
return;
}
const char kResourceId[] = "unique-id-for-multiprofile-copy-test";
drive::FakeDriveService* const main_service =
static_cast<drive::FakeDriveService*>(
drive::util::GetDriveServiceByProfile(profile()));
drive::FakeDriveService* const sub_service =
static_cast<drive::FakeDriveService*>(
drive::util::GetDriveServiceByProfile(second_profile_));
// Place a hosted document under root/test_dir of the sub profile.
sub_service->AddNewFileWithResourceId(
kResourceId, "application/vnd.google-apps.document", "", "test_dir",
"hosted_doc", true, base::Bind(&IgnoreDriveEntryResult));
// Place the hosted document with no parent in the main profile, for
// simulating the situation that the document is shared to the main profile.
main_service->AddNewFileWithResourceId(
kResourceId, "application/vnd.google-apps.document", "", "",
"hosted_doc", true, base::Bind(&IgnoreDriveEntryResult));
}
base::ScopedTempDir tmp_dir_; base::ScopedTempDir tmp_dir_;
DriveIntegrationServiceFactory::FactoryCallback DriveIntegrationServiceFactory::FactoryCallback
create_drive_integration_service_; create_drive_integration_service_;
...@@ -898,7 +869,6 @@ IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, RetainEntry) { ...@@ -898,7 +869,6 @@ IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, RetainEntry) {
IN_PROC_BROWSER_TEST_F(MultiProfileDriveFileSystemExtensionApiTest, IN_PROC_BROWSER_TEST_F(MultiProfileDriveFileSystemExtensionApiTest,
CrossProfileCopy) { CrossProfileCopy) {
AddTestHostedDocuments();
EXPECT_TRUE(RunFileSystemExtensionApiTest( EXPECT_TRUE(RunFileSystemExtensionApiTest(
"file_browser/multi_profile_copy", "file_browser/multi_profile_copy",
FILE_PATH_LITERAL("manifest.json"), FILE_PATH_LITERAL("manifest.json"),
......
...@@ -2357,19 +2357,14 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name, ...@@ -2357,19 +2357,14 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
drive::DriveIntegrationService* drive::DriveIntegrationService*
FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) {
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) { drive_volumes_[profile->GetOriginalProfile()] =
drive_volumes_[profile->GetOriginalProfile()] = std::make_unique<DriveFsTestVolume>(profile->GetOriginalProfile());
std::make_unique<DriveFsTestVolume>(profile->GetOriginalProfile()); if (!IsIncognitoModeTest() && !DoesTestStartWithNoVolumesMounted() &&
if (!IsIncognitoModeTest() && !DoesTestStartWithNoVolumesMounted() && profile->GetPath().BaseName().value() == "user") {
profile->GetPath().BaseName().value() == "user") { base::ThreadTaskRunnerHandle::Get()->PostTask(
base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE,
FROM_HERE, base::BindOnce(base::IgnoreResult(&LocalTestVolume::Mount),
base::BindOnce(base::IgnoreResult(&LocalTestVolume::Mount), base::Unretained(local_volume_.get()), profile));
base::Unretained(local_volume_.get()), profile));
}
} else {
drive_volumes_[profile->GetOriginalProfile()] =
std::make_unique<DriveTestVolume>();
} }
if (DoesTestStartWithNoVolumesMounted()) { if (DoesTestStartWithNoVolumesMounted()) {
profile->GetPrefs()->SetBoolean(drive::prefs::kDriveFsPinnedMigrated, true); profile->GetPrefs()->SetBoolean(drive::prefs::kDriveFsPinnedMigrated, true);
......
...@@ -200,8 +200,7 @@ bool MigrateToDriveFs(Profile* profile, ...@@ -200,8 +200,7 @@ bool MigrateToDriveFs(Profile* profile,
const auto* user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile); const auto* user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
auto* integration_service = auto* integration_service =
drive::DriveIntegrationServiceFactory::FindForProfile(profile); drive::DriveIntegrationServiceFactory::FindForProfile(profile);
if (!base::FeatureList::IsEnabled(chromeos::features::kDriveFs) || if (!integration_service || !integration_service->is_enabled() || !user ||
!integration_service || !integration_service->is_enabled() || !user ||
!user->GetAccountId().HasAccountIdKey()) { !user->GetAccountId().HasAccountIdKey()) {
return false; return false;
} }
...@@ -272,8 +271,7 @@ bool ConvertFileSystemURLToPathInsideCrostini( ...@@ -272,8 +271,7 @@ bool ConvertFileSystemURLToPathInsideCrostini(
std::string mount_point_name_drive; std::string mount_point_name_drive;
auto* integration_service = auto* integration_service =
drive::DriveIntegrationServiceFactory::FindForProfile(profile); drive::DriveIntegrationServiceFactory::FindForProfile(profile);
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs) && if (integration_service) {
integration_service) {
mount_point_name_drive = mount_point_name_drive =
integration_service->GetMountPointPath().BaseName().value(); integration_service->GetMountPointPath().BaseName().value();
} }
...@@ -375,11 +373,8 @@ bool ConvertPathToArcUrl(const base::FilePath& path, GURL* arc_url_out) { ...@@ -375,11 +373,8 @@ 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 = nullptr; drive::DriveIntegrationService* integration_service =
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) { drive::util::GetIntegrationServiceByProfile(primary_profile);
integration_service =
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)) ||
......
...@@ -149,85 +149,61 @@ TEST_F(FileManagerPathUtilTest, GetPathDisplayTextForSettings) { ...@@ -149,85 +149,61 @@ TEST_F(FileManagerPathUtilTest, GetPathDisplayTextForSettings) {
"/media/fuse/crostini_0123456789abcdef_termina_penguin/foo")); "/media/fuse/crostini_0123456789abcdef_termina_penguin/foo"));
EXPECT_EQ("foo", GetPathDisplayTextForSettings(profile_.get(), EXPECT_EQ("foo", GetPathDisplayTextForSettings(profile_.get(),
"/media/removable/foo")); "/media/removable/foo"));
{
base::test::ScopedFeatureList features; chromeos::disks::DiskMountManager::InitializeForTesting(
features.InitAndDisableFeature(chromeos::features::kDriveFs); new FakeDiskMountManager);
drive::DriveIntegrationServiceFactory::GetForProfile(profile_.get()) TestingProfile profile2(base::FilePath("/home/chronos/u-0123456789abcdef"));
->SetEnabled(true); chromeos::FakeChromeUserManager user_manager;
EXPECT_EQ("Google Drive \u203a My Drive \u203a foo", user_manager.AddUser(
GetPathDisplayTextForSettings( AccountId::FromUserEmailGaiaId(profile2.GetProfileUserName(), "12345"));
profile_.get(), "/special/drive-0123456789abcdef/root/foo")); PrefService* prefs = profile2.GetPrefs();
EXPECT_EQ( prefs->SetString(drive::prefs::kDriveFsProfileSalt, "a");
"Google Drive \u203a Shared drives \u203a A Team Drive \u203a foo",
GetPathDisplayTextForSettings( drive::DriveIntegrationServiceFactory::GetForProfile(&profile2)->SetEnabled(
profile_.get(), true);
"/special/drive-0123456789abcdef/team_drives/A Team Drive/foo")); EXPECT_EQ(
"Google Drive \u203a My Drive \u203a foo",
EXPECT_EQ( GetPathDisplayTextForSettings(
"Google Drive \u203a Computers \u203a My Other Computer \u203a bar", &profile2,
GetPathDisplayTextForSettings( "/media/fuse/drivefs-84675c855b63e12f384d45f033826980/root/foo"));
profile_.get(), EXPECT_EQ("Google Drive \u203a Shared drives \u203a A Team Drive \u203a foo",
"/special/drive-0123456789abcdef/Computers/My Other Computer/bar")); GetPathDisplayTextForSettings(
} &profile2,
{ "/media/fuse/drivefs-84675c855b63e12f384d45f033826980/"
base::test::ScopedFeatureList features; "team_drives/A Team Drive/foo"));
features.InitAndEnableFeature(chromeos::features::kDriveFs); EXPECT_EQ("Google Drive \u203a Computers \u203a My Other Computer \u203a bar",
chromeos::disks::DiskMountManager::InitializeForTesting( GetPathDisplayTextForSettings(
new FakeDiskMountManager); &profile2,
TestingProfile profile2(base::FilePath("/home/chronos/u-0123456789abcdef")); "/media/fuse/drivefs-84675c855b63e12f384d45f033826980/"
chromeos::FakeChromeUserManager user_manager; "Computers/My Other Computer/bar"));
user_manager.AddUser(
AccountId::FromUserEmailGaiaId(profile2.GetProfileUserName(), "12345")); EXPECT_EQ("Google Drive \u203a My Drive \u203a foo",
PrefService* prefs = profile2.GetPrefs(); GetPathDisplayTextForSettings(
prefs->SetString(drive::prefs::kDriveFsProfileSalt, "a"); &profile2, "/special/drive-0123456789abcdef/root/foo"));
EXPECT_EQ(
drive::DriveIntegrationServiceFactory::GetForProfile(&profile2)->SetEnabled( "Google Drive \u203a Shared drives \u203a A Team Drive \u203a foo",
true); GetPathDisplayTextForSettings(
EXPECT_EQ( &profile2,
"Google Drive \u203a My Drive \u203a foo", "/special/drive-0123456789abcdef/team_drives/A Team Drive/foo"));
GetPathDisplayTextForSettings(
&profile2, EXPECT_EQ(
"/media/fuse/drivefs-84675c855b63e12f384d45f033826980/root/foo")); "Google Drive \u203a Computers \u203a My Other Computer \u203a bar",
EXPECT_EQ( GetPathDisplayTextForSettings(
"Google Drive \u203a Shared drives \u203a A Team Drive \u203a foo", &profile2,
GetPathDisplayTextForSettings( "/special/drive-0123456789abcdef/Computers/My Other Computer/bar"));
&profile2,
"/media/fuse/drivefs-84675c855b63e12f384d45f033826980/" TestingProfile guest_profile(base::FilePath("/home/chronos/guest"));
"team_drives/A Team Drive/foo")); guest_profile.SetGuestSession(true);
EXPECT_EQ( guest_profile.set_profile_name("$guest");
"Google Drive \u203a Computers \u203a My Other Computer \u203a bar", ASSERT_TRUE(
GetPathDisplayTextForSettings( drive::DriveIntegrationServiceFactory::GetForProfile(&guest_profile));
&profile2,
"/media/fuse/drivefs-84675c855b63e12f384d45f033826980/" EXPECT_EQ("Downloads", GetPathDisplayTextForSettings(
"Computers/My Other Computer/bar")); &guest_profile, "/home/chronos/user/Downloads"));
// Test that a passthrough path doesn't crash on requesting the Drive mount
EXPECT_EQ("Google Drive \u203a My Drive \u203a foo", // path for a guest profile.
GetPathDisplayTextForSettings( EXPECT_EQ("foo", GetPathDisplayTextForSettings(&guest_profile, "foo"));
&profile2, "/special/drive-0123456789abcdef/root/foo"));
EXPECT_EQ(
"Google Drive \u203a Shared drives \u203a A Team Drive \u203a foo",
GetPathDisplayTextForSettings(
&profile2,
"/special/drive-0123456789abcdef/team_drives/A Team Drive/foo"));
EXPECT_EQ(
"Google Drive \u203a Computers \u203a My Other Computer \u203a bar",
GetPathDisplayTextForSettings(
&profile2,
"/special/drive-0123456789abcdef/Computers/My Other Computer/bar"));
TestingProfile guest_profile(base::FilePath("/home/chronos/guest"));
guest_profile.SetGuestSession(true);
guest_profile.set_profile_name("$guest");
ASSERT_TRUE(
drive::DriveIntegrationServiceFactory::GetForProfile(&guest_profile));
EXPECT_EQ("Downloads", GetPathDisplayTextForSettings(
&guest_profile, "/home/chronos/user/Downloads"));
// Test that a passthrough path doesn't crash on requesting the Drive mount
// path for a guest profile.
EXPECT_EQ("foo", GetPathDisplayTextForSettings(&guest_profile, "foo"));
}
chromeos::disks::DiskMountManager::Shutdown(); chromeos::disks::DiskMountManager::Shutdown();
} }
...@@ -331,46 +307,30 @@ TEST_F(FileManagerPathUtilTest, MigrateToDriveFs) { ...@@ -331,46 +307,30 @@ TEST_F(FileManagerPathUtilTest, MigrateToDriveFs) {
base::FilePath my_drive = old_drive.Append("root"); base::FilePath my_drive = old_drive.Append("root");
base::FilePath file_in_my_drive = old_drive.Append("root").Append("file.txt"); base::FilePath file_in_my_drive = old_drive.Append("root").Append("file.txt");
// DriveFS disabled, no changes. // Migrate paths under old drive mount.
TestingProfile profile2(base::FilePath("/home/chronos/u-0123456789abcdef"));
chromeos::FakeChromeUserManager user_manager;
user_manager.AddUser(
AccountId::FromUserEmailGaiaId(profile2.GetProfileUserName(), "12345"));
PrefService* prefs = profile2.GetPrefs();
prefs->SetString(drive::prefs::kDriveFsProfileSalt, "a");
drive::DriveIntegrationServiceFactory::GetForProfile(&profile2)->SetEnabled(
true);
base::FilePath result; base::FilePath result;
{ EXPECT_FALSE(MigrateToDriveFs(&profile2, other, &result));
base::test::ScopedFeatureList feature_list; EXPECT_TRUE(MigrateToDriveFs(&profile2, my_drive, &result));
feature_list.InitAndDisableFeature(chromeos::features::kDriveFs); EXPECT_EQ(base::FilePath(
drive::DriveIntegrationServiceFactory::GetForProfile(profile_.get()) "/media/fuse/drivefs-84675c855b63e12f384d45f033826980/root"),
->SetEnabled(true); result);
EXPECT_FALSE(MigrateToDriveFs(profile_.get(), other, &result)); EXPECT_TRUE(MigrateToDriveFs(&profile2, file_in_my_drive, &result));
EXPECT_FALSE(MigrateToDriveFs(profile_.get(), my_drive, &result)); EXPECT_EQ(
} base::FilePath("/media/fuse/drivefs-84675c855b63e12f384d45f033826980/"
// DriveFS enabled, migrate paths under old drive mount. "root/file.txt"),
{ result);
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(chromeos::features::kDriveFs);
TestingProfile profile2(base::FilePath("/home/chronos/u-0123456789abcdef"));
chromeos::FakeChromeUserManager user_manager;
user_manager.AddUser(
AccountId::FromUserEmailGaiaId(profile2.GetProfileUserName(), "12345"));
PrefService* prefs = profile2.GetPrefs();
prefs->SetString(drive::prefs::kDriveFsProfileSalt, "a");
drive::DriveIntegrationServiceFactory::GetForProfile(&profile2)->SetEnabled(
true);
EXPECT_FALSE(MigrateToDriveFs(&profile2, other, &result));
EXPECT_TRUE(MigrateToDriveFs(&profile2, my_drive, &result));
EXPECT_EQ(base::FilePath(
"/media/fuse/drivefs-84675c855b63e12f384d45f033826980/root"),
result);
EXPECT_TRUE(MigrateToDriveFs(&profile2, file_in_my_drive, &result));
EXPECT_EQ(
base::FilePath("/media/fuse/drivefs-84675c855b63e12f384d45f033826980/"
"root/file.txt"),
result);
}
} }
TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
base::test::ScopedFeatureList initial_features;
initial_features.InitAndEnableFeature(chromeos::features::kDriveFs);
storage::ExternalMountPoints* mount_points = storage::ExternalMountPoints* mount_points =
storage::ExternalMountPoints::GetSystemInstance(); storage::ExternalMountPoints::GetSystemInstance();
// Setup for DriveFS. // Setup for DriveFS.
...@@ -412,9 +372,6 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) { ...@@ -412,9 +372,6 @@ TEST_F(FileManagerPathUtilTest, ConvertFileSystemURLToPathInsideCrostini) {
storage::FileSystemMountOption(), base::FilePath(kRemovableMediaPath)); storage::FileSystemMountOption(), base::FilePath(kRemovableMediaPath));
{ {
base::test::ScopedFeatureList features;
features.InitAndEnableFeature(chromeos::features::kDriveFs);
base::FilePath inside; base::FilePath inside;
EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini( EXPECT_TRUE(ConvertFileSystemURLToPathInsideCrostini(
profile_.get(), profile_.get(),
......
...@@ -20,7 +20,6 @@ namespace util { ...@@ -20,7 +20,6 @@ namespace util {
namespace { namespace {
const char kAllowedPaths[] = "allowedPaths"; const char kAllowedPaths[] = "allowedPaths";
const char kNativePath[] = "nativePath";
const char kNativeOrDrivePath[] = "nativeOrDrivePath"; const char kNativeOrDrivePath[] = "nativeOrDrivePath";
const char kAnyPath[] = "anyPath"; const char kAnyPath[] = "anyPath";
const char kAnyPathOrUrl[] = "anyPathOrUrl"; const char kAnyPathOrUrl[] = "anyPathOrUrl";
...@@ -121,11 +120,6 @@ GURL GetFileManagerMainPageUrlWithParams( ...@@ -121,11 +120,6 @@ GURL GetFileManagerMainPageUrlWithParams(
if (file_types) { if (file_types) {
switch (file_types->allowed_paths) { switch (file_types->allowed_paths) {
case ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH: case ui::SelectFileDialog::FileTypeInfo::NATIVE_PATH:
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs))
arg_value.SetString(kAllowedPaths, kNativeOrDrivePath);
else
arg_value.SetString(kAllowedPaths, kNativePath);
break;
case ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH: case ui::SelectFileDialog::FileTypeInfo::NATIVE_OR_DRIVE_PATH:
arg_value.SetString(kAllowedPaths, kNativeOrDrivePath); arg_value.SetString(kAllowedPaths, kNativeOrDrivePath);
break; break;
...@@ -136,10 +130,8 @@ GURL GetFileManagerMainPageUrlWithParams( ...@@ -136,10 +130,8 @@ GURL GetFileManagerMainPageUrlWithParams(
arg_value.SetString(kAllowedPaths, kAnyPathOrUrl); arg_value.SetString(kAllowedPaths, kAnyPathOrUrl);
break; break;
} }
} else if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
arg_value.SetString(kAllowedPaths, kNativeOrDrivePath);
} else { } else {
arg_value.SetString(kAllowedPaths, kNativePath); arg_value.SetString(kAllowedPaths, kNativeOrDrivePath);
} }
std::string json_args; std::string json_args;
......
...@@ -59,13 +59,9 @@ TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) { ...@@ -59,13 +59,9 @@ TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) {
EXPECT_TRUE(url.query().find("+") == std::string::npos); EXPECT_TRUE(url.query().find("+") == std::string::npos);
EXPECT_TRUE(url.query().find("%20") != std::string::npos); EXPECT_TRUE(url.query().find("%20") != std::string::npos);
// With DriveFS, Drive is always allowed where native paths are. // With DriveFS, Drive is always allowed where native paths are.
std::string allowed_paths =
base::FeatureList::IsEnabled(chromeos::features::kDriveFs)
? "nativeOrDrivePath"
: "nativePath";
EXPECT_EQ(base::StringPrintf( EXPECT_EQ(base::StringPrintf(
"{\n" "{\n"
" \"allowedPaths\": \"%s\",\n" " \"allowedPaths\": \"nativeOrDrivePath\",\n"
" \"currentDirectoryURL\": " " \"currentDirectoryURL\": "
"\"filesystem:chrome-extension://abc/Downloads/\",\n" "\"filesystem:chrome-extension://abc/Downloads/\",\n"
" \"defaultExtension\": \"txt\",\n" " \"defaultExtension\": \"txt\",\n"
...@@ -75,8 +71,7 @@ TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) { ...@@ -75,8 +71,7 @@ TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrlWithParams_NoFileTypes) {
" \"targetName\": \"foo.txt\",\n" " \"targetName\": \"foo.txt\",\n"
" \"title\": \"some title\",\n" " \"title\": \"some title\",\n"
" \"type\": \"open-file\"\n" " \"type\": \"open-file\"\n"
"}\n", "}\n"),
allowed_paths.c_str()),
PrettyPrintEscapedJson(url.query())); PrettyPrintEscapedJson(url.query()));
} }
......
...@@ -187,26 +187,6 @@ TEST_F(ExternalFileURLLoaderFactoryTest, RegularFile) { ...@@ -187,26 +187,6 @@ TEST_F(ExternalFileURLLoaderFactoryTest, RegularFile) {
EXPECT_EQ(kExpectedFileContents, response_body); EXPECT_EQ(kExpectedFileContents, response_body);
} }
TEST_F(ExternalFileURLLoaderFactoryTest, HostedDocument) {
// Hosted documents are never opened via externalfile: URLs with DriveFS.
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
return;
}
// Open a gdoc file.
network::TestURLLoaderClient client;
network::mojom::URLLoaderPtr loader = CreateURLLoaderAndStart(
&client,
CreateRequest("externalfile:drive-test-user-hash/root/Document 1 "
"excludeDir-test.gdoc"));
client.RunUntilRedirectReceived();
// Make sure that a hosted document triggers redirection.
EXPECT_TRUE(client.has_received_redirect());
EXPECT_TRUE(client.redirect_info().new_url.is_valid());
EXPECT_TRUE(client.redirect_info().new_url.SchemeIs("https"));
}
TEST_F(ExternalFileURLLoaderFactoryTest, RootDirectory) { TEST_F(ExternalFileURLLoaderFactoryTest, RootDirectory) {
network::TestURLLoaderClient client; network::TestURLLoaderClient client;
network::mojom::URLLoaderPtr loader = CreateURLLoaderAndStart( network::mojom::URLLoaderPtr loader = CreateURLLoaderAndStart(
......
...@@ -144,16 +144,6 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest { ...@@ -144,16 +144,6 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
// necessary because the fetch starts lazily upon the first read operation. // necessary because the fetch starts lazily upon the first read operation.
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
PlatformAppBrowserTest::SetUpOnMainThread(); PlatformAppBrowserTest::SetUpOnMainThread();
if (!base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
std::unique_ptr<drive::ResourceEntry> entry;
drive::FileError error = drive::FILE_ERROR_FAILED;
integration_service_->file_system()->GetResourceEntry(
base::FilePath::FromUTF8Unsafe("drive/root"), // whatever
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
content::RunAllTasksUntilIdle();
ASSERT_EQ(drive::FILE_ERROR_OK, error);
}
} }
void TearDown() override { void TearDown() override {
...@@ -161,13 +151,7 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest { ...@@ -161,13 +151,7 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
PlatformAppBrowserTest::TearDown(); PlatformAppBrowserTest::TearDown();
} }
base::FilePath GetDriveMountPoint() { base::FilePath GetDriveMountPoint() { return drivefs_mount_point_; }
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
return drivefs_mount_point_;
} else {
return drive::util::GetDriveMountPointPath(browser()->profile());
}
}
private: private:
drive::DriveIntegrationService* CreateDriveIntegrationService( drive::DriveIntegrationService* CreateDriveIntegrationService(
......
...@@ -453,19 +453,8 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -453,19 +453,8 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
} }
void UpdateAboutResourceSection() { void UpdateAboutResourceSection() {
if (IsDriveFsEnabled()) { // TODO(crbug.com/896123): Maybe worth implementing.
// TODO(crbug.com/896123): Maybe worth implementing. SetSectionEnabled("account-information-section", false);
SetSectionEnabled("account-information-section", false);
return;
}
SetSectionEnabled("account-information-section", true);
auto* drive_service = GetDriveService();
if (drive_service) {
drive_service->GetAboutResource(
base::Bind(&DriveInternalsWebUIHandler::OnGetAboutResource,
weak_ptr_factory_.GetWeakPtr()));
}
} }
// Called when GetAboutResource() call to DriveService is complete. // Called when GetAboutResource() call to DriveService is complete.
...@@ -492,19 +481,8 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -492,19 +481,8 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
} }
void UpdateDeltaUpdateStatusSection() { void UpdateDeltaUpdateStatusSection() {
if (IsDriveFsEnabled()) { // TODO(crbug.com/896123): Maybe worth implementing.
// TODO(crbug.com/896123): Maybe worth implementing. SetSectionEnabled("delta-update-status-section", false);
SetSectionEnabled("delta-update-status-section", false);
return;
}
SetSectionEnabled("delta-update-status-section", true);
auto* debug_info_collector = GetDebugInfoCollector();
if (debug_info_collector) {
debug_info_collector->GetMetadata(base::Bind(
&DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate,
weak_ptr_factory_.GetWeakPtr()));
}
} }
// Callback for DebugInfoCollector::GetMetadata for delta update. // Callback for DebugInfoCollector::GetMetadata for delta update.
...@@ -555,62 +533,12 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -555,62 +533,12 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
} }
void UpdateInFlightOperationsSection() { void UpdateInFlightOperationsSection() {
if (IsDriveFsEnabled()) { // TODO(crbug.com/896123): Maybe worth implementing.
// TODO(crbug.com/896123): Maybe worth implementing. SetSectionEnabled("in-flight-operations-section", false);
SetSectionEnabled("in-flight-operations-section", false);
return;
}
SetSectionEnabled("in-flight-operations-section", true);
auto* integration_service = GetIntegrationService();
if (!integration_service)
return;
drive::JobListInterface* job_list = integration_service->job_list();
if (!job_list)
return;
std::vector<drive::JobInfo> info_list = job_list->GetJobInfoList();
base::ListValue in_flight_operations;
for (size_t i = 0; i < info_list.size(); ++i) {
const drive::JobInfo& info = info_list[i];
auto dict = std::make_unique<base::DictionaryValue>();
dict->SetInteger("id", info.job_id);
dict->SetString("type", drive::JobTypeToString(info.job_type));
dict->SetString("file_path", info.file_path.AsUTF8Unsafe());
dict->SetString("state", drive::JobStateToString(info.state));
dict->SetDouble("progress_current", info.num_completed_bytes);
dict->SetDouble("progress_total", info.num_total_bytes);
in_flight_operations.Append(std::move(dict));
}
MaybeCallJavascript("updateInFlightOperations",
std::move(in_flight_operations));
} }
void UpdateFileSystemContentsSection() { void UpdateFileSystemContentsSection() {
if (IsDriveFsEnabled()) { SetSectionEnabled("file-system-contents-section", false);
SetSectionEnabled("file-system-contents-section", false);
return;
}
SetSectionEnabled("file-system-contents-section", true);
drive::DebugInfoCollector* debug_info_collector = GetDebugInfoCollector();
if (!debug_info_collector)
return;
// Start rendering the file system tree as text.
const base::FilePath root_path = drive::util::GetDriveGrandRootPath();
debug_info_collector->GetResourceEntry(
root_path,
base::BindOnce(&DriveInternalsWebUIHandler::OnGetResourceEntryByPath,
weak_ptr_factory_.GetWeakPtr(), root_path));
debug_info_collector->ReadDirectory(
root_path,
base::Bind(&DriveInternalsWebUIHandler::OnReadDirectoryByPath,
weak_ptr_factory_.GetWeakPtr(), root_path));
} }
// Called when GetResourceEntryByPath() is complete. // Called when GetResourceEntryByPath() is complete.
...@@ -727,8 +655,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -727,8 +655,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
PrefService* pref_service = profile()->GetPrefs(); PrefService* pref_service = profile()->GetPrefs();
base::ListValue preferences; base::ListValue preferences;
AppendKeyValue(&preferences, "DriveFS",
IsDriveFsEnabled() ? "true" : "false");
for (size_t i = 0; i < base::size(kDriveRelatedPreferences); ++i) { for (size_t i = 0; i < base::size(kDriveRelatedPreferences); ++i) {
const std::string key = kDriveRelatedPreferences[i]; const std::string key = kDriveRelatedPreferences[i];
// As of now, all preferences are boolean. // As of now, all preferences are boolean.
...@@ -772,10 +698,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -772,10 +698,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
} }
void UpdateServiceLogSection() { void UpdateServiceLogSection() {
if (!IsDriveFsEnabled()) {
SetSectionEnabled("service-log-section", false);
return;
}
SetSectionEnabled("service-log-section", true); SetSectionEnabled("service-log-section", true);
if (service_log_file_is_processing_) if (service_log_file_is_processing_)
...@@ -818,20 +740,8 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -818,20 +740,8 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
} }
void UpdateCacheContentsSection() { void UpdateCacheContentsSection() {
if (IsDriveFsEnabled()) { // TODO(crbug.com/896123): Maybe worth implementing.
// TODO(crbug.com/896123): Maybe worth implementing. SetSectionEnabled("cache-contents-section", false);
SetSectionEnabled("cache-contents-section", false);
return;
}
SetSectionEnabled("cache-contents-section", true);
auto* debug_info_collector = GetDebugInfoCollector();
if (debug_info_collector) {
debug_info_collector->IterateFileCache(
base::Bind(&DriveInternalsWebUIHandler::OnUpdateCacheEntry,
weak_ptr_factory_.GetWeakPtr()),
base::DoNothing());
}
} }
// Called as the iterator for DebugInfoCollector::IterateFileCache(). // Called as the iterator for DebugInfoCollector::IterateFileCache().
...@@ -954,11 +864,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { ...@@ -954,11 +864,6 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
return service ? service->debug_info_collector() : NULL; return service ? service->debug_info_collector() : NULL;
} }
// Whether DriveFS is enabled.
bool IsDriveFsEnabled() {
return base::FeatureList::IsEnabled(chromeos::features::kDriveFs);
}
// The last event sent to the JavaScript side. // The last event sent to the JavaScript side.
int last_sent_event_id_; int last_sent_event_id_;
......
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