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

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

Issue 216053002: Files.app multi-profile: add back migration to old path format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « chrome/browser/chromeos/file_manager/path_util.h ('k') | 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 91ef187378e27625063176e6e618fea55178f699..f043fdf564bb18148120bbadd6307ea930ad2173 100644
--- a/chrome/browser/chromeos/file_manager/path_util.cc
+++ b/chrome/browser/chromeos/file_manager/path_util.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "net/base/escape.h"
@@ -25,8 +26,6 @@ const base::FilePath::CharType kOldDownloadsFolderPath[] =
FILE_PATH_LITERAL("/home/chronos/user/Downloads");
const base::FilePath::CharType kOldDriveFolderPath[] =
FILE_PATH_LITERAL("/special/drive");
-const base::FilePath::CharType kNoHashDriveFolderPath[] =
- FILE_PATH_LITERAL("/special/drive-");
} // namespace
@@ -60,19 +59,32 @@ bool MigratePathFromOldFormat(Profile* profile,
const base::FilePath downloads = GetDownloadsFolderForProfile(profile);
const base::FilePath drive = drive::util::GetDriveMountPointPath(profile);
- const base::FilePath bases[][2] = {
- {base::FilePath(kOldDownloadsFolderPath), downloads},
- {DownloadPrefs::GetDefaultDownloadDirectory(), downloads},
- {base::FilePath(kOldDriveFolderPath), drive},
- // TODO(kinaba): http://crbug.com/341284 Remove after M34 branching.
- // For a short period we incorrectly set "/special/drive-" as the Drive path
- // that needs to be fixed.
- {base::FilePath(kNoHashDriveFolderPath), drive},
- };
-
- for (size_t i = 0; i < arraysize(bases); ++i) {
- const base::FilePath& old_base = bases[i][0];
- const base::FilePath& new_base = bases[i][1];
+
+ 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));
+
+ // 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 (chromeos::UserManager::IsInitialized()) {
+ const chromeos::User* user =
hirono 2014/03/28 02:05:35 nit: const chromeos::User* const user
kinaba 2014/03/28 02:11:06 Done.
+ chromeos::UserManager::Get()->GetUserByProfile(profile);
+ if (user) {
+ base::FilePath hashed_downloads =
hirono 2014/03/28 02:05:35 nit: const base::FilePath
kinaba 2014/03/28 02:11:06 Done.
+ 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)) {
« no previous file with comments | « chrome/browser/chromeos/file_manager/path_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698