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

Check the Drive integration service is mounted before use

In guest mode, the Drive integration service exists, but it is not
mounted or enabled, meaning some operations on it will lead to a crash.
Use drive::util::GetIntegrationServiceByProfile instead of going through
the factory, as it also checks if drive is mounted.

Bug: 1029477
Change-Id: I5f3e71ee7e788507613f5fe6f158db4e0c4add87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2011467
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Auto-Submit: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarSergei Datsenko <dats@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733890}
parent f9c1da95
...@@ -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::DriveIntegrationServiceFactory::FindForProfile(primary_profile); drive::util::GetIntegrationServiceByProfile(primary_profile);
if ((integration_service && if ((integration_service &&
integration_service->GetMountPointPath().AppendRelativePath( integration_service->GetMountPointPath().AppendRelativePath(
path, &relative_path)) || path, &relative_path)) ||
......
...@@ -531,6 +531,8 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test { ...@@ -531,6 +531,8 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test {
ASSERT_TRUE(profile_manager_->CreateTestingProfile("user2@gmail.com")); ASSERT_TRUE(profile_manager_->CreateTestingProfile("user2@gmail.com"));
primary_profile->GetPrefs()->SetString(drive::prefs::kDriveFsProfileSalt, primary_profile->GetPrefs()->SetString(drive::prefs::kDriveFsProfileSalt,
"a"); "a");
primary_profile->GetPrefs()->SetBoolean(
drive::prefs::kDriveFsPinnedMigrated, true);
// 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>();
...@@ -550,10 +552,7 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test { ...@@ -550,10 +552,7 @@ class FileManagerPathUtilConvertUrlTest : public testing::Test {
drive::DriveIntegrationService* integration_service = drive::DriveIntegrationService* integration_service =
drive::DriveIntegrationServiceFactory::GetForProfile(primary_profile); drive::DriveIntegrationServiceFactory::GetForProfile(primary_profile);
drive_mount_point_ = integration_service->GetMountPointPath(); drive_mount_point_ = integration_service->GetMountPointPath();
mount_points->RegisterFileSystem( integration_service->OnMounted(drive_mount_point_);
drive_mount_point_.BaseName().AsUTF8Unsafe(),
storage::kFileSystemTypeNativeLocal, storage::FileSystemMountOption(),
drive_mount_point_);
// Add a crostini mount point for the primary profile. // Add a crostini mount point for the primary profile.
crostini_mount_point_ = GetCrostiniMountDirectory(primary_profile); crostini_mount_point_ = GetCrostiniMountDirectory(primary_profile);
......
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