1 // Copyright 2014 The Chromium OS 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 <brillo/http/http_transport.h> 6 7 #include <brillo/http/http_transport_curl.h> 8 9 namespace brillo { 10 namespace http { 11 12 const char kErrorDomain[] = "http_transport"; 13 const char kDirectProxy[] = "direct://"; 14 CreateDefault()15std::shared_ptr<Transport> Transport::CreateDefault() { 16 return std::make_shared<http::curl::Transport>(std::make_shared<CurlApi>()); 17 } 18 CreateDefaultWithProxy(const std::string & proxy)19std::shared_ptr<Transport> Transport::CreateDefaultWithProxy( 20 const std::string& proxy) { 21 if (proxy.empty() || proxy == kDirectProxy) { 22 return CreateDefault(); 23 } else { 24 return std::make_shared<http::curl::Transport>(std::make_shared<CurlApi>(), 25 proxy); 26 } 27 } 28 CertificateToPath(Transport::Certificate cert)29base::FilePath Transport::CertificateToPath(Transport::Certificate cert) { 30 const char* str; 31 switch (cert) { 32 case Certificate::kDefault: 33 str = 34 #ifdef __ANDROID__ 35 "/system/etc/security/cacerts_google"; 36 #else 37 "/usr/share/chromeos-ca-certificates"; 38 #endif 39 break; 40 case Certificate::kHermesProd: 41 str = "/usr/share/hermes-ca-certificates/prod"; 42 break; 43 case Certificate::kHermesTest: 44 str = "/usr/share/hermes-ca-certificates/test"; 45 break; 46 case Certificate::kNss: 47 str = "/etc/ssl/certs"; 48 break; 49 default: 50 CHECK(false) << "Invalid certificate"; 51 break; 52 } 53 return base::FilePath(str); 54 } 55 56 } // namespace http 57 } // namespace brillo 58