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 #include "chrome/browser/signin/signin_manager_factory.h" | 5 #include "chrome/browser/signin/signin_manager_factory.h" |
6 | 6 |
7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/signin/chrome_signin_manager_delegate.h" | 9 #include "chrome/browser/signin/chrome_signin_manager_delegate.h" |
10 #include "chrome/browser/signin/signin_manager.h" | 10 #include "chrome/browser/signin/signin_manager.h" |
11 #include "chrome/browser/signin/token_service_factory.h" | 11 #include "chrome/browser/signin/token_service_factory.h" |
12 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 12 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 14 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
15 #include "components/user_prefs/pref_registry_syncable.h" | 15 #include "components/user_prefs/pref_registry_syncable.h" |
16 | 16 |
17 SigninManagerFactory::SigninManagerFactory() | 17 SigninManagerFactory::SigninManagerFactory() |
18 : ProfileKeyedServiceFactory("SigninManager", | 18 : BrowserContextKeyedServiceFactory( |
19 ProfileDependencyManager::GetInstance()) { | 19 "SigninManager", |
| 20 BrowserContextDependencyManager::GetInstance()) { |
20 DependsOn(TokenServiceFactory::GetInstance()); | 21 DependsOn(TokenServiceFactory::GetInstance()); |
21 DependsOn(GlobalErrorServiceFactory::GetInstance()); | 22 DependsOn(GlobalErrorServiceFactory::GetInstance()); |
22 } | 23 } |
23 | 24 |
24 SigninManagerFactory::~SigninManagerFactory() {} | 25 SigninManagerFactory::~SigninManagerFactory() {} |
25 | 26 |
26 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
27 // static | 28 // static |
28 SigninManagerBase* SigninManagerFactory::GetForProfileIfExists( | 29 SigninManagerBase* SigninManagerFactory::GetForProfileIfExists( |
29 Profile* profile) { | 30 Profile* profile) { |
30 return static_cast<SigninManagerBase*>( | 31 return static_cast<SigninManagerBase*>( |
31 GetInstance()->GetServiceForProfile(profile, false)); | 32 GetInstance()->GetServiceForBrowserContext(profile, false)); |
32 } | 33 } |
33 | 34 |
34 // static | 35 // static |
35 SigninManagerBase* SigninManagerFactory::GetForProfile( | 36 SigninManagerBase* SigninManagerFactory::GetForProfile( |
36 Profile* profile) { | 37 Profile* profile) { |
37 return static_cast<SigninManagerBase*>( | 38 return static_cast<SigninManagerBase*>( |
38 GetInstance()->GetServiceForProfile(profile, true)); | 39 GetInstance()->GetServiceForBrowserContext(profile, true)); |
39 } | 40 } |
40 | 41 |
41 #else | 42 #else |
42 // static | 43 // static |
43 SigninManager* SigninManagerFactory::GetForProfile(Profile* profile) { | 44 SigninManager* SigninManagerFactory::GetForProfile(Profile* profile) { |
44 return static_cast<SigninManager*>( | 45 return static_cast<SigninManager*>( |
45 GetInstance()->GetServiceForProfile(profile, true)); | 46 GetInstance()->GetServiceForBrowserContext(profile, true)); |
46 } | 47 } |
47 | 48 |
48 // static | 49 // static |
49 SigninManager* SigninManagerFactory::GetForProfileIfExists(Profile* profile) { | 50 SigninManager* SigninManagerFactory::GetForProfileIfExists(Profile* profile) { |
50 return static_cast<SigninManager*>( | 51 return static_cast<SigninManager*>( |
51 GetInstance()->GetServiceForProfile(profile, false)); | 52 GetInstance()->GetServiceForBrowserContext(profile, false)); |
52 } | 53 } |
53 #endif | 54 #endif |
54 | 55 |
55 // static | 56 // static |
56 SigninManagerFactory* SigninManagerFactory::GetInstance() { | 57 SigninManagerFactory* SigninManagerFactory::GetInstance() { |
57 return Singleton<SigninManagerFactory>::get(); | 58 return Singleton<SigninManagerFactory>::get(); |
58 } | 59 } |
59 | 60 |
60 void SigninManagerFactory::RegisterUserPrefs( | 61 void SigninManagerFactory::RegisterUserPrefs( |
61 user_prefs::PrefRegistrySyncable* registry) { | 62 user_prefs::PrefRegistrySyncable* registry) { |
(...skipping 17 matching lines...) Expand all Loading... |
79 new ListValue, | 80 new ListValue, |
80 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 81 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
81 } | 82 } |
82 | 83 |
83 // static | 84 // static |
84 void SigninManagerFactory::RegisterPrefs(PrefRegistrySimple* registry) { | 85 void SigninManagerFactory::RegisterPrefs(PrefRegistrySimple* registry) { |
85 registry->RegisterStringPref(prefs::kGoogleServicesUsernamePattern, | 86 registry->RegisterStringPref(prefs::kGoogleServicesUsernamePattern, |
86 std::string()); | 87 std::string()); |
87 } | 88 } |
88 | 89 |
89 ProfileKeyedService* SigninManagerFactory::BuildServiceInstanceFor( | 90 BrowserContextKeyedService* SigninManagerFactory::BuildServiceInstanceFor( |
90 content::BrowserContext* context) const { | 91 content::BrowserContext* context) const { |
91 SigninManagerBase* service = NULL; | 92 SigninManagerBase* service = NULL; |
92 Profile* profile = static_cast<Profile*>(context); | 93 Profile* profile = static_cast<Profile*>(context); |
93 #if defined(OS_CHROMEOS) | 94 #if defined(OS_CHROMEOS) |
94 service = new SigninManagerBase(); | 95 service = new SigninManagerBase(); |
95 #else | 96 #else |
96 service = new SigninManager( | 97 service = new SigninManager( |
97 scoped_ptr<SigninManagerDelegate>( | 98 scoped_ptr<SigninManagerDelegate>( |
98 new ChromeSigninManagerDelegate(profile))); | 99 new ChromeSigninManagerDelegate(profile))); |
99 #endif | 100 #endif |
100 service->Initialize(profile, g_browser_process->local_state()); | 101 service->Initialize(profile, g_browser_process->local_state()); |
101 return service; | 102 return service; |
102 } | 103 } |
OLD | NEW |