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

Allow directories under Linux files mount point as download location

Allow Linux files directories as a downloads location as per
Android files in crosreview.com/1144992.

Bug: 863610
Change-Id: I5ddea45452ffd172231cf5516fc376ed6426e86c
Reviewed-on: https://chromium-review.googlesource.com/1158454Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579947}
parent 8768493d
......@@ -478,6 +478,14 @@ base::FilePath DownloadPrefs::SanitizeDownloadTargetPath(
return android_files_mount_point.Append(relative);
}
// Allow paths under the Linux files mount point.
base::FilePath linux_files_mount_point =
file_manager::util::GetCrostiniMountDirectory(profile_);
if (linux_files_mount_point.AppendRelativePath(path, &relative) &&
!relative.ReferencesParent()) {
return linux_files_mount_point.Append(relative);
}
// Fall back to the default download directory for all other paths.
return profile_download_dir;
#endif
......
......@@ -140,6 +140,13 @@ TEST(DownloadPrefsTest, DownloadDirSanitization) {
EXPECT_TRUE(prefs.DownloadPath().IsAbsolute());
EXPECT_EQ(prefs.DownloadPath(), testdir);
// Test a valid path for Linux files.
testdir = base::FilePath("/media/fuse/crostini_test_termina_penguin/testdir");
profile.GetPrefs()->SetString(prefs::kDownloadDefaultDirectory,
testdir.value());
EXPECT_TRUE(prefs.DownloadPath().IsAbsolute());
EXPECT_EQ(prefs.DownloadPath(), testdir);
// Test with an invalid path outside the download directory.
profile.GetPrefs()->SetString(prefs::kDownloadDefaultDirectory,
"/home/chronos");
......
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