Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 network_delegate_->NotifyRawBytesRead(*request_, bytes_read); | 821 network_delegate_->NotifyRawBytesRead(*request_, bytes_read); |
| 822 } | 822 } |
| 823 | 823 |
| 824 bool URLRequestJob::FilterHasData() { | 824 bool URLRequestJob::FilterHasData() { |
| 825 return filter_.get() && filter_->stream_data_len(); | 825 return filter_.get() && filter_->stream_data_len(); |
| 826 } | 826 } |
| 827 | 827 |
| 828 void URLRequestJob::UpdatePacketReadTimes() { | 828 void URLRequestJob::UpdatePacketReadTimes() { |
| 829 } | 829 } |
| 830 | 830 |
| 831 // Static. | |
|
mmenke
2014/11/20 16:23:45
nit: Think "// static" is more common (No period
Mike West
2014/11/21 09:29:29
Done.
| |
| 832 GURL URLRequestJob::ComputeReferrerForRedirect( | |
| 833 const URLRequest& request, | |
| 834 const GURL& redirect_destination) { | |
|
mmenke
2014/11/20 16:23:45
Definition order should match declaration order.
Mike West
2014/11/21 09:29:29
Done.
| |
| 835 GURL original_referrer(request.referrer()); | |
| 836 bool secure_referrer_but_insecure_destination = | |
| 837 original_referrer.SchemeIsSecure() && | |
| 838 !redirect_destination.SchemeIsSecure(); | |
| 839 bool same_origin = | |
| 840 original_referrer.GetOrigin() == redirect_destination.GetOrigin(); | |
| 841 switch (request.referrer_policy()) { | |
| 842 case URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: | |
| 843 return secure_referrer_but_insecure_destination ? GURL() | |
| 844 : original_referrer; | |
| 845 | |
| 846 case URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN: | |
| 847 if (same_origin) | |
| 848 return original_referrer; | |
| 849 else if (secure_referrer_but_insecure_destination) | |
| 850 return GURL(); | |
| 851 else | |
| 852 return original_referrer.GetOrigin(); | |
|
mmenke
2014/11/20 16:23:45
optional: Think using braces in else/ifs is a lit
Mike West
2014/11/21 09:29:29
Done.
| |
| 853 | |
| 854 case URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN: | |
| 855 return same_origin ? original_referrer : original_referrer.GetOrigin(); | |
| 856 | |
| 857 case URLRequest::NEVER_CLEAR_REFERRER: | |
| 858 return original_referrer; | |
| 859 } | |
| 860 | |
| 861 NOTREACHED(); | |
| 862 return GURL(); | |
| 863 } | |
| 864 | |
| 831 RedirectInfo URLRequestJob::ComputeRedirectInfo(const GURL& location, | 865 RedirectInfo URLRequestJob::ComputeRedirectInfo(const GURL& location, |
| 832 int http_status_code) { | 866 int http_status_code) { |
| 833 const GURL& url = request_->url(); | 867 const GURL& url = request_->url(); |
| 834 | 868 |
| 835 RedirectInfo redirect_info; | 869 RedirectInfo redirect_info; |
| 836 | 870 |
| 837 redirect_info.status_code = http_status_code; | 871 redirect_info.status_code = http_status_code; |
| 838 | 872 |
| 839 // The request method may change, depending on the status code. | 873 // The request method may change, depending on the status code. |
| 840 redirect_info.new_method = URLRequest::ComputeMethodForRedirect( | 874 redirect_info.new_method = URLRequest::ComputeMethodForRedirect( |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 856 | 890 |
| 857 // Update the first-party URL if appropriate. | 891 // Update the first-party URL if appropriate. |
| 858 if (request_->first_party_url_policy() == | 892 if (request_->first_party_url_policy() == |
| 859 URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT) { | 893 URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT) { |
| 860 redirect_info.new_first_party_for_cookies = redirect_info.new_url; | 894 redirect_info.new_first_party_for_cookies = redirect_info.new_url; |
| 861 } else { | 895 } else { |
| 862 redirect_info.new_first_party_for_cookies = | 896 redirect_info.new_first_party_for_cookies = |
| 863 request_->first_party_for_cookies(); | 897 request_->first_party_for_cookies(); |
| 864 } | 898 } |
| 865 | 899 |
| 866 // Suppress the referrer if we're redirecting out of https. | 900 // Alter the referrer if we're redirecting out of https or cross-origin. |
|
mmenke
2014/11/20 16:23:45
nit: --we're
Mike West
2014/11/21 09:29:29
Done.
| |
| 867 if (request_->referrer_policy() == | 901 redirect_info.new_referrer = |
| 868 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE && | 902 ComputeReferrerForRedirect(*request_, redirect_info.new_url).spec(); |
| 869 GURL(request_->referrer()).SchemeIsSecure() && | |
| 870 !redirect_info.new_url.SchemeIsSecure()) { | |
| 871 redirect_info.new_referrer.clear(); | |
| 872 } else { | |
| 873 redirect_info.new_referrer = request_->referrer(); | |
| 874 } | |
| 875 | 903 |
| 876 return redirect_info; | 904 return redirect_info; |
| 877 } | 905 } |
| 878 | 906 |
| 879 } // namespace net | 907 } // namespace net |
| OLD | NEW |