Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / signin / core / browser / signin_tracker.cc
blob2bbd4207d1be60181f06543748afe57934644a9d
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/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 AccountReconcilor* account_reconcilor,
15 SigninClient* client,
16 Observer* observer)
17 : token_service_(token_service),
18 signin_manager_(signin_manager),
19 account_reconcilor_(account_reconcilor),
20 client_(client),
21 observer_(observer) {
22 Initialize();
25 SigninTracker::~SigninTracker() {
26 signin_manager_->RemoveObserver(this);
27 token_service_->RemoveObserver(this);
29 if (account_reconcilor_) {
30 account_reconcilor_->RemoveMergeSessionObserver(this);
31 #if !defined(OS_CHROMEOS)
32 } else if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) {
33 SigninManager* manager = static_cast<SigninManager*>(signin_manager_);
34 manager->RemoveMergeSessionObserver(this);
35 #endif
39 void SigninTracker::Initialize() {
40 DCHECK(observer_);
41 signin_manager_->AddObserver(this);
42 token_service_->AddObserver(this);
45 void SigninTracker::GoogleSigninFailed(const GoogleServiceAuthError& error) {
46 observer_->SigninFailed(error);
49 void SigninTracker::OnRefreshTokenAvailable(const std::string& account_id) {
50 if (account_id != signin_manager_->GetAuthenticatedAccountId())
51 return;
53 if (account_reconcilor_) {
54 account_reconcilor_->AddMergeSessionObserver(this);
55 #if !defined(OS_CHROMEOS)
56 } else if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) {
57 SigninManager* manager = static_cast<SigninManager*>(signin_manager_);
58 manager->AddMergeSessionObserver(this);
59 #endif
62 observer_->SigninSuccess();
65 void SigninTracker::OnRefreshTokenRevoked(const std::string& account_id) {
66 NOTREACHED();
69 void SigninTracker::MergeSessionCompleted(
70 const std::string& account_id,
71 const GoogleServiceAuthError& error) {
72 observer_->MergeSessionComplete(error);