| 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/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/bind.h" | 12 #include "base/bind.h" |
| 14 #include "base/callback.h" | 13 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 16 #include "base/location.h" | 15 #include "base/location.h" |
| 17 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 20 #include "base/sequenced_task_runner.h" | 20 #include "base/sequenced_task_runner.h" |
| 21 #include "base/strings/string_tokenizer.h" | 21 #include "base/strings/string_tokenizer.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "jni/ProxyChangeListener_jni.h" | 24 #include "jni/ProxyChangeListener_jni.h" |
| 25 #include "net/base/host_port_pair.h" | 25 #include "net/base/host_port_pair.h" |
| 26 #include "net/proxy/proxy_config.h" | 26 #include "net/proxy/proxy_config.h" |
| 27 #include "url/third_party/mozilla/url_parse.h" | 27 #include "url/third_party/mozilla/url_parse.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 53 const std::string& proxy_host, | 53 const std::string& proxy_host, |
| 54 const std::string& proxy_port) { | 54 const std::string& proxy_port) { |
| 55 DCHECK(!proxy_host.empty()); | 55 DCHECK(!proxy_host.empty()); |
| 56 int port_as_int = 0; | 56 int port_as_int = 0; |
| 57 if (proxy_port.empty()) | 57 if (proxy_port.empty()) |
| 58 port_as_int = ProxyServer::GetDefaultPortForScheme(scheme); | 58 port_as_int = ProxyServer::GetDefaultPortForScheme(scheme); |
| 59 else if (!ConvertStringToPort(proxy_port, &port_as_int)) | 59 else if (!ConvertStringToPort(proxy_port, &port_as_int)) |
| 60 return ProxyServer(); | 60 return ProxyServer(); |
| 61 DCHECK(port_as_int > 0); | 61 DCHECK(port_as_int > 0); |
| 62 return ProxyServer( | 62 return ProxyServer( |
| 63 scheme, | 63 scheme, HostPortPair(proxy_host, static_cast<uint16_t>(port_as_int))); |
| 64 HostPortPair(proxy_host, static_cast<uint16>(port_as_int))); | |
| 65 } | 64 } |
| 66 | 65 |
| 67 ProxyServer LookupProxy(const std::string& prefix, | 66 ProxyServer LookupProxy(const std::string& prefix, |
| 68 const GetPropertyCallback& get_property, | 67 const GetPropertyCallback& get_property, |
| 69 ProxyServer::Scheme scheme) { | 68 ProxyServer::Scheme scheme) { |
| 70 DCHECK(!prefix.empty()); | 69 DCHECK(!prefix.empty()); |
| 71 std::string proxy_host = get_property.Run(prefix + ".proxyHost"); | 70 std::string proxy_host = get_property.Run(prefix + ".proxyHost"); |
| 72 if (!proxy_host.empty()) { | 71 if (!proxy_host.empty()) { |
| 73 std::string proxy_port = get_property.Run(prefix + ".proxyPort"); | 72 std::string proxy_port = get_property.Run(prefix + ".proxyPort"); |
| 74 return ConstructProxyServer(scheme, proxy_host, proxy_port); | 73 return ConstructProxyServer(scheme, proxy_host, proxy_port); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 network_task_runner, jni_task_runner, get_property_callback)) { | 405 network_task_runner, jni_task_runner, get_property_callback)) { |
| 407 delegate_->SetupJNI(); | 406 delegate_->SetupJNI(); |
| 408 delegate_->FetchInitialConfig(); | 407 delegate_->FetchInitialConfig(); |
| 409 } | 408 } |
| 410 | 409 |
| 411 void ProxyConfigServiceAndroid::ProxySettingsChanged() { | 410 void ProxyConfigServiceAndroid::ProxySettingsChanged() { |
| 412 delegate_->ProxySettingsChanged(); | 411 delegate_->ProxySettingsChanged(); |
| 413 } | 412 } |
| 414 | 413 |
| 415 } // namespace net | 414 } // namespace net |
| OLD | NEW |