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

Side by Side Diff: net/url_request/url_request.cc

Issue 2100583002: Apply Referrer-Policy header when following redirects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jochen suggestion Created 4 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 unified diff | Download patch
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 GURL referrer_url(referrer); 472 GURL referrer_url(referrer);
473 if (referrer_url.is_valid()) { 473 if (referrer_url.is_valid()) {
474 referrer_ = referrer_url.GetAsReferrer().spec(); 474 referrer_ = referrer_url.GetAsReferrer().spec();
475 } else { 475 } else {
476 referrer_ = referrer; 476 referrer_ = referrer;
477 } 477 }
478 } 478 }
479 479
480 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) { 480 void URLRequest::set_referrer_policy(ReferrerPolicy referrer_policy) {
481 DCHECK(!is_pending_); 481 DCHECK(!is_pending_);
482 // External callers shouldn't be setting NO_REFERRER or
483 // ORIGIN. |referrer_policy_| is only applied during server redirects,
484 // so external callers must set the referrer themselves using
485 // SetReferrer() for the initial request. Once the referrer has been
486 // set to an origin or to an empty string, there is no point in
487 // setting the policy to NO_REFERRER or ORIGIN as it would have the
488 // same effect as using NEVER_CLEAR_REFERRER across redirects.
489 DCHECK_NE(referrer_policy, NO_REFERRER);
490 DCHECK_NE(referrer_policy, ORIGIN);
482 referrer_policy_ = referrer_policy; 491 referrer_policy_ = referrer_policy;
483 } 492 }
484 493
485 void URLRequest::set_delegate(Delegate* delegate) { 494 void URLRequest::set_delegate(Delegate* delegate) {
486 DCHECK(!delegate_); 495 DCHECK(!delegate_);
487 DCHECK(delegate); 496 DCHECK(delegate);
488 delegate_ = delegate; 497 delegate_ = delegate;
489 } 498 }
490 499
491 void URLRequest::Start() { 500 void URLRequest::Start() {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 // TODO(jww): This is a layering violation and should be refactored somewhere 980 // TODO(jww): This is a layering violation and should be refactored somewhere
972 // up into //net's embedder. https://crbug.com/471397 981 // up into //net's embedder. https://crbug.com/471397
973 if (!url::Origin(redirect_info.new_url) 982 if (!url::Origin(redirect_info.new_url)
974 .IsSameOriginWith(url::Origin(url())) && 983 .IsSameOriginWith(url::Origin(url())) &&
975 extra_request_headers_.HasHeader(HttpRequestHeaders::kOrigin)) { 984 extra_request_headers_.HasHeader(HttpRequestHeaders::kOrigin)) {
976 extra_request_headers_.SetHeader(HttpRequestHeaders::kOrigin, 985 extra_request_headers_.SetHeader(HttpRequestHeaders::kOrigin,
977 url::Origin().Serialize()); 986 url::Origin().Serialize());
978 } 987 }
979 988
980 referrer_ = redirect_info.new_referrer; 989 referrer_ = redirect_info.new_referrer;
990 referrer_policy_ = redirect_info.new_referrer_policy;
981 first_party_for_cookies_ = redirect_info.new_first_party_for_cookies; 991 first_party_for_cookies_ = redirect_info.new_first_party_for_cookies;
982 token_binding_referrer_ = redirect_info.referred_token_binding_host; 992 token_binding_referrer_ = redirect_info.referred_token_binding_host;
983 993
984 url_chain_.push_back(redirect_info.new_url); 994 url_chain_.push_back(redirect_info.new_url);
985 --redirect_limit_; 995 --redirect_limit_;
986 996
987 Start(); 997 Start();
988 return OK; 998 return OK;
989 } 999 }
990 1000
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1196 }
1187 1197
1188 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { 1198 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const {
1189 if (job_) 1199 if (job_)
1190 job_->GetConnectionAttempts(out); 1200 job_->GetConnectionAttempts(out);
1191 else 1201 else
1192 out->clear(); 1202 out->clear();
1193 } 1203 }
1194 1204
1195 } // namespace net 1205 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698