Skip to content

Commit

Permalink
CrOS Allow download preferences to be any folder inside MyFiles
Browse files Browse the repository at this point in the history
Before this CL when MyFilesVolume flag is enabled users couldn't select
other folders inside MyFiles, only inside MyFiles/Downloads, this CL
fixes it.

The flag MyFilesVolume will be enabled by default in follow up CL.

this CL when MyFilesVolume flag is enabled

Test: browser_tests --gtest_filter=DownloadPrefsTest only passes with
Bug: 873539
Change-Id: I8dc172412a1fd7b7cc69bc82f75c39f29e2f984e
Reviewed-on: https://chromium-review.googlesource.com/c/1433635
Commit-Queue: Min Qin <qinmin@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: Min Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625733}
  • Loading branch information
Luciano Pacheco authored and Commit Bot committed Jan 24, 2019
1 parent b7f3df5 commit b430338
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions chrome/browser/download/download_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,14 @@ base::FilePath DownloadPrefs::SanitizeDownloadTargetPath(
const base::FilePath& path) const {
#if defined(OS_CHROMEOS)
// If |path| isn't absolute, fall back to the default directory.
base::FilePath profile_download_dir = GetDefaultDownloadDirectoryForProfile();
base::FilePath profile_myfiles_path =
file_manager::util::GetMyFilesFolderForProfile(profile_);

if (!path.IsAbsolute() || path.ReferencesParent())
return profile_download_dir;
return profile_myfiles_path;

// Allow default download directory and subdirs.
if (profile_download_dir == path || profile_download_dir.IsParent(path))
// Allow myfiles directory and subdirs.
if (profile_myfiles_path == path || profile_myfiles_path.IsParent(path))
return path;

// Allow paths under the drive mount point.
Expand All @@ -482,7 +484,7 @@ base::FilePath DownloadPrefs::SanitizeDownloadTargetPath(
return path;

// Fall back to the default download directory for all other paths.
return profile_download_dir;
return GetDefaultDownloadDirectoryForProfile();
#endif
return path;
}
Expand Down

0 comments on commit b430338

Please sign in to comment.