| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/chromeos/login/signin/oauth2_login_verifier.h" | 5 #include "chrome/browser/chromeos/login/signin/oauth2_login_verifier.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 std::vector<std::pair<std::string, bool> > accounts; | 46 std::vector<std::pair<std::string, bool> > accounts; |
| 47 if (cookie_manager_service_->ListAccounts(&accounts)) { | 47 if (cookie_manager_service_->ListAccounts(&accounts)) { |
| 48 OnGaiaAccountsInCookieUpdated( | 48 OnGaiaAccountsInCookieUpdated( |
| 49 accounts, GoogleServiceAuthError(GoogleServiceAuthError::NONE)); | 49 accounts, GoogleServiceAuthError(GoogleServiceAuthError::NONE)); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void OAuth2LoginVerifier::VerifyProfileTokens(Profile* profile) { | 53 void OAuth2LoginVerifier::VerifyProfileTokens(Profile* profile) { |
| 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 55 | 55 if (access_token_.empty()) { |
| 56 // TODO(xiyuan,mlerman): Use |access_token_| to cut down one round trip. | 56 cookie_manager_service_->AddAccountToCookie(primary_account_id_); |
| 57 // See http://crbug.com/483596 | 57 } else { |
| 58 cookie_manager_service_->AddAccountToCookie(primary_account_id_); | 58 cookie_manager_service_->AddAccountToCookieWithToken(primary_account_id_, |
| 59 access_token_); |
| 60 } |
| 59 } | 61 } |
| 60 | 62 |
| 61 void OAuth2LoginVerifier::OnAddAccountToCookieCompleted( | 63 void OAuth2LoginVerifier::OnAddAccountToCookieCompleted( |
| 62 const std::string& account_id, | 64 const std::string& account_id, |
| 63 const GoogleServiceAuthError& error) { | 65 const GoogleServiceAuthError& error) { |
| 64 if (account_id != primary_account_id_) | 66 if (account_id != primary_account_id_) |
| 65 return; | 67 return; |
| 66 | 68 |
| 67 if (error.state() == GoogleServiceAuthError::State::NONE) { | 69 if (error.state() == GoogleServiceAuthError::State::NONE) { |
| 68 VLOG(1) << "MergeSession successful."; | 70 VLOG(1) << "MergeSession successful."; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 83 delegate_->OnListAccountsSuccess(accounts); | 85 delegate_->OnListAccountsSuccess(accounts); |
| 84 return; | 86 return; |
| 85 } | 87 } |
| 86 | 88 |
| 87 LOG(WARNING) << "Failed to get list of session accounts, " | 89 LOG(WARNING) << "Failed to get list of session accounts, " |
| 88 << " error: " << error.state(); | 90 << " error: " << error.state(); |
| 89 delegate_->OnListAccountsFailure(IsConnectionOrServiceError(error)); | 91 delegate_->OnListAccountsFailure(IsConnectionOrServiceError(error)); |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace chromeos | 94 } // namespace chromeos |
| OLD | NEW |