Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / signin / core / browser / signin_tracker.cc
blob1249fd741b420101fb1c601bf7ef0ddf35072ee2
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,
15 SigninClient* client,
16 Observer* observer)
17 : token_service_(token_service),
18 signin_manager_(signin_manager),
19 cookie_manager_service_(cookie_manager_service),
20 client_(client),
21 observer_(observer) {
22 Initialize();
25 SigninTracker::~SigninTracker() {
26 signin_manager_->RemoveObserver(this);
27 token_service_->RemoveObserver(this);
28 cookie_manager_service_->RemoveObserver(this);
31 void SigninTracker::Initialize() {
32 DCHECK(observer_);
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())
44 return;
46 observer_->SigninSuccess();
49 void SigninTracker::OnRefreshTokenRevoked(const std::string& account_id) {
50 NOTREACHED();
53 void SigninTracker::OnAddAccountToCookieCompleted(
54 const std::string& account_id,
55 const GoogleServiceAuthError& error) {
56 observer_->AccountAddedToCookie(error);