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

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

Issue 140783005: Handle missing $HOME case in download path migration code for multi-profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d8a9c2818cbdd1ab6ee68f901362f0b3f17f9d9f..ee95003bca637f3d7c182ccc2103fa05b48ab2c5 100644
--- a/chrome/browser/chromeos/file_manager/path_util.cc
+++ b/chrome/browser/chromeos/file_manager/path_util.cc
@@ -9,6 +9,7 @@
#include "base/path_service.h"
#include "base/sys_info.h"
#include "chrome/browser/chromeos/drive/file_system_util.h"
+#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/profiles/profile.h"
namespace file_manager {
@@ -40,18 +41,30 @@ bool MigratePathFromOldFormat(Profile* profile,
}
// /home/chronos/user/Downloads/xxx => /home/chronos/u-hash/Downloads/xxx
- const base::FilePath old_base(kOldDownloadsFolderPath);
- base::FilePath relative;
- if (old_path == old_base ||
- old_base.AppendRelativePath(old_path, &relative)) {
- const base::FilePath new_base = GetDownloadsFolderForProfile(profile);
- *new_path = new_base.Append(relative);
- return old_path != *new_path;
+ //
+ // 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_bases[] = {
+ base::FilePath(kOldDownloadsFolderPath),
+ DownloadPrefs::GetDefaultDownloadDirectory(),
+ };
+ for (size_t i = 0; i < arraysize(old_bases); ++i) {
+ const base::FilePath& old_base = old_bases[i];
+ base::FilePath relative;
+ if (old_path == old_base ||
+ old_base.AppendRelativePath(old_path, &relative)) {
+ const base::FilePath new_base = GetDownloadsFolderForProfile(profile);
+ *new_path = new_base.Append(relative);
+ return old_path != *new_path;
+ }
}
return false;
}
-
} // namespace util
} // namespace file_manager
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698