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

Side by Side Diff: chrome/common/net/gaia/gaia_auth_fetcher.cc

Issue 8375039: Create a content::UrlFetcher interface that lives in content/public/common and convert users to i... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 bool GaiaAuthFetcher::HasPendingFetch() { 118 bool GaiaAuthFetcher::HasPendingFetch() {
119 return fetch_pending_; 119 return fetch_pending_;
120 } 120 }
121 121
122 void GaiaAuthFetcher::CancelRequest() { 122 void GaiaAuthFetcher::CancelRequest() {
123 fetcher_.reset(); 123 fetcher_.reset();
124 fetch_pending_ = false; 124 fetch_pending_ = false;
125 } 125 }
126 126
127 // static 127 // static
128 URLFetcher* GaiaAuthFetcher::CreateGaiaFetcher( 128 content::URLFetcher* GaiaAuthFetcher::CreateGaiaFetcher(
129 net::URLRequestContextGetter* getter, 129 net::URLRequestContextGetter* getter,
130 const std::string& body, 130 const std::string& body,
131 const GURL& gaia_gurl, 131 const GURL& gaia_gurl,
132 bool send_cookies, 132 bool send_cookies,
133 content::URLFetcherDelegate* delegate) { 133 content::URLFetcherDelegate* delegate) {
134 134
135 URLFetcher* to_return = 135 URLFetcher* to_return =
136 URLFetcher::Create(0, 136 URLFetcher::Create(0,
137 gaia_gurl, 137 gaia_gurl,
138 URLFetcher::POST, 138 URLFetcher::POST,
139 delegate); 139 delegate);
140 to_return->set_request_context(getter); 140 to_return->SetRequestContext(getter);
141 to_return->set_upload_data("application/x-www-form-urlencoded", body); 141 to_return->SetUploadData("application/x-www-form-urlencoded", body);
142 142
143 // The Gaia token exchange requests do not require any cookie-based 143 // The Gaia token exchange requests do not require any cookie-based
144 // identification as part of requests. We suppress sending any cookies to 144 // identification as part of requests. We suppress sending any cookies to
145 // maintain a separation between the user's browsing and Chrome's internal 145 // maintain a separation between the user's browsing and Chrome's internal
146 // services. Where such mixing is desired (MergeSession), it will be done 146 // services. Where such mixing is desired (MergeSession), it will be done
147 // explicitly. 147 // explicitly.
148 if (!send_cookies) 148 if (!send_cookies)
149 to_return->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES); 149 to_return->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES);
150 150
151 return to_return; 151 return to_return;
152 } 152 }
153 153
154 // static 154 // static
155 std::string GaiaAuthFetcher::MakeClientLoginBody( 155 std::string GaiaAuthFetcher::MakeClientLoginBody(
156 const std::string& username, 156 const std::string& username,
157 const std::string& password, 157 const std::string& password,
158 const std::string& source, 158 const std::string& source,
159 const char* service, 159 const char* service,
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 void GaiaAuthFetcher::OnMergeSessionFetched(const std::string& data, 573 void GaiaAuthFetcher::OnMergeSessionFetched(const std::string& data,
574 const net::URLRequestStatus& status, 574 const net::URLRequestStatus& status,
575 int response_code) { 575 int response_code) {
576 if (status.is_success() && response_code == RC_REQUEST_OK) { 576 if (status.is_success() && response_code == RC_REQUEST_OK) {
577 consumer_->OnMergeSessionSuccess(data); 577 consumer_->OnMergeSessionSuccess(data);
578 } else { 578 } else {
579 consumer_->OnMergeSessionFailure(GenerateAuthError(data, status)); 579 consumer_->OnMergeSessionFailure(GenerateAuthError(data, status));
580 } 580 }
581 } 581 }
582 582
583 void GaiaAuthFetcher::OnURLFetchComplete(const URLFetcher* source) { 583 void GaiaAuthFetcher::OnURLFetchComplete(const content::URLFetcher* source) {
584 fetch_pending_ = false; 584 fetch_pending_ = false;
585 const GURL& url = source->url(); 585 const GURL& url = source->GetUrl();
586 const net::URLRequestStatus& status = source->status(); 586 const net::URLRequestStatus& status = source->GetStatus();
587 int response_code = source->response_code(); 587 int response_code = source->GetResponseCode();
588 std::string data; 588 std::string data;
589 source->GetResponseAsString(&data); 589 source->GetResponseAsString(&data);
590 if (url == client_login_gurl_) { 590 if (url == client_login_gurl_) {
591 OnClientLoginFetched(data, status, response_code); 591 OnClientLoginFetched(data, status, response_code);
592 } else if (url == issue_auth_token_gurl_) { 592 } else if (url == issue_auth_token_gurl_) {
593 OnIssueAuthTokenFetched(data, status, response_code); 593 OnIssueAuthTokenFetched(data, status, response_code);
594 } else if (url == get_user_info_gurl_) { 594 } else if (url == get_user_info_gurl_) {
595 OnGetUserInfoFetched(data, status, response_code); 595 OnGetUserInfoFetched(data, status, response_code);
596 } else if (url == token_auth_gurl_) { 596 } else if (url == token_auth_gurl_) {
597 OnTokenAuthFetched(data, status, response_code); 597 OnTokenAuthFetched(data, status, response_code);
598 } else if (url == merge_session_gurl_ || 598 } else if (url == merge_session_gurl_ ||
599 (source && source->original_url() == merge_session_gurl_)) { 599 (source && source->GetOriginalUrl() == merge_session_gurl_)) {
600 // MergeSession may redirect, so check the original URL of the fetcher. 600 // MergeSession may redirect, so check the original URL of the fetcher.
601 OnMergeSessionFetched(data, status, response_code); 601 OnMergeSessionFetched(data, status, response_code);
602 } else { 602 } else {
603 NOTREACHED(); 603 NOTREACHED();
604 } 604 }
605 } 605 }
606 606
607 // static 607 // static
608 bool GaiaAuthFetcher::IsSecondFactorSuccess( 608 bool GaiaAuthFetcher::IsSecondFactorSuccess(
609 const std::string& alleged_error) { 609 const std::string& alleged_error) {
610 return alleged_error.find(kSecondFactor) != 610 return alleged_error.find(kSecondFactor) !=
611 std::string::npos; 611 std::string::npos;
612 } 612 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/gaia_auth_fetcher.h ('k') | chrome/common/net/gaia/gaia_auth_fetcher_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698