| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/profile_oauth2_token_service_factory.h" | 5 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 8 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 9 #include "chrome/browser/signin/signin_error_controller_factory.h" | 9 #include "chrome/browser/signin/signin_error_controller_factory.h" |
| 10 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 10 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 11 #include "chrome/browser/webdata/web_data_service_factory.h" | 11 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 13 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 14 | 14 |
| 15 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
| 16 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" | 16 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" |
| 17 #else | 17 #else |
| 18 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" | 18 #include "chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory() | 21 ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory() |
| 22 : BrowserContextKeyedServiceFactory( | 22 : BrowserContextKeyedServiceFactory( |
| 23 "ProfileOAuth2TokenService", | 23 "ProfileOAuth2TokenService", |
| 24 BrowserContextDependencyManager::GetInstance()) { | 24 BrowserContextDependencyManager::GetInstance()) { |
| 25 DependsOn(GlobalErrorServiceFactory::GetInstance()); | 25 DependsOn(GlobalErrorServiceFactory::GetInstance()); |
| 26 DependsOn(WebDataServiceFactory::GetInstance()); | 26 DependsOn(WebDataServiceFactory::GetInstance()); |
| 27 DependsOn(ChromeSigninClientFactory::GetInstance()); | 27 DependsOn(ChromeSigninClientFactory::GetInstance()); |
| 28 DependsOn(SigninErrorControllerFactory::GetInstance()); | 28 DependsOn(SigninErrorControllerFactory::GetInstance()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() { | 31 ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() { |
| 32 } | 32 } |
| 33 | 33 |
| 34 ProfileOAuth2TokenService* | 34 ProfileOAuth2TokenService* |
| 35 ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) { | 35 ProfileOAuth2TokenServiceFactory::GetForProfile(Profile* profile) { |
| 36 return static_cast<ProfileOAuth2TokenService*>( | 36 return static_cast<ProfileOAuth2TokenService*>( |
| 37 GetInstance()->GetServiceForBrowserContext(profile, true)); | 37 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 ProfileOAuth2TokenServiceFactory::PlatformSpecificOAuth2TokenService* | |
| 42 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | |
| 43 Profile* profile) { | |
| 44 return static_cast<PlatformSpecificOAuth2TokenService*>( | |
| 45 GetForProfile(profile)); | |
| 46 } | |
| 47 | |
| 48 // static | |
| 49 ProfileOAuth2TokenServiceFactory* | 41 ProfileOAuth2TokenServiceFactory* |
| 50 ProfileOAuth2TokenServiceFactory::GetInstance() { | 42 ProfileOAuth2TokenServiceFactory::GetInstance() { |
| 51 return Singleton<ProfileOAuth2TokenServiceFactory>::get(); | 43 return Singleton<ProfileOAuth2TokenServiceFactory>::get(); |
| 52 } | 44 } |
| 53 | 45 |
| 54 KeyedService* ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor( | 46 KeyedService* ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor( |
| 55 content::BrowserContext* context) const { | 47 content::BrowserContext* context) const { |
| 48 #if defined(OS_ANDROID) |
| 49 OAuth2TokenServiceDelegateAndroid* delegate = |
| 50 new OAuth2TokenServiceDelegateAndroid(); |
| 51 delegate->Initialize(); |
| 52 #else |
| 56 Profile* profile = static_cast<Profile*>(context); | 53 Profile* profile = static_cast<Profile*>(context); |
| 57 PlatformSpecificOAuth2TokenService* service = | 54 // TODO(acleung): This is br0ked for non-android right now. FIXME. |
| 58 new PlatformSpecificOAuth2TokenService(); | 55 MutableProfileOAuth2TokenServiceDelegate* delegate = |
| 59 service->Initialize( | 56 new MutableProfileOAuth2TokenServiceDelegate( |
| 60 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile), | 57 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile), |
| 61 SigninErrorControllerFactory::GetInstance()->GetForProfile(profile)); | 58 SigninErrorControllerFactory::GetInstance()->GetForProfile(profile)); |
| 59 #endif |
| 60 ProfileOAuth2TokenService* service = new ProfileOAuth2TokenService(delegate); |
| 62 return service; | 61 return service; |
| 63 } | 62 } |
| OLD | NEW |