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

Side by Side Diff: chrome/browser/chromeos/profiles/profile_helper.h

Issue 14581006: [cros mp] Load profiles from /home/chronos/u-[$hash], add GetUserIdHashFromProfile() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: networking_private_api - use user_id_hash only if --multi-profiles switch is passed Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_
6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ 6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
11 #include "chrome/browser/chromeos/login/user_manager.h" 12 #include "chrome/browser/chromeos/login/user_manager.h"
12 13
13 class Profile; 14 class Profile;
14 15
15 namespace chromeos { 16 namespace chromeos {
16 17
17 class ProfileHelper : public UserManager::UserSessionStateObserver { 18 class ProfileHelper : public UserManager::UserSessionStateObserver {
18 public: 19 public:
20 // Chrome OS profile directories have custom prefix.
21 // Profile path format: [user_data_dir]/u-[$hash]
22 // Ex.: /home/chronos/u-0123456789
23 static const char kProfileDirPrefix[];
24
19 ProfileHelper(); 25 ProfileHelper();
20 virtual ~ProfileHelper(); 26 virtual ~ProfileHelper();
21 27
22 // Returns Profile instance that corresponds to |user_id_hash|. 28 // Returns Profile instance that corresponds to |user_id_hash|.
23 static Profile* GetProfileByUserIdHash(const std::string& user_id_hash); 29 static Profile* GetProfileByUserIdHash(const std::string& user_id_hash);
24 30
25 // Returns OffTheRecord profile for use during signing phase. 31 // Returns OffTheRecord profile for use during signing phase.
26 static Profile* GetSigninProfile(); 32 static Profile* GetSigninProfile();
27 33
34 // Returns user_id hash for |profile| instance or empty string if hash
35 // could not be extracted from |profile|.
36 static std::string GetUserIdHashFromProfile(Profile* profile);
37
28 // Returns true if |profile| is the signin Profile. This can be used during 38 // Returns true if |profile| is the signin Profile. This can be used during
29 // construction of the signin Profile to determine if that Profile is the 39 // construction of the signin Profile to determine if that Profile is the
30 // signin Profile. 40 // signin Profile.
31 static bool IsSigninProfile(Profile* profile); 41 static bool IsSigninProfile(Profile* profile);
32 42
33 // Initialize a bunch of services that are tied to a browser profile. 43 // Initialize a bunch of services that are tied to a browser profile.
34 // TODO(dzhioev): Investigate whether or not this method is needed. 44 // TODO(dzhioev): Investigate whether or not this method is needed.
35 static void ProfileStartup(Profile* profile, bool process_startup); 45 static void ProfileStartup(Profile* profile, bool process_startup);
36 46
47 // Returns active user profile dir in a format [u-$hash].
48 base::FilePath GetActiveUserProfileDir();
49
37 // Should called once after UserManager instance has been created. 50 // Should called once after UserManager instance has been created.
38 void Initialize(); 51 void Initialize();
39 52
40 // Returns hash for active user ID which is used to identify that user profile 53 // Returns hash for active user ID which is used to identify that user profile
41 // on Chrome OS. 54 // on Chrome OS.
42 std::string active_user_id_hash() { return active_user_id_hash_; } 55 std::string active_user_id_hash() { return active_user_id_hash_; }
43 56
44 private: 57 private:
58 friend class ProfileHelperTest;
59
45 // UserManager::UserSessionStateObserver implementation: 60 // UserManager::UserSessionStateObserver implementation:
46 virtual void ActiveUserHashChanged(const std::string& hash) OVERRIDE; 61 virtual void ActiveUserHashChanged(const std::string& hash) OVERRIDE;
47 62
48 // Identifies path to active user profile on Chrome OS. 63 // Identifies path to active user profile on Chrome OS.
49 std::string active_user_id_hash_; 64 std::string active_user_id_hash_;
50 65
51 DISALLOW_COPY_AND_ASSIGN(ProfileHelper); 66 DISALLOW_COPY_AND_ASSIGN(ProfileHelper);
52 }; 67 };
53 68
54 } // namespace chromeos 69 } // namespace chromeos
55 70
56 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ 71 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_
57 72
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698