Chromium Code Reviews| Index: net/proxy/proxy_config_service_android.cc |
| diff --git a/net/proxy/proxy_config_service_android.cc b/net/proxy/proxy_config_service_android.cc |
| index 4129bf24c2f958d268cddc7282e049f3836ccb68..27658fae84b7d2f58ff2386b73538297f65862a1 100644 |
| --- a/net/proxy/proxy_config_service_android.cc |
| +++ b/net/proxy/proxy_config_service_android.cc |
| @@ -6,6 +6,7 @@ |
| #include <sys/system_properties.h> |
| +#include "base/android/jni_array.h" |
| #include "base/android/jni_string.h" |
| #include "base/basictypes.h" |
| #include "base/bind.h" |
| @@ -159,11 +160,24 @@ std::string GetJavaProperty(const std::string& property) { |
| std::string() : ConvertJavaStringToUTF8(env, result.obj()); |
| } |
| -void CreateStaticProxyConfig(const std::string& host, int port, |
| +void CreateStaticProxyConfig(const std::string& host, |
| + int port, |
| + const std::vector<std::string>& exclusion_list, |
| ProxyConfig* config) { |
| if (port != 0) { |
| std::string rules = base::StringPrintf("%s:%d", host.c_str(), port); |
| config->proxy_rules().ParseFromString(rules); |
| + config->proxy_rules().bypass_rules.Clear(); |
| + |
| + std::vector<std::string>::const_iterator itr; |
|
eroman
2014/09/23 21:17:09
nit: "it" is a more common iterator variable name
sgurun-gerrit only
2014/10/10 00:58:55
Done.
|
| + for (itr = exclusion_list.begin(); itr != exclusion_list.end(); ++itr) { |
| + std::string pattern; |
| + base::TrimWhitespaceASCII(*itr, base::TRIM_ALL, &pattern); |
| + if (pattern.empty()) |
| + continue; |
| + VLOG(0) << "Add bypass rules:" << pattern.c_str(); |
|
eroman
2014/09/23 21:17:09
Is this vlog necessary?
sgurun-gerrit only
2014/10/10 00:58:55
Done.
|
| + config->proxy_rules().bypass_rules.AddRuleForHostname("", pattern, -1); |
| + } |
| } else { |
| *config = ProxyConfig::CreateDirect(); |
| } |
| @@ -248,10 +262,11 @@ class ProxyConfigServiceAndroid::Delegate |
| } |
| // Called on the JNI thread. |
| - void ProxySettingsChangedTo(const std::string& host, int port) { |
| + void ProxySettingsChangedTo(const std::string& host, int port, |
| + const std::vector<std::string>& exclusion_list) { |
| DCHECK(OnJNIThread()); |
| ProxyConfig proxy_config; |
| - CreateStaticProxyConfig(host, port, &proxy_config); |
| + CreateStaticProxyConfig(host, port, exclusion_list, &proxy_config); |
| network_task_runner_->PostTask( |
| FROM_HERE, |
| base::Bind( |
| @@ -267,9 +282,13 @@ class ProxyConfigServiceAndroid::Delegate |
| // ProxyConfigServiceAndroid::JNIDelegate overrides. |
| virtual void ProxySettingsChangedTo(JNIEnv* env, jobject jself, |
| - jstring jhost, jint jport) OVERRIDE { |
| + jstring jhost, jint jport, |
| + jobjectArray jexclusion_list) OVERRIDE { |
| std::string host = ConvertJavaStringToUTF8(env, jhost); |
| - delegate_->ProxySettingsChangedTo(host, jport); |
| + std::vector<std::string> exclusion_list; |
| + base::android::AppendJavaStringArrayToStringVector( |
| + env, jexclusion_list, &exclusion_list); |
| + delegate_->ProxySettingsChangedTo(host, jport, exclusion_list); |
| } |
| virtual void ProxySettingsChanged(JNIEnv* env, jobject self) OVERRIDE { |