| 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_mac.h" | 5 #include "net/proxy/proxy_config_service_mac.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #include <SystemConfiguration/SystemConfiguration.h> | 8 #include <SystemConfiguration/SystemConfiguration.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 kSCPropNetProxiesFTPEnable, | 73 kSCPropNetProxiesFTPEnable, |
| 74 false)) { | 74 false)) { |
| 75 ProxyServer proxy_server = | 75 ProxyServer proxy_server = |
| 76 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, | 76 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, |
| 77 config_dict.get(), | 77 config_dict.get(), |
| 78 kSCPropNetProxiesFTPProxy, | 78 kSCPropNetProxiesFTPProxy, |
| 79 kSCPropNetProxiesFTPPort); | 79 kSCPropNetProxiesFTPPort); |
| 80 if (proxy_server.is_valid()) { | 80 if (proxy_server.is_valid()) { |
| 81 config->proxy_rules().type = | 81 config->proxy_rules().type = |
| 82 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; | 82 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; |
| 83 config->proxy_rules().proxy_for_ftp = proxy_server; | 83 config->proxy_rules().proxies_for_ftp.SetSingleProxyServer(proxy_server); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 if (GetBoolFromDictionary(config_dict.get(), | 86 if (GetBoolFromDictionary(config_dict.get(), |
| 87 kSCPropNetProxiesHTTPEnable, | 87 kSCPropNetProxiesHTTPEnable, |
| 88 false)) { | 88 false)) { |
| 89 ProxyServer proxy_server = | 89 ProxyServer proxy_server = |
| 90 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, | 90 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, |
| 91 config_dict.get(), | 91 config_dict.get(), |
| 92 kSCPropNetProxiesHTTPProxy, | 92 kSCPropNetProxiesHTTPProxy, |
| 93 kSCPropNetProxiesHTTPPort); | 93 kSCPropNetProxiesHTTPPort); |
| 94 if (proxy_server.is_valid()) { | 94 if (proxy_server.is_valid()) { |
| 95 config->proxy_rules().type = | 95 config->proxy_rules().type = |
| 96 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; | 96 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; |
| 97 config->proxy_rules().proxy_for_http = proxy_server; | 97 config->proxy_rules().proxies_for_http.SetSingleProxyServer(proxy_server); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 if (GetBoolFromDictionary(config_dict.get(), | 100 if (GetBoolFromDictionary(config_dict.get(), |
| 101 kSCPropNetProxiesHTTPSEnable, | 101 kSCPropNetProxiesHTTPSEnable, |
| 102 false)) { | 102 false)) { |
| 103 ProxyServer proxy_server = | 103 ProxyServer proxy_server = |
| 104 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, | 104 ProxyServer::FromDictionary(ProxyServer::SCHEME_HTTP, |
| 105 config_dict.get(), | 105 config_dict.get(), |
| 106 kSCPropNetProxiesHTTPSProxy, | 106 kSCPropNetProxiesHTTPSProxy, |
| 107 kSCPropNetProxiesHTTPSPort); | 107 kSCPropNetProxiesHTTPSPort); |
| 108 if (proxy_server.is_valid()) { | 108 if (proxy_server.is_valid()) { |
| 109 config->proxy_rules().type = | 109 config->proxy_rules().type = |
| 110 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; | 110 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; |
| 111 config->proxy_rules().proxy_for_https = proxy_server; | 111 config->proxy_rules().proxies_for_https. |
| 112 SetSingleProxyServer(proxy_server); |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 if (GetBoolFromDictionary(config_dict.get(), | 115 if (GetBoolFromDictionary(config_dict.get(), |
| 115 kSCPropNetProxiesSOCKSEnable, | 116 kSCPropNetProxiesSOCKSEnable, |
| 116 false)) { | 117 false)) { |
| 117 ProxyServer proxy_server = | 118 ProxyServer proxy_server = |
| 118 ProxyServer::FromDictionary(ProxyServer::SCHEME_SOCKS5, | 119 ProxyServer::FromDictionary(ProxyServer::SCHEME_SOCKS5, |
| 119 config_dict.get(), | 120 config_dict.get(), |
| 120 kSCPropNetProxiesSOCKSProxy, | 121 kSCPropNetProxiesSOCKSProxy, |
| 121 kSCPropNetProxiesSOCKSPort); | 122 kSCPropNetProxiesSOCKSPort); |
| 122 if (proxy_server.is_valid()) { | 123 if (proxy_server.is_valid()) { |
| 123 config->proxy_rules().type = | 124 config->proxy_rules().type = |
| 124 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; | 125 ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; |
| 125 config->proxy_rules().fallback_proxy = proxy_server; | 126 config->proxy_rules().fallback_proxies.SetSingleProxyServer(proxy_server); |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 // proxy bypass list | 130 // proxy bypass list |
| 130 | 131 |
| 131 CFArrayRef bypass_array_ref = base::mac::GetValueFromDictionary<CFArrayRef>( | 132 CFArrayRef bypass_array_ref = base::mac::GetValueFromDictionary<CFArrayRef>( |
| 132 config_dict.get(), kSCPropNetProxiesExceptionsList); | 133 config_dict.get(), kSCPropNetProxiesExceptionsList); |
| 133 if (bypass_array_ref) { | 134 if (bypass_array_ref) { |
| 134 CFIndex bypass_array_count = CFArrayGetCount(bypass_array_ref); | 135 CFIndex bypass_array_count = CFArrayGetCount(bypass_array_ref); |
| 135 for (CFIndex i = 0; i < bypass_array_count; ++i) { | 136 for (CFIndex i = 0; i < bypass_array_count; ++i) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // Keep track of the last value we have seen. | 277 // Keep track of the last value we have seen. |
| 277 has_fetched_config_ = true; | 278 has_fetched_config_ = true; |
| 278 last_config_fetched_ = new_config; | 279 last_config_fetched_ = new_config; |
| 279 | 280 |
| 280 // Notify all the observers. | 281 // Notify all the observers. |
| 281 FOR_EACH_OBSERVER(Observer, observers_, | 282 FOR_EACH_OBSERVER(Observer, observers_, |
| 282 OnProxyConfigChanged(new_config, CONFIG_VALID)); | 283 OnProxyConfigChanged(new_config, CONFIG_VALID)); |
| 283 } | 284 } |
| 284 | 285 |
| 285 } // namespace net | 286 } // namespace net |
| OLD | NEW |