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

Unified Diff: content/child/web_url_loader_impl.cc

Issue 398903002: Plumb redirect info out of net, through content, and into child processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a TODO Created 6 years, 5 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
Index: content/child/web_url_loader_impl.cc
diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc
index 5fe04707bed2d64298d13c550dd4029bed75870e..b1869d783ebbdbbff112f8a2ea3bdd7f7746bff4 100644
--- a/content/child/web_url_loader_impl.cc
+++ b/content/child/web_url_loader_impl.cc
@@ -27,7 +27,7 @@
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
-#include "net/url_request/url_request.h"
+#include "net/url_request/redirect_info.h"
#include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
#include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
#include "third_party/WebKit/public/platform/WebURL.h"
@@ -223,8 +223,7 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
// RequestPeer methods:
virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE;
- virtual bool OnReceivedRedirect(const GURL& new_url,
- const GURL& new_first_party_for_cookies,
+ virtual bool OnReceivedRedirect(const net::RedirectInfo& redirect_info,
const ResourceResponseInfo& info) OVERRIDE;
virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE;
virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE;
@@ -470,8 +469,7 @@ void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) {
}
bool WebURLLoaderImpl::Context::OnReceivedRedirect(
- const GURL& new_url,
- const GURL& new_first_party_for_cookies,
+ const net::RedirectInfo& redirect_info,
const ResourceResponseInfo& info) {
if (!client_)
return false;
@@ -482,23 +480,16 @@ bool WebURLLoaderImpl::Context::OnReceivedRedirect(
// TODO(darin): We lack sufficient information to construct the actual
// request that resulted from the redirect.
- WebURLRequest new_request(new_url);
- new_request.setFirstPartyForCookies(new_first_party_for_cookies);
+ WebURLRequest new_request(redirect_info.url);
+ new_request.setFirstPartyForCookies(redirect_info.first_party_for_cookies);
new_request.setDownloadToFile(request_.downloadToFile());
- WebString referrer_string = WebString::fromUTF8("Referer");
- WebString referrer = WebSecurityPolicy::generateReferrerHeader(
- referrer_policy_,
- new_url,
- request_.httpHeaderField(referrer_string));
- if (!referrer.isEmpty())
- new_request.setHTTPReferrer(referrer, referrer_policy_);
-
- std::string method = request_.httpMethod().utf8();
- std::string new_method = net::URLRequest::ComputeMethodForRedirect(
- method, response.httpStatusCode());
- new_request.setHTTPMethod(WebString::fromUTF8(new_method));
- if (new_method == method)
+ new_request.setHTTPReferrer(WebString::fromUTF8(redirect_info.referrer),
+ referrer_policy_);
mmenke 2014/07/17 16:55:09 Should we keep the isEmpty check?
davidben 2014/07/17 22:03:55 WebURLRequest internally does a check. https://co
+
+ std::string old_method = request_.httpMethod().utf8();
+ new_request.setHTTPMethod(WebString::fromUTF8(redirect_info.method));
+ if (redirect_info.method == old_method)
new_request.setHTTPBody(request_.httpBody());
// Protect from deletion during call to willSendRequest.
@@ -508,11 +499,11 @@ bool WebURLLoaderImpl::Context::OnReceivedRedirect(
request_ = new_request;
// Only follow the redirect if WebKit left the URL unmodified.
- if (new_url == GURL(new_request.url())) {
+ if (redirect_info.url == GURL(new_request.url())) {
// First-party cookie logic moved from DocumentLoader in Blink to
// CrossSiteResourceHandler in the browser. Assert that Blink didn't try to
mmenke 2014/07/17 16:55:09 Is this still accurate?
davidben 2014/07/17 22:03:55 Fixed.
// change it to something else.
- DCHECK_EQ(new_first_party_for_cookies.spec(),
+ DCHECK_EQ(redirect_info.first_party_for_cookies.spec(),
request_.firstPartyForCookies().string().utf8());
return true;
}

Powered by Google App Engine
This is Rietveld 408576698