Index: net/url_request/url_request.h |
diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h |
index 0357c6ae803236d3f8f44be6cf03843cadd882cd..b4f2079526129e9af958ca5de1fc256508e15ab3 100644 |
--- a/net/url_request/url_request.h |
+++ b/net/url_request/url_request.h |
@@ -51,6 +51,7 @@ class CookieOptions; |
class HostPortPair; |
class IOBuffer; |
struct LoadTimingInfo; |
+struct RedirectInfo; |
class SSLCertRequestInfo; |
class SSLInfo; |
class UploadDataStream; |
@@ -108,6 +109,15 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), |
NEVER_CLEAR_REFERRER, |
}; |
+ // First-party URL redirect policy: During server redirects, the first-party |
+ // URL for cookies normally doesn't change. However, if the request is a |
+ // top-level first-party request, the first-party URL should be updated to the |
+ // URL on every redirect. |
+ enum FirstPartyURLPolicy { |
+ NEVER_CHANGE_FIRST_PARTY_URL, |
+ UPDATE_FIRST_PARTY_URL_ON_REDIRECT, |
+ }; |
+ |
// This class handles network interception. Use with |
// (Un)RegisterRequestInterceptor. |
class NET_EXPORT Interceptor { |
@@ -185,10 +195,10 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), |
// |
class NET_EXPORT Delegate { |
public: |
- // Called upon a server-initiated redirect. The delegate may call the |
- // request's Cancel method to prevent the redirect from being followed. |
- // Since there may be multiple chained redirects, there may also be more |
- // than one redirect call. |
+ // Called upon receiving a redirect. The delegate may call the request's |
+ // Cancel method to prevent the redirect from being followed. Since there |
+ // may be multiple chained redirects, there may also be more than one |
+ // redirect call. |
// |
// When this function is called, the request will still contain the |
// original URL, the destination of the redirect is provided in 'new_url'. |
@@ -202,7 +212,7 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), |
// need to set it if they are happy with the default behavior of not |
// deferring redirect. |
virtual void OnReceivedRedirect(URLRequest* request, |
- const GURL& new_url, |
+ const RedirectInfo& redirect_info, |
bool* defer_redirect); |
// Called when we receive an authentication failure. The delegate should |
@@ -324,10 +334,17 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), |
const GURL& first_party_for_cookies() const { |
return first_party_for_cookies_; |
} |
- // This method may be called before Start() or FollowDeferredRedirect() is |
- // called. |
+ // This method may only be called before Start(). |
void set_first_party_for_cookies(const GURL& first_party_for_cookies); |
+ // The first-party URL policy to apply when updating the first party URL |
+ // during redirects. The first-party URL policy may only be changed before |
+ // Start() is called. |
+ FirstPartyURLPolicy first_party_url_policy() const { |
+ return first_party_url_policy_; |
+ } |
+ void set_first_party_url_policy(FirstPartyURLPolicy first_party_url_policy); |
+ |
// The request method, as an uppercase string. "GET" is the default value. |
// The request method may only be changed before Start() is called and |
// should only be assigned an uppercase value. |
@@ -350,6 +367,7 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), |
// The referrer policy to apply when updating the referrer during redirects. |
// The referrer policy may only be changed before Start() is called. |
+ ReferrerPolicy referrer_policy() const { return referrer_policy_; } |
void set_referrer_policy(ReferrerPolicy referrer_policy); |
// Sets the delegate of the request. This value may be changed at any time, |
@@ -682,10 +700,11 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), |
// Allow the URLRequestJob to redirect this request. Returns OK if |
// successful, otherwise an error code is returned. |
- int Redirect(const GURL& location, int http_status_code); |
+ int Redirect(const RedirectInfo& redirect_info); |
// Called by URLRequestJob to allow interception when a redirect occurs. |
- void NotifyReceivedRedirect(const GURL& location, bool* defer_redirect); |
+ void NotifyReceivedRedirect(const RedirectInfo& redirect_info, |
+ bool* defer_redirect); |
// Called by URLRequestHttpJob (note, only HTTP(S) jobs will call this) to |
// allow deferral of network initialization. |
@@ -788,6 +807,7 @@ class NET_EXPORT URLRequest : NON_EXPORTED_BASE(public base::NonThreadSafe), |
std::string method_; // "GET", "POST", etc. Should be all uppercase. |
std::string referrer_; |
ReferrerPolicy referrer_policy_; |
+ FirstPartyURLPolicy first_party_url_policy_; |
HttpRequestHeaders extra_request_headers_; |
int load_flags_; // Flags indicating the request type for the load; |
// expected values are LOAD_* enums above. |