blob: 2d58e4382f92f7e04c11898157c6436eb6ba67d7 [file] [log] [blame]
[email protected]a263ff52014-04-23 19:46:531// 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.
4
Colin Blundell3e0efae2018-06-05 07:11:495#include "components/invalidation/impl/profile_identity_provider.h"
[email protected]a263ff52014-04-23 19:46:536
[email protected]a263ff52014-04-23 19:46:537#include "components/signin/core/browser/profile_oauth2_token_service.h"
8
Colin Blundell3e0efae2018-06-05 07:11:499namespace invalidation {
10
[email protected]a263ff52014-04-23 19:46:5311ProfileIdentityProvider::ProfileIdentityProvider(
12 SigninManagerBase* signin_manager,
Colin Blundell12b411d22018-05-23 09:24:2613 ProfileOAuth2TokenService* token_service)
14 : signin_manager_(signin_manager), token_service_(token_service) {
[email protected]a263ff52014-04-23 19:46:5315 signin_manager_->AddObserver(this);
16}
17
18ProfileIdentityProvider::~ProfileIdentityProvider() {
19 signin_manager_->RemoveObserver(this);
20}
21
[email protected]a263ff52014-04-23 19:46:5322std::string ProfileIdentityProvider::GetActiveAccountId() {
23 return signin_manager_->GetAuthenticatedAccountId();
24}
25
Colin Blundella212f4f2018-06-05 14:13:1126bool ProfileIdentityProvider::IsActiveAccountAvailable() {
27 if (GetActiveAccountId().empty() || !token_service_ ||
28 !token_service_->RefreshTokenIsAvailable(GetActiveAccountId()))
29 return false;
30
31 return true;
32}
33
[email protected]a263ff52014-04-23 19:46:5334OAuth2TokenService* ProfileIdentityProvider::GetTokenService() {
35 return token_service_;
36}
37
[email protected]a263ff52014-04-23 19:46:5338void ProfileIdentityProvider::GoogleSigninSucceeded(
rogerta22aa58e2014-08-29 15:15:5739 const std::string& account_id,
Mihai Sardarescub4b697e2017-07-04 16:41:4640 const std::string& username) {
[email protected]a263ff52014-04-23 19:46:5341 FireOnActiveAccountLogin();
42}
43
rogerta22aa58e2014-08-29 15:15:5744void ProfileIdentityProvider::GoogleSignedOut(const std::string& account_id,
45 const std::string& username) {
[email protected]a263ff52014-04-23 19:46:5346 FireOnActiveAccountLogout();
47}
Colin Blundell3e0efae2018-06-05 07:11:4948
49} // namespace invalidation