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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
19 #include "base/string_tokenizer.h" | |
20 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 20 #include "base/strings/string_tokenizer.h" |
21 #include "googleurl/src/url_parse.h" | 21 #include "googleurl/src/url_parse.h" |
22 #include "jni/ProxyChangeListener_jni.h" | 22 #include "jni/ProxyChangeListener_jni.h" |
23 #include "net/base/host_port_pair.h" | 23 #include "net/base/host_port_pair.h" |
24 #include "net/proxy/proxy_config.h" | 24 #include "net/proxy/proxy_config.h" |
25 | 25 |
26 using base::android::AttachCurrentThread; | 26 using base::android::AttachCurrentThread; |
27 using base::android::ConvertUTF8ToJavaString; | 27 using base::android::ConvertUTF8ToJavaString; |
28 using base::android::ConvertJavaStringToUTF8; | 28 using base::android::ConvertJavaStringToUTF8; |
29 using base::android::CheckException; | 29 using base::android::CheckException; |
30 using base::android::ClearException; | 30 using base::android::ClearException; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 const GetPropertyCallback& get_property, | 94 const GetPropertyCallback& get_property, |
95 ProxyBypassRules* bypass_rules) { | 95 ProxyBypassRules* bypass_rules) { |
96 // The format of a hostname pattern is a list of hostnames that are separated | 96 // The format of a hostname pattern is a list of hostnames that are separated |
97 // by | and that use * as a wildcard. For example, setting the | 97 // by | and that use * as a wildcard. For example, setting the |
98 // http.nonProxyHosts property to *.android.com|*.kernel.org will cause | 98 // http.nonProxyHosts property to *.android.com|*.kernel.org will cause |
99 // requests to http://developer.android.com to be made without a proxy. | 99 // requests to http://developer.android.com to be made without a proxy. |
100 std::string non_proxy_hosts = | 100 std::string non_proxy_hosts = |
101 get_property.Run(scheme + ".nonProxyHosts"); | 101 get_property.Run(scheme + ".nonProxyHosts"); |
102 if (non_proxy_hosts.empty()) | 102 if (non_proxy_hosts.empty()) |
103 return; | 103 return; |
104 StringTokenizer tokenizer(non_proxy_hosts, "|"); | 104 base::StringTokenizer tokenizer(non_proxy_hosts, "|"); |
105 while (tokenizer.GetNext()) { | 105 while (tokenizer.GetNext()) { |
106 std::string token = tokenizer.token(); | 106 std::string token = tokenizer.token(); |
107 std::string pattern; | 107 std::string pattern; |
108 TrimWhitespaceASCII(token, TRIM_ALL, &pattern); | 108 TrimWhitespaceASCII(token, TRIM_ALL, &pattern); |
109 if (pattern.empty()) | 109 if (pattern.empty()) |
110 continue; | 110 continue; |
111 // '?' is not one of the specified pattern characters above. | 111 // '?' is not one of the specified pattern characters above. |
112 DCHECK_EQ(std::string::npos, pattern.find('?')); | 112 DCHECK_EQ(std::string::npos, pattern.find('?')); |
113 bypass_rules->AddRuleForHostname(scheme, pattern, -1); | 113 bypass_rules->AddRuleForHostname(scheme, pattern, -1); |
114 } | 114 } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 network_task_runner, jni_task_runner, get_property_callback)) { | 329 network_task_runner, jni_task_runner, get_property_callback)) { |
330 delegate_->SetupJNI(); | 330 delegate_->SetupJNI(); |
331 delegate_->FetchInitialConfig(); | 331 delegate_->FetchInitialConfig(); |
332 } | 332 } |
333 | 333 |
334 void ProxyConfigServiceAndroid::ProxySettingsChanged() { | 334 void ProxyConfigServiceAndroid::ProxySettingsChanged() { |
335 delegate_->ProxySettingsChanged(); | 335 delegate_->ProxySettingsChanged(); |
336 } | 336 } |
337 | 337 |
338 } // namespace net | 338 } // namespace net |
OLD | NEW |