Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1247)

Unified Diff: chrome/browser/chromeos/file_manager/path_util.cc

Issue 677373002: Remove migation code for file manager path preference. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/file_manager/path_util.cc
diff --git a/chrome/browser/chromeos/file_manager/path_util.cc b/chrome/browser/chromeos/file_manager/path_util.cc
index cf9b0ed3937cce96e5ce9a25fc2a8cb32679fb02..4416f145fd3f6bc262152ea61bfa15d5d5a09074 100644
--- a/chrome/browser/chromeos/file_manager/path_util.cc
+++ b/chrome/browser/chromeos/file_manager/path_util.cc
@@ -21,13 +21,6 @@ namespace util {
namespace {
const char kDownloadsFolderName[] = "Downloads";
-const base::FilePath::CharType kOldDownloadsFolderPath[] =
- FILE_PATH_LITERAL("/home/chronos/user/Downloads");
-const base::FilePath::CharType kOldDriveFolderPath[] =
- FILE_PATH_LITERAL("/special/drive");
-// Unintended path introduced in crbug.com/363026.
-const base::FilePath::CharType kBuggyDriveFolderPath[] =
- FILE_PATH_LITERAL("/special/drive-user");
} // namespace
@@ -50,52 +43,14 @@ base::FilePath GetDownloadsFolderForProfile(Profile* profile) {
bool MigratePathFromOldFormat(Profile* profile,
const base::FilePath& old_path,
base::FilePath* new_path) {
- // M34:
- // /home/chronos/user/Downloads/xxx => /home/chronos/u-hash/Downloads/xxx
- // /special/drive => /special/drive-xxx
- //
- // Old path format comes either from stored old settings or from the initial
- // default value set in DownloadPrefs::RegisterProfilePrefs in profile-unaware
- // code location. In the former case it is "/home/chronos/user/Downloads",
- // and in the latter case it is DownloadPrefs::GetDefaultDownloadDirectory().
- // Those two paths coincides as long as $HOME=/home/chronos/user, but the
- // environment variable is phasing out (crbug.com/333031) so we care both.
+ const base::FilePath old_base = DownloadPrefs::GetDefaultDownloadDirectory();
+ const base::FilePath new_base = GetDownloadsFolderForProfile(profile);
- const base::FilePath downloads = GetDownloadsFolderForProfile(profile);
- const base::FilePath drive = drive::util::GetDriveMountPointPath(profile);
-
- std::vector<std::pair<base::FilePath, base::FilePath> > bases;
- bases.push_back(std::make_pair(base::FilePath(kOldDownloadsFolderPath),
- downloads));
- bases.push_back(std::make_pair(DownloadPrefs::GetDefaultDownloadDirectory(),
- downloads));
- bases.push_back(std::make_pair(base::FilePath(kOldDriveFolderPath), drive));
- bases.push_back(std::make_pair(base::FilePath(kBuggyDriveFolderPath), drive));
-
- // Trying migrating u-<hash>/Downloads to the current download path. This is
- // no-op when multi-profile is enabled. This is necessary for (1) back
- // migration when multi-profile flag is enabled and then disabled, or (2) in
- // some edge cases (crbug.com/356322) that u-<hash> path is temporarily used.
- if (user_manager::UserManager::IsInitialized()) {
- const user_manager::User* const user =
- chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
- if (user) {
- const base::FilePath hashed_downloads =
- chromeos::ProfileHelper::GetProfilePathByUserIdHash(
- user->username_hash()).AppendASCII(kDownloadsFolderName);
- bases.push_back(std::make_pair(hashed_downloads, downloads));
- }
- }
-
- for (size_t i = 0; i < bases.size(); ++i) {
- const base::FilePath& old_base = bases[i].first;
- const base::FilePath& new_base = bases[i].second;
- base::FilePath relative;
- if (old_path == old_base ||
- old_base.AppendRelativePath(old_path, &relative)) {
- *new_path = new_base.Append(relative);
- return old_path != *new_path;
- }
+ base::FilePath relative;
+ if (old_path == old_base ||
+ old_base.AppendRelativePath(old_path, &relative)) {
+ *new_path = new_base.Append(relative);
+ return old_path != *new_path;
}
return false;
« no previous file with comments | « chrome/browser/chromeos/file_manager/path_util.h ('k') | chrome/browser/chromeos/file_manager/path_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698