18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file. 48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/account_reconcilor_factory.h" 68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/profiles/profile.h" 8e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch#include "chrome/browser/signin/chrome_signin_client_factory.h" 98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/signin/signin_manager_factory.h" 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/content/browser_context_dependency_manager.h" 128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)AccountReconcilorFactory::AccountReconcilorFactory() 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) : BrowserContextKeyedServiceFactory( 158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) "AccountReconcilor", 168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) BrowserContextDependencyManager::GetInstance()) { 17e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch DependsOn(ChromeSigninClientFactory::GetInstance()); 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DependsOn(SigninManagerFactory::GetInstance()); 208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)AccountReconcilorFactory::~AccountReconcilorFactory() {} 238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// static 258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)AccountReconcilor* AccountReconcilorFactory::GetForProfile( 268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) Profile* profile) { 278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return static_cast<AccountReconcilor*>( 288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) GetInstance()->GetServiceForBrowserContext(profile, true)); 298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// static 328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)AccountReconcilorFactory* AccountReconcilorFactory::GetInstance() { 338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) return Singleton<AccountReconcilorFactory>::get(); 348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)KeyedService* AccountReconcilorFactory::BuildServiceInstanceFor( 378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) content::BrowserContext* context) const { 38e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch Profile* profile = Profile::FromBrowserContext(context); 39e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch AccountReconcilor* reconcilor = new AccountReconcilor( 40c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 41c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch SigninManagerFactory::GetForProfile(profile), 42c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ChromeSigninClientFactory::GetForProfile(profile)); 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) reconcilor->Initialize(true /* start_reconcile_if_tokens_available */); 44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return reconcilor; 458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void AccountReconcilorFactory::RegisterProfilePrefs( 488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) user_prefs::PrefRegistrySyncable* registry) { 498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)} 50