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/system_monitor/system_monitor.h" | |
21 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
22 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
24 #include "content/common/notification_observer.h" | 23 #include "content/common/notification_observer.h" |
25 #include "content/common/notification_registrar.h" | 24 #include "content/common/notification_registrar.h" |
26 | 25 |
27 class FilePath; | 26 class FilePath; |
28 class NewProfileLauncher; | 27 class NewProfileLauncher; |
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(); |
39 }; | 38 }; |
40 | 39 |
41 class ProfileManager : public base::NonThreadSafe, | 40 class ProfileManager : public base::NonThreadSafe, |
42 public base::SystemMonitor::PowerObserver, | |
43 public BrowserList::Observer, | 41 public BrowserList::Observer, |
44 public NotificationObserver, | 42 public NotificationObserver, |
45 public Profile::Delegate { | 43 public Profile::Delegate { |
46 public: | 44 public: |
47 ProfileManager(); | 45 ProfileManager(); |
48 virtual ~ProfileManager(); | 46 virtual ~ProfileManager(); |
49 | 47 |
50 // Invokes SessionServiceFactory::ShutdownForProfile() for all profiles. | 48 // Invokes SessionServiceFactory::ShutdownForProfile() for all profiles. |
51 static void ShutdownSessionServices(); | 49 static void ShutdownSessionServices(); |
52 | 50 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // been stored in Local State, hand back the Default profile. | 88 // been stored in Local State, hand back the Default profile. |
91 Profile* GetLastUsedProfile(const FilePath& user_data_dir); | 89 Profile* GetLastUsedProfile(const FilePath& user_data_dir); |
92 | 90 |
93 // Register the mapping of a directory to a profile name in Local State. | 91 // Register the mapping of a directory to a profile name in Local State. |
94 void RegisterProfileName(Profile* profile); | 92 void RegisterProfileName(Profile* profile); |
95 | 93 |
96 // Returns created profiles. Note, profiles order is NOT guaranteed to be | 94 // Returns created profiles. Note, profiles order is NOT guaranteed to be |
97 // related with the creation order. | 95 // related with the creation order. |
98 std::vector<Profile*> GetLoadedProfiles() const; | 96 std::vector<Profile*> GetLoadedProfiles() const; |
99 | 97 |
100 // PowerObserver notifications | |
101 virtual void OnSuspend(); | |
102 virtual void OnResume(); | |
103 | |
104 // NotificationObserver implementation. | 98 // NotificationObserver implementation. |
105 virtual void Observe(NotificationType type, | 99 virtual void Observe(NotificationType type, |
106 const NotificationSource& source, | 100 const NotificationSource& source, |
107 const NotificationDetails& details); | 101 const NotificationDetails& details); |
108 | 102 |
109 // BrowserList::Observer implementation. | 103 // BrowserList::Observer implementation. |
110 virtual void OnBrowserAdded(const Browser* browser); | 104 virtual void OnBrowserAdded(const Browser* browser); |
111 virtual void OnBrowserRemoved(const Browser* browser); | 105 virtual void OnBrowserRemoved(const Browser* browser); |
112 virtual void OnBrowserSetLastActive(const Browser* browser); | 106 virtual void OnBrowserSetLastActive(const Browser* browser); |
113 | 107 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 }; | 189 }; |
196 | 190 |
197 // Same as the ProfileManager, but doesn't initialize some services of the | 191 // Same as the ProfileManager, but doesn't initialize some services of the |
198 // profile. This one is useful in unittests. | 192 // profile. This one is useful in unittests. |
199 class ProfileManagerWithoutInit : public ProfileManager { | 193 class ProfileManagerWithoutInit : public ProfileManager { |
200 protected: | 194 protected: |
201 virtual void DoFinalInit(Profile*) {} | 195 virtual void DoFinalInit(Profile*) {} |
202 }; | 196 }; |
203 | 197 |
204 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 198 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
OLD | NEW |