1 // Copyright 2016 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. 4 5 #include "chrome/browser/signin/account_investigator_factory.h" 6 7 #include "base/memory/singleton.h" 8 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/signin/identity_manager_factory.h" 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" 11 #include "components/pref_registry/pref_registry_syncable.h" 12 #include "components/prefs/pref_service_factory.h" 13 #include "components/signin/core/browser/account_investigator.h" 14 #include "components/signin/public/identity_manager/identity_manager.h" 15 16 // static GetInstance()17AccountInvestigatorFactory* AccountInvestigatorFactory::GetInstance() { 18 return base::Singleton<AccountInvestigatorFactory>::get(); 19 } 20 21 // static GetForProfile(Profile * profile)22AccountInvestigator* AccountInvestigatorFactory::GetForProfile( 23 Profile* profile) { 24 return static_cast<AccountInvestigator*>( 25 GetInstance()->GetServiceForBrowserContext(profile, true)); 26 } 27 AccountInvestigatorFactory()28AccountInvestigatorFactory::AccountInvestigatorFactory() 29 : BrowserContextKeyedServiceFactory( 30 "AccountInvestigator", 31 BrowserContextDependencyManager::GetInstance()) { 32 DependsOn(IdentityManagerFactory::GetInstance()); 33 } 34 ~AccountInvestigatorFactory()35AccountInvestigatorFactory::~AccountInvestigatorFactory() {} 36 BuildServiceInstanceFor(content::BrowserContext * context) const37KeyedService* AccountInvestigatorFactory::BuildServiceInstanceFor( 38 content::BrowserContext* context) const { 39 Profile* profile(Profile::FromBrowserContext(context)); 40 AccountInvestigator* investigator = new AccountInvestigator( 41 profile->GetPrefs(), IdentityManagerFactory::GetForProfile(profile)); 42 investigator->Initialize(); 43 return investigator; 44 } 45 RegisterProfilePrefs(user_prefs::PrefRegistrySyncable * registry)46void AccountInvestigatorFactory::RegisterProfilePrefs( 47 user_prefs::PrefRegistrySyncable* registry) { 48 AccountInvestigator::RegisterPrefs(registry); 49 } 50 ServiceIsCreatedWithBrowserContext() const51bool AccountInvestigatorFactory::ServiceIsCreatedWithBrowserContext() const { 52 return true; 53 } 54 ServiceIsNULLWhileTesting() const55bool AccountInvestigatorFactory::ServiceIsNULLWhileTesting() const { 56 return true; 57 } 58