OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/signin/account_tracker_service_factory.h" | 5 #include "chrome/browser/signin/account_tracker_service_factory.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
11 #include "components/pref_registry/pref_registry_syncable.h" | 11 #include "components/pref_registry/pref_registry_syncable.h" |
12 #include "components/signin/core/browser/account_tracker_service.h" | 12 #include "components/signin/core/browser/account_tracker_service.h" |
13 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 14 #include "components/signin/core/common/signin_pref_names.h" |
14 | 15 |
15 AccountTrackerServiceFactory::AccountTrackerServiceFactory() | 16 AccountTrackerServiceFactory::AccountTrackerServiceFactory() |
16 : BrowserContextKeyedServiceFactory( | 17 : BrowserContextKeyedServiceFactory( |
17 "AccountTrackerServiceFactory", | 18 "AccountTrackerServiceFactory", |
18 BrowserContextDependencyManager::GetInstance()) { | 19 BrowserContextDependencyManager::GetInstance()) { |
19 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 20 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
20 } | 21 } |
21 | 22 |
22 AccountTrackerServiceFactory::~AccountTrackerServiceFactory() { | 23 AccountTrackerServiceFactory::~AccountTrackerServiceFactory() { |
23 } | 24 } |
24 | 25 |
25 // static | 26 // static |
26 AccountTrackerService* | 27 AccountTrackerService* |
27 AccountTrackerServiceFactory::GetForProfile(Profile* profile) { | 28 AccountTrackerServiceFactory::GetForProfile(Profile* profile) { |
28 return static_cast<AccountTrackerService*>( | 29 return static_cast<AccountTrackerService*>( |
29 GetInstance()->GetServiceForBrowserContext(profile, true)); | 30 GetInstance()->GetServiceForBrowserContext(profile, true)); |
30 } | 31 } |
31 | 32 |
32 // static | 33 // static |
33 AccountTrackerServiceFactory* AccountTrackerServiceFactory::GetInstance() { | 34 AccountTrackerServiceFactory* AccountTrackerServiceFactory::GetInstance() { |
34 return Singleton<AccountTrackerServiceFactory>::get(); | 35 return Singleton<AccountTrackerServiceFactory>::get(); |
35 } | 36 } |
36 | 37 |
37 void AccountTrackerServiceFactory::RegisterProfilePrefs( | 38 void AccountTrackerServiceFactory::RegisterProfilePrefs( |
38 user_prefs::PrefRegistrySyncable* registry) { | 39 user_prefs::PrefRegistrySyncable* registry) { |
39 registry->RegisterListPref( | 40 registry->RegisterListPref( |
40 AccountTrackerService::kAccountInfoPref, | 41 AccountTrackerService::kAccountInfoPref, |
41 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 42 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 43 registry->RegisterIntegerPref( |
| 44 prefs::kAccountIdMigrationState, |
| 45 AccountTrackerService::MIGRATION_NOT_STARTED, |
| 46 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
42 } | 47 } |
43 | 48 |
44 KeyedService* AccountTrackerServiceFactory::BuildServiceInstanceFor( | 49 KeyedService* AccountTrackerServiceFactory::BuildServiceInstanceFor( |
45 content::BrowserContext* context) const { | 50 content::BrowserContext* context) const { |
46 Profile* profile = static_cast<Profile*>(context); | 51 Profile* profile = static_cast<Profile*>(context); |
47 AccountTrackerService* service = new AccountTrackerService(); | 52 AccountTrackerService* service = new AccountTrackerService(); |
48 service->Initialize( | 53 service->Initialize( |
49 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 54 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
50 profile->GetPrefs(), | 55 profile->GetPrefs(), |
51 profile->GetRequestContext()); | 56 profile->GetRequestContext()); |
52 return service; | 57 return service; |
53 } | 58 } |
OLD | NEW |