1*6777b538SAndroid Build Coastguard Worker // Copyright 2012 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker #ifndef NET_BASE_NETWORK_DELEGATE_H_ 6*6777b538SAndroid Build Coastguard Worker #define NET_BASE_NETWORK_DELEGATE_H_ 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Worker #include <stdint.h> 9*6777b538SAndroid Build Coastguard Worker 10*6777b538SAndroid Build Coastguard Worker #include <optional> 11*6777b538SAndroid Build Coastguard Worker #include <set> 12*6777b538SAndroid Build Coastguard Worker #include <string> 13*6777b538SAndroid Build Coastguard Worker 14*6777b538SAndroid Build Coastguard Worker #include "base/functional/callback.h" 15*6777b538SAndroid Build Coastguard Worker #include "base/gtest_prod_util.h" 16*6777b538SAndroid Build Coastguard Worker #include "base/threading/thread_checker.h" 17*6777b538SAndroid Build Coastguard Worker #include "net/base/auth.h" 18*6777b538SAndroid Build Coastguard Worker #include "net/base/completion_once_callback.h" 19*6777b538SAndroid Build Coastguard Worker #include "net/base/net_export.h" 20*6777b538SAndroid Build Coastguard Worker #include "net/cookies/canonical_cookie.h" 21*6777b538SAndroid Build Coastguard Worker #include "net/cookies/cookie_inclusion_status.h" 22*6777b538SAndroid Build Coastguard Worker #include "net/cookies/cookie_setting_override.h" 23*6777b538SAndroid Build Coastguard Worker #include "net/cookies/site_for_cookies.h" 24*6777b538SAndroid Build Coastguard Worker #include "net/first_party_sets/first_party_set_metadata.h" 25*6777b538SAndroid Build Coastguard Worker #include "net/first_party_sets/first_party_sets_cache_filter.h" 26*6777b538SAndroid Build Coastguard Worker #include "net/proxy_resolution/proxy_retry_info.h" 27*6777b538SAndroid Build Coastguard Worker 28*6777b538SAndroid Build Coastguard Worker class GURL; 29*6777b538SAndroid Build Coastguard Worker 30*6777b538SAndroid Build Coastguard Worker namespace url { 31*6777b538SAndroid Build Coastguard Worker class Origin; 32*6777b538SAndroid Build Coastguard Worker } 33*6777b538SAndroid Build Coastguard Worker 34*6777b538SAndroid Build Coastguard Worker namespace net { 35*6777b538SAndroid Build Coastguard Worker 36*6777b538SAndroid Build Coastguard Worker // NOTE: Layering violations! 37*6777b538SAndroid Build Coastguard Worker // We decided to accept these violations (depending 38*6777b538SAndroid Build Coastguard Worker // on other net/ submodules from net/base/), because otherwise NetworkDelegate 39*6777b538SAndroid Build Coastguard Worker // would have to be broken up into too many smaller interfaces targeted to each 40*6777b538SAndroid Build Coastguard Worker // submodule. Also, since the lower levels in net/ may callback into higher 41*6777b538SAndroid Build Coastguard Worker // levels, we may encounter dangerous casting issues. 42*6777b538SAndroid Build Coastguard Worker // 43*6777b538SAndroid Build Coastguard Worker // NOTE: It is not okay to add any compile-time dependencies on symbols outside 44*6777b538SAndroid Build Coastguard Worker // of net/base here, because we have a net_base library. Forward declarations 45*6777b538SAndroid Build Coastguard Worker // are ok. 46*6777b538SAndroid Build Coastguard Worker class CookieOptions; 47*6777b538SAndroid Build Coastguard Worker class CookieInclusionStatus; 48*6777b538SAndroid Build Coastguard Worker class HttpRequestHeaders; 49*6777b538SAndroid Build Coastguard Worker class HttpResponseHeaders; 50*6777b538SAndroid Build Coastguard Worker class IPEndPoint; 51*6777b538SAndroid Build Coastguard Worker class URLRequest; 52*6777b538SAndroid Build Coastguard Worker 53*6777b538SAndroid Build Coastguard Worker class NET_EXPORT NetworkDelegate { 54*6777b538SAndroid Build Coastguard Worker public: 55*6777b538SAndroid Build Coastguard Worker virtual ~NetworkDelegate(); 56*6777b538SAndroid Build Coastguard Worker 57*6777b538SAndroid Build Coastguard Worker // Notification interface called by the network stack. Note that these 58*6777b538SAndroid Build Coastguard Worker // functions mostly forward to the private virtuals. They also add some sanity 59*6777b538SAndroid Build Coastguard Worker // checking on parameters. See the corresponding virtuals for explanations of 60*6777b538SAndroid Build Coastguard Worker // the methods and their arguments. 61*6777b538SAndroid Build Coastguard Worker int NotifyBeforeURLRequest(URLRequest* request, 62*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback, 63*6777b538SAndroid Build Coastguard Worker GURL* new_url); 64*6777b538SAndroid Build Coastguard Worker using OnBeforeStartTransactionCallback = 65*6777b538SAndroid Build Coastguard Worker base::OnceCallback<void(int, const std::optional<HttpRequestHeaders>&)>; 66*6777b538SAndroid Build Coastguard Worker int NotifyBeforeStartTransaction(URLRequest* request, 67*6777b538SAndroid Build Coastguard Worker const HttpRequestHeaders& headers, 68*6777b538SAndroid Build Coastguard Worker OnBeforeStartTransactionCallback callback); 69*6777b538SAndroid Build Coastguard Worker int NotifyHeadersReceived( 70*6777b538SAndroid Build Coastguard Worker URLRequest* request, 71*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback, 72*6777b538SAndroid Build Coastguard Worker const HttpResponseHeaders* original_response_headers, 73*6777b538SAndroid Build Coastguard Worker scoped_refptr<HttpResponseHeaders>* override_response_headers, 74*6777b538SAndroid Build Coastguard Worker const IPEndPoint& remote_endpoint, 75*6777b538SAndroid Build Coastguard Worker std::optional<GURL>* preserve_fragment_on_redirect_url); 76*6777b538SAndroid Build Coastguard Worker void NotifyBeforeRedirect(URLRequest* request, 77*6777b538SAndroid Build Coastguard Worker const GURL& new_location); 78*6777b538SAndroid Build Coastguard Worker void NotifyResponseStarted(URLRequest* request, int net_error); 79*6777b538SAndroid Build Coastguard Worker void NotifyCompleted(URLRequest* request, bool started, int net_error); 80*6777b538SAndroid Build Coastguard Worker void NotifyURLRequestDestroyed(URLRequest* request); 81*6777b538SAndroid Build Coastguard Worker void NotifyPACScriptError(int line_number, const std::u16string& error); 82*6777b538SAndroid Build Coastguard Worker bool AnnotateAndMoveUserBlockedCookies( 83*6777b538SAndroid Build Coastguard Worker const URLRequest& request, 84*6777b538SAndroid Build Coastguard Worker const net::FirstPartySetMetadata& first_party_set_metadata, 85*6777b538SAndroid Build Coastguard Worker CookieAccessResultList& maybe_included_cookies, 86*6777b538SAndroid Build Coastguard Worker CookieAccessResultList& excluded_cookies); 87*6777b538SAndroid Build Coastguard Worker bool CanSetCookie(const URLRequest& request, 88*6777b538SAndroid Build Coastguard Worker const net::CanonicalCookie& cookie, 89*6777b538SAndroid Build Coastguard Worker CookieOptions* options, 90*6777b538SAndroid Build Coastguard Worker const net::FirstPartySetMetadata& first_party_set_metadata, 91*6777b538SAndroid Build Coastguard Worker CookieInclusionStatus* inclusion_status); 92*6777b538SAndroid Build Coastguard Worker 93*6777b538SAndroid Build Coastguard Worker // PrivacySetting is kStateDisallowed iff the given |url| has to be 94*6777b538SAndroid Build Coastguard Worker // requested over connection that is not tracked by the server. 95*6777b538SAndroid Build Coastguard Worker // 96*6777b538SAndroid Build Coastguard Worker // Usually PrivacySetting is kStateAllowed, unless user privacy settings 97*6777b538SAndroid Build Coastguard Worker // block cookies from being get or set. 98*6777b538SAndroid Build Coastguard Worker // 99*6777b538SAndroid Build Coastguard Worker // It may be set to kPartitionedStateAllowedOnly if the request allows 100*6777b538SAndroid Build Coastguard Worker // partitioned state to be sent over the connection, but unpartitioned 101*6777b538SAndroid Build Coastguard Worker // state should be blocked. 102*6777b538SAndroid Build Coastguard Worker enum class PrivacySetting { 103*6777b538SAndroid Build Coastguard Worker kStateAllowed, 104*6777b538SAndroid Build Coastguard Worker kStateDisallowed, 105*6777b538SAndroid Build Coastguard Worker // First-party requests will never have this setting. 106*6777b538SAndroid Build Coastguard Worker kPartitionedStateAllowedOnly, 107*6777b538SAndroid Build Coastguard Worker }; 108*6777b538SAndroid Build Coastguard Worker PrivacySetting ForcePrivacyMode(const URLRequest& request) const; 109*6777b538SAndroid Build Coastguard Worker 110*6777b538SAndroid Build Coastguard Worker bool CancelURLRequestWithPolicyViolatingReferrerHeader( 111*6777b538SAndroid Build Coastguard Worker const URLRequest& request, 112*6777b538SAndroid Build Coastguard Worker const GURL& target_url, 113*6777b538SAndroid Build Coastguard Worker const GURL& referrer_url) const; 114*6777b538SAndroid Build Coastguard Worker 115*6777b538SAndroid Build Coastguard Worker bool CanQueueReportingReport(const url::Origin& origin) const; 116*6777b538SAndroid Build Coastguard Worker void CanSendReportingReports( 117*6777b538SAndroid Build Coastguard Worker std::set<url::Origin> origins, 118*6777b538SAndroid Build Coastguard Worker base::OnceCallback<void(std::set<url::Origin>)> result_callback) const; 119*6777b538SAndroid Build Coastguard Worker bool CanSetReportingClient(const url::Origin& origin, 120*6777b538SAndroid Build Coastguard Worker const GURL& endpoint) const; 121*6777b538SAndroid Build Coastguard Worker bool CanUseReportingClient(const url::Origin& origin, 122*6777b538SAndroid Build Coastguard Worker const GURL& endpoint) const; 123*6777b538SAndroid Build Coastguard Worker 124*6777b538SAndroid Build Coastguard Worker protected: 125*6777b538SAndroid Build Coastguard Worker // Adds the given ExclusionReason to all cookies in 126*6777b538SAndroid Build Coastguard Worker // `mayble_included_cookies`, and moves the contents of 127*6777b538SAndroid Build Coastguard Worker // `maybe_included_cookies` to `excluded_cookies`. 128*6777b538SAndroid Build Coastguard Worker static void ExcludeAllCookies( 129*6777b538SAndroid Build Coastguard Worker net::CookieInclusionStatus::ExclusionReason reason, 130*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& maybe_included_cookies, 131*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& excluded_cookies); 132*6777b538SAndroid Build Coastguard Worker 133*6777b538SAndroid Build Coastguard Worker // Does the same as ExcludeAllCookies but will still include 134*6777b538SAndroid Build Coastguard Worker // cookies that are partitioned if cookies are not disabled 135*6777b538SAndroid Build Coastguard Worker // globally. 136*6777b538SAndroid Build Coastguard Worker static void ExcludeAllCookiesExceptPartitioned( 137*6777b538SAndroid Build Coastguard Worker net::CookieInclusionStatus::ExclusionReason reason, 138*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& maybe_included_cookies, 139*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& excluded_cookies); 140*6777b538SAndroid Build Coastguard Worker 141*6777b538SAndroid Build Coastguard Worker // Moves any cookie in `maybe_included_cookies` that has an ExclusionReason 142*6777b538SAndroid Build Coastguard Worker // into `excluded_cookies`. 143*6777b538SAndroid Build Coastguard Worker static void MoveExcludedCookies( 144*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& maybe_included_cookies, 145*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& excluded_cookies); 146*6777b538SAndroid Build Coastguard Worker 147*6777b538SAndroid Build Coastguard Worker THREAD_CHECKER(thread_checker_); 148*6777b538SAndroid Build Coastguard Worker 149*6777b538SAndroid Build Coastguard Worker private: 150*6777b538SAndroid Build Coastguard Worker FRIEND_TEST_ALL_PREFIXES(NetworkDelegateTest, ExcludeAllCookies); 151*6777b538SAndroid Build Coastguard Worker FRIEND_TEST_ALL_PREFIXES(NetworkDelegateTest, MoveExcludedCookies); 152*6777b538SAndroid Build Coastguard Worker // This is the interface for subclasses of NetworkDelegate to implement. These 153*6777b538SAndroid Build Coastguard Worker // member functions will be called by the respective public notification 154*6777b538SAndroid Build Coastguard Worker // member function, which will perform basic sanity checking. 155*6777b538SAndroid Build Coastguard Worker // 156*6777b538SAndroid Build Coastguard Worker // Note that these member functions refer to URLRequests which may be canceled 157*6777b538SAndroid Build Coastguard Worker // or destroyed at any time. Implementations which return ERR_IO_PENDING must 158*6777b538SAndroid Build Coastguard Worker // also implement OnURLRequestDestroyed and OnCompleted to handle cancelation. 159*6777b538SAndroid Build Coastguard Worker // See below for details. 160*6777b538SAndroid Build Coastguard Worker // 161*6777b538SAndroid Build Coastguard Worker // (NetworkDelegateImpl has default implementations of these member functions. 162*6777b538SAndroid Build Coastguard Worker // NetworkDelegate implementations should consider subclassing 163*6777b538SAndroid Build Coastguard Worker // NetworkDelegateImpl.) 164*6777b538SAndroid Build Coastguard Worker 165*6777b538SAndroid Build Coastguard Worker // Called before a request is sent. Allows the delegate to rewrite the URL 166*6777b538SAndroid Build Coastguard Worker // being fetched by modifying |new_url|. If set, the URL must be valid. The 167*6777b538SAndroid Build Coastguard Worker // reference fragment from the original URL is not automatically appended to 168*6777b538SAndroid Build Coastguard Worker // |new_url|; callers are responsible for copying the reference fragment if 169*6777b538SAndroid Build Coastguard Worker // desired. 170*6777b538SAndroid Build Coastguard Worker // 171*6777b538SAndroid Build Coastguard Worker // Returns OK to continue with the request, ERR_IO_PENDING if the result is 172*6777b538SAndroid Build Coastguard Worker // not ready yet, and any other status code to cancel the request. If 173*6777b538SAndroid Build Coastguard Worker // returning ERR_IO_PENDING, call |callback| when the result is ready. Note, 174*6777b538SAndroid Build Coastguard Worker // however, that a pending operation may be cancelled by 175*6777b538SAndroid Build Coastguard Worker // OnURLRequestDestroyed. Once cancelled, |request| and |new_url| become 176*6777b538SAndroid Build Coastguard Worker // invalid and |callback| may not be called. 177*6777b538SAndroid Build Coastguard Worker // 178*6777b538SAndroid Build Coastguard Worker // The default implementation returns OK (continue with request). 179*6777b538SAndroid Build Coastguard Worker virtual int OnBeforeURLRequest(URLRequest* request, 180*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback, 181*6777b538SAndroid Build Coastguard Worker GURL* new_url) = 0; 182*6777b538SAndroid Build Coastguard Worker 183*6777b538SAndroid Build Coastguard Worker // Called right before the network transaction starts. Allows the delegate to 184*6777b538SAndroid Build Coastguard Worker // read |headers| and modify them by passing a new copy to |callback| before 185*6777b538SAndroid Build Coastguard Worker // they get sent out. 186*6777b538SAndroid Build Coastguard Worker // 187*6777b538SAndroid Build Coastguard Worker // Returns OK to continue with the request, ERR_IO_PENDING if the result is 188*6777b538SAndroid Build Coastguard Worker // not ready yet, and any other status code to cancel the request. If 189*6777b538SAndroid Build Coastguard Worker // returning ERR_IO_PENDING, call |callback| when the result is ready. Note, 190*6777b538SAndroid Build Coastguard Worker // however, that a pending operation may be cancelled by OnURLRequestDestroyed 191*6777b538SAndroid Build Coastguard Worker // or OnCompleted. Once cancelled, |request| and |headers| become invalid and 192*6777b538SAndroid Build Coastguard Worker // |callback| may not be called. 193*6777b538SAndroid Build Coastguard Worker // 194*6777b538SAndroid Build Coastguard Worker // The default implementation returns OK (continue with request). 195*6777b538SAndroid Build Coastguard Worker virtual int OnBeforeStartTransaction( 196*6777b538SAndroid Build Coastguard Worker URLRequest* request, 197*6777b538SAndroid Build Coastguard Worker const HttpRequestHeaders& headers, 198*6777b538SAndroid Build Coastguard Worker OnBeforeStartTransactionCallback callback) = 0; 199*6777b538SAndroid Build Coastguard Worker 200*6777b538SAndroid Build Coastguard Worker // Called for HTTP requests when the headers have been received. 201*6777b538SAndroid Build Coastguard Worker // |original_response_headers| contains the headers as received over the 202*6777b538SAndroid Build Coastguard Worker // network, these must not be modified. |override_response_headers| can be set 203*6777b538SAndroid Build Coastguard Worker // to new values, that should be considered as overriding 204*6777b538SAndroid Build Coastguard Worker // |original_response_headers|. 205*6777b538SAndroid Build Coastguard Worker // If the response is a redirect, and the Location response header value is 206*6777b538SAndroid Build Coastguard Worker // identical to |preserve_fragment_on_redirect_url|, then the redirect is 207*6777b538SAndroid Build Coastguard Worker // never blocked and the reference fragment is not copied from the original 208*6777b538SAndroid Build Coastguard Worker // URL to the redirection target. 209*6777b538SAndroid Build Coastguard Worker // 210*6777b538SAndroid Build Coastguard Worker // Returns OK to continue with the request, ERR_IO_PENDING if the result is 211*6777b538SAndroid Build Coastguard Worker // not ready yet, and any other status code to cancel the request. If 212*6777b538SAndroid Build Coastguard Worker // returning ERR_IO_PENDING, call |callback| when the result is ready. Note, 213*6777b538SAndroid Build Coastguard Worker // however, that a pending operation may be cancelled by 214*6777b538SAndroid Build Coastguard Worker // OnURLRequestDestroyed. Once cancelled, |request|, 215*6777b538SAndroid Build Coastguard Worker // |original_response_headers|, |override_response_headers|, and 216*6777b538SAndroid Build Coastguard Worker // |preserve_fragment_on_redirect_url| become invalid and |callback| may not 217*6777b538SAndroid Build Coastguard Worker // be called. 218*6777b538SAndroid Build Coastguard Worker virtual int OnHeadersReceived( 219*6777b538SAndroid Build Coastguard Worker URLRequest* request, 220*6777b538SAndroid Build Coastguard Worker CompletionOnceCallback callback, 221*6777b538SAndroid Build Coastguard Worker const HttpResponseHeaders* original_response_headers, 222*6777b538SAndroid Build Coastguard Worker scoped_refptr<HttpResponseHeaders>* override_response_headers, 223*6777b538SAndroid Build Coastguard Worker const IPEndPoint& remote_endpoint, 224*6777b538SAndroid Build Coastguard Worker std::optional<GURL>* preserve_fragment_on_redirect_url) = 0; 225*6777b538SAndroid Build Coastguard Worker 226*6777b538SAndroid Build Coastguard Worker // Called right after a redirect response code was received. |new_location| is 227*6777b538SAndroid Build Coastguard Worker // only valid for the duration of the call. 228*6777b538SAndroid Build Coastguard Worker virtual void OnBeforeRedirect(URLRequest* request, 229*6777b538SAndroid Build Coastguard Worker const GURL& new_location) = 0; 230*6777b538SAndroid Build Coastguard Worker 231*6777b538SAndroid Build Coastguard Worker // This corresponds to URLRequestDelegate::OnResponseStarted. 232*6777b538SAndroid Build Coastguard Worker virtual void OnResponseStarted(URLRequest* request, int net_error) = 0; 233*6777b538SAndroid Build Coastguard Worker 234*6777b538SAndroid Build Coastguard Worker // Indicates that the URL request has been completed or failed. 235*6777b538SAndroid Build Coastguard Worker // |started| indicates whether the request has been started. If false, 236*6777b538SAndroid Build Coastguard Worker // some information like the socket address is not available. 237*6777b538SAndroid Build Coastguard Worker virtual void OnCompleted(URLRequest* request, 238*6777b538SAndroid Build Coastguard Worker bool started, 239*6777b538SAndroid Build Coastguard Worker int net_error) = 0; 240*6777b538SAndroid Build Coastguard Worker 241*6777b538SAndroid Build Coastguard Worker // Called when an URLRequest is being destroyed. Note that the request is 242*6777b538SAndroid Build Coastguard Worker // being deleted, so it's not safe to call any methods that may result in 243*6777b538SAndroid Build Coastguard Worker // a virtual method call. 244*6777b538SAndroid Build Coastguard Worker virtual void OnURLRequestDestroyed(URLRequest* request) = 0; 245*6777b538SAndroid Build Coastguard Worker 246*6777b538SAndroid Build Coastguard Worker // Corresponds to ProxyResolverJSBindings::OnError. 247*6777b538SAndroid Build Coastguard Worker virtual void OnPACScriptError(int line_number, 248*6777b538SAndroid Build Coastguard Worker const std::u16string& error) = 0; 249*6777b538SAndroid Build Coastguard Worker 250*6777b538SAndroid Build Coastguard Worker // Called when reading cookies to allow the network delegate to block access 251*6777b538SAndroid Build Coastguard Worker // to individual cookies, by adding the appropriate ExclusionReason and moving 252*6777b538SAndroid Build Coastguard Worker // them to the `excluded_cookies` list. This method will never be invoked 253*6777b538SAndroid Build Coastguard Worker // when LOAD_DO_NOT_SEND_COOKIES is specified. 254*6777b538SAndroid Build Coastguard Worker // 255*6777b538SAndroid Build Coastguard Worker // Returns false if the delegate has blocked access to all cookies; true 256*6777b538SAndroid Build Coastguard Worker // otherwise. 257*6777b538SAndroid Build Coastguard Worker virtual bool OnAnnotateAndMoveUserBlockedCookies( 258*6777b538SAndroid Build Coastguard Worker const URLRequest& request, 259*6777b538SAndroid Build Coastguard Worker const net::FirstPartySetMetadata& first_party_set_metadata, 260*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& maybe_included_cookies, 261*6777b538SAndroid Build Coastguard Worker net::CookieAccessResultList& excluded_cookies) = 0; 262*6777b538SAndroid Build Coastguard Worker 263*6777b538SAndroid Build Coastguard Worker // Called when a cookie is set to allow the network delegate to block access 264*6777b538SAndroid Build Coastguard Worker // to the cookie. If the cookie is allowed, `inclusion_status` may be updated 265*6777b538SAndroid Build Coastguard Worker // to include reason to warn about the given cookie according to the user 266*6777b538SAndroid Build Coastguard Worker // cookie-blocking settings; Otherwise, `inclusion_status` may be updated with 267*6777b538SAndroid Build Coastguard Worker // the proper exclusion reasons, if not then proper reasons need to be 268*6777b538SAndroid Build Coastguard Worker // manually added in the caller. This method will never be invoked when 269*6777b538SAndroid Build Coastguard Worker // LOAD_DO_NOT_SAVE_COOKIES is specified. 270*6777b538SAndroid Build Coastguard Worker virtual bool OnCanSetCookie( 271*6777b538SAndroid Build Coastguard Worker const URLRequest& request, 272*6777b538SAndroid Build Coastguard Worker const CanonicalCookie& cookie, 273*6777b538SAndroid Build Coastguard Worker CookieOptions* options, 274*6777b538SAndroid Build Coastguard Worker const net::FirstPartySetMetadata& first_party_set_metadata, 275*6777b538SAndroid Build Coastguard Worker CookieInclusionStatus* inclusion_status) = 0; 276*6777b538SAndroid Build Coastguard Worker 277*6777b538SAndroid Build Coastguard Worker virtual PrivacySetting OnForcePrivacyMode( 278*6777b538SAndroid Build Coastguard Worker const URLRequest& request) const = 0; 279*6777b538SAndroid Build Coastguard Worker 280*6777b538SAndroid Build Coastguard Worker // Called when the |referrer_url| for requesting |target_url| during handling 281*6777b538SAndroid Build Coastguard Worker // of the |request| is does not comply with the referrer policy (e.g. a 282*6777b538SAndroid Build Coastguard Worker // secure referrer for an insecure initial target). 283*6777b538SAndroid Build Coastguard Worker // Returns true if the request should be cancelled. Otherwise, the referrer 284*6777b538SAndroid Build Coastguard Worker // header is stripped from the request. 285*6777b538SAndroid Build Coastguard Worker virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( 286*6777b538SAndroid Build Coastguard Worker const URLRequest& request, 287*6777b538SAndroid Build Coastguard Worker const GURL& target_url, 288*6777b538SAndroid Build Coastguard Worker const GURL& referrer_url) const = 0; 289*6777b538SAndroid Build Coastguard Worker 290*6777b538SAndroid Build Coastguard Worker virtual bool OnCanQueueReportingReport(const url::Origin& origin) const = 0; 291*6777b538SAndroid Build Coastguard Worker 292*6777b538SAndroid Build Coastguard Worker virtual void OnCanSendReportingReports( 293*6777b538SAndroid Build Coastguard Worker std::set<url::Origin> origins, 294*6777b538SAndroid Build Coastguard Worker base::OnceCallback<void(std::set<url::Origin>)> result_callback) 295*6777b538SAndroid Build Coastguard Worker const = 0; 296*6777b538SAndroid Build Coastguard Worker 297*6777b538SAndroid Build Coastguard Worker virtual bool OnCanSetReportingClient(const url::Origin& origin, 298*6777b538SAndroid Build Coastguard Worker const GURL& endpoint) const = 0; 299*6777b538SAndroid Build Coastguard Worker 300*6777b538SAndroid Build Coastguard Worker virtual bool OnCanUseReportingClient(const url::Origin& origin, 301*6777b538SAndroid Build Coastguard Worker const GURL& endpoint) const = 0; 302*6777b538SAndroid Build Coastguard Worker }; 303*6777b538SAndroid Build Coastguard Worker 304*6777b538SAndroid Build Coastguard Worker } // namespace net 305*6777b538SAndroid Build Coastguard Worker 306*6777b538SAndroid Build Coastguard Worker #endif // NET_BASE_NETWORK_DELEGATE_H_ 307