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 "ios/chrome/browser/signin/about_signin_internals_factory.h"
7 #include "base/memory/singleton.h"
8 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
9 #include "components/signin/core/browser/about_signin_internals.h"
10 #include "ios/chrome/browser/signin/account_tracker_service_factory.h"
11 #include "ios/chrome/browser/signin/gaia_cookie_manager_service_factory.h"
12 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
13 #include "ios/chrome/browser/signin/signin_client_factory.h"
14 #include "ios/chrome/browser/signin/signin_error_controller_factory.h"
15 #include "ios/chrome/browser/signin/signin_manager_factory.h"
16 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
20 AboutSigninInternalsFactory::AboutSigninInternalsFactory()
21 : BrowserStateKeyedServiceFactory(
22 "AboutSigninInternals",
23 BrowserStateDependencyManager::GetInstance()) {
24 DependsOn(AccountTrackerServiceFactory::GetInstance());
25 DependsOn(GaiaCookieManagerServiceFactory::GetInstance());
26 DependsOn(OAuth2TokenServiceFactory::GetInstance());
27 DependsOn(SigninClientFactory::GetInstance());
28 DependsOn(SigninErrorControllerFactory::GetInstance());
29 DependsOn(SigninManagerFactory::GetInstance());
32 AboutSigninInternalsFactory::~AboutSigninInternalsFactory() {}
35 AboutSigninInternals
* AboutSigninInternalsFactory::GetForBrowserState(
36 ios::ChromeBrowserState
* browser_state
) {
37 return static_cast<AboutSigninInternals
*>(
38 GetInstance()->GetServiceForBrowserState(browser_state
, true));
42 AboutSigninInternalsFactory
* AboutSigninInternalsFactory::GetInstance() {
43 return base::Singleton
<AboutSigninInternalsFactory
>::get();
46 scoped_ptr
<KeyedService
> AboutSigninInternalsFactory::BuildServiceInstanceFor(
47 web::BrowserState
* context
) const {
48 ios::ChromeBrowserState
* chrome_browser_state
=
49 ios::ChromeBrowserState::FromBrowserState(context
);
50 scoped_ptr
<AboutSigninInternals
> service(new AboutSigninInternals(
51 OAuth2TokenServiceFactory::GetForBrowserState(chrome_browser_state
),
52 AccountTrackerServiceFactory::GetForBrowserState(chrome_browser_state
),
53 SigninManagerFactory::GetForBrowserState(chrome_browser_state
),
54 SigninErrorControllerFactory::GetForBrowserState(chrome_browser_state
),
55 GaiaCookieManagerServiceFactory::GetForBrowserState(
56 chrome_browser_state
)));
58 SigninClientFactory::GetForBrowserState(chrome_browser_state
));
59 return service
.Pass();
62 void AboutSigninInternalsFactory::RegisterBrowserStatePrefs(
63 user_prefs::PrefRegistrySyncable
* user_prefs
) {
64 AboutSigninInternals::RegisterPrefs(user_prefs
);