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