OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/proxy/proxy_config_service_ios.h" | 5 #include "net/proxy/proxy_config_service_ios.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #include <CFNetwork/CFProxySupport.h> | 8 #include <CFNetwork/CFProxySupport.h> |
9 | 9 |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 void GetCurrentProxyConfig(ProxyConfig* config) { | 39 void GetCurrentProxyConfig(ProxyConfig* config) { |
40 base::ScopedCFTypeRef<CFDictionaryRef> config_dict( | 40 base::ScopedCFTypeRef<CFDictionaryRef> config_dict( |
41 CFNetworkCopySystemProxySettings()); | 41 CFNetworkCopySystemProxySettings()); |
42 DCHECK(config_dict); | 42 DCHECK(config_dict); |
43 | 43 |
44 // Auto-detect is not supported. | 44 // Auto-detect is not supported. |
45 // The kCFNetworkProxiesProxyAutoDiscoveryEnable key is not available on iOS. | 45 // The kCFNetworkProxiesProxyAutoDiscoveryEnable key is not available on iOS. |
46 | 46 |
47 // PAC file | 47 // PAC file |
48 | 48 |
49 if (GetBoolFromDictionary(config_dict.get(), | 49 if (GetBoolFromDictionary( |
50 kCFNetworkProxiesProxyAutoConfigEnable, | 50 config_dict.get(), kCFNetworkProxiesProxyAutoConfigEnable, false)) { |
51 false)) { | |
52 CFStringRef pac_url_ref = base::mac::GetValueFromDictionary<CFStringRef>( | 51 CFStringRef pac_url_ref = base::mac::GetValueFromDictionary<CFStringRef>( |
53 config_dict.get(), kCFNetworkProxiesProxyAutoConfigURLString); | 52 config_dict.get(), kCFNetworkProxiesProxyAutoConfigURLString); |
54 if (pac_url_ref) | 53 if (pac_url_ref) |
55 config->set_pac_url(GURL(base::SysCFStringRefToUTF8(pac_url_ref))); | 54 config->set_pac_url(GURL(base::SysCFStringRefToUTF8(pac_url_ref))); |
56 } | 55 } |
57 | 56 |
58 // Proxies (for now http). | 57 // Proxies (for now http). |
59 | 58 |
60 // The following keys are not available on iOS: | 59 // The following keys are not available on iOS: |
61 // kCFNetworkProxiesFTPEnable | 60 // kCFNetworkProxiesFTPEnable |
62 // kCFNetworkProxiesFTPProxy | 61 // kCFNetworkProxiesFTPProxy |
63 // kCFNetworkProxiesFTPPort | 62 // kCFNetworkProxiesFTPPort |
64 // kCFNetworkProxiesHTTPSEnable | 63 // kCFNetworkProxiesHTTPSEnable |
65 // kCFNetworkProxiesHTTPSProxy | 64 // kCFNetworkProxiesHTTPSProxy |
66 // kCFNetworkProxiesHTTPSPort | 65 // kCFNetworkProxiesHTTPSPort |
67 // kCFNetworkProxiesSOCKSEnable | 66 // kCFNetworkProxiesSOCKSEnable |
68 // kCFNetworkProxiesSOCKSProxy | 67 // kCFNetworkProxiesSOCKSProxy |
69 // kCFNetworkProxiesSOCKSPort | 68 // kCFNetworkProxiesSOCKSPort |
70 if (GetBoolFromDictionary(config_dict.get(), | 69 if (GetBoolFromDictionary( |
71 kCFNetworkProxiesHTTPEnable, | 70 config_dict.get(), kCFNetworkProxiesHTTPEnable, false)) { |
72 false)) { | |
73 ProxyServer proxy_server = | 71 ProxyServer proxy_server = |
74 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, | 72 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, |
75 config_dict.get(), | 73 config_dict.get(), |
76 kCFNetworkProxiesHTTPProxy, | 74 kCFNetworkProxiesHTTPProxy, |
77 kCFNetworkProxiesHTTPPort); | 75 kCFNetworkProxiesHTTPPort); |
78 if (proxy_server.is_valid()) { | 76 if (proxy_server.is_valid()) { |
79 config->proxy_rules().type = | 77 config->proxy_rules().type = |
80 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; | 78 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; |
81 config->proxy_rules().proxies_for_http.SetSingleProxyServer(proxy_server); | 79 config->proxy_rules().proxies_for_http.SetSingleProxyServer(proxy_server); |
82 // Desktop Safari applies the HTTP proxy to http:// URLs only, but | 80 // Desktop Safari applies the HTTP proxy to http:// URLs only, but |
(...skipping 17 matching lines...) Expand all Loading... |
100 | 98 |
101 ProxyConfigServiceIOS::ProxyConfigServiceIOS() | 99 ProxyConfigServiceIOS::ProxyConfigServiceIOS() |
102 : PollingProxyConfigService(base::TimeDelta::FromSeconds(kPollIntervalSec), | 100 : PollingProxyConfigService(base::TimeDelta::FromSeconds(kPollIntervalSec), |
103 GetCurrentProxyConfig) { | 101 GetCurrentProxyConfig) { |
104 } | 102 } |
105 | 103 |
106 ProxyConfigServiceIOS::~ProxyConfigServiceIOS() { | 104 ProxyConfigServiceIOS::~ProxyConfigServiceIOS() { |
107 } | 105 } |
108 | 106 |
109 } // namespace net | 107 } // namespace net |
OLD | NEW |