Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/net/gaia/gaia_auth_fetcher.h" | 5 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 kLoadFlagsIgnoreCookies, | 500 kLoadFlagsIgnoreCookies, |
| 501 this)); | 501 this)); |
| 502 fetch_pending_ = true; | 502 fetch_pending_ = true; |
| 503 fetcher_->Start(); | 503 fetcher_->Start(); |
| 504 } | 504 } |
| 505 | 505 |
| 506 void GaiaAuthFetcher::StartOAuthLoginTokenFetch( | 506 void GaiaAuthFetcher::StartOAuthLoginTokenFetch( |
| 507 const std::string& auth_token) { | 507 const std::string& auth_token) { |
| 508 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; | 508 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
| 509 | 509 |
| 510 DVLOG(1) << "Starting OAuth login token fetch"; | 510 DVLOG(1) << "Starting OAuth login token fetch with auth_token"; |
| 511 request_body_ = MakeGetAuthCodeBody(); | 511 request_body_ = MakeGetAuthCodeBody(); |
| 512 | 512 client_login_to_oauth2_gurl_ = |
| 513 // If no auth_token is given, then make sure to use the cookie jar with this | 513 GURL(GaiaUrls::GetInstance()->client_login_to_oauth2_url()); |
| 514 // request. Otherwise the token contains all the necessary information and | |
| 515 // the cookie jar should not be touched. | |
| 516 int load_flags = net::LOAD_NORMAL; | |
| 517 std::string auth_code_header = ""; | |
| 518 | |
| 519 if (!auth_token.empty()) { | |
| 520 load_flags = kLoadFlagsIgnoreCookies; | |
| 521 auth_code_header = MakeGetAuthCodeHeader(auth_token); | |
| 522 } | |
| 523 | 514 |
| 524 fetcher_.reset(CreateGaiaFetcher(getter_, | 515 fetcher_.reset(CreateGaiaFetcher(getter_, |
| 525 request_body_, | 516 request_body_, |
| 526 auth_code_header, | 517 MakeGetAuthCodeHeader(auth_token), |
| 527 client_login_to_oauth2_gurl_, | 518 client_login_to_oauth2_gurl_, |
| 528 load_flags, | 519 kLoadFlagsIgnoreCookies, |
| 529 this)); | 520 this)); |
| 530 fetch_pending_ = true; | 521 fetch_pending_ = true; |
| 531 fetcher_->Start(); | 522 fetcher_->Start(); |
| 523 } | |
| 524 | |
| 525 void GaiaAuthFetcher::StartOAuthLoginTokenFetchWithCookies( | |
| 526 const std::string& session_index) { | |
| 527 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; | |
| 528 | |
| 529 DVLOG(1) << "Starting OAuth login token fetch with cookie jar"; | |
| 530 request_body_ = MakeGetAuthCodeBody(); | |
| 531 | |
| 532 std::string url = GaiaUrls::GetInstance()->client_login_to_oauth2_url(); | |
| 533 if (!session_index.empty()) { | |
| 534 url += "?authuser="; | |
| 535 url += session_index; | |
|
Andrew T Wilson (Slow)
2012/03/06 20:42:46
Can you do url += "?authuser=" + session_index; or
Roger Tawa OOO till Jul 10th
2012/03/06 21:25:17
Done.
| |
| 536 } | |
| 537 client_login_to_oauth2_gurl_ = GURL(url); | |
| 538 | |
| 539 fetcher_.reset(CreateGaiaFetcher(getter_, | |
| 540 request_body_, | |
| 541 "", | |
| 542 client_login_to_oauth2_gurl_, | |
| 543 net::LOAD_NORMAL, | |
| 544 this)); | |
| 545 fetch_pending_ = true; | |
| 546 fetcher_->Start(); | |
| 532 } | 547 } |
| 533 | 548 |
| 534 void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid) { | 549 void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid) { |
| 535 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; | 550 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
| 536 | 551 |
| 537 DVLOG(1) << "Starting GetUserInfo for lsid=" << lsid; | 552 DVLOG(1) << "Starting GetUserInfo for lsid=" << lsid; |
| 538 request_body_ = MakeGetUserInfoBody(lsid); | 553 request_body_ = MakeGetUserInfoBody(lsid); |
| 539 fetcher_.reset(CreateGaiaFetcher(getter_, | 554 fetcher_.reset(CreateGaiaFetcher(getter_, |
| 540 request_body_, | 555 request_body_, |
| 541 "", | 556 "", |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 NOTREACHED(); | 887 NOTREACHED(); |
| 873 } | 888 } |
| 874 } | 889 } |
| 875 | 890 |
| 876 // static | 891 // static |
| 877 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 892 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
| 878 const std::string& alleged_error) { | 893 const std::string& alleged_error) { |
| 879 return alleged_error.find(kSecondFactor) != | 894 return alleged_error.find(kSecondFactor) != |
| 880 std::string::npos; | 895 std::string::npos; |
| 881 } | 896 } |
| OLD | NEW |