OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This class keeps track of the currently-active profiles in the runtime. | 5 // This class keeps track of the currently-active profiles in the runtime. |
6 | 6 |
7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 Profile* GetDefaultProfile(const FilePath& user_data_dir); | 55 Profile* GetDefaultProfile(const FilePath& user_data_dir); |
56 | 56 |
57 // Same as instance method but provides the default user_data_dir as well. | 57 // Same as instance method but provides the default user_data_dir as well. |
58 static Profile* GetDefaultProfile(); | 58 static Profile* GetDefaultProfile(); |
59 | 59 |
60 // Returns a profile for a specific profile directory within the user data | 60 // Returns a profile for a specific profile directory within the user data |
61 // dir. This will return an existing profile it had already been created, | 61 // dir. This will return an existing profile it had already been created, |
62 // otherwise it will create and manage it. | 62 // otherwise it will create and manage it. |
63 Profile* GetProfile(const FilePath& profile_dir); | 63 Profile* GetProfile(const FilePath& profile_dir); |
64 | 64 |
65 // Multi-profile support. | |
66 size_t GetNumberOfProfiles(); | |
67 string16 GetNameOfProfileAtIndex(size_t index); | |
sky
2011/06/13 23:15:15
const string16&
sail
2011/06/13 23:26:12
Hm.. in this case the name of the profile is store
sky
2011/06/13 23:59:39
2011/06/13 23:26:12, sail wrote:
| |
68 FilePath GetFilePathOfProfileAtIndex(size_t index, | |
69 const FilePath& user_data_dir); | |
70 | |
65 // Explicit asynchronous creation of the profile. |observer| is called | 71 // Explicit asynchronous creation of the profile. |observer| is called |
66 // when profile is created. If profile has already been created, observer | 72 // when profile is created. If profile has already been created, observer |
67 // is called immediately. Should be called on the UI thread. | 73 // is called immediately. Should be called on the UI thread. |
68 void CreateProfileAsync(const FilePath& user_data_dir, | 74 void CreateProfileAsync(const FilePath& user_data_dir, |
69 ProfileManagerObserver* observer); | 75 ProfileManagerObserver* observer); |
70 | 76 |
71 // Initiates default profile creation. If default profile has already been | 77 // Initiates default profile creation. If default profile has already been |
72 // created, observer is called immediately. Should be called on the UI thread. | 78 // created, observer is called immediately. Should be called on the UI thread. |
73 static void CreateDefaultProfileAsync(ProfileManagerObserver* observer); | 79 static void CreateDefaultProfileAsync(ProfileManagerObserver* observer); |
74 | 80 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 // Adds a pre-existing Profile object to the set managed by this | 172 // Adds a pre-existing Profile object to the set managed by this |
167 // ProfileManager. This ProfileManager takes ownership of the Profile. | 173 // ProfileManager. This ProfileManager takes ownership of the Profile. |
168 // The Profile should not already be managed by this ProfileManager. | 174 // The Profile should not already be managed by this ProfileManager. |
169 // Returns true if the profile was added, false otherwise. | 175 // Returns true if the profile was added, false otherwise. |
170 bool AddProfile(Profile* profile); | 176 bool AddProfile(Profile* profile); |
171 | 177 |
172 // Registers profile with given info. Returns pointer to created ProfileInfo | 178 // Registers profile with given info. Returns pointer to created ProfileInfo |
173 // entry. | 179 // entry. |
174 ProfileInfo* RegisterProfile(Profile* profile, bool created); | 180 ProfileInfo* RegisterProfile(Profile* profile, bool created); |
175 | 181 |
182 typedef std::pair<FilePath, string16> ProfilePathAndName; | |
183 typedef std::vector<ProfilePathAndName> ProfilePathAndNames; | |
184 ProfilePathAndNames GetSortedProfilesFromDirectoryMap(); | |
185 | |
186 static bool CompareProfilePathAndName( | |
187 const ProfileManager::ProfilePathAndName& pair1, | |
188 const ProfileManager::ProfilePathAndName& pair2); | |
189 | |
176 NotificationRegistrar registrar_; | 190 NotificationRegistrar registrar_; |
177 | 191 |
178 // Indicates that a user has logged in and that the profile specified | 192 // Indicates that a user has logged in and that the profile specified |
179 // in the --login-profile command line argument should be used as the | 193 // in the --login-profile command line argument should be used as the |
180 // default. | 194 // default. |
181 bool logged_in_; | 195 bool logged_in_; |
182 | 196 |
183 // Maps profile path to ProfileInfo (if profile has been created). Use | 197 // Maps profile path to ProfileInfo (if profile has been created). Use |
184 // RegisterProfile() to add into this map. | 198 // RegisterProfile() to add into this map. |
185 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; | 199 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; |
186 ProfilesInfoMap profiles_info_; | 200 ProfilesInfoMap profiles_info_; |
187 | 201 |
188 DISALLOW_COPY_AND_ASSIGN(ProfileManager); | 202 DISALLOW_COPY_AND_ASSIGN(ProfileManager); |
189 }; | 203 }; |
190 | 204 |
191 // Same as the ProfileManager, but doesn't initialize some services of the | 205 // Same as the ProfileManager, but doesn't initialize some services of the |
192 // profile. This one is useful in unittests. | 206 // profile. This one is useful in unittests. |
193 class ProfileManagerWithoutInit : public ProfileManager { | 207 class ProfileManagerWithoutInit : public ProfileManager { |
194 protected: | 208 protected: |
195 virtual void DoFinalInit(Profile*) {} | 209 virtual void DoFinalInit(Profile*) {} |
196 }; | 210 }; |
197 | 211 |
198 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 212 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
OLD | NEW |