OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/account_fetcher_service_factory.h" | 5 #include "chrome/browser/signin/account_fetcher_service_factory.h" |
6 | 6 |
7 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | |
8 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/signin/account_tracker_service_factory.h" | 8 #include "chrome/browser/signin/account_tracker_service_factory.h" |
10 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 9 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
12 #include "components/invalidation/impl/profile_invalidation_provider.h" | |
13 #include "components/invalidation/public/invalidation_service.h" | |
14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
15 #include "components/signin/core/browser/account_fetcher_service.h" | 12 #include "components/signin/core/browser/account_fetcher_service.h" |
16 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
17 | 14 |
18 AccountFetcherServiceFactory::AccountFetcherServiceFactory() | 15 AccountFetcherServiceFactory::AccountFetcherServiceFactory() |
19 : BrowserContextKeyedServiceFactory( | 16 : BrowserContextKeyedServiceFactory( |
20 "AccountFetcherServiceFactory", | 17 "AccountFetcherServiceFactory", |
21 BrowserContextDependencyManager::GetInstance()) { | 18 BrowserContextDependencyManager::GetInstance()) { |
22 DependsOn(AccountTrackerServiceFactory::GetInstance()); | 19 DependsOn(AccountTrackerServiceFactory::GetInstance()); |
23 DependsOn(ChromeSigninClientFactory::GetInstance()); | 20 DependsOn(ChromeSigninClientFactory::GetInstance()); |
24 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 21 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
25 DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance()); | |
26 } | 22 } |
27 | 23 |
28 AccountFetcherServiceFactory::~AccountFetcherServiceFactory() {} | 24 AccountFetcherServiceFactory::~AccountFetcherServiceFactory() {} |
29 | 25 |
30 // static | 26 // static |
31 AccountFetcherService* AccountFetcherServiceFactory::GetForProfile( | 27 AccountFetcherService* AccountFetcherServiceFactory::GetForProfile( |
32 Profile* profile) { | 28 Profile* profile) { |
33 return static_cast<AccountFetcherService*>( | 29 return static_cast<AccountFetcherService*>( |
34 GetInstance()->GetServiceForBrowserContext(profile, true)); | 30 GetInstance()->GetServiceForBrowserContext(profile, true)); |
35 } | 31 } |
36 | 32 |
37 // static | 33 // static |
38 AccountFetcherServiceFactory* AccountFetcherServiceFactory::GetInstance() { | 34 AccountFetcherServiceFactory* AccountFetcherServiceFactory::GetInstance() { |
39 return base::Singleton<AccountFetcherServiceFactory>::get(); | 35 return base::Singleton<AccountFetcherServiceFactory>::get(); |
40 } | 36 } |
41 | 37 |
42 void AccountFetcherServiceFactory::RegisterProfilePrefs( | 38 void AccountFetcherServiceFactory::RegisterProfilePrefs( |
43 user_prefs::PrefRegistrySyncable* registry) { | 39 user_prefs::PrefRegistrySyncable* registry) { |
44 AccountFetcherService::RegisterPrefs(registry); | 40 AccountFetcherService::RegisterPrefs(registry); |
45 } | 41 } |
46 | 42 |
47 KeyedService* AccountFetcherServiceFactory::BuildServiceInstanceFor( | 43 KeyedService* AccountFetcherServiceFactory::BuildServiceInstanceFor( |
48 content::BrowserContext* context) const { | 44 content::BrowserContext* context) const { |
49 Profile* profile = Profile::FromBrowserContext(context); | 45 Profile* profile = Profile::FromBrowserContext(context); |
50 AccountFetcherService* service = new AccountFetcherService(); | 46 AccountFetcherService* service = new AccountFetcherService(); |
51 invalidation::ProfileInvalidationProvider* invalidation_provider = | |
52 invalidation::ProfileInvalidationProviderFactory::GetForProfile(profile); | |
53 // Chrome OS login and guest profiles do not support invalidation. This is | |
54 // fine as they do not have GAIA credentials anyway. http://crbug.com/358169 | |
55 invalidation::InvalidationService* invalidation_service = | |
56 invalidation_provider ? invalidation_provider->GetInvalidationService() | |
57 : nullptr; | |
58 service->Initialize(ChromeSigninClientFactory::GetForProfile(profile), | 47 service->Initialize(ChromeSigninClientFactory::GetForProfile(profile), |
59 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 48 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
60 AccountTrackerServiceFactory::GetForProfile(profile), | 49 AccountTrackerServiceFactory::GetForProfile(profile)); |
61 invalidation_service); | 50 if (profile->AsTestingProfile() != nullptr) |
| 51 service->DisableScheduledRefreshForTesting(); |
62 return service; | 52 return service; |
63 } | 53 } |
OLD | NEW |