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

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

Issue 714813003: Referrer Policy: Add new policies to URLRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback. 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 unified diff | Download patch
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_job.cc » ('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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 job_->SetUpload(upload_data_stream_.get()); 646 job_->SetUpload(upload_data_stream_.get());
647 647
648 is_pending_ = true; 648 is_pending_ = true;
649 is_redirecting_ = false; 649 is_redirecting_ = false;
650 650
651 response_info_.was_cached = false; 651 response_info_.was_cached = false;
652 652
653 // If the referrer is secure, but the requested URL is not, the referrer 653 // If the referrer is secure, but the requested URL is not, the referrer
654 // policy should be something non-default. If you hit this, please file a 654 // policy should be something non-default. If you hit this, please file a
655 // bug. 655 // bug.
656 if (referrer_policy_ == 656 GURL referrer(referrer_);
jochen (gone - plz use gerrit) 2014/11/19 10:25:13 what about moving this to a helper function?
657 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE && 657 bool referrer_policy_requires_secure_referrer_transitions =
658 GURL(referrer_).SchemeIsSecure() && !url().SchemeIsSecure()) { 658 referrer_policy_ ==
659 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE ||
660 referrer_policy_ ==
661 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN;
662 bool secure_referrer_in_insecure_request =
663 referrer.SchemeIsSecure() && !url().SchemeIsSecure();
664 bool referrer_is_origin_only = referrer.GetOrigin() == referrer;
665 bool cross_origin_referrer = referrer.GetOrigin() != url().GetOrigin();
666 bool referrer_is_invalid =
667 (referrer_policy_requires_secure_referrer_transitions &&
668 secure_referrer_in_insecure_request) ||
669 (referrer_policy_ ==
670 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN &&
671 cross_origin_referrer && !referrer_is_origin_only);
672
673 if (referrer_is_invalid) {
659 if (!network_delegate_ || 674 if (!network_delegate_ ||
660 !network_delegate_->CancelURLRequestWithPolicyViolatingReferrerHeader( 675 !network_delegate_->CancelURLRequestWithPolicyViolatingReferrerHeader(
661 *this, url(), GURL(referrer_))) { 676 *this, url(), GURL(referrer_))) {
662 referrer_.clear(); 677 referrer_.clear();
663 } else { 678 } else {
664 // We need to clear the referrer anyway to avoid an infinite recursion 679 // We need to clear the referrer anyway to avoid an infinite recursion
665 // when starting the error job. 680 // when starting the error job.
666 referrer_.clear(); 681 referrer_.clear();
667 std::string source("delegate"); 682 std::string source("delegate");
668 net_log_.AddEvent(NetLog::TYPE_CANCELLED, 683 net_log_.AddEvent(NetLog::TYPE_CANCELLED,
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 new base::debug::StackTrace(NULL, 0); 1244 new base::debug::StackTrace(NULL, 0);
1230 *stack_trace_copy = stack_trace; 1245 *stack_trace_copy = stack_trace;
1231 stack_trace_.reset(stack_trace_copy); 1246 stack_trace_.reset(stack_trace_copy);
1232 } 1247 }
1233 1248
1234 const base::debug::StackTrace* URLRequest::stack_trace() const { 1249 const base::debug::StackTrace* URLRequest::stack_trace() const {
1235 return stack_trace_.get(); 1250 return stack_trace_.get();
1236 } 1251 }
1237 1252
1238 } // namespace net 1253 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698