Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: net/proxy/proxy_config_service_android.cc

Issue 421493002: Use Android proxy's exclusion list to enable proxy bypass (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some compile errors Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_config_service_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..64fcab86f493e823e3b680ad752d8885e11264f1 100644
--- a/net/proxy/proxy_config_service_android.cc
+++ b/net/proxy/proxy_config_service_android.cc
@@ -159,11 +159,26 @@ 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::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();
+ if (!exclusion_list.empty()) {
eroman 2014/07/25 21:11:15 This block is essentially equivalent to: config->
sgurun-gerrit only 2014/07/26 00:57:09 Thanks. Actually this made me realize that there a
+ base::StringTokenizer tokenizer(exclusion_list, ",");
+ while (tokenizer.GetNext()) {
+ std::string token = tokenizer.token();
+ std::string pattern;
+ base::TrimWhitespaceASCII(token, base::TRIM_ALL, &pattern);
+ if (pattern.empty())
+ continue;
+ VLOG(0) << "Add bypass rules:" << pattern.c_str();
+ config->proxy_rules().bypass_rules.AddRuleFromString(pattern);
+ }
+ }
} else {
*config = ProxyConfig::CreateDirect();
}
@@ -248,10 +263,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::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 +283,12 @@ class ProxyConfigServiceAndroid::Delegate
// ProxyConfigServiceAndroid::JNIDelegate overrides.
virtual void ProxySettingsChangedTo(JNIEnv* env, jobject jself,
- jstring jhost, jint jport) OVERRIDE {
+ jstring jhost, jint jport,
+ jstring jexclusion_list) OVERRIDE {
std::string host = ConvertJavaStringToUTF8(env, jhost);
- delegate_->ProxySettingsChangedTo(host, jport);
+ std::string exclusion_list =
+ ConvertJavaStringToUTF8(env, jexclusion_list);
+ delegate_->ProxySettingsChangedTo(host, jport, exclusion_list);
}
virtual void ProxySettingsChanged(JNIEnv* env, jobject self) OVERRIDE {
« no previous file with comments | « net/proxy/proxy_config_service_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698