1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/url_request/url_request_context.h" 6 7 #include "base/string_util.h" 8 #include "net/base/cookie_store.h" 9 #include "net/base/host_resolver.h" 10 #include "net/ftp/ftp_transaction_factory.h" 11 #include "net/http/http_transaction_factory.h" 12 13 namespace net { 14 15 URLRequestContext::URLRequestContext() 16 : is_main_(false), 17 net_log_(NULL), 18 host_resolver_(NULL), 19 cert_verifier_(NULL), 20 dnsrr_resolver_(NULL), 21 dns_cert_checker_(NULL), 22 http_auth_handler_factory_(NULL), 23 network_delegate_(NULL), 24 cookie_policy_(NULL), 25 transport_security_state_(NULL), 26 http_transaction_factory_(NULL), 27 ftp_transaction_factory_(NULL) 28 #ifdef ANDROID 29 , valid_uid_(false), 30 calling_uid_(0) 31 #endif 32 {} 33 34 void URLRequestContext::CopyFrom(URLRequestContext* other) { 35 // Copy URLRequestContext parameters. 36 // Do not copy is_main_. 37 set_net_log(other->net_log()); 38 set_host_resolver(other->host_resolver()); 39 set_cert_verifier(other->cert_verifier()); 40 set_dnsrr_resolver(other->dnsrr_resolver()); 41 set_dns_cert_checker(other->dns_cert_checker()); 42 set_http_auth_handler_factory(other->http_auth_handler_factory()); 43 set_proxy_service(other->proxy_service()); 44 set_ssl_config_service(other->ssl_config_service()); 45 set_network_delegate(other->network_delegate()); 46 set_cookie_store(other->cookie_store()); 47 set_cookie_policy(other->cookie_policy()); 48 set_transport_security_state(other->transport_security_state()); 49 // FTPAuthCache is unique per context. 50 set_accept_language(other->accept_language()); 51 set_accept_charset(other->accept_charset()); 52 set_referrer_charset(other->referrer_charset()); 53 set_http_transaction_factory(other->http_transaction_factory()); 54 set_ftp_transaction_factory(other->ftp_transaction_factory()); 55 #ifdef ANDROID 56 calling_uid_ = 0; 57 valid_uid_ = other->getUID(&calling_uid_); 58 #endif 59 } 60 61 void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { 62 cookie_store_ = cookie_store; 63 } 64 65 const std::string& URLRequestContext::GetUserAgent(const GURL& url) const { 66 return EmptyString(); 67 } 68 69 bool URLRequestContext::IsSNIAvailable() const { 70 if (!ssl_config_service_) 71 return false; 72 73 SSLConfig ssl_config; 74 ssl_config_service_->GetSSLConfig(&ssl_config); 75 return ssl_config.tls1_enabled; 76 } 77 78 #ifdef ANDROID 79 void URLRequestContext::setUID(uid_t uid) { 80 valid_uid_ = true; 81 calling_uid_ = uid; 82 } 83 84 bool URLRequestContext::getUID(uid_t *uid) const { 85 if (!valid_uid_) { 86 return false; 87 } 88 *uid = calling_uid_; 89 return true; 90 } 91 #endif 92 93 URLRequestContext::~URLRequestContext() { 94 } 95 96 } // namespace net 97