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

Unified Diff: net/url_request/url_request_job.cc

Issue 714813003: Referrer Policy: Add new policies to URLRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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: net/url_request/url_request_job.cc
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 36101953c6c6c2966cbb29d83b80231d79200868..5b263797b92cddb7f5258307bac0ed7cb9be0c17 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -846,14 +846,29 @@ RedirectInfo URLRequestJob::ComputeRedirectInfo(const GURL& location,
request_->first_party_for_cookies();
}
- // Suppress the referrer if we're redirecting out of https.
- if (request_->referrer_policy() ==
- URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE &&
- GURL(request_->referrer()).SchemeIsSecure() &&
- !redirect_info.new_url.SchemeIsSecure()) {
- redirect_info.new_referrer.clear();
- } else {
+ // Alter the referrer if we're redirecting out of https or cross-origin.
+ switch (request_->referrer_policy()) {
+ case URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE:
mmenke 2014/11/12 15:11:12 optional: Suggest using braces on all blocks, for
+ if (GURL(request_->referrer()).SchemeIsSecure() &&
+ !redirect_info.new_url.SchemeIsSecure())
+ redirect_info.new_referrer.clear();
mmenke 2014/11/12 15:11:12 nit: Use brace when conditional of an if takes up
+ break;
Ryan Sleevi 2014/11/13 20:00:33 BUG?: In the old code, this was unified as a singl
mmenke 2014/11/13 20:06:37 The fact that no test caught that is rather concer
mmenke 2014/11/13 20:06:37 The fact that no test caught that is very concerni
+
+ case URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN: {
+ GURL original_referrer(request_->referrer());
mmenke 2014/11/12 15:11:12 No need for a copy here - can just use const GURL&
+ if (original_referrer.SchemeIsSecure() &&
+ !redirect_info.new_url.SchemeIsSecure()) {
+ redirect_info.new_referrer.clear();
+ } else if (original_referrer.GetOrigin() !=
+ redirect_info.new_url.GetOrigin()) {
+ redirect_info.new_referrer = original_referrer.GetOrigin().spec();
+ }
+ break;
+ }
+
+ case URLRequest::NEVER_CLEAR_REFERRER:
redirect_info.new_referrer = request_->referrer();
+ break;
mmenke 2014/11/12 15:11:12 fix indent
}
return redirect_info;
« content/browser/loader/resource_dispatcher_host_impl.cc ('K') | « net/url_request/url_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698