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

Side by Side 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: Helper. 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
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_job.h" 5 #include "net/url_request/url_request_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/power_monitor/power_monitor.h" 10 #include "base/power_monitor/power_monitor.h"
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 856
857 // Update the first-party URL if appropriate. 857 // Update the first-party URL if appropriate.
858 if (request_->first_party_url_policy() == 858 if (request_->first_party_url_policy() ==
859 URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT) { 859 URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT) {
860 redirect_info.new_first_party_for_cookies = redirect_info.new_url; 860 redirect_info.new_first_party_for_cookies = redirect_info.new_url;
861 } else { 861 } else {
862 redirect_info.new_first_party_for_cookies = 862 redirect_info.new_first_party_for_cookies =
863 request_->first_party_for_cookies(); 863 request_->first_party_for_cookies();
864 } 864 }
865 865
866 // Suppress the referrer if we're redirecting out of https. 866 // Alter the referrer if we're redirecting out of https or cross-origin.
867 if (request_->referrer_policy() == 867 GURL original_referrer(request_->referrer());
868 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE && 868 switch (request_->referrer_policy()) {
869 GURL(request_->referrer()).SchemeIsSecure() && 869 case URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE:
870 !redirect_info.new_url.SchemeIsSecure()) { 870 if (original_referrer.SchemeIsSecure() &&
871 redirect_info.new_referrer.clear(); 871 !redirect_info.new_url.SchemeIsSecure()) {
872 } else { 872 redirect_info.new_referrer.clear();
873 redirect_info.new_referrer = request_->referrer(); 873 } else {
874 redirect_info.new_referrer = request_->referrer();
875 }
876 break;
877
878 case URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN:
879 if (original_referrer.SchemeIsSecure() &&
880 !redirect_info.new_url.SchemeIsSecure()) {
881 redirect_info.new_referrer.clear();
882 } else if (original_referrer.GetOrigin() !=
883 redirect_info.new_url.GetOrigin()) {
884 redirect_info.new_referrer = original_referrer.GetOrigin().spec();
885 } else {
886 redirect_info.new_referrer = request_->referrer();
887 }
888 break;
889
890 case URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN:
891 if (original_referrer.GetOrigin() != redirect_info.new_url.GetOrigin())
892 redirect_info.new_referrer = original_referrer.GetOrigin().spec();
893 else
894 redirect_info.new_referrer = request_->referrer();
895 break;
896
897 case URLRequest::NEVER_CLEAR_REFERRER:
898 redirect_info.new_referrer = request_->referrer();
899 break;
mmenke 2014/11/19 16:29:03 Suggestion: This is basically a subset of the log
Mike West 2014/11/20 10:45:30 That makes a ton of sense. I've done it as a stati
874 } 900 }
875 901
876 return redirect_info; 902 return redirect_info;
877 } 903 }
878 904
879 } // namespace net 905 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698