Commit c4453e28 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Suport MyFiles for crostini path sharing

Bug: 878324
Change-Id: I09976b84a4016d687c505f0808d92d57ab87ee7c
Reviewed-on: https://chromium-review.googlesource.com/c/1312138
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarNicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606262}
parent ee2630a9
......@@ -73,19 +73,24 @@ void CallSeneschalSharePath(
vm_tools::seneschal::SharePathRequest request;
base::FilePath drivefs_path;
base::FilePath relative_path;
drive::DriveIntegrationService* integration_service =
drive::DriveIntegrationServiceFactory::GetForProfile(profile);
drive::DriveIntegrationService* integration_service = nullptr;
if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs)) {
integration_service =
drive::DriveIntegrationServiceFactory::GetForProfile(profile);
}
base::FilePath drivefs_mount_point_path;
base::FilePath drivefs_mount_name;
// Allow download directory and subdirs.
// Allow MyFiles|Downloads directory and subdirs.
bool allowed_path = false;
base::FilePath downloads =
file_manager::util::GetDownloadsFolderForProfile(profile);
if (downloads == path || downloads.AppendRelativePath(path, &relative_path)) {
base::FilePath my_files =
file_manager::util::GetMyFilesFolderForProfile(profile);
if (my_files == path || my_files.AppendRelativePath(path, &relative_path)) {
allowed_path = true;
request.set_storage_location(
vm_tools::seneschal::SharePathRequest::DOWNLOADS);
base::FeatureList::IsEnabled(chromeos::features::kMyFilesVolume)
? vm_tools::seneschal::SharePathRequest::MY_FILES
: vm_tools::seneschal::SharePathRequest::DOWNLOADS);
request.set_owner_id(crostini::CryptohomeIdForProfile(profile));
} else if (base::FeatureList::IsEnabled(chromeos::features::kDriveFs) &&
integration_service &&
......
......@@ -110,7 +110,6 @@ class CrostiniSharePathTest : public testing::Test {
chromeos::switches::kCrostiniFiles);
// Setup for DriveFS.
features_.InitAndEnableFeature(chromeos::features::kDriveFs);
user_manager.AddUser(AccountId::FromUserEmailGaiaId(
profile()->GetProfileUserName(), "12345"));
profile()->GetPrefs()->SetString(drive::prefs::kDriveFsProfileSalt, "a");
......@@ -167,6 +166,19 @@ TEST_F(CrostiniSharePathTest, SuccessDownloadsRoot) {
run_loop()->Run();
}
TEST_F(CrostiniSharePathTest, SuccessMyFilesRoot) {
features_.InitAndEnableFeature(chromeos::features::kMyFilesVolume);
base::FilePath my_files =
file_manager::util::GetMyFilesFolderForProfile(profile());
SharePath(profile(), "vm-running", my_files, PERSIST_NO,
base::BindOnce(&CrostiniSharePathTest::SharePathCallback,
base::Unretained(this), Persist::NO,
SeneschalClientCalled::YES,
&vm_tools::seneschal::SharePathRequest::MY_FILES, "",
Success::YES, "", run_loop()->QuitClosure()));
run_loop()->Run();
}
TEST_F(CrostiniSharePathTest, SuccessNoPersist) {
SharePath(profile(), "vm-running", share_path_, PERSIST_NO,
base::BindOnce(
......@@ -189,6 +201,7 @@ TEST_F(CrostiniSharePathTest, SuccessPersist) {
}
TEST_F(CrostiniSharePathTest, SuccessDriveFsMyDrive) {
features_.InitAndEnableFeature(chromeos::features::kDriveFs);
SharePath(profile(), "vm-running", drivefs_.Append("root").Append("my"),
PERSIST_NO,
base::BindOnce(
......@@ -199,7 +212,19 @@ TEST_F(CrostiniSharePathTest, SuccessDriveFsMyDrive) {
run_loop()->Run();
}
TEST_F(CrostiniSharePathTest, FailureDriveFsDisabled) {
features_.InitAndDisableFeature(chromeos::features::kDriveFs);
SharePath(
profile(), "vm-running", drivefs_.Append("root").Append("my"), PERSIST_NO,
base::BindOnce(&CrostiniSharePathTest::SharePathCallback,
base::Unretained(this), Persist::NO,
SeneschalClientCalled::NO, nullptr, "my", Success::NO,
"Path is not allowed", run_loop()->QuitClosure()));
run_loop()->Run();
}
TEST_F(CrostiniSharePathTest, SuccessDriveFsMyDriveRoot) {
features_.InitAndEnableFeature(chromeos::features::kDriveFs);
SharePath(profile(), "vm-running", drivefs_.Append("root"), PERSIST_NO,
base::BindOnce(
&CrostiniSharePathTest::SharePathCallback,
......@@ -210,6 +235,7 @@ TEST_F(CrostiniSharePathTest, SuccessDriveFsMyDriveRoot) {
}
TEST_F(CrostiniSharePathTest, FailDriveFsRoot) {
features_.InitAndEnableFeature(chromeos::features::kDriveFs);
SharePath(profile(), "vm-running", drivefs_, PERSIST_NO,
base::BindOnce(&CrostiniSharePathTest::SharePathCallback,
base::Unretained(this), Persist::NO,
......@@ -219,6 +245,7 @@ TEST_F(CrostiniSharePathTest, FailDriveFsRoot) {
}
TEST_F(CrostiniSharePathTest, SuccessDriveFsTeamDrives) {
features_.InitAndEnableFeature(chromeos::features::kDriveFs);
SharePath(profile(), "vm-running",
drivefs_.Append("team_drives").Append("team"), PERSIST_NO,
base::BindOnce(
......@@ -230,6 +257,7 @@ TEST_F(CrostiniSharePathTest, SuccessDriveFsTeamDrives) {
}
TEST_F(CrostiniSharePathTest, SuccessDriveFsComputers) {
features_.InitAndEnableFeature(chromeos::features::kDriveFs);
SharePath(profile(), "vm-running", drivefs_.Append("Computers").Append("pc"),
PERSIST_NO,
base::BindOnce(
......@@ -241,6 +269,7 @@ TEST_F(CrostiniSharePathTest, SuccessDriveFsComputers) {
}
TEST_F(CrostiniSharePathTest, FailDriveFsTrash) {
features_.InitAndEnableFeature(chromeos::features::kDriveFs);
SharePath(profile(), "vm-running",
drivefs_.Append(".Trash").Append("in-the-trash"), PERSIST_NO,
base::BindOnce(&CrostiniSharePathTest::SharePathCallback,
......
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