1 // Copyright 2018 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_consistency_mode_manager_factory.h" 6 7 #include "base/check.h" 8 #include "build/build_config.h" 9 #include "chrome/browser/profiles/profile.h" 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" 11 #include "components/keyed_service/content/browser_context_keyed_service_factory.h" 12 13 // static 14 AccountConsistencyModeManagerFactory* GetInstance()15AccountConsistencyModeManagerFactory::GetInstance() { 16 return base::Singleton<AccountConsistencyModeManagerFactory>::get(); 17 } 18 19 // static 20 AccountConsistencyModeManager* GetForProfile(Profile * profile)21AccountConsistencyModeManagerFactory::GetForProfile(Profile* profile) { 22 DCHECK(profile); 23 return static_cast<AccountConsistencyModeManager*>( 24 GetInstance()->GetServiceForBrowserContext(profile, true)); 25 } 26 AccountConsistencyModeManagerFactory()27AccountConsistencyModeManagerFactory::AccountConsistencyModeManagerFactory() 28 : BrowserContextKeyedServiceFactory( 29 "AccountConsistencyModeManager", 30 BrowserContextDependencyManager::GetInstance()) {} 31 32 AccountConsistencyModeManagerFactory::~AccountConsistencyModeManagerFactory() = 33 default; 34 BuildServiceInstanceFor(content::BrowserContext * context) const35KeyedService* AccountConsistencyModeManagerFactory::BuildServiceInstanceFor( 36 content::BrowserContext* context) const { 37 DCHECK(!context->IsOffTheRecord()); 38 Profile* profile = Profile::FromBrowserContext(context); 39 40 return AccountConsistencyModeManager::ShouldBuildServiceForProfile(profile) 41 ? new AccountConsistencyModeManager(profile) 42 : nullptr; 43 } 44 RegisterProfilePrefs(user_prefs::PrefRegistrySyncable * registry)45void AccountConsistencyModeManagerFactory::RegisterProfilePrefs( 46 user_prefs::PrefRegistrySyncable* registry) { 47 AccountConsistencyModeManager::RegisterProfilePrefs(registry); 48 } 49 ServiceIsCreatedWithBrowserContext() const50bool AccountConsistencyModeManagerFactory::ServiceIsCreatedWithBrowserContext() 51 const { 52 return true; 53 } 54