1 // Copyright (c) 2014 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_tracker_service_factory.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/signin/chrome_signin_client_factory.h"
10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
11 #include "components/signin/core/browser/account_tracker_service.h"
13 AccountTrackerServiceFactory::AccountTrackerServiceFactory()
14 : BrowserContextKeyedServiceFactory(
15 "AccountTrackerServiceFactory",
16 BrowserContextDependencyManager::GetInstance()) {
17 DependsOn(ChromeSigninClientFactory::GetInstance());
20 AccountTrackerServiceFactory::~AccountTrackerServiceFactory() {
24 AccountTrackerService
*
25 AccountTrackerServiceFactory::GetForProfile(Profile
* profile
) {
26 return static_cast<AccountTrackerService
*>(
27 GetInstance()->GetServiceForBrowserContext(profile
, true));
31 AccountTrackerServiceFactory
* AccountTrackerServiceFactory::GetInstance() {
32 return base::Singleton
<AccountTrackerServiceFactory
>::get();
35 void AccountTrackerServiceFactory::RegisterProfilePrefs(
36 user_prefs::PrefRegistrySyncable
* registry
) {
37 AccountTrackerService::RegisterPrefs(registry
);
40 KeyedService
* AccountTrackerServiceFactory::BuildServiceInstanceFor(
41 content::BrowserContext
* context
) const {
42 Profile
* profile
= static_cast<Profile
*>(context
);
43 AccountTrackerService
* service
= new AccountTrackerService();
44 service
->Initialize(ChromeSigninClientFactory::GetForProfile(profile
));