| 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_android.h" | 5 #include "net/proxy/proxy_config_service_android.h" |
| 6 | 6 |
| 7 #include <sys/system_properties.h> | 7 #include <sys/system_properties.h> |
| 8 | 8 |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Returns true if a valid proxy was found. | 117 // Returns true if a valid proxy was found. |
| 118 bool GetProxyRules(const GetPropertyCallback& get_property, | 118 bool GetProxyRules(const GetPropertyCallback& get_property, |
| 119 ProxyConfig::ProxyRules* rules) { | 119 ProxyConfig::ProxyRules* rules) { |
| 120 // See libcore/luni/src/main/java/java/net/ProxySelectorImpl.java for the | 120 // See libcore/luni/src/main/java/java/net/ProxySelectorImpl.java for the |
| 121 // mostly equivalent Android implementation. There is one intentional | 121 // mostly equivalent Android implementation. There is one intentional |
| 122 // difference: by default Chromium uses the HTTP port (80) for HTTPS | 122 // difference: by default Chromium uses the HTTP port (80) for HTTPS |
| 123 // connections via proxy. This default is identical on other platforms. | 123 // connections via proxy. This default is identical on other platforms. |
| 124 // On the opposite, Java spec suggests to use HTTPS port (443) by default (the | 124 // On the opposite, Java spec suggests to use HTTPS port (443) by default (the |
| 125 // default value of https.proxyPort). | 125 // default value of https.proxyPort). |
| 126 rules->type = ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; | 126 rules->type = ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME; |
| 127 rules->proxy_for_http = LookupProxy("http", get_property, | 127 rules->proxies_for_http.SetSingleProxyServer( |
| 128 ProxyServer::SCHEME_HTTP); | 128 LookupProxy("http", get_property, ProxyServer::SCHEME_HTTP)); |
| 129 rules->proxy_for_https = LookupProxy("https", get_property, | 129 rules->proxies_for_https.SetSingleProxyServer( |
| 130 ProxyServer::SCHEME_HTTP); | 130 LookupProxy("https", get_property, ProxyServer::SCHEME_HTTP)); |
| 131 rules->proxy_for_ftp = LookupProxy("ftp", get_property, | 131 rules->proxies_for_ftp.SetSingleProxyServer( |
| 132 ProxyServer::SCHEME_HTTP); | 132 LookupProxy("ftp", get_property, ProxyServer::SCHEME_HTTP)); |
| 133 rules->fallback_proxy = LookupSocksProxy(get_property); | 133 rules->fallback_proxies.SetSingleProxyServer(LookupSocksProxy(get_property)); |
| 134 rules->bypass_rules.Clear(); | 134 rules->bypass_rules.Clear(); |
| 135 AddBypassRules("ftp", get_property, &rules->bypass_rules); | 135 AddBypassRules("ftp", get_property, &rules->bypass_rules); |
| 136 AddBypassRules("http", get_property, &rules->bypass_rules); | 136 AddBypassRules("http", get_property, &rules->bypass_rules); |
| 137 AddBypassRules("https", get_property, &rules->bypass_rules); | 137 AddBypassRules("https", get_property, &rules->bypass_rules); |
| 138 return rules->proxy_for_http.is_valid() || | 138 // We know a proxy was found if not all of the proxy lists are empty. |
| 139 rules->proxy_for_https.is_valid() || | 139 return !(rules->proxies_for_http.IsEmpty() && |
| 140 rules->proxy_for_ftp.is_valid() || | 140 rules->proxies_for_https.IsEmpty() && |
| 141 rules->fallback_proxy.is_valid(); | 141 rules->proxies_for_ftp.IsEmpty() && |
| 142 rules->fallback_proxies.IsEmpty()); |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 void GetLatestProxyConfigInternal(const GetPropertyCallback& get_property, | 145 void GetLatestProxyConfigInternal(const GetPropertyCallback& get_property, |
| 145 ProxyConfig* config) { | 146 ProxyConfig* config) { |
| 146 if (!GetProxyRules(get_property, &config->proxy_rules())) | 147 if (!GetProxyRules(get_property, &config->proxy_rules())) |
| 147 *config = ProxyConfig::CreateDirect(); | 148 *config = ProxyConfig::CreateDirect(); |
| 148 } | 149 } |
| 149 | 150 |
| 150 std::string GetJavaProperty(const std::string& property) { | 151 std::string GetJavaProperty(const std::string& property) { |
| 151 // Use Java System.getProperty to get configuration information. | 152 // Use Java System.getProperty to get configuration information. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 network_task_runner, jni_task_runner, get_property_callback)) { | 330 network_task_runner, jni_task_runner, get_property_callback)) { |
| 330 delegate_->SetupJNI(); | 331 delegate_->SetupJNI(); |
| 331 delegate_->FetchInitialConfig(); | 332 delegate_->FetchInitialConfig(); |
| 332 } | 333 } |
| 333 | 334 |
| 334 void ProxyConfigServiceAndroid::ProxySettingsChanged() { | 335 void ProxyConfigServiceAndroid::ProxySettingsChanged() { |
| 335 delegate_->ProxySettingsChanged(); | 336 delegate_->ProxySettingsChanged(); |
| 336 } | 337 } |
| 337 | 338 |
| 338 } // namespace net | 339 } // namespace net |
| OLD | NEW |