Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / signin / account_tracker_service_factory.cc
blob60ddfff4aa78a6df8784b0f1e9146375ff778ea9
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 "chrome/browser/signin/profile_oauth2_token_service_factory.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "components/pref_registry/pref_registry_syncable.h"
13 #include "components/signin/core/browser/account_tracker_service.h"
14 #include "components/signin/core/browser/profile_oauth2_token_service.h"
15 #include "components/signin/core/common/signin_pref_names.h"
17 AccountTrackerServiceFactory::AccountTrackerServiceFactory()
18 : BrowserContextKeyedServiceFactory(
19 "AccountTrackerServiceFactory",
20 BrowserContextDependencyManager::GetInstance()) {
21 DependsOn(ChromeSigninClientFactory::GetInstance());
22 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
25 AccountTrackerServiceFactory::~AccountTrackerServiceFactory() {
28 // static
29 AccountTrackerService*
30 AccountTrackerServiceFactory::GetForProfile(Profile* profile) {
31 return static_cast<AccountTrackerService*>(
32 GetInstance()->GetServiceForBrowserContext(profile, true));
35 // static
36 AccountTrackerServiceFactory* AccountTrackerServiceFactory::GetInstance() {
37 return Singleton<AccountTrackerServiceFactory>::get();
40 void AccountTrackerServiceFactory::RegisterProfilePrefs(
41 user_prefs::PrefRegistrySyncable* registry) {
42 registry->RegisterListPref(
43 AccountTrackerService::kAccountInfoPref,
44 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
45 registry->RegisterIntegerPref(
46 prefs::kAccountIdMigrationState,
47 AccountTrackerService::MIGRATION_NOT_STARTED,
48 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
51 KeyedService* AccountTrackerServiceFactory::BuildServiceInstanceFor(
52 content::BrowserContext* context) const {
53 Profile* profile = static_cast<Profile*>(context);
54 AccountTrackerService* service = new AccountTrackerService();
55 service->Initialize(
56 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
57 ChromeSigninClientFactory::GetForProfile(profile));
58 return service;