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

Unified Diff: net/android/java/src/org/chromium/net/ProxyChangeListener.java

Issue 573013002: Detect whether a PAC url is present on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed pac to uppercase Created 6 years, 3 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 | « no previous file | net/proxy/proxy_config_service_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/android/java/src/org/chromium/net/ProxyChangeListener.java
diff --git a/net/android/java/src/org/chromium/net/ProxyChangeListener.java b/net/android/java/src/org/chromium/net/ProxyChangeListener.java
index 63bfb30514cae20a672e8526aa8a3d73919d3189..b130da06f842199480ca35268bd5be9676ed803b 100644
--- a/net/android/java/src/org/chromium/net/ProxyChangeListener.java
+++ b/net/android/java/src/org/chromium/net/ProxyChangeListener.java
@@ -9,7 +9,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Proxy;
+import android.net.Uri;
import android.os.Build;
+import android.text.TextUtils;
import android.util.Log;
import org.chromium.base.CalledByNative;
@@ -34,12 +36,14 @@ public class ProxyChangeListener {
private Delegate mDelegate;
private static class ProxyConfig {
- public ProxyConfig(String host, int port) {
+ public ProxyConfig(String host, int port, String pacUrl) {
mHost = host;
mPort = port;
+ mPacUrl = pacUrl;
}
public final String mHost;
public final int mPort;
+ public final String mPacUrl;
}
public interface Delegate {
@@ -91,7 +95,7 @@ public class ProxyChangeListener {
// Extract a ProxyConfig object from the supplied Intent's extra data
// bundle. The android.net.ProxyProperties class is not exported from
- // tne Android SDK, so we have to use reflection to get at it and invoke
+ // the Android SDK, so we have to use reflection to get at it and invoke
// methods on it. If we fail, return an empty proxy config (meaning
// 'direct').
// TODO(sgurun): once android.net.ProxyInfo is public, rewrite this.
@@ -99,6 +103,7 @@ public class ProxyChangeListener {
try {
final String GET_HOST_NAME = "getHost";
final String GET_PORT_NAME = "getPort";
+ final String GET_PAC_FILE_URL = "getPacFileUrl";
String className;
String proxyInfo;
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
@@ -121,7 +126,23 @@ public class ProxyChangeListener {
String host = (String) getHostMethod.invoke(props);
int port = (Integer) getPortMethod.invoke(props);
- return new ProxyConfig(host, port);
+ // TODO(xunjieli): rewrite this once the API is public.
+ if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
+ Method getPacFileUrlMethod =
+ cls.getDeclaredMethod(GET_PAC_FILE_URL);
+ String pacFileUrl = (String) getPacFileUrlMethod.invoke(props);
+ if (!TextUtils.isEmpty(pacFileUrl)) {
+ return new ProxyConfig(host, port, pacFileUrl);
+ }
+ } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
+ Method getPacFileUrlMethod =
+ cls.getDeclaredMethod(GET_PAC_FILE_URL);
+ Uri pacFileUrl = (Uri) getPacFileUrlMethod.invoke(props);
+ if (!Uri.EMPTY.equals(pacFileUrl)) {
+ return new ProxyConfig(host, port, pacFileUrl.toString());
+ }
+ }
+ return new ProxyConfig(host, port, null);
} catch (ClassNotFoundException ex) {
Log.e(TAG, "Using no proxy configuration due to exception:" + ex);
return null;
@@ -154,7 +175,7 @@ public class ProxyChangeListener {
// Note that this code currently runs on a MESSAGE_LOOP_UI thread, but
// the C++ code must run the callbacks on the network thread.
if (cfg != null) {
- nativeProxySettingsChangedTo(mNativePtr, cfg.mHost, cfg.mPort);
+ nativeProxySettingsChangedTo(mNativePtr, cfg.mHost, cfg.mPort, cfg.mPacUrl);
} else {
nativeProxySettingsChanged(mNativePtr);
}
@@ -184,7 +205,9 @@ public class ProxyChangeListener {
@NativeClassQualifiedName("ProxyConfigServiceAndroid::JNIDelegate")
private native void nativeProxySettingsChangedTo(long nativePtr,
String host,
- int port);
+ int port,
+ String pacUrl);
+
@NativeClassQualifiedName("ProxyConfigServiceAndroid::JNIDelegate")
private native void nativeProxySettingsChanged(long nativePtr);
}
« no previous file with comments | « no previous file | net/proxy/proxy_config_service_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698