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