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

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

Issue 2053693002: WIP: Move 'Upgrade-Insecure-Requests' to the browser process. Base URL: https://chromium.googlesource.com/chromium/src.git@replicate
Patch Set: DCHECK. Created 4 years 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 #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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 // First-party URL redirect policy: During server redirects, the first-party 113 // 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 114 // 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 115 // top-level first-party request, the first-party URL should be updated to the
116 // URL on every redirect. 116 // URL on every redirect.
117 enum FirstPartyURLPolicy { 117 enum FirstPartyURLPolicy {
118 NEVER_CHANGE_FIRST_PARTY_URL, 118 NEVER_CHANGE_FIRST_PARTY_URL,
119 UPDATE_FIRST_PARTY_URL_ON_REDIRECT, 119 UPDATE_FIRST_PARTY_URL_ON_REDIRECT,
120 }; 120 };
121 121
122 // 'Upgrade-Insecure-Requests' gives developers the ability to force some
123 // requests to upgrade themselves to secure transport before hitting the
124 // network (along with any redirects they encounter along the way). The
125 // insecure request policy governs this behavior:
126 //
127 // * DO_NOT_UPGRADE_INSECURE_REQUESTS is the default behavior, which does
128 // not upgrade insecure request (hence the clever name).
129 //
130 // * UPGRADE_ALL_INSECURE_REQUESTS will upgrade any insecure request to
131 // secure transport.
132 //
133 // * UPGRADE_SAME_HOST_INSECURE_REQUESTS will upgrade any insecure request
134 // whose target's host matches the request's initiator's host.
135 //
136 // See https://w3c.github.io/webappsec-upgrade-insecure-requests/ for detail.
137 enum InsecureRequestPolicy {
138 DO_NOT_UPGRADE_INSECURE_REQUESTS,
139 UPGRADE_SAME_HOST_INSECURE_REQUESTS,
140 UPGRADE_ALL_INSECURE_REQUESTS
141 };
142
122 // The delegate's methods are called from the message loop of the thread 143 // The delegate's methods are called from the message loop of the thread
123 // on which the request's Start() method is called. See above for the 144 // on which the request's Start() method is called. See above for the
124 // ordering of callbacks. 145 // ordering of callbacks.
125 // 146 //
126 // The callbacks will be called in the following order: 147 // The callbacks will be called in the following order:
127 // Start() 148 // Start()
128 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or 149 // - OnCertificateRequested* (zero or more calls, if the SSL server and/or
129 // SSL proxy requests a client certificate for authentication) 150 // SSL proxy requests a client certificate for authentication)
130 // - OnSSLCertificateError* (zero or one call, if the SSL server's 151 // - OnSSLCertificateError* (zero or one call, if the SSL server's
131 // certificate has an error) 152 // certificate has an error)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // This value is used to perform the cross-origin check specified in Section 322 // This value is used to perform the cross-origin check specified in Section
302 // 4.3 of https://tools.ietf.org/html/draft-west-first-party-cookies. 323 // 4.3 of https://tools.ietf.org/html/draft-west-first-party-cookies.
303 // 324 //
304 // Note: the initiator can be null for browser-initiated top level 325 // Note: the initiator can be null for browser-initiated top level
305 // navigations. This is different from a unique Origin (e.g. in sandboxed 326 // navigations. This is different from a unique Origin (e.g. in sandboxed
306 // iframes). 327 // iframes).
307 const base::Optional<url::Origin>& initiator() const { return initiator_; } 328 const base::Optional<url::Origin>& initiator() const { return initiator_; }
308 // This method may only be called before Start(). 329 // This method may only be called before Start().
309 void set_initiator(const base::Optional<url::Origin>& initiator); 330 void set_initiator(const base::Optional<url::Origin>& initiator);
310 331
332 // The insecure request policy to apply to this request. This may only be
333 // changed prior to calling Start().
334 InsecureRequestPolicy insecure_request_policy() const {
335 return insecure_request_policy_;
336 }
337 void set_insecure_request_policy(
338 InsecureRequestPolicy insecure_request_policy);
mmenke 2016/12/15 19:24:22 If we see a redirect response with Content-Securit
339
311 // The request method, as an uppercase string. "GET" is the default value. 340 // 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 341 // The request method may only be changed before Start() is called and
313 // should only be assigned an uppercase value. 342 // should only be assigned an uppercase value.
314 const std::string& method() const { return method_; } 343 const std::string& method() const { return method_; }
315 void set_method(const std::string& method); 344 void set_method(const std::string& method);
316 345
317 // The referrer URL for the request. This header may actually be suppressed 346 // The referrer URL for the request. This header may actually be suppressed
318 // from the underlying network request for security reasons (e.g., a HTTPS 347 // 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 348 // URL will not be sent as the referrer for a HTTP request). The referrer
320 // may only be changed before Start() is called. 349 // may only be changed before Start() is called.
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // or after the response headers are received. 673 // or after the response headers are received.
645 void GetConnectionAttempts(ConnectionAttempts* out) const; 674 void GetConnectionAttempts(ConnectionAttempts* out) const;
646 675
647 // Gets the over the wire raw header size of the response after https 676 // Gets the over the wire raw header size of the response after https
648 // encryption, 0 for cached responses. 677 // encryption, 0 for cached responses.
649 int raw_header_size() const { return raw_header_size_; } 678 int raw_header_size() const { return raw_header_size_; }
650 679
651 // Returns the error status of the request. 680 // Returns the error status of the request.
652 // Do not use! Going to be protected! 681 // Do not use! Going to be protected!
653 const URLRequestStatus& status() const { return status_; } 682 const URLRequestStatus& status() const { return status_; }
683
654 protected: 684 protected:
655 // Allow the URLRequestJob class to control the is_pending() flag. 685 // Allow the URLRequestJob class to control the is_pending() flag.
656 void set_is_pending(bool value) { is_pending_ = value; } 686 void set_is_pending(bool value) { is_pending_ = value; }
657 687
658 // Allow the URLRequestJob class to set our status too. 688 // Allow the URLRequestJob class to set our status too.
659 void set_status(URLRequestStatus status); 689 void set_status(URLRequestStatus status);
660 690
661 // Allow the URLRequestJob to redirect this request. Returns OK if 691 // Allow the URLRequestJob to redirect this request. Returns OK if
662 // successful, otherwise an error code is returned. 692 // successful, otherwise an error code is returned.
663 int Redirect(const RedirectInfo& redirect_info); 693 int Redirect(const RedirectInfo& redirect_info);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 787
758 std::vector<GURL> url_chain_; 788 std::vector<GURL> url_chain_;
759 GURL first_party_for_cookies_; 789 GURL first_party_for_cookies_;
760 base::Optional<url::Origin> initiator_; 790 base::Optional<url::Origin> initiator_;
761 GURL delegate_redirect_url_; 791 GURL delegate_redirect_url_;
762 std::string method_; // "GET", "POST", etc. Should be all uppercase. 792 std::string method_; // "GET", "POST", etc. Should be all uppercase.
763 std::string referrer_; 793 std::string referrer_;
764 ReferrerPolicy referrer_policy_; 794 ReferrerPolicy referrer_policy_;
765 std::string token_binding_referrer_; 795 std::string token_binding_referrer_;
766 FirstPartyURLPolicy first_party_url_policy_; 796 FirstPartyURLPolicy first_party_url_policy_;
797 InsecureRequestPolicy insecure_request_policy_;
767 HttpRequestHeaders extra_request_headers_; 798 HttpRequestHeaders extra_request_headers_;
768 int load_flags_; // Flags indicating the request type for the load; 799 int load_flags_; // Flags indicating the request type for the load;
769 // expected values are LOAD_* enums above. 800 // expected values are LOAD_* enums above.
770 801
771 // Never access methods of the |delegate_| directly. Always use the 802 // Never access methods of the |delegate_| directly. Always use the
772 // Notify... methods for this. 803 // Notify... methods for this.
773 Delegate* delegate_; 804 Delegate* delegate_;
774 805
775 // Current error status of the job. When no error has been encountered, this 806 // Current error status of the job. When no error has been encountered, this
776 // will be SUCCESS. If multiple errors have been encountered, this will be 807 // will be SUCCESS. If multiple errors have been encountered, this will be
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 883
853 // The raw header size of the response. 884 // The raw header size of the response.
854 int raw_header_size_; 885 int raw_header_size_;
855 886
856 DISALLOW_COPY_AND_ASSIGN(URLRequest); 887 DISALLOW_COPY_AND_ASSIGN(URLRequest);
857 }; 888 };
858 889
859 } // namespace net 890 } // namespace net
860 891
861 #endif // NET_URL_REQUEST_URL_REQUEST_H_ 892 #endif // NET_URL_REQUEST_URL_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698