OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/signin/profile_oauth2_token_service_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/signin/core/browser/account_tracker_service.h" |
| 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 14 |
| 15 AccountTrackerServiceFactory::AccountTrackerServiceFactory() |
| 16 : BrowserContextKeyedServiceFactory( |
| 17 "AccountTrackerServiceFactory", |
| 18 BrowserContextDependencyManager::GetInstance()) { |
| 19 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| 20 } |
| 21 |
| 22 AccountTrackerServiceFactory::~AccountTrackerServiceFactory() { |
| 23 } |
| 24 |
| 25 // static |
| 26 AccountTrackerService* |
| 27 AccountTrackerServiceFactory::GetForProfile(Profile* profile) { |
| 28 return static_cast<AccountTrackerService*>( |
| 29 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 30 } |
| 31 |
| 32 // static |
| 33 AccountTrackerServiceFactory* AccountTrackerServiceFactory::GetInstance() { |
| 34 return Singleton<AccountTrackerServiceFactory>::get(); |
| 35 } |
| 36 |
| 37 void AccountTrackerServiceFactory::RegisterProfilePrefs( |
| 38 user_prefs::PrefRegistrySyncable* registry) { |
| 39 registry->RegisterListPref( |
| 40 AccountTrackerService::kAccountInfoPref, |
| 41 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 42 } |
| 43 |
| 44 KeyedService* AccountTrackerServiceFactory::BuildServiceInstanceFor( |
| 45 content::BrowserContext* context) const { |
| 46 Profile* profile = static_cast<Profile*>(context); |
| 47 AccountTrackerService* service = new AccountTrackerService(); |
| 48 service->Initialize( |
| 49 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 50 profile->GetPrefs(), |
| 51 profile->GetRequestContext()); |
| 52 return service; |
| 53 } |
OLD | NEW |