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
3 // found in the LICENSE file.
5 #include "chrome/browser/signin/profile_identity_provider.h"
7 #include "components/signin/core/browser/profile_oauth2_token_service.h"
9 #if !defined(OS_ANDROID)
10 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
13 ProfileIdentityProvider::ProfileIdentityProvider(
14 SigninManagerBase
* signin_manager
,
15 ProfileOAuth2TokenService
* token_service
,
16 LoginUIService
* login_ui_service
)
17 : signin_manager_(signin_manager
),
18 token_service_(token_service
),
19 login_ui_service_(login_ui_service
) {
20 signin_manager_
->AddObserver(this);
23 ProfileIdentityProvider::~ProfileIdentityProvider() {
24 signin_manager_
->RemoveObserver(this);
27 std::string
ProfileIdentityProvider::GetActiveUsername() {
28 return signin_manager_
->GetAuthenticatedUsername();
31 std::string
ProfileIdentityProvider::GetActiveAccountId() {
32 return signin_manager_
->GetAuthenticatedAccountId();
35 OAuth2TokenService
* ProfileIdentityProvider::GetTokenService() {
36 return token_service_
;
39 bool ProfileIdentityProvider::RequestLogin() {
40 #if defined(OS_ANDROID)
43 login_ui_service_
->ShowLoginPopup();
48 void ProfileIdentityProvider::GoogleSigninSucceeded(
49 const std::string
& account_id
,
50 const std::string
& username
,
51 const std::string
& password
) {
52 FireOnActiveAccountLogin();
55 void ProfileIdentityProvider::GoogleSignedOut(const std::string
& account_id
,
56 const std::string
& username
) {
57 FireOnActiveAccountLogout();