OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_ |
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_ |
7 | 7 |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "chrome/browser/profiles/profile_keyed_service_factory.h" | 9 #include "chrome/browser/profiles/profile_keyed_service_factory.h" |
10 | 10 |
11 class SigninManager; | 11 class SigninManager; |
12 class SigninManagerBase; | 12 class SigninManagerBase; |
13 class PrefRegistrySimple; | 13 class PrefRegistrySimple; |
14 class PrefRegistrySyncable; | |
15 class Profile; | 14 class Profile; |
16 | 15 |
17 // Singleton that owns all SigninManagers and associates them with | 16 // Singleton that owns all SigninManagers and associates them with |
18 // Profiles. Listens for the Profile's destruction notification and cleans up | 17 // Profiles. Listens for the Profile's destruction notification and cleans up |
19 // the associated SigninManager. | 18 // the associated SigninManager. |
20 class SigninManagerFactory : public ProfileKeyedServiceFactory { | 19 class SigninManagerFactory : public ProfileKeyedServiceFactory { |
21 public: | 20 public: |
22 | 21 |
23 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
24 // Returns the instance of SigninManager associated with this profile | 23 // Returns the instance of SigninManager associated with this profile |
25 // (creating one if none exists). Returns NULL if this profile cannot have a | 24 // (creating one if none exists). Returns NULL if this profile cannot have a |
26 // SigninManager (for example, if |profile| is incognito). | 25 // SigninManager (for example, if |profile| is incognito). |
27 static SigninManagerBase* GetForProfile(Profile* profile); | 26 static SigninManagerBase* GetForProfile(Profile* profile); |
28 | 27 |
29 // Returns the instance of SigninManager associated with this profile. Returns | 28 // Returns the instance of SigninManager associated with this profile. Returns |
30 // null if no SigninManager instance currently exists (will not create a new | 29 // null if no SigninManager instance currently exists (will not create a new |
31 // instance). | 30 // instance). |
32 static SigninManagerBase* GetForProfileIfExists(Profile* profile); | 31 static SigninManagerBase* GetForProfileIfExists(Profile* profile); |
33 #else | 32 #else |
34 // On non-ChromeOS platforms, the SigninManager the factory creates will be | 33 // On non-ChromeOS platforms, the SigninManager the factory creates will be |
35 // an instance of the extended SigninManager class. | 34 // an instance of the extended SigninManager class. |
36 static SigninManager* GetForProfile(Profile* profile); | 35 static SigninManager* GetForProfile(Profile* profile); |
37 static SigninManager* GetForProfileIfExists(Profile* profile); | 36 static SigninManager* GetForProfileIfExists(Profile* profile); |
38 #endif | 37 #endif |
39 | 38 |
40 // Returns an instance of the SigninManagerFactory singleton. | 39 // Returns an instance of the SigninManagerFactory singleton. |
41 static SigninManagerFactory* GetInstance(); | 40 static SigninManagerFactory* GetInstance(); |
42 | 41 |
43 // Implementation of ProfileKeyedServiceFactory (public so tests can call it). | 42 // Implementation of ProfileKeyedServiceFactory (public so tests can call it). |
44 virtual void RegisterUserPrefs(PrefRegistrySyncable* registry) OVERRIDE; | 43 virtual void RegisterUserPrefs( |
| 44 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; |
45 | 45 |
46 // Registers the browser-global prefs used by SigninManager. | 46 // Registers the browser-global prefs used by SigninManager. |
47 static void RegisterPrefs(PrefRegistrySimple* registry); | 47 static void RegisterPrefs(PrefRegistrySimple* registry); |
48 | 48 |
49 private: | 49 private: |
50 friend struct DefaultSingletonTraits<SigninManagerFactory>; | 50 friend struct DefaultSingletonTraits<SigninManagerFactory>; |
51 | 51 |
52 SigninManagerFactory(); | 52 SigninManagerFactory(); |
53 virtual ~SigninManagerFactory(); | 53 virtual ~SigninManagerFactory(); |
54 | 54 |
55 // ProfileKeyedServiceFactory: | 55 // ProfileKeyedServiceFactory: |
56 virtual ProfileKeyedService* BuildServiceInstanceFor( | 56 virtual ProfileKeyedService* BuildServiceInstanceFor( |
57 content::BrowserContext* profile) const OVERRIDE; | 57 content::BrowserContext* profile) const OVERRIDE; |
58 }; | 58 }; |
59 | 59 |
60 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_ | 60 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_ |
OLD | NEW |