1 // Copyright 2015 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 "ios/chrome/browser/signin/account_tracker_service_factory.h"
7 #include "base/memory/singleton.h"
8 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
9 #include "components/signin/core/browser/account_tracker_service.h"
10 #include "ios/chrome/browser/signin/signin_client_factory.h"
11 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
15 AccountTrackerServiceFactory::AccountTrackerServiceFactory()
16 : BrowserStateKeyedServiceFactory(
17 "AccountTrackerService",
18 BrowserStateDependencyManager::GetInstance()) {
19 DependsOn(SigninClientFactory::GetInstance());
22 AccountTrackerServiceFactory::~AccountTrackerServiceFactory() {}
25 AccountTrackerService
* AccountTrackerServiceFactory::GetForBrowserState(
26 ios::ChromeBrowserState
* browser_state
) {
27 return static_cast<AccountTrackerService
*>(
28 GetInstance()->GetServiceForBrowserState(browser_state
, true));
32 AccountTrackerServiceFactory
* AccountTrackerServiceFactory::GetInstance() {
33 return Singleton
<AccountTrackerServiceFactory
>::get();
36 void AccountTrackerServiceFactory::RegisterBrowserStatePrefs(
37 user_prefs::PrefRegistrySyncable
* registry
) {
38 AccountTrackerService::RegisterPrefs(registry
);
41 scoped_ptr
<KeyedService
> AccountTrackerServiceFactory::BuildServiceInstanceFor(
42 web::BrowserState
* context
) const {
43 ios::ChromeBrowserState
* chrome_browser_state
=
44 ios::ChromeBrowserState::FromBrowserState(context
);
45 scoped_ptr
<AccountTrackerService
> service(new AccountTrackerService());
47 SigninClientFactory::GetForBrowserState(chrome_browser_state
));
48 return service
.Pass();