Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1558)

Unified Diff: chrome/common/net/gaia/gaia_auth_fetcher.cc

Issue 7121014: When a user logs into sync, the appropriate cookies are retrieved so that (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Uploading after sync merge Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/net/gaia/gaia_auth_fetcher.h ('k') | chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/net/gaia/gaia_auth_fetcher.cc
===================================================================
--- chrome/common/net/gaia/gaia_auth_fetcher.cc (revision 89823)
+++ chrome/common/net/gaia/gaia_auth_fetcher.cc (working copy)
@@ -49,6 +49,11 @@
// static
const char GaiaAuthFetcher::kGetUserInfoFormat[] =
"LSID=%s";
+// static
+const char GaiaAuthFetcher::kTokenAuthFormat[] =
+ "auth=%s&"
+ "continue=%s&"
+ "source=%s";
// static
const char GaiaAuthFetcher::kAccountDeletedError[] = "AccountDeleted";
@@ -92,6 +97,7 @@
client_login_gurl_(GaiaUrls::GetInstance()->client_login_url()),
issue_auth_token_gurl_(GaiaUrls::GetInstance()->issue_auth_token_url()),
get_user_info_gurl_(GaiaUrls::GetInstance()->get_user_info_url()),
+ token_auth_gurl_(GaiaUrls::GetInstance()->token_auth_url()),
fetch_pending_(false) {}
GaiaAuthFetcher::~GaiaAuthFetcher() {}
@@ -188,6 +194,19 @@
return base::StringPrintf(kGetUserInfoFormat, encoded_lsid.c_str());
}
+// static
+std::string GaiaAuthFetcher::MakeTokenAuthBody(const std::string& auth_token,
+ const std::string& continue_url,
+ const std::string& source) {
+ std::string encoded_auth_token = EscapeUrlEncodedData(auth_token, true);
+ std::string encoded_continue_url = EscapeUrlEncodedData(continue_url, true);
+ std::string encoded_source = EscapeUrlEncodedData(source, true);
+ return base::StringPrintf(kTokenAuthFormat,
+ encoded_auth_token.c_str(),
+ encoded_continue_url.c_str(),
+ encoded_source.c_str());
+}
+
// Helper method that extracts tokens from a successful reply.
// static
void GaiaAuthFetcher::ParseClientLoginResponse(const std::string& data,
@@ -299,6 +318,24 @@
fetcher_->Start();
}
+void GaiaAuthFetcher::StartTokenAuth(const std::string& auth_token) {
+ DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
+
+ VLOG(1) << "Starting TokenAuth with auth_token=" << auth_token;
+
+ // The continue URL is a required parameter of the TokenAuth API, but in this
+ // case we don't actually need or want to navigate to it. Setting it to
+ // an arbitrary Google URL.
+ std::string continue_url("http://www.google.com");
+ request_body_ = MakeTokenAuthBody(auth_token, continue_url, source_);
+ fetcher_.reset(CreateGaiaFetcher(getter_,
+ request_body_,
+ token_auth_gurl_,
+ this));
+ fetch_pending_ = true;
+ fetcher_->Start();
+}
+
// static
GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError(
const std::string& data,
@@ -406,6 +443,16 @@
}
}
+void GaiaAuthFetcher::OnTokenAuthFetched(const std::string& data,
+ const net::URLRequestStatus& status,
+ int response_code) {
+ if (status.is_success() && response_code == RC_REQUEST_OK) {
+ consumer_->OnTokenAuthSuccess(data);
+ } else {
+ consumer_->OnTokenAuthFailure(GenerateAuthError(data, status));
+ }
+}
+
void GaiaAuthFetcher::OnURLFetchComplete(const URLFetcher* source,
const GURL& url,
const net::URLRequestStatus& status,
@@ -419,6 +466,8 @@
OnIssueAuthTokenFetched(data, status, response_code);
} else if (url == get_user_info_gurl_) {
OnGetUserInfoFetched(data, status, response_code);
+ } else if (url == token_auth_gurl_) {
+ OnTokenAuthFetched(data, status, response_code);
} else {
NOTREACHED();
}
« no previous file with comments | « chrome/common/net/gaia/gaia_auth_fetcher.h ('k') | chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698