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/profile_oauth2_token_service_factory.h"
10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 AccountReconcilorFactory::AccountReconcilorFactory()
14 : BrowserContextKeyedServiceFactory(
16 BrowserContextDependencyManager::GetInstance()) {
17 DependsOn(ChromeSigninClientFactory::GetInstance());
18 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
19 DependsOn(SigninManagerFactory::GetInstance());
22 AccountReconcilorFactory::~AccountReconcilorFactory() {}
25 AccountReconcilor
* AccountReconcilorFactory::GetForProfile(
27 return static_cast<AccountReconcilor
*>(
28 GetInstance()->GetServiceForBrowserContext(profile
, true));
32 AccountReconcilorFactory
* AccountReconcilorFactory::GetInstance() {
33 return Singleton
<AccountReconcilorFactory
>::get();
36 KeyedService
* AccountReconcilorFactory::BuildServiceInstanceFor(
37 content::BrowserContext
* context
) const {
38 Profile
* profile
= Profile::FromBrowserContext(context
);
39 AccountReconcilor
* reconcilor
= new AccountReconcilor(
40 ProfileOAuth2TokenServiceFactory::GetForProfile(profile
),
41 SigninManagerFactory::GetForProfile(profile
),
42 ChromeSigninClientFactory::GetForProfile(profile
));
43 reconcilor
->Initialize(true /* start_reconcile_if_tokens_available */);
47 void AccountReconcilorFactory::RegisterProfilePrefs(
48 user_prefs::PrefRegistrySyncable
* registry
) {