Chromium Code Reviews| 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" | |
| 10 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 11 #include "google_apis/gaia/gaia_auth_fetcher.h" | 13 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 12 #include "google_apis/gaia/gaia_constants.h" | 14 #include "google_apis/gaia/gaia_constants.h" |
| 13 | 15 |
| 14 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile, | 16 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile, |
| 15 Observer* observer) | 17 Observer* observer) |
| 16 : profile_(profile) { | 18 : profile_(profile) { |
| 17 if (observer) | 19 if (observer) |
| 18 AddObserver(observer); | 20 AddObserver(observer); |
| 19 } | 21 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 const GoogleServiceAuthError& error) { | 74 const GoogleServiceAuthError& error) { |
| 73 VLOG(1) << "Failed MergeSession" | 75 VLOG(1) << "Failed MergeSession" |
| 74 << " account=" << accounts_.front() | 76 << " account=" << accounts_.front() |
| 75 << " error=" << error.ToString(); | 77 << " error=" << error.ToString(); |
| 76 const std::string account_id = accounts_.front(); | 78 const std::string account_id = accounts_.front(); |
| 77 MergeNextAccount(); | 79 MergeNextAccount(); |
| 78 SignalComplete(account_id, error); | 80 SignalComplete(account_id, error); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void GoogleAutoLoginHelper::StartFetching() { | 83 void GoogleAutoLoginHelper::StartFetching() { |
| 82 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); | 84 uber_token_fetcher_.reset(new UbertokenFetcher( |
|
blundell
2014/01/15 12:09:51
I didn't want to tackle GoogleAutoLoginHelper in t
| |
| 85 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), | |
| 86 this, | |
| 87 profile_->GetRequestContext())); | |
| 83 uber_token_fetcher_->StartFetchingToken(accounts_.front()); | 88 uber_token_fetcher_->StartFetchingToken(accounts_.front()); |
| 84 } | 89 } |
| 85 | 90 |
| 86 void GoogleAutoLoginHelper::SignalComplete( | 91 void GoogleAutoLoginHelper::SignalComplete( |
| 87 const std::string& account_id, | 92 const std::string& account_id, |
| 88 const GoogleServiceAuthError& error) { | 93 const GoogleServiceAuthError& error) { |
| 89 // Its possible for the observer to delete |this| object. Don't access | 94 // Its possible for the observer to delete |this| object. Don't access |
| 90 // access any members after this calling the observer. This method should | 95 // access any members after this calling the observer. This method should |
| 91 // be the last call in any other method. | 96 // be the last call in any other method. |
| 92 FOR_EACH_OBSERVER(Observer, observer_list_, | 97 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 93 MergeSessionCompleted(account_id, error)); | 98 MergeSessionCompleted(account_id, error)); |
| 94 } | 99 } |
| 95 | 100 |
| 96 void GoogleAutoLoginHelper::MergeNextAccount() { | 101 void GoogleAutoLoginHelper::MergeNextAccount() { |
| 97 gaia_auth_fetcher_.reset(); | 102 gaia_auth_fetcher_.reset(); |
| 98 accounts_.pop_front(); | 103 accounts_.pop_front(); |
| 99 if (accounts_.empty()) { | 104 if (accounts_.empty()) { |
| 100 uber_token_fetcher_.reset(); | 105 uber_token_fetcher_.reset(); |
| 101 } else { | 106 } else { |
| 102 StartFetching(); | 107 StartFetching(); |
| 103 } | 108 } |
| 104 } | 109 } |
| OLD | NEW |