Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / signin / core / browser / profile_identity_provider.cc
blob3be796e2d64e3f19e127d294d506c13da474d97c
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 "components/signin/core/browser/profile_identity_provider.h"
7 #include "base/callback.h"
8 #include "components/signin/core/browser/profile_oauth2_token_service.h"
10 ProfileIdentityProvider::ProfileIdentityProvider(
11 SigninManagerBase* signin_manager,
12 ProfileOAuth2TokenService* token_service,
13 const base::Closure& request_login_callback)
14 : signin_manager_(signin_manager),
15 token_service_(token_service),
16 request_login_callback_(request_login_callback) {
17 signin_manager_->AddObserver(this);
20 ProfileIdentityProvider::~ProfileIdentityProvider() {
21 signin_manager_->RemoveObserver(this);
24 std::string ProfileIdentityProvider::GetActiveUsername() {
25 return signin_manager_->GetAuthenticatedAccountInfo().email;
28 std::string ProfileIdentityProvider::GetActiveAccountId() {
29 return signin_manager_->GetAuthenticatedAccountId();
32 OAuth2TokenService* ProfileIdentityProvider::GetTokenService() {
33 return token_service_;
36 bool ProfileIdentityProvider::RequestLogin() {
37 if (request_login_callback_.is_null())
38 return false;
39 request_login_callback_.Run();
40 return true;
43 void ProfileIdentityProvider::GoogleSigninSucceeded(
44 const std::string& account_id,
45 const std::string& username,
46 const std::string& password) {
47 FireOnActiveAccountLogin();
50 void ProfileIdentityProvider::GoogleSignedOut(const std::string& account_id,
51 const std::string& username) {
52 FireOnActiveAccountLogout();