1 // Copyright (c) 2012 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/about_signin_internals_factory.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/signin/account_tracker_service_factory.h"
9 #include "chrome/browser/signin/chrome_signin_client_factory.h"
10 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
12 #include "chrome/browser/signin/signin_error_controller_factory.h"
13 #include "chrome/browser/signin/signin_manager_factory.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/signin/core/browser/about_signin_internals.h"
16 #include "components/signin/core/browser/signin_manager.h"
18 AboutSigninInternalsFactory::AboutSigninInternalsFactory()
19 : BrowserContextKeyedServiceFactory(
20 "AboutSigninInternals",
21 BrowserContextDependencyManager::GetInstance()) {
22 DependsOn(AccountTrackerServiceFactory::GetInstance());
23 DependsOn(ChromeSigninClientFactory::GetInstance());
24 DependsOn(GaiaCookieManagerServiceFactory::GetInstance());
25 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
26 DependsOn(SigninErrorControllerFactory::GetInstance());
27 DependsOn(SigninManagerFactory::GetInstance());
30 AboutSigninInternalsFactory::~AboutSigninInternalsFactory() {}
33 AboutSigninInternals
* AboutSigninInternalsFactory::GetForProfile(
35 return static_cast<AboutSigninInternals
*>(
36 GetInstance()->GetServiceForBrowserContext(profile
, true));
40 AboutSigninInternalsFactory
* AboutSigninInternalsFactory::GetInstance() {
41 return base::Singleton
<AboutSigninInternalsFactory
>::get();
44 void AboutSigninInternalsFactory::RegisterProfilePrefs(
45 user_prefs::PrefRegistrySyncable
* user_prefs
) {
46 AboutSigninInternals::RegisterPrefs(user_prefs
);
49 KeyedService
* AboutSigninInternalsFactory::BuildServiceInstanceFor(
50 content::BrowserContext
* context
) const {
51 Profile
* profile
= Profile::FromBrowserContext(context
);
52 AboutSigninInternals
* service
= new AboutSigninInternals(
53 ProfileOAuth2TokenServiceFactory::GetForProfile(profile
),
54 AccountTrackerServiceFactory::GetForProfile(profile
),
55 SigninManagerFactory::GetForProfile(profile
),
56 SigninErrorControllerFactory::GetForProfile(profile
),
57 GaiaCookieManagerServiceFactory::GetForProfile(profile
));
58 service
->Initialize(ChromeSigninClientFactory::GetForProfile(profile
));