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/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "google_apis/gaia/gaia_auth_fetcher.h" | 9 #include "google_apis/gaia/gaia_auth_fetcher.h" |
10 #include "google_apis/gaia/gaia_constants.h" | 10 #include "google_apis/gaia/gaia_constants.h" |
11 | 11 |
12 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile) | 12 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile) |
13 : profile_(profile) {} | 13 : profile_(profile) {} |
14 | 14 |
15 GoogleAutoLoginHelper::~GoogleAutoLoginHelper() {} | 15 GoogleAutoLoginHelper::~GoogleAutoLoginHelper() {} |
16 | 16 |
17 void GoogleAutoLoginHelper::LogIn() { | 17 void GoogleAutoLoginHelper::LogIn() { |
18 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); | 18 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); |
19 uber_token_fetcher_->StartFetchingToken(); | 19 uber_token_fetcher_->StartFetchingToken(); |
20 } | 20 } |
21 | 21 |
22 void GoogleAutoLoginHelper::LogIn(const std::string& account_id) { | 22 void GoogleAutoLoginHelper::LogIn(const std::string& account_id) { |
23 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); | 23 if (uber_token_fetcher_.get()) { |
24 uber_token_fetcher_->StartFetchingToken(account_id); | 24 accounts_.push_back(account_id); |
25 } else { | |
26 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); | |
27 uber_token_fetcher_->StartFetchingToken(account_id); | |
28 } | |
25 } | 29 } |
26 | 30 |
27 void GoogleAutoLoginHelper::OnUbertokenSuccess(const std::string& uber_token) { | 31 void GoogleAutoLoginHelper::OnUbertokenSuccess(const std::string& uber_token) { |
28 gaia_auth_fetcher_.reset(new GaiaAuthFetcher( | 32 gaia_auth_fetcher_.reset(new GaiaAuthFetcher( |
29 this, GaiaConstants::kChromeSource, profile_->GetRequestContext())); | 33 this, GaiaConstants::kChromeSource, profile_->GetRequestContext())); |
30 gaia_auth_fetcher_->StartMergeSession(uber_token); | 34 gaia_auth_fetcher_->StartMergeSession(uber_token); |
31 } | 35 } |
32 | 36 |
33 void GoogleAutoLoginHelper::OnUbertokenFailure( | 37 void GoogleAutoLoginHelper::OnUbertokenFailure( |
34 const GoogleServiceAuthError& error) { | 38 const GoogleServiceAuthError& error) { |
35 VLOG(1) << "Failed to retrieve ubertoken, error: " << error.ToString(); | 39 VLOG(1) << "Failed to retrieve ubertoken, error: " << error.ToString(); |
36 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 40 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
37 } | 41 } |
38 | 42 |
39 void GoogleAutoLoginHelper::OnMergeSessionSuccess(const std::string& data) { | 43 void GoogleAutoLoginHelper::OnMergeSessionSuccess(const std::string& data) { |
40 DVLOG(1) << "MergeSession successful." << data; | 44 DVLOG(1) << "MergeSession successful." << data; |
41 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 45 if (accounts_.empty()) { |
46 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | |
47 } else { | |
48 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); | |
49 uber_token_fetcher_->StartFetchingToken(accounts_.front()); | |
50 accounts_.pop_front(); | |
51 } | |
42 } | 52 } |
43 | 53 |
44 void GoogleAutoLoginHelper::OnMergeSessionFailure( | 54 void GoogleAutoLoginHelper::OnMergeSessionFailure( |
45 const GoogleServiceAuthError& error) { | 55 const GoogleServiceAuthError& error) { |
46 VLOG(1) << "Failed MergeSession request, error: " << error.ToString(); | 56 VLOG(1) << "Failed MergeSession request, error: " << error.ToString(); |
47 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 57 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
Roger Tawa OOO till Jul 10th
2013/11/21 16:02:32
If the |accounts_| list is not empty, should it ke
acleung1
2013/11/26 09:28:31
Not completely sure. I think continuing makes more
| |
48 } | 58 } |
OLD | NEW |