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

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

Issue 2108423002: Revert of Apply Referrer-Policy header when following redirects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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);
491 referrer_policy_ = referrer_policy; 482 referrer_policy_ = referrer_policy;
492 } 483 }
493 484
494 void URLRequest::set_delegate(Delegate* delegate) { 485 void URLRequest::set_delegate(Delegate* delegate) {
495 DCHECK(!delegate_); 486 DCHECK(!delegate_);
496 DCHECK(delegate); 487 DCHECK(delegate);
497 delegate_ = delegate; 488 delegate_ = delegate;
498 } 489 }
499 490
500 void URLRequest::Start() { 491 void URLRequest::Start() {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 // TODO(jww): This is a layering violation and should be refactored somewhere 971 // TODO(jww): This is a layering violation and should be refactored somewhere
981 // up into //net's embedder. https://crbug.com/471397 972 // up into //net's embedder. https://crbug.com/471397
982 if (!url::Origin(redirect_info.new_url) 973 if (!url::Origin(redirect_info.new_url)
983 .IsSameOriginWith(url::Origin(url())) && 974 .IsSameOriginWith(url::Origin(url())) &&
984 extra_request_headers_.HasHeader(HttpRequestHeaders::kOrigin)) { 975 extra_request_headers_.HasHeader(HttpRequestHeaders::kOrigin)) {
985 extra_request_headers_.SetHeader(HttpRequestHeaders::kOrigin, 976 extra_request_headers_.SetHeader(HttpRequestHeaders::kOrigin,
986 url::Origin().Serialize()); 977 url::Origin().Serialize());
987 } 978 }
988 979
989 referrer_ = redirect_info.new_referrer; 980 referrer_ = redirect_info.new_referrer;
990 referrer_policy_ = redirect_info.new_referrer_policy;
991 first_party_for_cookies_ = redirect_info.new_first_party_for_cookies; 981 first_party_for_cookies_ = redirect_info.new_first_party_for_cookies;
992 token_binding_referrer_ = redirect_info.referred_token_binding_host; 982 token_binding_referrer_ = redirect_info.referred_token_binding_host;
993 983
994 url_chain_.push_back(redirect_info.new_url); 984 url_chain_.push_back(redirect_info.new_url);
995 --redirect_limit_; 985 --redirect_limit_;
996 986
997 Start(); 987 Start();
998 return OK; 988 return OK;
999 } 989 }
1000 990
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 } 1186 }
1197 1187
1198 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { 1188 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const {
1199 if (job_) 1189 if (job_)
1200 job_->GetConnectionAttempts(out); 1190 job_->GetConnectionAttempts(out);
1201 else 1191 else
1202 out->clear(); 1192 out->clear();
1203 } 1193 }
1204 1194
1205 } // namespace net 1195 } // 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