| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_identity_provider.h" | 5 #include "chrome/browser/signin/profile_identity_provider.h" |
| 6 | 6 |
| 7 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 8 |
| 9 #if !defined(OS_ANDROID) |
| 7 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 10 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 8 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 11 #endif |
| 9 | 12 |
| 10 ProfileIdentityProvider::ProfileIdentityProvider( | 13 ProfileIdentityProvider::ProfileIdentityProvider( |
| 11 SigninManagerBase* signin_manager, | 14 SigninManagerBase* signin_manager, |
| 12 ProfileOAuth2TokenService* token_service, | 15 ProfileOAuth2TokenService* token_service, |
| 13 LoginUIService* login_ui_service) | 16 LoginUIService* login_ui_service) |
| 14 : signin_manager_(signin_manager), | 17 : signin_manager_(signin_manager), |
| 15 token_service_(token_service), | 18 token_service_(token_service), |
| 16 login_ui_service_(login_ui_service) { | 19 login_ui_service_(login_ui_service) { |
| 17 signin_manager_->AddObserver(this); | 20 signin_manager_->AddObserver(this); |
| 18 } | 21 } |
| 19 | 22 |
| 20 ProfileIdentityProvider::~ProfileIdentityProvider() { | 23 ProfileIdentityProvider::~ProfileIdentityProvider() { |
| 21 signin_manager_->RemoveObserver(this); | 24 signin_manager_->RemoveObserver(this); |
| 22 } | 25 } |
| 23 | 26 |
| 24 std::string ProfileIdentityProvider::GetActiveUsername() { | 27 std::string ProfileIdentityProvider::GetActiveUsername() { |
| 25 return signin_manager_->GetAuthenticatedUsername(); | 28 return signin_manager_->GetAuthenticatedUsername(); |
| 26 } | 29 } |
| 27 | 30 |
| 28 std::string ProfileIdentityProvider::GetActiveAccountId() { | 31 std::string ProfileIdentityProvider::GetActiveAccountId() { |
| 29 return signin_manager_->GetAuthenticatedAccountId(); | 32 return signin_manager_->GetAuthenticatedAccountId(); |
| 30 } | 33 } |
| 31 | 34 |
| 32 OAuth2TokenService* ProfileIdentityProvider::GetTokenService() { | 35 OAuth2TokenService* ProfileIdentityProvider::GetTokenService() { |
| 33 return token_service_; | 36 return token_service_; |
| 34 } | 37 } |
| 35 | 38 |
| 36 bool ProfileIdentityProvider::RequestLogin() { | 39 bool ProfileIdentityProvider::RequestLogin() { |
| 40 #if defined(OS_ANDROID) |
| 41 return false; |
| 42 #else |
| 37 login_ui_service_->ShowLoginPopup(); | 43 login_ui_service_->ShowLoginPopup(); |
| 38 return true; | 44 return true; |
| 45 #endif |
| 39 } | 46 } |
| 40 | 47 |
| 41 void ProfileIdentityProvider::GoogleSigninSucceeded( | 48 void ProfileIdentityProvider::GoogleSigninSucceeded( |
| 42 const std::string& username, | 49 const std::string& username, |
| 43 const std::string& password) { | 50 const std::string& password) { |
| 44 FireOnActiveAccountLogin(); | 51 FireOnActiveAccountLogin(); |
| 45 } | 52 } |
| 46 | 53 |
| 47 void ProfileIdentityProvider::GoogleSignedOut(const std::string& username) { | 54 void ProfileIdentityProvider::GoogleSignedOut(const std::string& username) { |
| 48 FireOnActiveAccountLogout(); | 55 FireOnActiveAccountLogout(); |
| 49 } | 56 } |
| OLD | NEW |