Index: google_apis/gaia/gaia_auth_fetcher.cc |
diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc |
index 5464da89873c79c1907c7bc48abb3cad71c2086e..b0046d5eb30094023cb3354db2e3553919226a52 100644 |
--- a/google_apis/gaia/gaia_auth_fetcher.cc |
+++ b/google_apis/gaia/gaia_auth_fetcher.cc |
@@ -186,6 +186,8 @@ GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, |
base::StringPrintf(kUberAuthTokenURLFormat, source.c_str()))), |
oauth_login_gurl_(GaiaUrls::GetInstance()->oauth1_login_url()), |
list_accounts_gurl_(GaiaUrls::GetInstance()->list_accounts_url()), |
+ get_check_connection_info_url_( |
+ GaiaUrls::GetInstance()->get_check_connection_info_url()), |
client_login_to_oauth2_gurl_( |
GaiaUrls::GetInstance()->client_login_to_oauth2_url()), |
fetch_pending_(false) {} |
@@ -349,16 +351,24 @@ std::string GaiaAuthFetcher::MakeGetUserInfoBody(const std::string& lsid) { |
// static |
std::string GaiaAuthFetcher::MakeMergeSessionBody( |
const std::string& auth_token, |
+ const std::string& external_cc_result, |
const std::string& continue_url, |
const std::string& source) { |
std::string encoded_auth_token = net::EscapeUrlEncodedData(auth_token, true); |
std::string encoded_continue_url = net::EscapeUrlEncodedData(continue_url, |
true); |
std::string encoded_source = net::EscapeUrlEncodedData(source, true); |
- return base::StringPrintf(kMergeSessionFormat, |
- encoded_auth_token.c_str(), |
- encoded_continue_url.c_str(), |
- encoded_source.c_str()); |
+ std::string result = base::StringPrintf(kMergeSessionFormat, |
+ encoded_auth_token.c_str(), |
+ encoded_continue_url.c_str(), |
+ encoded_source.c_str()); |
+ if (!external_cc_result.empty()) { |
+ base::StringAppendF(&result, "&externalCcResult=%s", |
+ net::EscapeUrlEncodedData( |
+ external_cc_result, true).c_str()); |
+ } |
+ |
+ return result; |
} |
// static |
@@ -622,7 +632,8 @@ void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid) { |
fetcher_->Start(); |
} |
-void GaiaAuthFetcher::StartMergeSession(const std::string& uber_token) { |
+void GaiaAuthFetcher::StartMergeSession(const std::string& uber_token, |
+ const std::string& external_cc_result) { |
DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
DVLOG(1) << "Starting MergeSession with uber_token=" << uber_token; |
@@ -636,7 +647,8 @@ void GaiaAuthFetcher::StartMergeSession(const std::string& uber_token) { |
// created such that it sends the cookies with the request, which is |
// different from all other requests the fetcher can make. |
std::string continue_url("http://www.google.com"); |
- request_body_ = MakeMergeSessionBody(uber_token, continue_url, source_); |
+ request_body_ = MakeMergeSessionBody(uber_token, external_cc_result, |
+ continue_url, source_); |
fetcher_.reset(CreateGaiaFetcher(getter_, |
request_body_, |
std::string(), |
@@ -695,6 +707,19 @@ void GaiaAuthFetcher::StartListAccounts() { |
fetcher_->Start(); |
} |
+void GaiaAuthFetcher::StartGetCheckConnectionInfo() { |
+ DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
+ |
+ fetcher_.reset(CreateGaiaFetcher(getter_, |
+ std::string(), |
+ std::string(), |
+ get_check_connection_info_url_, |
+ kLoadFlagsIgnoreCookies, |
+ this)); |
+ fetch_pending_ = true; |
+ fetcher_->Start(); |
+} |
+ |
// static |
GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( |
const std::string& data, |
@@ -891,6 +916,17 @@ void GaiaAuthFetcher::OnOAuthLoginFetched(const std::string& data, |
} |
} |
+void GaiaAuthFetcher::OnGetCheckConnectionInfoFetched( |
+ const std::string& data, |
+ const net::URLRequestStatus& status, |
+ int response_code) { |
+ if (status.is_success() && response_code == net::HTTP_OK) { |
+ consumer_->OnGetCheckConnectionInfoSuccess(data); |
+ } else { |
+ consumer_->OnGetCheckConnectionInfoError(GenerateAuthError(data, status)); |
+ } |
+} |
+ |
void GaiaAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
fetch_pending_ = false; |
// Some of the GAIA requests perform redirects, which results in the final |
@@ -932,6 +968,8 @@ void GaiaAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
OnOAuth2RevokeTokenFetched(data, status, response_code); |
} else if (url == list_accounts_gurl_) { |
OnListAccountsFetched(data, status, response_code); |
+ } else if (url == get_check_connection_info_url_) { |
+ OnGetCheckConnectionInfoFetched(data, status, response_code); |
} else { |
NOTREACHED(); |
} |