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/signin_tracker.h"
7 #include "components/signin/core/browser/gaia_cookie_manager_service.h"
8 #include "components/signin/core/browser/profile_oauth2_token_service.h"
9 #include "components/signin/core/browser/signin_client.h"
10 #include "google_apis/gaia/gaia_constants.h"
12 SigninTracker::SigninTracker(ProfileOAuth2TokenService
* token_service
,
13 SigninManagerBase
* signin_manager
,
14 GaiaCookieManagerService
* cookie_manager_service
,
17 : token_service_(token_service
),
18 signin_manager_(signin_manager
),
19 cookie_manager_service_(cookie_manager_service
),
25 SigninTracker::~SigninTracker() {
26 signin_manager_
->RemoveObserver(this);
27 token_service_
->RemoveObserver(this);
28 cookie_manager_service_
->RemoveObserver(this);
31 void SigninTracker::Initialize() {
33 signin_manager_
->AddObserver(this);
34 token_service_
->AddObserver(this);
35 cookie_manager_service_
->AddObserver(this);
38 void SigninTracker::GoogleSigninFailed(const GoogleServiceAuthError
& error
) {
39 observer_
->SigninFailed(error
);
42 void SigninTracker::OnRefreshTokenAvailable(const std::string
& account_id
) {
43 if (account_id
!= signin_manager_
->GetAuthenticatedAccountId())
46 observer_
->SigninSuccess();
49 void SigninTracker::OnRefreshTokenRevoked(const std::string
& account_id
) {
53 void SigninTracker::OnAddAccountToCookieCompleted(
54 const std::string
& account_id
,
55 const GoogleServiceAuthError
& error
) {
56 observer_
->AccountAddedToCookie(error
);