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 #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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 // factories to be queried. If no factory handles the request, then the | 78 // factories to be queried. If no factory handles the request, then the |
79 // default job will be used. | 79 // default job will be used. |
80 typedef URLRequestJob* (ProtocolFactory)(URLRequest* request, | 80 typedef URLRequestJob* (ProtocolFactory)(URLRequest* request, |
81 NetworkDelegate* network_delegate, | 81 NetworkDelegate* network_delegate, |
82 const std::string& scheme); | 82 const std::string& scheme); |
83 | 83 |
84 // Referrer policies (see set_referrer_policy): During server redirects, the | 84 // Referrer policies (see set_referrer_policy): During server redirects, the |
85 // referrer header might be cleared, if the protocol changes from HTTPS to | 85 // referrer header might be cleared, if the protocol changes from HTTPS to |
86 // HTTP. This is the default behavior of URLRequest, corresponding to | 86 // HTTP. This is the default behavior of URLRequest, corresponding to |
87 // CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE. Alternatively, the | 87 // CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE. Alternatively, the |
88 // referrer policy can be set to strip the referrer down to an origin upon | 88 // referrer policy can be set to: |
89 // cross-origin navigation (ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN), or | 89 // - strip the referrer down to an origin upon cross-origin navigation |
90 // never change the referrer header (NEVER_CLEAR_REFERRER). Embedders will | 90 // (ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN), |
91 // want to use these options when implementing referrer policy support | 91 // - never change the referrer header (NEVER_CLEAR_REFERRER), |
92 // (https://w3c.github.io/webappsec/specs/referrer-policy/). | 92 // - strip the referrer down to an origin regardless of the redirect |
93 // location (ORIGIN), or | |
94 // - always clear the referrer regardless of the redirect location | |
95 // (NO_REFERRER). | |
mmenke
2016/06/28 21:32:08
optional: Could move each of these to just before
estark
2016/06/28 22:38:42
Done.
| |
96 // Embedders will want to use these options when implementing referrer policy | |
97 // support (https://w3c.github.io/webappsec/specs/referrer-policy/). | |
93 // | 98 // |
94 // REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN is a slight variant | 99 // REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN is a slight variant |
95 // on CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: If the request | 100 // on CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: If the request |
96 // downgrades from HTTPS to HTTP, the referrer will be cleared. If the request | 101 // downgrades from HTTPS to HTTP, the referrer will be cleared. If the request |
97 // transitions cross-origin (but does not downgrade), the referrer's | 102 // transitions cross-origin (but does not downgrade), the referrer's |
98 // granularity will be reduced (currently stripped down to an origin rather | 103 // granularity will be reduced (currently stripped down to an origin rather |
99 // than a full URL). Same-origin requests will send the full referrer. | 104 // than a full URL). Same-origin requests will send the full referrer. |
100 enum ReferrerPolicy { | 105 enum ReferrerPolicy { |
101 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 106 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
102 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, | 107 REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN, |
103 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN, | 108 ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN, |
104 NEVER_CLEAR_REFERRER, | 109 NEVER_CLEAR_REFERRER, |
110 ORIGIN, | |
111 NO_REFERRER, | |
112 MAX_REFERRER_POLICY | |
105 }; | 113 }; |
106 | 114 |
107 // First-party URL redirect policy: During server redirects, the first-party | 115 // First-party URL redirect policy: During server redirects, the first-party |
108 // URL for cookies normally doesn't change. However, if the request is a | 116 // URL for cookies normally doesn't change. However, if the request is a |
109 // top-level first-party request, the first-party URL should be updated to the | 117 // top-level first-party request, the first-party URL should be updated to the |
110 // URL on every redirect. | 118 // URL on every redirect. |
111 enum FirstPartyURLPolicy { | 119 enum FirstPartyURLPolicy { |
112 NEVER_CHANGE_FIRST_PARTY_URL, | 120 NEVER_CHANGE_FIRST_PARTY_URL, |
113 UPDATE_FIRST_PARTY_URL_ON_REDIRECT, | 121 UPDATE_FIRST_PARTY_URL_ON_REDIRECT, |
114 }; | 122 }; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 // from the underlying network request for security reasons (e.g., a HTTPS | 320 // from the underlying network request for security reasons (e.g., a HTTPS |
313 // URL will not be sent as the referrer for a HTTP request). The referrer | 321 // URL will not be sent as the referrer for a HTTP request). The referrer |
314 // may only be changed before Start() is called. | 322 // may only be changed before Start() is called. |
315 const std::string& referrer() const { return referrer_; } | 323 const std::string& referrer() const { return referrer_; } |
316 // Referrer is sanitized to remove URL fragment, user name and password. | 324 // Referrer is sanitized to remove URL fragment, user name and password. |
317 void SetReferrer(const std::string& referrer); | 325 void SetReferrer(const std::string& referrer); |
318 | 326 |
319 // The referrer policy to apply when updating the referrer during redirects. | 327 // The referrer policy to apply when updating the referrer during redirects. |
320 // The referrer policy may only be changed before Start() is called. | 328 // The referrer policy may only be changed before Start() is called. |
321 ReferrerPolicy referrer_policy() const { return referrer_policy_; } | 329 ReferrerPolicy referrer_policy() const { return referrer_policy_; } |
322 void set_referrer_policy(ReferrerPolicy referrer_policy); | 330 void set_referrer_policy(ReferrerPolicy referrer_policy); |
mmenke
2016/06/28 21:32:08
Optional: Could DCHECK that the policy is not set
estark
2016/06/28 22:38:42
Done.
| |
323 | 331 |
324 // If this request should include a referred Token Binding, this returns the | 332 // If this request should include a referred Token Binding, this returns the |
325 // hostname of the referrer that indicated this request should include a | 333 // hostname of the referrer that indicated this request should include a |
326 // referred Token Binding. Otherwise, this returns the empty string. | 334 // referred Token Binding. Otherwise, this returns the empty string. |
327 const std::string& token_binding_referrer() const { | 335 const std::string& token_binding_referrer() const { |
328 return token_binding_referrer_; | 336 return token_binding_referrer_; |
329 } | 337 } |
330 | 338 |
331 // Sets the delegate of the request. This is only to allow creating a request | 339 // Sets the delegate of the request. This is only to allow creating a request |
332 // before creating its delegate. |delegate| must be non-NULL and the request | 340 // before creating its delegate. |delegate| must be non-NULL and the request |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 | 864 |
857 // The proxy server used for this request, if any. | 865 // The proxy server used for this request, if any. |
858 HostPortPair proxy_server_; | 866 HostPortPair proxy_server_; |
859 | 867 |
860 DISALLOW_COPY_AND_ASSIGN(URLRequest); | 868 DISALLOW_COPY_AND_ASSIGN(URLRequest); |
861 }; | 869 }; |
862 | 870 |
863 } // namespace net | 871 } // namespace net |
864 | 872 |
865 #endif // NET_URL_REQUEST_URL_REQUEST_H_ | 873 #endif // NET_URL_REQUEST_URL_REQUEST_H_ |
OLD | NEW |