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

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

Issue 2278823004: Stop supporting legacy keywords in Referrer-Policy header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jochen comment Created 4 years, 3 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 | « no previous file | net/url_request/url_request_job_unittest.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_job.h" 5 #include "net/url_request/url_request_job.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 URLRequest* request) { 72 URLRequest* request) {
73 URLRequest::ReferrerPolicy new_policy = request->referrer_policy(); 73 URLRequest::ReferrerPolicy new_policy = request->referrer_policy();
74 74
75 std::string referrer_policy_header; 75 std::string referrer_policy_header;
76 request->GetResponseHeaderByName("Referrer-Policy", &referrer_policy_header); 76 request->GetResponseHeaderByName("Referrer-Policy", &referrer_policy_header);
77 std::vector<std::string> policy_tokens = 77 std::vector<std::string> policy_tokens =
78 base::SplitString(referrer_policy_header, ",", base::TRIM_WHITESPACE, 78 base::SplitString(referrer_policy_header, ",", base::TRIM_WHITESPACE,
79 base::SPLIT_WANT_NONEMPTY); 79 base::SPLIT_WANT_NONEMPTY);
80 80
81 for (const auto& token : policy_tokens) { 81 for (const auto& token : policy_tokens) {
82 if (base::CompareCaseInsensitiveASCII(token, "never") == 0 || 82 if (base::CompareCaseInsensitiveASCII(token, "no-referrer") == 0) {
83 base::CompareCaseInsensitiveASCII(token, "no-referrer") == 0) {
84 new_policy = URLRequest::NO_REFERRER; 83 new_policy = URLRequest::NO_REFERRER;
85 continue; 84 continue;
86 } 85 }
87 86
88 if (base::CompareCaseInsensitiveASCII(token, "default") == 0 || 87 if (base::CompareCaseInsensitiveASCII(token,
89 base::CompareCaseInsensitiveASCII(token,
90 "no-referrer-when-downgrade") == 0) { 88 "no-referrer-when-downgrade") == 0) {
91 new_policy = 89 new_policy =
92 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE; 90 URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
93 continue; 91 continue;
94 } 92 }
95 93
96 if (base::CompareCaseInsensitiveASCII(token, "origin") == 0) { 94 if (base::CompareCaseInsensitiveASCII(token, "origin") == 0) {
97 new_policy = URLRequest::ORIGIN; 95 new_policy = URLRequest::ORIGIN;
98 continue; 96 continue;
99 } 97 }
100 98
101 if (base::CompareCaseInsensitiveASCII(token, "origin-when-cross-origin") == 99 if (base::CompareCaseInsensitiveASCII(token, "origin-when-cross-origin") ==
102 0) { 100 0) {
103 new_policy = URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN; 101 new_policy = URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN;
104 continue; 102 continue;
105 } 103 }
106 104
107 if (base::CompareCaseInsensitiveASCII(token, "always") == 0 || 105 if (base::CompareCaseInsensitiveASCII(token, "unsafe-url") == 0) {
108 base::CompareCaseInsensitiveASCII(token, "unsafe-url") == 0) {
109 new_policy = URLRequest::NEVER_CLEAR_REFERRER; 106 new_policy = URLRequest::NEVER_CLEAR_REFERRER;
110 continue; 107 continue;
111 } 108 }
112 } 109 }
113 return new_policy; 110 return new_policy;
114 } 111 }
115 112
116 } // namespace 113 } // namespace
117 114
118 URLRequestJob::URLRequestJob(URLRequest* request, 115 URLRequestJob::URLRequestJob(URLRequest* request,
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 int64_t total_sent_bytes = GetTotalSentBytes(); 1008 int64_t total_sent_bytes = GetTotalSentBytes();
1012 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); 1009 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_);
1013 if (total_sent_bytes > last_notified_total_sent_bytes_) { 1010 if (total_sent_bytes > last_notified_total_sent_bytes_) {
1014 network_delegate_->NotifyNetworkBytesSent( 1011 network_delegate_->NotifyNetworkBytesSent(
1015 request_, total_sent_bytes - last_notified_total_sent_bytes_); 1012 request_, total_sent_bytes - last_notified_total_sent_bytes_);
1016 } 1013 }
1017 last_notified_total_sent_bytes_ = total_sent_bytes; 1014 last_notified_total_sent_bytes_ = total_sent_bytes;
1018 } 1015 }
1019 1016
1020 } // namespace net 1017 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/url_request/url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698