Chromium Code Reviews| 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); | |
| 68 FilePath GetFilePathOfProfileAtIndex(size_t index, FilePath user_data_dir); | |
|
sky
2011/06/10 16:24:14
const FilePath&
sail
2011/06/11 01:27:37
Done.
| |
| 69 | |
| 65 // Explicit asynchronous creation of the profile. |observer| is called | 70 // Explicit asynchronous creation of the profile. |observer| is called |
| 66 // when profile is created. If profile has already been created, observer | 71 // when profile is created. If profile has already been created, observer |
| 67 // is called immediately. Should be called on the UI thread. | 72 // is called immediately. Should be called on the UI thread. |
| 68 void CreateProfileAsync(const FilePath& user_data_dir, | 73 void CreateProfileAsync(const FilePath& user_data_dir, |
| 69 ProfileManagerObserver* observer); | 74 ProfileManagerObserver* observer); |
| 70 | 75 |
| 71 // Initiates default profile creation. If default profile has already been | 76 // Initiates default profile creation. If default profile has already been |
| 72 // created, observer is called immediately. Should be called on the UI thread. | 77 // created, observer is called immediately. Should be called on the UI thread. |
| 73 static void CreateDefaultProfileAsync(ProfileManagerObserver* observer); | 78 static void CreateDefaultProfileAsync(ProfileManagerObserver* observer); |
| 74 | 79 |
| (...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 | 171 // Adds a pre-existing Profile object to the set managed by this |
| 167 // ProfileManager. This ProfileManager takes ownership of the Profile. | 172 // ProfileManager. This ProfileManager takes ownership of the Profile. |
| 168 // The Profile should not already be managed by this ProfileManager. | 173 // The Profile should not already be managed by this ProfileManager. |
| 169 // Returns true if the profile was added, false otherwise. | 174 // Returns true if the profile was added, false otherwise. |
| 170 bool AddProfile(Profile* profile); | 175 bool AddProfile(Profile* profile); |
| 171 | 176 |
| 172 // Registers profile with given info. Returns pointer to created ProfileInfo | 177 // Registers profile with given info. Returns pointer to created ProfileInfo |
| 173 // entry. | 178 // entry. |
| 174 ProfileInfo* RegisterProfile(Profile* profile, bool created); | 179 ProfileInfo* RegisterProfile(Profile* profile, bool created); |
| 175 | 180 |
| 181 std::vector<std::pair<FilePath, string16> > | |
|
sky
2011/06/10 16:24:14
How about a typedef. And document what the string1
sail
2011/06/11 01:27:37
Done.
| |
| 182 GetSortedProfilesFromDirectoryMap(); | |
| 183 | |
| 176 NotificationRegistrar registrar_; | 184 NotificationRegistrar registrar_; |
| 177 | 185 |
| 178 // Indicates that a user has logged in and that the profile specified | 186 // 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 | 187 // in the --login-profile command line argument should be used as the |
| 180 // default. | 188 // default. |
| 181 bool logged_in_; | 189 bool logged_in_; |
| 182 | 190 |
| 183 // Maps profile path to ProfileInfo (if profile has been created). Use | 191 // Maps profile path to ProfileInfo (if profile has been created). Use |
| 184 // RegisterProfile() to add into this map. | 192 // RegisterProfile() to add into this map. |
| 185 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; | 193 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; |
| 186 ProfilesInfoMap profiles_info_; | 194 ProfilesInfoMap profiles_info_; |
| 187 | 195 |
| 188 DISALLOW_COPY_AND_ASSIGN(ProfileManager); | 196 DISALLOW_COPY_AND_ASSIGN(ProfileManager); |
| 189 }; | 197 }; |
| 190 | 198 |
| 191 // Same as the ProfileManager, but doesn't initialize some services of the | 199 // Same as the ProfileManager, but doesn't initialize some services of the |
| 192 // profile. This one is useful in unittests. | 200 // profile. This one is useful in unittests. |
| 193 class ProfileManagerWithoutInit : public ProfileManager { | 201 class ProfileManagerWithoutInit : public ProfileManager { |
| 194 protected: | 202 protected: |
| 195 virtual void DoFinalInit(Profile*) {} | 203 virtual void DoFinalInit(Profile*) {} |
| 196 }; | 204 }; |
| 197 | 205 |
| 198 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 206 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
| OLD | NEW |