| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/signin/google_auto_login_helper.h" | 5 #include "chrome/browser/signin/google_auto_login_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/signin/profile_oauth2_token_service.h" | |
| 11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | |
| 12 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 13 #include "google_apis/gaia/gaia_auth_fetcher.h" | 11 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 14 #include "google_apis/gaia/gaia_constants.h" | 12 #include "google_apis/gaia/gaia_constants.h" |
| 15 | 13 |
| 16 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile, | 14 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile, |
| 17 Observer* observer) | 15 Observer* observer) |
| 18 : profile_(profile) { | 16 : profile_(profile) { |
| 19 if (observer) | 17 if (observer) |
| 20 AddObserver(observer); | 18 AddObserver(observer); |
| 21 } | 19 } |
| 22 | 20 |
| 23 GoogleAutoLoginHelper::~GoogleAutoLoginHelper() { | 21 GoogleAutoLoginHelper::~GoogleAutoLoginHelper() { |
| 24 DCHECK(accounts_.empty()); | 22 DCHECK(accounts_.empty()); |
| 25 } | 23 } |
| 26 | 24 |
| 27 void GoogleAutoLoginHelper::LogIn() { | |
| 28 ProfileOAuth2TokenService* token_service = | |
| 29 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | |
| 30 LogIn(token_service->GetPrimaryAccountId()); | |
| 31 } | |
| 32 | |
| 33 void GoogleAutoLoginHelper::LogIn(const std::string& account_id) { | 25 void GoogleAutoLoginHelper::LogIn(const std::string& account_id) { |
| 34 accounts_.push_back(account_id); | 26 accounts_.push_back(account_id); |
| 35 if (accounts_.size() == 1) | 27 if (accounts_.size() == 1) |
| 36 StartFetching(); | 28 StartFetching(); |
| 37 } | 29 } |
| 38 | 30 |
| 39 void GoogleAutoLoginHelper::AddObserver(Observer* observer) { | 31 void GoogleAutoLoginHelper::AddObserver(Observer* observer) { |
| 40 observer_list_.AddObserver(observer); | 32 observer_list_.AddObserver(observer); |
| 41 } | 33 } |
| 42 | 34 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 95 |
| 104 void GoogleAutoLoginHelper::MergeNextAccount() { | 96 void GoogleAutoLoginHelper::MergeNextAccount() { |
| 105 gaia_auth_fetcher_.reset(); | 97 gaia_auth_fetcher_.reset(); |
| 106 accounts_.pop_front(); | 98 accounts_.pop_front(); |
| 107 if (accounts_.empty()) { | 99 if (accounts_.empty()) { |
| 108 uber_token_fetcher_.reset(); | 100 uber_token_fetcher_.reset(); |
| 109 } else { | 101 } else { |
| 110 StartFetching(); | 102 StartFetching(); |
| 111 } | 103 } |
| 112 } | 104 } |
| OLD | NEW |