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

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

Issue 2918313002: Implement new referrer policies (Closed)
Patch Set: update public/platform/OWNERS per presubmit 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
« no previous file with comments | « ios/web/public/referrer_util_unittest.cc ('k') | net/url_request/url_request.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 #ifndef NET_URL_REQUEST_URL_REQUEST_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_H_
6 #define NET_URL_REQUEST_URL_REQUEST_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 const std::string& scheme); 80 const std::string& scheme);
81 81
82 // A ReferrerPolicy for the request can be set with 82 // A ReferrerPolicy for the request can be set with
83 // set_referrer_policy() and controls the contents of the Referer 83 // set_referrer_policy() and controls the contents of the Referer
84 // header when URLRequest follows server redirects. Note that setting 84 // header when URLRequest follows server redirects. Note that setting
85 // a ReferrerPolicy on the request has no effect on the Referer header 85 // a ReferrerPolicy on the request has no effect on the Referer header
86 // of the initial leg of the request; the caller is responsible for 86 // of the initial leg of the request; the caller is responsible for
87 // setting the initial Referer, and the ReferrerPolicy only controls 87 // setting the initial Referer, and the ReferrerPolicy only controls
88 // what happens to the Referer while following redirects. 88 // what happens to the Referer while following redirects.
89 enum ReferrerPolicy { 89 enum ReferrerPolicy {
90 // Clear the referrer header if the protocol changes from HTTPS to 90 // Clear the referrer header if the header value is HTTPS but the request
91 // HTTP. This is the default behavior of URLRequest. 91 // destination is HTTP. This is the default behavior of URLRequest.
92 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, 92 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
93 // A slight variant on 93 // A slight variant on CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE:
94 // CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: If the 94 // If the request destination is HTTP, an HTTPS referrer will be cleared. If
95 // request downgrades from HTTPS to HTTP, the referrer will be 95 // the request's destination is cross-origin with the referrer (but does not
96 // cleared. If the request transitions cross-origin (but does not 96 // downgrade), the referrer's granularity will be stripped down to an origin
97 // downgrade), the referrer's granularity will be reduced (currently 97 // rather than a full URL. Same-origin requests will send the full referrer.
98 // stripped down to an origin rather than a full URL). Same-origin
99 // requests will send the full referrer.
100 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, 98 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN,
101 // Strip the referrer down to an origin upon cross-origin navigation. 99 // Strip the referrer down to an origin when the origin of the referrer is
100 // different from the destination's origin.
102 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN, 101 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN,
103 // Never change the referrer. 102 // Never change the referrer.
104 NEVER_CLEAR_REFERRER, 103 NEVER_CLEAR_REFERRER,
105 // Strip the referrer down to the origin regardless of the redirect 104 // Strip the referrer down to the origin regardless of the redirect
106 // location. 105 // location.
107 ORIGIN, 106 ORIGIN,
108 // Always clear the referrer regardless of the redirect location. 107 // Clear the referrer when the request's referrer is cross-origin with
108 // the request's destination.
109 CLEAR_REFERRER_ON_TRANSITION_CROSS_ORIGIN,
110 // Strip the referrer down to the origin, but clear it entirely if the
111 // referrer value is HTTPS and the destination is HTTP.
112 ORIGIN_CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
113 // Always clear the referrer regardless of the request destination.
109 NO_REFERRER, 114 NO_REFERRER,
110 MAX_REFERRER_POLICY 115 MAX_REFERRER_POLICY
111 }; 116 };
112 117
113 // First-party URL redirect policy: During server redirects, the first-party 118 // First-party URL redirect policy: During server redirects, the first-party
114 // URL for cookies normally doesn't change. However, if the request is a 119 // URL for cookies normally doesn't change. However, if the request is a
115 // top-level first-party request, the first-party URL should be updated to the 120 // top-level first-party request, the first-party URL should be updated to the
116 // URL on every redirect. 121 // URL on every redirect.
117 enum FirstPartyURLPolicy { 122 enum FirstPartyURLPolicy {
118 NEVER_CHANGE_FIRST_PARTY_URL, 123 NEVER_CHANGE_FIRST_PARTY_URL,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 const base::Optional<url::Origin>& initiator() const { return initiator_; } 312 const base::Optional<url::Origin>& initiator() const { return initiator_; }
308 // This method may only be called before Start(). 313 // This method may only be called before Start().
309 void set_initiator(const base::Optional<url::Origin>& initiator); 314 void set_initiator(const base::Optional<url::Origin>& initiator);
310 315
311 // The request method, as an uppercase string. "GET" is the default value. 316 // The request method, as an uppercase string. "GET" is the default value.
312 // The request method may only be changed before Start() is called and 317 // The request method may only be changed before Start() is called and
313 // should only be assigned an uppercase value. 318 // should only be assigned an uppercase value.
314 const std::string& method() const { return method_; } 319 const std::string& method() const { return method_; }
315 void set_method(const std::string& method); 320 void set_method(const std::string& method);
316 321
317 // The referrer URL for the request. This header may actually be suppressed 322 // The referrer URL for the request
318 // from the underlying network request for security reasons (e.g., a HTTPS
319 // URL will not be sent as the referrer for a HTTP request). The referrer
320 // may only be changed before Start() is called.
321 const std::string& referrer() const { return referrer_; } 323 const std::string& referrer() const { return referrer_; }
322 // Referrer is sanitized to remove URL fragment, user name and password. 324 // Sets the referrer URL for the request. Can only be changed before Start()
325 // is called. |referrer| is sanitized to remove URL fragment, user name and
326 // password. If a referrer policy is set via set_referrer_policy(), then
327 // |referrer| should obey the policy; if it doesn't, it will be cleared when
328 // the request is started. The referrer URL may be suppressed or changed
329 // during the course of the request, for example because of a referrer policy
330 // set with set_referrer_policy().
323 void SetReferrer(const std::string& referrer); 331 void SetReferrer(const std::string& referrer);
324 332
325 // The referrer policy to apply when updating the referrer during redirects. 333 // The referrer policy to apply when updating the referrer during redirects.
326 // The referrer policy may only be changed before Start() is called. 334 // The referrer policy may only be changed before Start() is called. Any
335 // referrer set via SetReferrer() is expected to obey the policy set via
336 // set_referrer_policy(); otherwise the referrer will be cleared when the
337 // request is started.
327 ReferrerPolicy referrer_policy() const { return referrer_policy_; } 338 ReferrerPolicy referrer_policy() const { return referrer_policy_; }
328 void set_referrer_policy(ReferrerPolicy referrer_policy); 339 void set_referrer_policy(ReferrerPolicy referrer_policy);
329 340
330 // If this request should include a referred Token Binding, this returns the 341 // If this request should include a referred Token Binding, this returns the
331 // hostname of the referrer that indicated this request should include a 342 // hostname of the referrer that indicated this request should include a
332 // referred Token Binding. Otherwise, this returns the empty string. 343 // referred Token Binding. Otherwise, this returns the empty string.
333 const std::string& token_binding_referrer() const { 344 const std::string& token_binding_referrer() const {
334 return token_binding_referrer_; 345 return token_binding_referrer_;
335 } 346 }
336 347
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 const NetworkTrafficAnnotationTag traffic_annotation_; 872 const NetworkTrafficAnnotationTag traffic_annotation_;
862 873
863 THREAD_CHECKER(thread_checker_); 874 THREAD_CHECKER(thread_checker_);
864 875
865 DISALLOW_COPY_AND_ASSIGN(URLRequest); 876 DISALLOW_COPY_AND_ASSIGN(URLRequest);
866 }; 877 };
867 878
868 } // namespace net 879 } // namespace net
869 880
870 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 881 #endif // NET_URL_REQUEST_URL_REQUEST_H_
OLDNEW
« no previous file with comments | « ios/web/public/referrer_util_unittest.cc ('k') | net/url_request/url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698