Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / signin / account_fetcher_service_factory.cc
blob53e206e228c744c6d6e196a12f3a9568a365cf7b
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 "chrome/browser/signin/account_fetcher_service_factory.h"
7 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/signin/account_tracker_service_factory.h"
10 #include "chrome/browser/signin/chrome_signin_client_factory.h"
11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
12 #include "components/invalidation/impl/profile_invalidation_provider.h"
13 #include "components/invalidation/public/invalidation_service.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/pref_registry/pref_registry_syncable.h"
16 #include "components/signin/core/browser/account_fetcher_service.h"
17 #include "components/signin/core/browser/profile_oauth2_token_service.h"
19 AccountFetcherServiceFactory::AccountFetcherServiceFactory()
20 : BrowserContextKeyedServiceFactory(
21 "AccountFetcherServiceFactory",
22 BrowserContextDependencyManager::GetInstance()) {
23 DependsOn(AccountTrackerServiceFactory::GetInstance());
24 DependsOn(ChromeSigninClientFactory::GetInstance());
25 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
26 DependsOn(invalidation::ProfileInvalidationProviderFactory::GetInstance());
29 AccountFetcherServiceFactory::~AccountFetcherServiceFactory() {}
31 // static
32 AccountFetcherService* AccountFetcherServiceFactory::GetForProfile(
33 Profile* profile) {
34 return static_cast<AccountFetcherService*>(
35 GetInstance()->GetServiceForBrowserContext(profile, true));
38 // static
39 AccountFetcherServiceFactory* AccountFetcherServiceFactory::GetInstance() {
40 return Singleton<AccountFetcherServiceFactory>::get();
43 void AccountFetcherServiceFactory::RegisterProfilePrefs(
44 user_prefs::PrefRegistrySyncable* registry) {
45 registry->RegisterInt64Pref(AccountFetcherService::kLastUpdatePref, 0);
48 KeyedService* AccountFetcherServiceFactory::BuildServiceInstanceFor(
49 content::BrowserContext* context) const {
50 Profile* profile = Profile::FromBrowserContext(context);
51 AccountFetcherService* service = new AccountFetcherService();
52 invalidation::ProfileInvalidationProvider* invalidation_provider =
53 invalidation::ProfileInvalidationProviderFactory::GetForProfile(profile);
54 // Chrome OS login and guest profiles do not support invalidation. This is
55 // fine as they do not have GAIA credentials anyway. http://crbug.com/358169
56 invalidation::InvalidationService* invalidation_service =
57 invalidation_provider ? invalidation_provider->GetInvalidationService()
58 : nullptr;
59 service->Initialize(ChromeSigninClientFactory::GetForProfile(profile),
60 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
61 AccountTrackerServiceFactory::GetForProfile(profile),
62 invalidation_service);
63 return service;