10f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
20f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
30f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// found in the LICENSE file.
40f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
50f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_PATH_UTIL_H_
60f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_PATH_UTIL_H_
70f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <string>
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
100f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)class Profile;
110f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
120f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)namespace base {
130f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)class FilePath;
140f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)}
150f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
160f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)namespace file_manager {
170f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)namespace util {
180f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
190f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Gets the absolute path for the 'Downloads' folder for the |profile|.
200f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)base::FilePath GetDownloadsFolderForProfile(Profile* profile);
210f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
220f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Converts |old_path| to |new_path| and returns true, if the old path points
230f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// to an old location of user folders (in "Downloads" or "Google Drive").
240f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// The |profile| argument is used for determining the location of the
250f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// "Downloads" folder.
260f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//
270f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)// Here's the list of relocations we have made so far.
280f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// M27: crbug.com/229304, Migration code for this is removed in M34.
300f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   The "Google Drive" folder is moved from /special/drive to
310f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   /special/drive/root to stored shared files outside of "My Drive" in
320f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   /special/drive/other.
330f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// M34: crbug.com/313539
350f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   The "Downloads" folder is changed from /home/chronos/user/Downloads to
36effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch//   /home/chronos/u-<hash>/Downloads when multi-profile is enabled.
370f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//
380f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   The path "/home/chronos/user" is a hard link to the u-<hash> directory of
390f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   the primary profile of the current session. The two paths always meant the
400f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   same directory before multi-profiles. However, for secondary profiles in
410f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   a multi-profile session, the "user" path cannot be used to mean "its own"
420f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)//   Download folder anymore. Thus we are switching to always use "u-<hash>"
43effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch//   that consistently works whether or not it is primary.
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//
45effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// M35: crbug.com/356322
46effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch//   It turned out even if multi-profile is disabled, u-<hash> style profile
47effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch//   can be used in some situations. To address the cases, we add a migration
48effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch//   from /home/chronos/u-<hash>/Downloads to current Download path.
49effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch//   This just results in no-op when multi-profile is enabled.
500f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)bool MigratePathFromOldFormat(Profile* profile,
510f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                              const base::FilePath& old_path,
520f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)                              base::FilePath* new_path);
530f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// The canonical mount point name for "Downloads" folder.
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)std::string GetDownloadsMountPointName(Profile* profile);
565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
570f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)}  // namespace util
580f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)}  // namespace file_manager
590f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)
600f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#endif  // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_PATH_UTIL_H_
61