| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chromecast/browser/url_request_context_factory.h" | 5 #include "chromecast/browser/url_request_context_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/threading/worker_pool.h" | 13 #include "base/threading/worker_pool.h" |
| 14 #include "chromecast/base/chromecast_switches.h" | 14 #include "chromecast/base/chromecast_switches.h" |
| 15 #include "chromecast/browser/cast_http_user_agent_settings.h" | 15 #include "chromecast/browser/cast_http_user_agent_settings.h" |
| 16 #include "chromecast/browser/cast_network_delegate.h" | 16 #include "chromecast/browser/cast_network_delegate.h" |
| 17 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/cookie_store_factory.h" | 19 #include "content/public/browser/cookie_store_factory.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
| 22 #include "net/cert/cert_verifier.h" | 22 #include "net/cert/cert_verifier.h" |
| 23 #include "net/cert/ct_policy_enforcer.h" | 23 #include "net/cert/ct_policy_enforcer.h" |
| 24 #include "net/cert/multi_log_ct_verifier.h" | 24 #include "net/cert/ct_policy_status.h" |
| 25 #include "net/cert/do_nothing_ct_verifier.h" |
| 25 #include "net/cert_net/nss_ocsp.h" | 26 #include "net/cert_net/nss_ocsp.h" |
| 26 #include "net/cookies/cookie_store.h" | 27 #include "net/cookies/cookie_store.h" |
| 27 #include "net/dns/host_resolver.h" | 28 #include "net/dns/host_resolver.h" |
| 28 #include "net/http/http_auth_handler_factory.h" | 29 #include "net/http/http_auth_handler_factory.h" |
| 29 #include "net/http/http_network_layer.h" | 30 #include "net/http/http_network_layer.h" |
| 30 #include "net/http/http_server_properties_impl.h" | 31 #include "net/http/http_server_properties_impl.h" |
| 31 #include "net/http/http_stream_factory.h" | 32 #include "net/http/http_stream_factory.h" |
| 32 #include "net/proxy/proxy_service.h" | 33 #include "net/proxy/proxy_service.h" |
| 33 #include "net/ssl/channel_id_service.h" | 34 #include "net/ssl/channel_id_service.h" |
| 34 #include "net/ssl/default_channel_id_store.h" | 35 #include "net/ssl/default_channel_id_store.h" |
| 35 #include "net/ssl/ssl_config_service_defaults.h" | 36 #include "net/ssl/ssl_config_service_defaults.h" |
| 36 #include "net/url_request/data_protocol_handler.h" | 37 #include "net/url_request/data_protocol_handler.h" |
| 37 #include "net/url_request/file_protocol_handler.h" | 38 #include "net/url_request/file_protocol_handler.h" |
| 38 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
| 39 #include "net/url_request/url_request_context_getter.h" | 40 #include "net/url_request/url_request_context_getter.h" |
| 40 #include "net/url_request/url_request_intercepting_job_factory.h" | 41 #include "net/url_request/url_request_intercepting_job_factory.h" |
| 41 #include "net/url_request/url_request_job_factory_impl.h" | 42 #include "net/url_request/url_request_job_factory_impl.h" |
| 42 | 43 |
| 43 namespace chromecast { | 44 namespace chromecast { |
| 44 namespace shell { | 45 namespace shell { |
| 45 | 46 |
| 46 namespace { | 47 namespace { |
| 47 | 48 |
| 48 const char kCookieStoreFile[] = "Cookies"; | 49 const char kCookieStoreFile[] = "Cookies"; |
| 49 | 50 |
| 51 // A CTPolicyEnforcer that accepts all certificates. |
| 52 class IgnoresCTPolicyEnforcer : public net::CTPolicyEnforcer { |
| 53 public: |
| 54 IgnoresCTPolicyEnforcer() = default; |
| 55 ~IgnoresCTPolicyEnforcer() override = default; |
| 56 |
| 57 net::ct::CertPolicyCompliance DoesConformToCertPolicy( |
| 58 net::X509Certificate* cert, |
| 59 const net::SCTList& verified_scts, |
| 60 const net::NetLogWithSource& net_log) override { |
| 61 return net::ct::CertPolicyCompliance::CERT_POLICY_COMPLIES_VIA_SCTS; |
| 62 } |
| 63 |
| 64 net::ct::EVPolicyCompliance DoesConformToCTEVPolicy( |
| 65 net::X509Certificate* cert, |
| 66 const net::ct::EVCertsWhitelist* ev_whitelist, |
| 67 const net::SCTList& verified_scts, |
| 68 const net::NetLogWithSource& net_log) override { |
| 69 return net::ct::EVPolicyCompliance::EV_POLICY_DOES_NOT_APPLY; |
| 70 } |
| 71 }; |
| 72 |
| 50 } // namespace | 73 } // namespace |
| 51 | 74 |
| 52 // Private classes to expose URLRequestContextGetter that call back to the | 75 // Private classes to expose URLRequestContextGetter that call back to the |
| 53 // URLRequestContextFactory to create the URLRequestContext on demand. | 76 // URLRequestContextFactory to create the URLRequestContext on demand. |
| 54 // | 77 // |
| 55 // The URLRequestContextFactory::URLRequestContextGetter class is used for both | 78 // The URLRequestContextFactory::URLRequestContextGetter class is used for both |
| 56 // the system and media URLRequestCotnexts. | 79 // the system and media URLRequestCotnexts. |
| 57 class URLRequestContextFactory::URLRequestContextGetter | 80 class URLRequestContextFactory::URLRequestContextGetter |
| 58 : public net::URLRequestContextGetter { | 81 : public net::URLRequestContextGetter { |
| 59 public: | 82 public: |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 221 } |
| 199 | 222 |
| 200 void URLRequestContextFactory::InitializeSystemContextDependencies() { | 223 void URLRequestContextFactory::InitializeSystemContextDependencies() { |
| 201 if (system_dependencies_initialized_) | 224 if (system_dependencies_initialized_) |
| 202 return; | 225 return; |
| 203 | 226 |
| 204 host_resolver_ = net::HostResolver::CreateDefaultResolver(NULL); | 227 host_resolver_ = net::HostResolver::CreateDefaultResolver(NULL); |
| 205 cert_verifier_ = net::CertVerifier::CreateDefault(); | 228 cert_verifier_ = net::CertVerifier::CreateDefault(); |
| 206 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 229 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
| 207 transport_security_state_.reset(new net::TransportSecurityState()); | 230 transport_security_state_.reset(new net::TransportSecurityState()); |
| 208 cert_transparency_verifier_.reset(new net::MultiLogCTVerifier()); | 231 // Certificate transparency is current disabled for Chromecast. |
| 209 ct_policy_enforcer_.reset(new net::CTPolicyEnforcer()); | 232 cert_transparency_verifier_.reset(new net::DoNothingCTVerifier()); |
| 233 ct_policy_enforcer_.reset(new IgnoresCTPolicyEnforcer()); |
| 210 | 234 |
| 211 http_auth_handler_factory_ = | 235 http_auth_handler_factory_ = |
| 212 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get()); | 236 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get()); |
| 213 | 237 |
| 214 // TODO(lcwu): http://crbug.com/392352. For performance reasons, | 238 // TODO(lcwu): http://crbug.com/392352. For performance reasons, |
| 215 // a persistent (on-disk) HttpServerProperties might be desirable | 239 // a persistent (on-disk) HttpServerProperties might be desirable |
| 216 // in the future. | 240 // in the future. |
| 217 http_server_properties_.reset(new net::HttpServerPropertiesImpl); | 241 http_server_properties_.reset(new net::HttpServerPropertiesImpl); |
| 218 | 242 |
| 219 proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver( | 243 proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver( |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 422 |
| 399 void URLRequestContextFactory::InitializeNetworkDelegates() { | 423 void URLRequestContextFactory::InitializeNetworkDelegates() { |
| 400 app_network_delegate_->Initialize(false); | 424 app_network_delegate_->Initialize(false); |
| 401 LOG(INFO) << "Initialized app network delegate."; | 425 LOG(INFO) << "Initialized app network delegate."; |
| 402 system_network_delegate_->Initialize(false); | 426 system_network_delegate_->Initialize(false); |
| 403 LOG(INFO) << "Initialized system network delegate."; | 427 LOG(INFO) << "Initialized system network delegate."; |
| 404 } | 428 } |
| 405 | 429 |
| 406 } // namespace shell | 430 } // namespace shell |
| 407 } // namespace chromecast | 431 } // namespace chromecast |
| OLD | NEW |