[email protected] | 9045b882 | 2012-01-13 20:35:35 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_BASE_NETWORK_DELEGATE_H_ |
| 6 | #define NET_BASE_NETWORK_DELEGATE_H_ |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 7 | |
sclittle | ce72c48 | 2015-08-24 20:20:59 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 9c8ae8c | 2012-03-09 13:13:35 | [diff] [blame] | 10 | #include <string> |
| 11 | |
[email protected] | c2911d7 | 2011-10-03 22:16:36 | [diff] [blame] | 12 | #include "base/callback.h" |
[email protected] | 4b35521 | 2013-06-11 10:35:19 | [diff] [blame] | 13 | #include "base/strings/string16.h" |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 14 | #include "base/threading/thread_checker.h" |
[email protected] | c2911d7 | 2011-10-03 22:16:36 | [diff] [blame] | 15 | #include "net/base/auth.h" |
[email protected] | 05cc4e7 | 2011-03-08 21:29:48 | [diff] [blame] | 16 | #include "net/base/completion_callback.h" |
bnc | 81c46c1f | 2016-10-04 16:25:59 | [diff] [blame] | 17 | #include "net/base/net_export.h" |
[email protected] | 8da4b181 | 2012-07-25 13:54:38 | [diff] [blame] | 18 | #include "net/cookies/canonical_cookie.h" |
Lily Houghton | 582d462 | 2018-01-22 22:43:40 | [diff] [blame^] | 19 | #include "net/proxy_resolution/proxy_retry_info.h" |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 20 | |
[email protected] | 4c76d7c | 2011-04-15 19:14:12 | [diff] [blame] | 21 | class GURL; |
| 22 | |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 23 | namespace base { |
| 24 | class FilePath; |
| 25 | } |
| 26 | |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 27 | namespace url { |
| 28 | class Origin; |
| 29 | } |
| 30 | |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 31 | namespace net { |
| 32 | |
| 33 | // NOTE: Layering violations! |
| 34 | // We decided to accept these violations (depending |
| 35 | // on other net/ submodules from net/base/), because otherwise NetworkDelegate |
| 36 | // would have to be broken up into too many smaller interfaces targeted to each |
| 37 | // submodule. Also, since the lower levels in net/ may callback into higher |
| 38 | // levels, we may encounter dangerous casting issues. |
| 39 | // |
| 40 | // NOTE: It is not okay to add any compile-time dependencies on symbols outside |
| 41 | // of net/base here, because we have a net_base library. Forward declarations |
| 42 | // are ok. |
[email protected] | 9c8ae8c | 2012-03-09 13:13:35 | [diff] [blame] | 43 | class CookieOptions; |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 44 | class HttpRequestHeaders; |
[email protected] | ea8141e | 2011-10-05 13:12:51 | [diff] [blame] | 45 | class HttpResponseHeaders; |
[email protected] | 597a1ab | 2014-06-26 08:12:27 | [diff] [blame] | 46 | class ProxyInfo; |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 47 | class URLRequest; |
| 48 | |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 49 | class NET_EXPORT NetworkDelegate { |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 50 | public: |
[email protected] | c2911d7 | 2011-10-03 22:16:36 | [diff] [blame] | 51 | // AuthRequiredResponse indicates how a NetworkDelegate handles an |
| 52 | // OnAuthRequired call. It's placed in this file to prevent url_request.h |
| 53 | // from having to include network_delegate.h. |
| 54 | enum AuthRequiredResponse { |
| 55 | AUTH_REQUIRED_RESPONSE_NO_ACTION, |
| 56 | AUTH_REQUIRED_RESPONSE_SET_AUTH, |
| 57 | AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, |
| 58 | AUTH_REQUIRED_RESPONSE_IO_PENDING, |
| 59 | }; |
| 60 | typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; |
| 61 | |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 62 | virtual ~NetworkDelegate(); |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 63 | |
| 64 | // Notification interface called by the network stack. Note that these |
| 65 | // functions mostly forward to the private virtuals. They also add some sanity |
[email protected] | 4875ba1 | 2011-03-30 22:31:51 | [diff] [blame] | 66 | // checking on parameters. See the corresponding virtuals for explanations of |
| 67 | // the methods and their arguments. |
| 68 | int NotifyBeforeURLRequest(URLRequest* request, |
[email protected] | 084262c | 2011-12-01 21:12:47 | [diff] [blame] | 69 | const CompletionCallback& callback, |
[email protected] | 4c76d7c | 2011-04-15 19:14:12 | [diff] [blame] | 70 | GURL* new_url); |
ryansturm | 2343cb6 | 2016-06-15 01:09:00 | [diff] [blame] | 71 | int NotifyBeforeStartTransaction(URLRequest* request, |
| 72 | const CompletionCallback& callback, |
| 73 | HttpRequestHeaders* headers); |
ryansturm | 49a8cb1 | 2016-06-15 16:51:09 | [diff] [blame] | 74 | void NotifyBeforeSendHeaders(URLRequest* request, |
| 75 | const ProxyInfo& proxy_info, |
| 76 | const ProxyRetryInfoMap& proxy_retry_info, |
| 77 | HttpRequestHeaders* headers); |
ryansturm | 2343cb6 | 2016-06-15 01:09:00 | [diff] [blame] | 78 | void NotifyStartTransaction(URLRequest* request, |
| 79 | const HttpRequestHeaders& headers); |
[email protected] | ea8141e | 2011-10-05 13:12:51 | [diff] [blame] | 80 | int NotifyHeadersReceived( |
| 81 | URLRequest* request, |
[email protected] | 084262c | 2011-12-01 21:12:47 | [diff] [blame] | 82 | const CompletionCallback& callback, |
[email protected] | 507af8f | 2012-10-20 00:42:32 | [diff] [blame] | 83 | const HttpResponseHeaders* original_response_headers, |
[email protected] | 5f71413 | 2014-03-26 10:41:16 | [diff] [blame] | 84 | scoped_refptr<HttpResponseHeaders>* override_response_headers, |
| 85 | GURL* allowed_unsafe_redirect_url); |
[email protected] | 31b2e5f | 2011-04-20 16:58:32 | [diff] [blame] | 86 | void NotifyBeforeRedirect(URLRequest* request, |
| 87 | const GURL& new_location); |
maksim.sisov | 0f4aa14 | 2016-09-05 05:55:28 | [diff] [blame] | 88 | void NotifyResponseStarted(URLRequest* request, int net_error); |
| 89 | // Deprecated. |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 90 | void NotifyResponseStarted(URLRequest* request); |
sclittle | a133de0 | 2015-11-10 23:54:21 | [diff] [blame] | 91 | void NotifyNetworkBytesReceived(URLRequest* request, int64_t bytes_received); |
| 92 | void NotifyNetworkBytesSent(URLRequest* request, int64_t bytes_sent); |
maksim.sisov | 0f4aa14 | 2016-09-05 05:55:28 | [diff] [blame] | 93 | void NotifyCompleted(URLRequest* request, bool started, int net_error); |
| 94 | // Deprecated. |
[email protected] | 9045b882 | 2012-01-13 20:35:35 | [diff] [blame] | 95 | void NotifyCompleted(URLRequest* request, bool started); |
[email protected] | 4875ba1 | 2011-03-30 22:31:51 | [diff] [blame] | 96 | void NotifyURLRequestDestroyed(URLRequest* request); |
[email protected] | 42cba2fb | 2013-03-29 19:58:57 | [diff] [blame] | 97 | void NotifyPACScriptError(int line_number, const base::string16& error); |
[email protected] | c2911d7 | 2011-10-03 22:16:36 | [diff] [blame] | 98 | AuthRequiredResponse NotifyAuthRequired(URLRequest* request, |
| 99 | const AuthChallengeInfo& auth_info, |
| 100 | const AuthCallback& callback, |
| 101 | AuthCredentials* credentials); |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 102 | bool CanGetCookies(const URLRequest& request, |
| 103 | const CookieList& cookie_list); |
| 104 | bool CanSetCookie(const URLRequest& request, |
Victor Costan | 70f8551 | 2017-11-20 16:14:46 | [diff] [blame] | 105 | const net::CanonicalCookie& cookie, |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 106 | CookieOptions* options); |
| 107 | bool CanAccessFile(const URLRequest& request, |
satorux | ddac044 | 2017-05-29 06:06:18 | [diff] [blame] | 108 | const base::FilePath& original_path, |
| 109 | const base::FilePath& absolute_path) const; |
[email protected] | e6d01765 | 2013-05-17 18:01:40 | [diff] [blame] | 110 | bool CanEnablePrivacyMode(const GURL& url, |
Mike West | b85da8ed | 2017-08-10 14:16:46 | [diff] [blame] | 111 | const GURL& site_for_cookies) const; |
[email protected] | 82a3767 | 2011-05-03 12:02:41 | [diff] [blame] | 112 | |
estark | 7625d81 | 2015-10-12 20:10:41 | [diff] [blame] | 113 | bool AreExperimentalCookieFeaturesEnabled() const; |
mkwst | c5fa776 | 2016-03-28 09:28:23 | [diff] [blame] | 114 | |
jochen | 0e3b3a6 | 2014-09-16 18:31:23 | [diff] [blame] | 115 | bool CancelURLRequestWithPolicyViolatingReferrerHeader( |
| 116 | const URLRequest& request, |
| 117 | const GURL& target_url, |
| 118 | const GURL& referrer_url) const; |
| 119 | |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 120 | bool CanQueueReportingReport(const url::Origin& origin) const; |
| 121 | bool CanSendReportingReport(const url::Origin& origin) const; |
| 122 | bool CanSetReportingClient(const url::Origin& origin, |
| 123 | const GURL& endpoint) const; |
| 124 | bool CanUseReportingClient(const url::Origin& origin, |
| 125 | const GURL& endpoint) const; |
| 126 | |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 127 | protected: |
| 128 | THREAD_CHECKER(thread_checker_); |
| 129 | |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 130 | private: |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 131 | // This is the interface for subclasses of NetworkDelegate to implement. These |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 132 | // member functions will be called by the respective public notification |
| 133 | // member function, which will perform basic sanity checking. |
mgersh | 1571517 | 2016-11-16 16:03:25 | [diff] [blame] | 134 | // |
| 135 | // (NetworkDelegateImpl has default implementations of these member functions. |
| 136 | // NetworkDelegate implementations should consider subclassing |
| 137 | // NetworkDelegateImpl.) |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 138 | |
[email protected] | 4c76d7c | 2011-04-15 19:14:12 | [diff] [blame] | 139 | // Called before a request is sent. Allows the delegate to rewrite the URL |
[email protected] | f878230e | 2014-04-03 15:36:14 | [diff] [blame] | 140 | // being fetched by modifying |new_url|. If set, the URL must be valid. The |
| 141 | // reference fragment from the original URL is not automatically appended to |
| 142 | // |new_url|; callers are responsible for copying the reference fragment if |
| 143 | // desired. |
| 144 | // |callback| and |new_url| are valid only until OnURLRequestDestroyed is |
| 145 | // called for this request. Returns a net status code, generally either OK to |
| 146 | // continue with the request or ERR_IO_PENDING if the result is not ready yet. |
| 147 | // A status code other than OK and ERR_IO_PENDING will cancel the request and |
| 148 | // report the status code as the reason. |
[email protected] | c6c6e565 | 2013-10-29 02:40:30 | [diff] [blame] | 149 | // |
| 150 | // The default implementation returns OK (continue with request). |
[email protected] | 4875ba1 | 2011-03-30 22:31:51 | [diff] [blame] | 151 | virtual int OnBeforeURLRequest(URLRequest* request, |
[email protected] | 084262c | 2011-12-01 21:12:47 | [diff] [blame] | 152 | const CompletionCallback& callback, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 153 | GURL* new_url) = 0; |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 154 | |
ryansturm | 2343cb6 | 2016-06-15 01:09:00 | [diff] [blame] | 155 | // Called right before the network transaction starts. Allows the delegate to |
[email protected] | 5aa2013 | 2011-04-27 23:11:34 | [diff] [blame] | 156 | // read/write |headers| before they get sent out. |callback| and |headers| are |
[email protected] | 9045b882 | 2012-01-13 20:35:35 | [diff] [blame] | 157 | // valid only until OnCompleted or OnURLRequestDestroyed is called for this |
| 158 | // request. |
[email protected] | c6c6e565 | 2013-10-29 02:40:30 | [diff] [blame] | 159 | // See OnBeforeURLRequest for return value description. Returns OK by default. |
ryansturm | 2343cb6 | 2016-06-15 01:09:00 | [diff] [blame] | 160 | virtual int OnBeforeStartTransaction(URLRequest* request, |
| 161 | const CompletionCallback& callback, |
| 162 | HttpRequestHeaders* headers) = 0; |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 163 | |
ryansturm | 49a8cb1 | 2016-06-15 16:51:09 | [diff] [blame] | 164 | // Called after a connection is established , and just before headers are sent |
| 165 | // to the destination server (i.e., not called for HTTP CONNECT requests). For |
| 166 | // non-tunneled requests using HTTP proxies, |headers| will include any |
| 167 | // proxy-specific headers as well. Allows the delegate to read/write |headers| |
| 168 | // before they get sent out. |headers| is valid only until OnCompleted or |
| 169 | // OnURLRequestDestroyed is called for this request. |
| 170 | virtual void OnBeforeSendHeaders(URLRequest* request, |
| 171 | const ProxyInfo& proxy_info, |
| 172 | const ProxyRetryInfoMap& proxy_retry_info, |
| 173 | HttpRequestHeaders* headers) = 0; |
[email protected] | 597a1ab | 2014-06-26 08:12:27 | [diff] [blame] | 174 | |
[email protected] | 5796dc94 | 2011-07-14 19:26:10 | [diff] [blame] | 175 | // Called right before the HTTP request(s) are being sent to the network. |
[email protected] | 9045b882 | 2012-01-13 20:35:35 | [diff] [blame] | 176 | // |headers| is only valid until OnCompleted or OnURLRequestDestroyed is |
| 177 | // called for this request. |
ryansturm | 2343cb6 | 2016-06-15 01:09:00 | [diff] [blame] | 178 | virtual void OnStartTransaction(URLRequest* request, |
| 179 | const HttpRequestHeaders& headers) = 0; |
[email protected] | 82b4230 | 2011-04-20 16:28:16 | [diff] [blame] | 180 | |
[email protected] | c6c6e565 | 2013-10-29 02:40:30 | [diff] [blame] | 181 | // Called for HTTP requests when the headers have been received. |
[email protected] | ea8141e | 2011-10-05 13:12:51 | [diff] [blame] | 182 | // |original_response_headers| contains the headers as received over the |
| 183 | // network, these must not be modified. |override_response_headers| can be set |
| 184 | // to new values, that should be considered as overriding |
| 185 | // |original_response_headers|. |
[email protected] | f878230e | 2014-04-03 15:36:14 | [diff] [blame] | 186 | // If the response is a redirect, and the Location response header value is |
| 187 | // identical to |allowed_unsafe_redirect_url|, then the redirect is never |
| 188 | // blocked and the reference fragment is not copied from the original URL |
| 189 | // to the redirection target. |
| 190 | // |
[email protected] | 9045b882 | 2012-01-13 20:35:35 | [diff] [blame] | 191 | // |callback|, |original_response_headers|, and |override_response_headers| |
| 192 | // are only valid until OnURLRequestDestroyed is called for this request. |
[email protected] | c6c6e565 | 2013-10-29 02:40:30 | [diff] [blame] | 193 | // See OnBeforeURLRequest for return value description. Returns OK by default. |
[email protected] | ea8141e | 2011-10-05 13:12:51 | [diff] [blame] | 194 | virtual int OnHeadersReceived( |
| 195 | URLRequest* request, |
[email protected] | 084262c | 2011-12-01 21:12:47 | [diff] [blame] | 196 | const CompletionCallback& callback, |
[email protected] | 507af8f | 2012-10-20 00:42:32 | [diff] [blame] | 197 | const HttpResponseHeaders* original_response_headers, |
[email protected] | 5f71413 | 2014-03-26 10:41:16 | [diff] [blame] | 198 | scoped_refptr<HttpResponseHeaders>* override_response_headers, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 199 | GURL* allowed_unsafe_redirect_url) = 0; |
[email protected] | ea8141e | 2011-10-05 13:12:51 | [diff] [blame] | 200 | |
[email protected] | 31b2e5f | 2011-04-20 16:58:32 | [diff] [blame] | 201 | // Called right after a redirect response code was received. |
[email protected] | 9045b882 | 2012-01-13 20:35:35 | [diff] [blame] | 202 | // |new_location| is only valid until OnURLRequestDestroyed is called for this |
| 203 | // request. |
[email protected] | 31b2e5f | 2011-04-20 16:58:32 | [diff] [blame] | 204 | virtual void OnBeforeRedirect(URLRequest* request, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 205 | const GURL& new_location) = 0; |
[email protected] | 31b2e5f | 2011-04-20 16:58:32 | [diff] [blame] | 206 | |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 207 | // This corresponds to URLRequestDelegate::OnResponseStarted. |
maksim.sisov | 0f4aa14 | 2016-09-05 05:55:28 | [diff] [blame] | 208 | virtual void OnResponseStarted(URLRequest* request, int net_error); |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 209 | |
sclittle | ce72c48 | 2015-08-24 20:20:59 | [diff] [blame] | 210 | // Called when bytes are received from the network, such as after receiving |
| 211 | // headers or reading raw response bytes. This includes localhost requests. |
| 212 | // |bytes_received| is the number of bytes measured at the application layer |
| 213 | // that have been received over the network for this request since the last |
| 214 | // time OnNetworkBytesReceived was called. |bytes_received| will always be |
| 215 | // greater than 0. |
| 216 | // Currently, this is only implemented for HTTP transactions, and |
| 217 | // |bytes_received| does not include TLS overhead or TCP retransmits. |
sclittle | a133de0 | 2015-11-10 23:54:21 | [diff] [blame] | 218 | virtual void OnNetworkBytesReceived(URLRequest* request, |
sclittle | ce72c48 | 2015-08-24 20:20:59 | [diff] [blame] | 219 | int64_t bytes_received) = 0; |
[email protected] | 8523ba5 | 2011-05-22 19:00:58 | [diff] [blame] | 220 | |
sclittle | 28d558b | 2015-09-28 21:40:52 | [diff] [blame] | 221 | // Called when bytes are sent over the network, such as when sending request |
| 222 | // headers or uploading request body bytes. This includes localhost requests. |
| 223 | // |bytes_sent| is the number of bytes measured at the application layer that |
| 224 | // have been sent over the network for this request since the last time |
| 225 | // OnNetworkBytesSent was called. |bytes_sent| will always be greater than 0. |
| 226 | // Currently, this is only implemented for HTTP transactions, and |bytes_sent| |
| 227 | // does not include TLS overhead or TCP retransmits. |
sclittle | a133de0 | 2015-11-10 23:54:21 | [diff] [blame] | 228 | virtual void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) = 0; |
sclittle | 28d558b | 2015-09-28 21:40:52 | [diff] [blame] | 229 | |
[email protected] | 4894438 | 2011-04-23 13:28:16 | [diff] [blame] | 230 | // Indicates that the URL request has been completed or failed. |
[email protected] | 9045b882 | 2012-01-13 20:35:35 | [diff] [blame] | 231 | // |started| indicates whether the request has been started. If false, |
| 232 | // some information like the socket address is not available. |
maksim.sisov | 0f4aa14 | 2016-09-05 05:55:28 | [diff] [blame] | 233 | virtual void OnCompleted(URLRequest* request, bool started, int net_error); |
| 234 | // Deprecated. |
| 235 | virtual void OnCompleted(URLRequest* request, bool started); |
[email protected] | 4b50cb5 | 2011-03-10 00:29:37 | [diff] [blame] | 236 | |
[email protected] | 4875ba1 | 2011-03-30 22:31:51 | [diff] [blame] | 237 | // Called when an URLRequest is being destroyed. Note that the request is |
| 238 | // being deleted, so it's not safe to call any methods that may result in |
| 239 | // a virtual method call. |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 240 | virtual void OnURLRequestDestroyed(URLRequest* request) = 0; |
[email protected] | 4875ba1 | 2011-03-30 22:31:51 | [diff] [blame] | 241 | |
[email protected] | 82a3767 | 2011-05-03 12:02:41 | [diff] [blame] | 242 | // Corresponds to ProxyResolverJSBindings::OnError. |
[email protected] | 42cba2fb | 2013-03-29 19:58:57 | [diff] [blame] | 243 | virtual void OnPACScriptError(int line_number, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 244 | const base::string16& error) = 0; |
[email protected] | 7efc582d | 2011-08-03 20:46:35 | [diff] [blame] | 245 | |
[email protected] | c2911d7 | 2011-10-03 22:16:36 | [diff] [blame] | 246 | // Called when a request receives an authentication challenge |
| 247 | // specified by |auth_info|, and is unable to respond using cached |
| 248 | // credentials. |callback| and |credentials| must be non-NULL, and must |
| 249 | // be valid until OnURLRequestDestroyed is called for |request|. |
| 250 | // |
| 251 | // The following return values are allowed: |
| 252 | // - AUTH_REQUIRED_RESPONSE_NO_ACTION: |auth_info| is observed, but |
| 253 | // no action is being taken on it. |
| 254 | // - AUTH_REQUIRED_RESPONSE_SET_AUTH: |credentials| is filled in with |
| 255 | // a username and password, which should be used in a response to |
| 256 | // |auth_info|. |
| 257 | // - AUTH_REQUIRED_RESPONSE_CANCEL_AUTH: The authentication challenge |
| 258 | // should not be attempted. |
| 259 | // - AUTH_REQUIRED_RESPONSE_IO_PENDING: The action will be decided |
| 260 | // asynchronously. |callback| will be invoked when the decision is made, |
| 261 | // and one of the other AuthRequiredResponse values will be passed in with |
| 262 | // the same semantics as described above. |
| 263 | virtual AuthRequiredResponse OnAuthRequired( |
| 264 | URLRequest* request, |
| 265 | const AuthChallengeInfo& auth_info, |
| 266 | const AuthCallback& callback, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 267 | AuthCredentials* credentials) = 0; |
[email protected] | 9c8ae8c | 2012-03-09 13:13:35 | [diff] [blame] | 268 | |
| 269 | // Called when reading cookies to allow the network delegate to block access |
| 270 | // to the cookie. This method will never be invoked when |
| 271 | // LOAD_DO_NOT_SEND_COOKIES is specified. |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 272 | virtual bool OnCanGetCookies(const URLRequest& request, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 273 | const CookieList& cookie_list) = 0; |
[email protected] | 9c8ae8c | 2012-03-09 13:13:35 | [diff] [blame] | 274 | |
| 275 | // Called when a cookie is set to allow the network delegate to block access |
| 276 | // to the cookie. This method will never be invoked when |
| 277 | // LOAD_DO_NOT_SAVE_COOKIES is specified. |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 278 | virtual bool OnCanSetCookie(const URLRequest& request, |
Victor Costan | 70f8551 | 2017-11-20 16:14:46 | [diff] [blame] | 279 | const net::CanonicalCookie& cookie, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 280 | CookieOptions* options) = 0; |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 281 | |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 282 | // Called when a file access is attempted to allow the network delegate to |
satorux | ddac044 | 2017-05-29 06:06:18 | [diff] [blame] | 283 | // allow or block access to the given file path, provided in the original |
| 284 | // and absolute forms (i.e. symbolic link is resolved). It's up to |
| 285 | // subclasses of NetworkDelegate to decide which path to use for |
| 286 | // checking. Returns true if access is allowed. |
[email protected] | 4c219e2 | 2012-05-05 19:41:04 | [diff] [blame] | 287 | virtual bool OnCanAccessFile(const URLRequest& request, |
satorux | ddac044 | 2017-05-29 06:06:18 | [diff] [blame] | 288 | const base::FilePath& original_path, |
| 289 | const base::FilePath& absolute_path) const = 0; |
[email protected] | 9c8ae8c | 2012-03-09 13:13:35 | [diff] [blame] | 290 | |
[email protected] | e6d01765 | 2013-05-17 18:01:40 | [diff] [blame] | 291 | // Returns true if the given |url| has to be requested over connection that |
| 292 | // is not tracked by the server. Usually is false, unless user privacy |
| 293 | // settings block cookies from being get or set. |
Mike West | b85da8ed | 2017-08-10 14:16:46 | [diff] [blame] | 294 | virtual bool OnCanEnablePrivacyMode(const GURL& url, |
| 295 | const GURL& site_for_cookies) const = 0; |
[email protected] | e6d01765 | 2013-05-17 18:01:40 | [diff] [blame] | 296 | |
jww | 601411a | 2015-11-20 19:46:57 | [diff] [blame] | 297 | // Returns true if the embedder has enabled the experimental features, and |
| 298 | // false otherwise. |
estark | 7625d81 | 2015-10-12 20:10:41 | [diff] [blame] | 299 | virtual bool OnAreExperimentalCookieFeaturesEnabled() const = 0; |
mkwst | 0513c9d | 2015-04-01 05:53:15 | [diff] [blame] | 300 | |
jochen | 0e3b3a6 | 2014-09-16 18:31:23 | [diff] [blame] | 301 | // Called when the |referrer_url| for requesting |target_url| during handling |
| 302 | // of the |request| is does not comply with the referrer policy (e.g. a |
| 303 | // secure referrer for an insecure initial target). |
| 304 | // Returns true if the request should be cancelled. Otherwise, the referrer |
| 305 | // header is stripped from the request. |
| 306 | virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
| 307 | const URLRequest& request, |
| 308 | const GURL& target_url, |
megjablon | c175145 | 2014-12-09 19:46:47 | [diff] [blame] | 309 | const GURL& referrer_url) const = 0; |
juliatuttle | fcf4720 | 2017-05-23 15:53:02 | [diff] [blame] | 310 | |
| 311 | virtual bool OnCanQueueReportingReport(const url::Origin& origin) const = 0; |
| 312 | |
| 313 | virtual bool OnCanSendReportingReport(const url::Origin& origin) const = 0; |
| 314 | |
| 315 | virtual bool OnCanSetReportingClient(const url::Origin& origin, |
| 316 | const GURL& endpoint) const = 0; |
| 317 | |
| 318 | virtual bool OnCanUseReportingClient(const url::Origin& origin, |
| 319 | const GURL& endpoint) const = 0; |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | } // namespace net |
| 323 | |
| 324 | #endif // NET_BASE_NETWORK_DELEGATE_H_ |