1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/signin/account_reconcilor_factory.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/signin/chrome_signin_client_factory.h"
9 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
11 #include "chrome/browser/signin/signin_manager_factory.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 AccountReconcilorFactory::AccountReconcilorFactory()
15 : BrowserContextKeyedServiceFactory(
17 BrowserContextDependencyManager::GetInstance()) {
18 DependsOn(ChromeSigninClientFactory::GetInstance());
19 DependsOn(GaiaCookieManagerServiceFactory::GetInstance());
20 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
21 DependsOn(SigninManagerFactory::GetInstance());
24 AccountReconcilorFactory::~AccountReconcilorFactory() {}
27 AccountReconcilor
* AccountReconcilorFactory::GetForProfile(
29 return static_cast<AccountReconcilor
*>(
30 GetInstance()->GetServiceForBrowserContext(profile
, true));
34 AccountReconcilorFactory
* AccountReconcilorFactory::GetInstance() {
35 return Singleton
<AccountReconcilorFactory
>::get();
38 KeyedService
* AccountReconcilorFactory::BuildServiceInstanceFor(
39 content::BrowserContext
* context
) const {
40 Profile
* profile
= Profile::FromBrowserContext(context
);
41 AccountReconcilor
* reconcilor
= new AccountReconcilor(
42 ProfileOAuth2TokenServiceFactory::GetForProfile(profile
),
43 SigninManagerFactory::GetForProfile(profile
),
44 ChromeSigninClientFactory::GetForProfile(profile
),
45 GaiaCookieManagerServiceFactory::GetForProfile(profile
));
46 reconcilor
->Initialize(true /* start_reconcile_if_tokens_available */);
50 void AccountReconcilorFactory::RegisterProfilePrefs(
51 user_prefs::PrefRegistrySyncable
* registry
) {