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