Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / signin / profile_oauth2_token_service_factory.cc
blob55bca667335bcd51bc6858b9e06a6f40ceaf6085
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/profile_oauth2_token_service_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/signin_error_controller_factory.h"
11 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
12 #include "chrome/browser/web_data_service_factory.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "components/signin/core/browser/profile_oauth2_token_service.h"
16 #if defined(OS_ANDROID)
17 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h"
18 #else
19 #include "chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h"
20 #endif
22 ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory()
23 : BrowserContextKeyedServiceFactory(
24 "ProfileOAuth2TokenService",
25 BrowserContextDependencyManager::GetInstance()) {
26 DependsOn(GlobalErrorServiceFactory::GetInstance());
27 DependsOn(WebDataServiceFactory::GetInstance());
28 DependsOn(ChromeSigninClientFactory::GetInstance());
29 DependsOn(SigninErrorControllerFactory::GetInstance());
30 DependsOn(AccountTrackerServiceFactory::GetInstance());
33 ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() {
36 ProfileOAuth2TokenService*
37 ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) {
38 return static_cast<ProfileOAuth2TokenService*>(
39 GetInstance()->GetServiceForBrowserContext(profile, true));
42 // static
43 ProfileOAuth2TokenServiceFactory*
44 ProfileOAuth2TokenServiceFactory::GetInstance() {
45 return Singleton<ProfileOAuth2TokenServiceFactory>::get();
48 KeyedService* ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor(
49 content::BrowserContext* context) const {
50 #if defined(OS_ANDROID)
51 OAuth2TokenServiceDelegateAndroid* delegate =
52 new OAuth2TokenServiceDelegateAndroid();
53 delegate->Initialize();
54 #else
55 Profile* profile = static_cast<Profile*>(context);
56 MutableProfileOAuth2TokenServiceDelegate* delegate =
57 new MutableProfileOAuth2TokenServiceDelegate(
58 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
59 SigninErrorControllerFactory::GetInstance()->GetForProfile(profile),
60 AccountTrackerServiceFactory::GetInstance()->GetForProfile(profile));
61 #endif
62 ProfileOAuth2TokenService* service = new ProfileOAuth2TokenService(delegate);
63 return service;