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

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

Issue 2918313002: Implement new referrer policies (Closed)
Patch Set: ios fix Created 3 years, 6 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
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/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (base::CompareCaseInsensitiveASCII(token, "origin-when-cross-origin") == 108 if (base::CompareCaseInsensitiveASCII(token, "origin-when-cross-origin") ==
109 0) { 109 0) {
110 new_policy = URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN; 110 new_policy = URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN;
111 continue; 111 continue;
112 } 112 }
113 113
114 if (base::CompareCaseInsensitiveASCII(token, "unsafe-url") == 0) { 114 if (base::CompareCaseInsensitiveASCII(token, "unsafe-url") == 0) {
115 new_policy = URLRequest::NEVER_CLEAR_REFERRER; 115 new_policy = URLRequest::NEVER_CLEAR_REFERRER;
116 continue; 116 continue;
117 } 117 }
118
119 if (base::CompareCaseInsensitiveASCII(token, "same-origin") == 0) {
120 new_policy = URLRequest::CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN;
121 continue;
122 }
123
124 if (base::CompareCaseInsensitiveASCII(token, "strict-origin") == 0) {
125 new_policy =
126 URLRequest::ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE;
127 continue;
128 }
129
130 if (base::CompareCaseInsensitiveASCII(
131 token, "strict-origin-when-cross-origin") == 0) {
132 new_policy =
133 URLRequest::REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN;
134 continue;
135 }
118 } 136 }
119 return new_policy; 137 return new_policy;
120 } 138 }
121 139
122 } // namespace 140 } // namespace
123 141
124 // Each SourceStreams own the previous SourceStream in the chain, but the 142 // Each SourceStreams own the previous SourceStream in the chain, but the
125 // ultimate source is URLRequestJob, which has other ownership semantics, so 143 // ultimate source is URLRequestJob, which has other ownership semantics, so
126 // this class is a proxy for URLRequestJob that is owned by the first stream 144 // this class is a proxy for URLRequestJob that is owned by the first stream
127 // (in dataflow order). 145 // (in dataflow order).
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return referrer_origin.GetURL(); 408 return referrer_origin.GetURL();
391 } 409 }
392 410
393 case URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN: 411 case URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN:
394 return same_origin ? original_referrer : referrer_origin.GetURL(); 412 return same_origin ? original_referrer : referrer_origin.GetURL();
395 413
396 case URLRequest::NEVER_CLEAR_REFERRER: 414 case URLRequest::NEVER_CLEAR_REFERRER:
397 return original_referrer; 415 return original_referrer;
398 case URLRequest::ORIGIN: 416 case URLRequest::ORIGIN:
399 return referrer_origin.GetURL(); 417 return referrer_origin.GetURL();
418 case URLRequest::CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN:
419 if (same_origin)
420 return original_referrer;
421 return GURL();
422 case URLRequest::ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE:
423 if (secure_referrer_but_insecure_destination)
424 return GURL();
425 return referrer_origin.GetURL();
400 case URLRequest::NO_REFERRER: 426 case URLRequest::NO_REFERRER:
401 return GURL(); 427 return GURL();
402 case URLRequest::MAX_REFERRER_POLICY: 428 case URLRequest::MAX_REFERRER_POLICY:
403 NOTREACHED(); 429 NOTREACHED();
404 return GURL(); 430 return GURL();
405 } 431 }
406 432
407 NOTREACHED(); 433 NOTREACHED();
408 return GURL(); 434 return GURL();
409 } 435 }
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 int64_t total_sent_bytes = GetTotalSentBytes(); 878 int64_t total_sent_bytes = GetTotalSentBytes();
853 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_); 879 DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_);
854 if (total_sent_bytes > last_notified_total_sent_bytes_) { 880 if (total_sent_bytes > last_notified_total_sent_bytes_) {
855 network_delegate_->NotifyNetworkBytesSent( 881 network_delegate_->NotifyNetworkBytesSent(
856 request_, total_sent_bytes - last_notified_total_sent_bytes_); 882 request_, total_sent_bytes - last_notified_total_sent_bytes_);
857 } 883 }
858 last_notified_total_sent_bytes_ = total_sent_bytes; 884 last_notified_total_sent_bytes_ = total_sent_bytes;
859 } 885 }
860 886
861 } // namespace net 887 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698