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 |
11 #include <list> | 11 #include <list> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/hash_tables.h" | 16 #include "base/hash_tables.h" |
17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
23 #include "content/common/notification_observer.h" | 23 #include "content/common/notification_observer.h" |
24 #include "content/common/notification_registrar.h" | 24 #include "content/common/notification_registrar.h" |
25 | 25 |
26 class FilePath; | 26 class FilePath; |
27 class NewProfileLauncher; | 27 class NewProfileLauncher; |
28 class ProfileInfoCache; | |
29 | 28 |
30 class ProfileManagerObserver { | 29 class ProfileManagerObserver { |
31 public: | 30 public: |
32 // This method is called when profile is ready. If profile creation has | 31 // This method is called when profile is ready. If profile creation has |
33 // failed, method is called with |profile| equal to NULL. | 32 // failed, method is called with |profile| equal to NULL. |
34 virtual void OnProfileCreated(Profile* profile) = 0; | 33 virtual void OnProfileCreated(Profile* profile) = 0; |
35 | 34 |
36 // If true, delete the observer after the profile has been created. Default | 35 // If true, delete the observer after the profile has been created. Default |
37 // is false. | 36 // is false. |
38 virtual bool DeleteAfterCreation(); | 37 virtual bool DeleteAfterCreation(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 140 |
142 // Creates a new profile in the next available multiprofile directory. | 141 // Creates a new profile in the next available multiprofile directory. |
143 // Directories are named "profile_1", "profile_2", etc., in sequence of | 142 // Directories are named "profile_1", "profile_2", etc., in sequence of |
144 // creation. (Because directories can be removed, however, it may be the case | 143 // creation. (Because directories can be removed, however, it may be the case |
145 // that at some point the list of numbered profiles is not continuous.) | 144 // that at some point the list of numbered profiles is not continuous.) |
146 static void CreateMultiProfileAsync(); | 145 static void CreateMultiProfileAsync(); |
147 | 146 |
148 // Register multi-profile related preferences in Local State. | 147 // Register multi-profile related preferences in Local State. |
149 static void RegisterPrefs(PrefService* prefs); | 148 static void RegisterPrefs(PrefService* prefs); |
150 | 149 |
151 // Returns a ProfileInfoCache object which can be used to get information | |
152 // about profiles without having to load them from disk. | |
153 ProfileInfoCache& GetProfileInfoCache(); | |
154 | |
155 protected: | 150 protected: |
156 // Does final initial actions. | 151 // Does final initial actions. |
157 virtual void DoFinalInit(Profile* profile); | 152 virtual void DoFinalInit(Profile* profile); |
158 | 153 |
159 private: | 154 private: |
160 friend class ExtensionEventRouterForwarderTest; | 155 friend class ExtensionEventRouterForwarderTest; |
161 | 156 |
162 // This struct contains information about profiles which are being loaded or | 157 // This struct contains information about profiles which are being loaded or |
163 // were loaded. | 158 // were loaded. |
164 struct ProfileInfo { | 159 struct ProfileInfo { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // Indicates that a user has logged in and that the profile specified | 197 // Indicates that a user has logged in and that the profile specified |
203 // in the --login-profile command line argument should be used as the | 198 // in the --login-profile command line argument should be used as the |
204 // default. | 199 // default. |
205 bool logged_in_; | 200 bool logged_in_; |
206 | 201 |
207 // Maps profile path to ProfileInfo (if profile has been created). Use | 202 // Maps profile path to ProfileInfo (if profile has been created). Use |
208 // RegisterProfile() to add into this map. | 203 // RegisterProfile() to add into this map. |
209 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; | 204 typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap; |
210 ProfilesInfoMap profiles_info_; | 205 ProfilesInfoMap profiles_info_; |
211 | 206 |
212 scoped_ptr<ProfileInfoCache> profile_info_cache_; | |
213 | |
214 DISALLOW_COPY_AND_ASSIGN(ProfileManager); | 207 DISALLOW_COPY_AND_ASSIGN(ProfileManager); |
215 }; | 208 }; |
216 | 209 |
217 // Same as the ProfileManager, but doesn't initialize some services of the | 210 // Same as the ProfileManager, but doesn't initialize some services of the |
218 // profile. This one is useful in unittests. | 211 // profile. This one is useful in unittests. |
219 class ProfileManagerWithoutInit : public ProfileManager { | 212 class ProfileManagerWithoutInit : public ProfileManager { |
220 protected: | 213 protected: |
221 virtual void DoFinalInit(Profile*) {} | 214 virtual void DoFinalInit(Profile*) {} |
222 }; | 215 }; |
223 | 216 |
224 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 217 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
OLD | NEW |