Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / components / signin / core / browser / signin_tracker.cc
blobad5954f6185c120f9ffc760596ce0981fffe8299
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/account_reconcilor.h"
8 #include "components/signin/core/browser/gaia_cookie_manager_service.h"
9 #include "components/signin/core/browser/profile_oauth2_token_service.h"
10 #include "components/signin/core/browser/signin_client.h"
11 #include "google_apis/gaia/gaia_constants.h"
13 SigninTracker::SigninTracker(ProfileOAuth2TokenService* token_service,
14 SigninManagerBase* signin_manager,
15 AccountReconcilor* account_reconcilor,
16 GaiaCookieManagerService* cookie_manager_service,
17 SigninClient* client,
18 Observer* observer)
19 : token_service_(token_service),
20 signin_manager_(signin_manager),
21 account_reconcilor_(account_reconcilor),
22 cookie_manager_service_(cookie_manager_service),
23 client_(client),
24 observer_(observer) {
25 Initialize();
28 SigninTracker::~SigninTracker() {
29 signin_manager_->RemoveObserver(this);
30 token_service_->RemoveObserver(this);
31 cookie_manager_service_->RemoveObserver(this);
34 void SigninTracker::Initialize() {
35 DCHECK(observer_);
36 signin_manager_->AddObserver(this);
37 token_service_->AddObserver(this);
38 cookie_manager_service_->AddObserver(this);
41 void SigninTracker::GoogleSigninFailed(const GoogleServiceAuthError& error) {
42 observer_->SigninFailed(error);
45 void SigninTracker::OnRefreshTokenAvailable(const std::string& account_id) {
46 if (account_id != signin_manager_->GetAuthenticatedAccountId())
47 return;
49 observer_->SigninSuccess();
52 void SigninTracker::OnRefreshTokenRevoked(const std::string& account_id) {
53 NOTREACHED();
56 void SigninTracker::OnAddAccountToCookieCompleted(
57 const std::string& account_id,
58 const GoogleServiceAuthError& error) {
59 observer_->MergeSessionComplete(error);