[email protected] | 9c4eff2 | 2012-03-20 22:42:29 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
| 5 | // This class represents contextual information (cookies, cache, etc.) |
ricea | 29e27d1 | 2016-08-10 02:09:18 | [diff] [blame] | 6 | // that's necessary when processing resource requests. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 7 | |
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 8 | #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
| 9 | #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 10 | |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 11 | #include <stdint.h> |
danakj | 8522a25b | 2016-04-16 00:17:36 | [diff] [blame] | 12 | #include <memory> |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 13 | #include <set> |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 14 | #include <string> |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 15 | |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 16 | #include "base/memory/raw_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 17 | #include "base/memory/ref_counted.h" |
[email protected] | 18590f2 | 2011-07-29 16:41:28 | [diff] [blame] | 18 | #include "base/memory/weak_ptr.h" |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 19 | #include "base/threading/thread_checker.h" |
Yutaka Hirano | 53c9e85 | 2022-03-29 18:13:31 | [diff] [blame] | 20 | #include "base/types/pass_key.h" |
Nicolas Ouellet-Payeur | 6e833b5 | 2019-07-02 17:18:08 | [diff] [blame] | 21 | #include "build/build_config.h" |
Yuta Hijikata | 101ed2a | 2020-11-18 07:50:39 | [diff] [blame] | 22 | #include "build/chromeos_buildflags.h" |
[email protected] | 172da1b | 2011-08-12 15:52:26 | [diff] [blame] | 23 | #include "net/base/net_export.h" |
Stefano Duo | 44af16c | 2022-02-10 15:23:11 | [diff] [blame] | 24 | #include "net/base/network_change_notifier.h" |
[email protected] | 2ca01e5 | 2013-10-31 22:05:19 | [diff] [blame] | 25 | #include "net/base/request_priority.h" |
ainozaki | 7eefe91 | 2021-10-12 03:40:26 | [diff] [blame] | 26 | #include "net/log/net_log_source.h" |
Scott Violet | 0caaaf43 | 2018-03-24 00:43:59 | [diff] [blame] | 27 | #include "net/net_buildflags.h" |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 28 | #include "net/traffic_annotation/network_traffic_annotation.h" |
[email protected] | 8a26ff6 | 2012-08-24 21:49:20 | [diff] [blame] | 29 | #include "net/url_request/url_request.h" |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 30 | #include "third_party/abseil-cpp/absl/types/optional.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 31 | |
[email protected] | 8ac1a75 | 2008-07-31 19:40:37 | [diff] [blame] | 32 | namespace net { |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 33 | class CertVerifier; |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 34 | class CookieStore; |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 35 | class CTPolicyEnforcer; |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 36 | class HostResolver; |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 37 | class HttpAuthHandlerFactory; |
Matt Menke | 30a878c | 2021-07-20 22:25:09 | [diff] [blame] | 38 | struct HttpNetworkSessionContext; |
| 39 | struct HttpNetworkSessionParams; |
Matt Menke | ce5d76537 | 2021-08-17 18:24:12 | [diff] [blame] | 40 | class HttpServerProperties; |
[email protected] | b65ce094 | 2009-03-16 20:13:33 | [diff] [blame] | 41 | class HttpTransactionFactory; |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 42 | class HttpUserAgentSettings; |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame] | 43 | class NetLog; |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 44 | class NetworkDelegate; |
Yutaka Hirano | 11a9834 | 2022-03-29 16:26:28 | [diff] [blame] | 45 | class NetworkErrorLoggingService; |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 46 | class NetworkQualityEstimator; |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame] | 47 | class ProxyDelegate; |
Nicolas Arciniega | 8ec5bfa | 2020-03-20 05:07:26 | [diff] [blame] | 48 | class ProxyResolutionService; |
Victor Vasiliev | 7752898d | 2019-11-14 21:30:22 | [diff] [blame] | 49 | class QuicContext; |
Yutaka Hirano | 11a9834 | 2022-03-29 16:26:28 | [diff] [blame] | 50 | class ReportingService; |
Chris Thompson | f31b249 | 2020-07-21 05:47:42 | [diff] [blame] | 51 | class SCTAuditingDelegate; |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 52 | class SSLConfigService; |
Matt Menke | ce5d76537 | 2021-08-17 18:24:12 | [diff] [blame] | 53 | class TransportSecurityState; |
[email protected] | eaadd905 | 2009-06-23 18:02:23 | [diff] [blame] | 54 | class URLRequest; |
[email protected] | a8c1e745 | 2011-05-14 06:17:07 | [diff] [blame] | 55 | class URLRequestJobFactory; |
[email protected] | a73a280 | 2012-05-02 19:20:15 | [diff] [blame] | 56 | class URLRequestThrottlerManager; |
Yutaka Hirano | 11a9834 | 2022-03-29 16:26:28 | [diff] [blame] | 57 | class URLRequestContextStorage; |
| 58 | class URLRequestContextBuilder; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 59 | |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 60 | #if BUILDFLAG(ENABLE_REPORTING) |
Julia Tuttle | cba7d22 | 2018-02-23 19:37:27 | [diff] [blame] | 61 | class NetworkErrorLoggingService; |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 62 | class ReportingService; |
| 63 | #endif // BUILDFLAG(ENABLE_REPORTING) |
| 64 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 65 | // Subclass to provide application-specific context for URLRequest |
ricea | 29e27d1 | 2016-08-10 02:09:18 | [diff] [blame] | 66 | // instances. URLRequestContext does not own these member variables, since they |
| 67 | // may be shared with other contexts. URLRequestContextStorage can be used for |
| 68 | // automatic lifetime management. Most callers should use an existing |
| 69 | // URLRequestContext rather than creating a new one, as guaranteeing that the |
| 70 | // URLRequestContext is destroyed before its members can be difficult. |
Kenichi Ishibashi | a92b965 | 2021-09-10 23:43:44 | [diff] [blame] | 71 | class NET_EXPORT URLRequestContext { |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 72 | public: |
Yutaka Hirano | 53c9e85 | 2022-03-29 18:13:31 | [diff] [blame] | 73 | // URLRequestContext must be created by URLRequestContextBuilder. |
| 74 | explicit URLRequestContext(base::PassKey<URLRequestContextBuilder> pass_key); |
Peter Boström | 293b134 | 2021-09-22 17:31:43 | [diff] [blame] | 75 | |
| 76 | URLRequestContext(const URLRequestContext&) = delete; |
| 77 | URLRequestContext& operator=(const URLRequestContext&) = delete; |
| 78 | |
Kenichi Ishibashi | a92b965 | 2021-09-10 23:43:44 | [diff] [blame] | 79 | virtual ~URLRequestContext(); |
[email protected] | 18590f2 | 2011-07-29 16:41:28 | [diff] [blame] | 80 | |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 81 | // May return nullptr if this context doesn't have an associated network |
| 82 | // session. |
Matt Menke | 30a878c | 2021-07-20 22:25:09 | [diff] [blame] | 83 | const HttpNetworkSessionParams* GetNetworkSessionParams() const; |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 84 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 85 | // May return nullptr if this context doesn't have an associated network |
| 86 | // session. |
Matt Menke | 30a878c | 2021-07-20 22:25:09 | [diff] [blame] | 87 | const HttpNetworkSessionContext* GetNetworkSessionContext() const; |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame] | 88 | |
Yuta Hijikata | 101ed2a | 2020-11-18 07:50:39 | [diff] [blame] | 89 | // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is |
| 90 | // complete. |
Xiaohan Wang | 2a6845b | 2022-01-08 04:40:57 | [diff] [blame] | 91 | #if !BUILDFLAG(IS_WIN) && \ |
| 92 | !(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 93 | // This function should not be used in Chromium, please use the version with |
| 94 | // NetworkTrafficAnnotationTag in the future. |
Nicolas Ouellet-Payeur | 6e833b5 | 2019-07-02 17:18:08 | [diff] [blame] | 95 | // |
| 96 | // The unannotated method is not available on desktop Linux + Windows. It's |
| 97 | // available on other platforms, since we only audit network annotations on |
| 98 | // Linux & Windows. |
danakj | 8522a25b | 2016-04-16 00:17:36 | [diff] [blame] | 99 | std::unique_ptr<URLRequest> CreateRequest( |
| 100 | const GURL& url, |
| 101 | RequestPriority priority, |
| 102 | URLRequest::Delegate* delegate) const; |
Nicolas Ouellet-Payeur | 6e833b5 | 2019-07-02 17:18:08 | [diff] [blame] | 103 | #endif |
[email protected] | 8a26ff6 | 2012-08-24 21:49:20 | [diff] [blame] | 104 | |
Matt Menke | fe9a9df | 2021-09-08 17:55:24 | [diff] [blame] | 105 | // `traffic_annotation` is metadata about the network traffic send via this |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 106 | // URLRequest, see net::DefineNetworkTrafficAnnotation. Note that: |
| 107 | // - net provides the API for tagging requests with an opaque identifier. |
Nicolas Ouellet-Payeur | 326a269 | 2021-07-15 01:17:33 | [diff] [blame] | 108 | // - chrome/browser/privacy/traffic_annotation.proto contains the Chrome |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 109 | // specific .proto describing the verbose annotation format that Chrome's |
| 110 | // callsites are expected to follow. |
| 111 | // - tools/traffic_annotation/ contains sample and template for annotation and |
| 112 | // tools will be added for verification following crbug.com/690323. |
Matt Menke | fe9a9df | 2021-09-08 17:55:24 | [diff] [blame] | 113 | // |
| 114 | // `is_for_websockets` should be true iff this was created for use by a |
| 115 | // websocket. HTTP/HTTPS requests fail if it's true, and WS/WSS requests fail |
| 116 | // if it's false. This is to protect against broken consumers. |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 117 | // |
| 118 | // `net_log_source_id` is used to construct NetLogWithSource using the |
| 119 | // specified Source ID. This method is expected to be used when URLRequest |
| 120 | // wants to take over existing NetLogSource. |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 121 | std::unique_ptr<URLRequest> CreateRequest( |
| 122 | const GURL& url, |
| 123 | RequestPriority priority, |
| 124 | URLRequest::Delegate* delegate, |
Matt Menke | fe9a9df | 2021-09-08 17:55:24 | [diff] [blame] | 125 | NetworkTrafficAnnotationTag traffic_annotation, |
ainozaki | b220727 | 2021-09-17 01:30:35 | [diff] [blame] | 126 | bool is_for_websockets = false, |
ainozaki | 7eefe91 | 2021-10-12 03:40:26 | [diff] [blame] | 127 | const absl::optional<net::NetLogSource> net_log_source = |
| 128 | absl::nullopt) const; |
rhalavati | a9b551d | 2017-02-09 12:03:00 | [diff] [blame] | 129 | |
| 130 | NetLog* net_log() const { return net_log_; } |
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 131 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 132 | HostResolver* host_resolver() const { |
[email protected] | 8a00f00a | 2009-06-12 00:49:38 | [diff] [blame] | 133 | return host_resolver_; |
| 134 | } |
| 135 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 136 | CertVerifier* cert_verifier() const { |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 137 | return cert_verifier_; |
| 138 | } |
| 139 | |
[email protected] | 63de95b | 2008-12-10 04:11:27 | [diff] [blame] | 140 | // Get the proxy service for this context. |
Nicolas Arciniega | 8ec5bfa | 2020-03-20 05:07:26 | [diff] [blame] | 141 | ProxyResolutionService* proxy_resolution_service() const { |
Lily Houghton | 8c2f97d | 2018-01-22 05:06:59 | [diff] [blame] | 142 | return proxy_resolution_service_; |
| 143 | } |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 144 | |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame] | 145 | ProxyDelegate* proxy_delegate() const { return proxy_delegate_; } |
Wojciech Dzierżanowski | 1f82356 | 2019-01-18 11:26:00 | [diff] [blame] | 146 | |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 147 | // Get the ssl config service for this context. |
Ryan Sleevi | b8449e0 | 2018-07-15 04:31:07 | [diff] [blame] | 148 | SSLConfigService* ssl_config_service() const { return ssl_config_service_; } |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 149 | |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 150 | // Gets the HTTP Authentication Handler Factory for this context. |
| 151 | // The factory is only valid for the lifetime of this URLRequestContext |
[email protected] | ef2bf42 | 2012-05-11 03:27:09 | [diff] [blame] | 152 | HttpAuthHandlerFactory* http_auth_handler_factory() const { |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 153 | return http_auth_handler_factory_; |
| 154 | } |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 155 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 156 | // Gets the http transaction factory for this context. |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 157 | HttpTransactionFactory* http_transaction_factory() const { |
[email protected] | db8f44c | 2008-12-13 04:52:01 | [diff] [blame] | 158 | return http_transaction_factory_; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 159 | } |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 160 | |
[email protected] | 0651b81 | 2011-02-24 00:22:50 | [diff] [blame] | 161 | NetworkDelegate* network_delegate() const { return network_delegate_; } |
[email protected] | d05ef99c | 2011-02-01 21:38:16 | [diff] [blame] | 162 | |
bnc | 525e175a | 2016-06-20 12:36:40 | [diff] [blame] | 163 | HttpServerProperties* http_server_properties() const { |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 164 | return http_server_properties_; |
| 165 | } |
| 166 | |
[email protected] | be6fca6c | 2010-01-30 21:48:57 | [diff] [blame] | 167 | // Gets the cookie store for this context (may be null, in which case |
| 168 | // cookies are not stored). |
mmenke | 606c59c | 2016-03-07 18:20:55 | [diff] [blame] | 169 | CookieStore* cookie_store() const { return cookie_store_; } |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 170 | |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 171 | TransportSecurityState* transport_security_state() const { |
[email protected] | 284303b6 | 2013-11-28 15:11:54 | [diff] [blame] | 172 | return transport_security_state_; |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 173 | } |
[email protected] | a9cea754 | 2009-05-20 04:30:23 | [diff] [blame] | 174 | |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 175 | CTPolicyEnforcer* ct_policy_enforcer() const { return ct_policy_enforcer_; } |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 176 | |
Chris Thompson | f31b249 | 2020-07-21 05:47:42 | [diff] [blame] | 177 | SCTAuditingDelegate* sct_auditing_delegate() const { |
| 178 | return sct_auditing_delegate_; |
| 179 | } |
Chris Thompson | f31b249 | 2020-07-21 05:47:42 | [diff] [blame] | 180 | |
[email protected] | a8c1e745 | 2011-05-14 06:17:07 | [diff] [blame] | 181 | const URLRequestJobFactory* job_factory() const { return job_factory_; } |
[email protected] | a8c1e745 | 2011-05-14 06:17:07 | [diff] [blame] | 182 | |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 183 | // May return nullptr. |
[email protected] | a73a280 | 2012-05-02 19:20:15 | [diff] [blame] | 184 | URLRequestThrottlerManager* throttler_manager() const { |
| 185 | return throttler_manager_; |
| 186 | } |
[email protected] | a73a280 | 2012-05-02 19:20:15 | [diff] [blame] | 187 | |
Victor Vasiliev | 7752898d | 2019-11-14 21:30:22 | [diff] [blame] | 188 | QuicContext* quic_context() const { return quic_context_; } |
Victor Vasiliev | 7752898d | 2019-11-14 21:30:22 | [diff] [blame] | 189 | |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 190 | // Gets the URLRequest objects that hold a reference to this |
| 191 | // URLRequestContext. |
Helen Li | f5e4a75 | 2018-01-02 16:03:02 | [diff] [blame] | 192 | std::set<const URLRequest*>* url_requests() const { |
| 193 | return url_requests_.get(); |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 194 | } |
| 195 | |
[email protected] | 42455949 | 2014-07-22 00:27:40 | [diff] [blame] | 196 | // CHECKs that no URLRequests using this context remain. Subclasses should |
| 197 | // additionally call AssertNoURLRequests() within their own destructor, |
| 198 | // prior to implicit destruction of subclass-owned state. |
[email protected] | 1e714bba | 2012-04-10 17:01:05 | [diff] [blame] | 199 | void AssertNoURLRequests() const; |
| 200 | |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 201 | // Get the underlying |HttpUserAgentSettings| implementation that provides |
[email protected] | 84f0543 | 2013-03-15 01:00:12 | [diff] [blame] | 202 | // the HTTP Accept-Language and User-Agent header values. |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 203 | const HttpUserAgentSettings* http_user_agent_settings() const { |
| 204 | return http_user_agent_settings_; |
| 205 | } |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 206 | |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 207 | // Gets the NetworkQualityEstimator associated with this context. |
| 208 | // May return nullptr. |
| 209 | NetworkQualityEstimator* network_quality_estimator() const { |
| 210 | return network_quality_estimator_; |
| 211 | } |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 212 | |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 213 | #if BUILDFLAG(ENABLE_REPORTING) |
juliatuttle | 2b8dd2d1 | 2017-04-12 21:27:41 | [diff] [blame] | 214 | ReportingService* reporting_service() const { return reporting_service_; } |
juliatuttle | 2b8dd2d1 | 2017-04-12 21:27:41 | [diff] [blame] | 215 | |
Julia Tuttle | cba7d22 | 2018-02-23 19:37:27 | [diff] [blame] | 216 | NetworkErrorLoggingService* network_error_logging_service() const { |
| 217 | return network_error_logging_service_; |
Julia Tuttle | f9b7406 | 2017-07-27 14:44:05 | [diff] [blame] | 218 | } |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 219 | #endif // BUILDFLAG(ENABLE_REPORTING) |
Julia Tuttle | f9b7406 | 2017-07-27 14:44:05 | [diff] [blame] | 220 | |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 221 | bool enable_brotli() const { return enable_brotli_; } |
| 222 | |
mgersh | d21d6d14 | 2016-12-14 23:06:36 | [diff] [blame] | 223 | // Returns current value of the |check_cleartext_permitted| flag. |
| 224 | bool check_cleartext_permitted() const { return check_cleartext_permitted_; } |
| 225 | |
Matt Menke | ee10f041 | 2020-05-14 14:16:03 | [diff] [blame] | 226 | bool require_network_isolation_key() const { |
| 227 | return require_network_isolation_key_; |
| 228 | } |
| 229 | |
Stefano Duo | 44af16c | 2022-02-10 15:23:11 | [diff] [blame] | 230 | // If != NetworkChangeNotifier::kInvalidNetworkHandle, the network which this |
| 231 | // context has been bound to. |
| 232 | NetworkChangeNotifier::NetworkHandle bound_network() const { |
| 233 | return bound_network_; |
| 234 | } |
Stefano Duo | 44af16c | 2022-02-10 15:23:11 | [diff] [blame] | 235 | |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 236 | void AssertCalledOnValidThread() { |
| 237 | DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
| 238 | } |
| 239 | |
Yutaka Hirano | 11a9834 | 2022-03-29 16:26:28 | [diff] [blame] | 240 | // DEPRECATED: Do not use this even in tests. This is for a legacy use. |
| 241 | void SetJobFactoryForTesting(const URLRequestJobFactory* job_factory) { |
| 242 | job_factory_ = job_factory; |
| 243 | } |
| 244 | |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 245 | private: |
Yutaka Hirano | 11a9834 | 2022-03-29 16:26:28 | [diff] [blame] | 246 | friend class URLRequestContextStorage; |
| 247 | friend class URLRequestContextBuilder; |
| 248 | void set_net_log(NetLog* net_log) { net_log_ = net_log; } |
| 249 | void set_host_resolver(HostResolver* host_resolver) { |
| 250 | DCHECK(host_resolver); |
| 251 | host_resolver_ = host_resolver; |
| 252 | } |
| 253 | void set_cert_verifier(CertVerifier* cert_verifier) { |
| 254 | cert_verifier_ = cert_verifier; |
| 255 | } |
| 256 | void set_proxy_resolution_service( |
| 257 | ProxyResolutionService* proxy_resolution_service) { |
| 258 | proxy_resolution_service_ = proxy_resolution_service; |
| 259 | } |
| 260 | void set_proxy_delegate(ProxyDelegate* proxy_delegate) { |
| 261 | proxy_delegate_ = proxy_delegate; |
| 262 | } |
| 263 | void set_ssl_config_service(SSLConfigService* service) { |
| 264 | ssl_config_service_ = service; |
| 265 | } |
| 266 | void set_http_auth_handler_factory(HttpAuthHandlerFactory* factory) { |
| 267 | http_auth_handler_factory_ = factory; |
| 268 | } |
| 269 | void set_http_transaction_factory(HttpTransactionFactory* factory) { |
| 270 | http_transaction_factory_ = factory; |
| 271 | } |
| 272 | void set_network_delegate(NetworkDelegate* network_delegate) { |
| 273 | network_delegate_ = network_delegate; |
| 274 | } |
| 275 | void set_http_server_properties( |
| 276 | HttpServerProperties* http_server_properties) { |
| 277 | http_server_properties_ = http_server_properties; |
| 278 | } |
| 279 | void set_cookie_store(CookieStore* cookie_store); |
| 280 | void set_transport_security_state(TransportSecurityState* state) { |
| 281 | transport_security_state_ = state; |
| 282 | } |
| 283 | void set_ct_policy_enforcer(CTPolicyEnforcer* enforcer) { |
| 284 | ct_policy_enforcer_ = enforcer; |
| 285 | } |
| 286 | void set_sct_auditing_delegate(SCTAuditingDelegate* delegate) { |
| 287 | sct_auditing_delegate_ = delegate; |
| 288 | } |
| 289 | void set_job_factory(const URLRequestJobFactory* job_factory) { |
| 290 | job_factory_ = job_factory; |
| 291 | } |
| 292 | void set_throttler_manager(URLRequestThrottlerManager* throttler_manager) { |
| 293 | throttler_manager_ = throttler_manager; |
| 294 | } |
| 295 | void set_quic_context(QuicContext* quic_context) { |
| 296 | quic_context_ = quic_context; |
| 297 | } |
| 298 | void set_http_user_agent_settings( |
| 299 | const HttpUserAgentSettings* http_user_agent_settings) { |
| 300 | http_user_agent_settings_ = http_user_agent_settings; |
| 301 | } |
| 302 | void set_network_quality_estimator( |
| 303 | NetworkQualityEstimator* network_quality_estimator) { |
| 304 | network_quality_estimator_ = network_quality_estimator; |
| 305 | } |
| 306 | #if BUILDFLAG(ENABLE_REPORTING) |
| 307 | void set_reporting_service(ReportingService* reporting_service) { |
| 308 | reporting_service_ = reporting_service; |
| 309 | } |
| 310 | void set_network_error_logging_service( |
| 311 | NetworkErrorLoggingService* network_error_logging_service) { |
| 312 | network_error_logging_service_ = network_error_logging_service; |
| 313 | } |
| 314 | #endif // BUILDFLAG(ENABLE_REPORTING) |
| 315 | void set_enable_brotli(bool enable_brotli) { enable_brotli_ = enable_brotli; } |
| 316 | void set_check_cleartext_permitted(bool check_cleartext_permitted) { |
| 317 | check_cleartext_permitted_ = check_cleartext_permitted; |
| 318 | } |
| 319 | void set_require_network_isolation_key(bool require_network_isolation_key) { |
| 320 | require_network_isolation_key_ = require_network_isolation_key; |
| 321 | } |
| 322 | void set_bound_network(NetworkChangeNotifier::NetworkHandle network) { |
| 323 | bound_network_ = network; |
| 324 | } |
| 325 | |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 326 | // Ownership for these members are not defined here. Clients should either |
| 327 | // provide storage elsewhere or have a subclass take ownership. |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 328 | raw_ptr<NetLog> net_log_; |
| 329 | raw_ptr<HostResolver> host_resolver_; |
| 330 | raw_ptr<CertVerifier> cert_verifier_; |
| 331 | raw_ptr<HttpAuthHandlerFactory> http_auth_handler_factory_; |
| 332 | raw_ptr<ProxyResolutionService> proxy_resolution_service_; |
| 333 | raw_ptr<ProxyDelegate> proxy_delegate_; |
| 334 | raw_ptr<SSLConfigService> ssl_config_service_; |
| 335 | raw_ptr<NetworkDelegate> network_delegate_; |
| 336 | raw_ptr<HttpServerProperties> http_server_properties_; |
| 337 | raw_ptr<const HttpUserAgentSettings> http_user_agent_settings_; |
| 338 | raw_ptr<CookieStore> cookie_store_; |
| 339 | raw_ptr<TransportSecurityState> transport_security_state_; |
| 340 | raw_ptr<CTPolicyEnforcer> ct_policy_enforcer_; |
| 341 | raw_ptr<SCTAuditingDelegate> sct_auditing_delegate_; |
| 342 | raw_ptr<HttpTransactionFactory> http_transaction_factory_; |
| 343 | raw_ptr<const URLRequestJobFactory> job_factory_; |
| 344 | raw_ptr<URLRequestThrottlerManager> throttler_manager_; |
| 345 | raw_ptr<QuicContext> quic_context_; |
| 346 | raw_ptr<NetworkQualityEstimator> network_quality_estimator_; |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 347 | #if BUILDFLAG(ENABLE_REPORTING) |
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 348 | raw_ptr<ReportingService> reporting_service_; |
| 349 | raw_ptr<NetworkErrorLoggingService> network_error_logging_service_; |
Julia Tuttle | 3f9acac | 2017-11-20 22:06:30 | [diff] [blame] | 350 | #endif // BUILDFLAG(ENABLE_REPORTING) |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 351 | |
Helen Li | f5e4a75 | 2018-01-02 16:03:02 | [diff] [blame] | 352 | std::unique_ptr<std::set<const URLRequest*>> url_requests_; |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame] | 353 | |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 354 | // Enables Brotli Content-Encoding support. |
Tsuyoshi Horo | 8e0dfac2 | 2022-06-09 01:42:57 | [diff] [blame] | 355 | bool enable_brotli_ = false; |
mgersh | d21d6d14 | 2016-12-14 23:06:36 | [diff] [blame] | 356 | // Enables checking system policy before allowing a cleartext http or ws |
| 357 | // request. Only used on Android. |
Tsuyoshi Horo | 8e0dfac2 | 2022-06-09 01:42:57 | [diff] [blame] | 358 | bool check_cleartext_permitted_ = false; |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 359 | |
Matt Menke | ee10f041 | 2020-05-14 14:16:03 | [diff] [blame] | 360 | // Triggers a DCHECK if a NetworkIsolationKey/IsolationInfo is not provided to |
| 361 | // a request when true. |
Tsuyoshi Horo | 8e0dfac2 | 2022-06-09 01:42:57 | [diff] [blame] | 362 | bool require_network_isolation_key_ = false; |
Matt Menke | ee10f041 | 2020-05-14 14:16:03 | [diff] [blame] | 363 | |
Stefano Duo | 44af16c | 2022-02-10 15:23:11 | [diff] [blame] | 364 | NetworkChangeNotifier::NetworkHandle bound_network_; |
| 365 | |
gab | 47aa7da | 2017-06-02 16:09:43 | [diff] [blame] | 366 | THREAD_CHECKER(thread_checker_); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 367 | }; |
| 368 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 369 | } // namespace net |
| 370 | |
[email protected] | 43530b3 | 2008-08-04 22:21:34 | [diff] [blame] | 371 | #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |