| Index: chrome/android/java/src/org/chromium/chrome/browser/net/spdyproxy/DataReductionProxySettings.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/net/spdyproxy/DataReductionProxySettings.java b/chrome/android/java/src/org/chromium/chrome/browser/net/spdyproxy/DataReductionProxySettings.java
|
| index 569eb7cbc3aeba429aefe2160b02333ce4260a63..d4112bcd0eb1e6a26705abd465c8ec463d165562 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/net/spdyproxy/DataReductionProxySettings.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/net/spdyproxy/DataReductionProxySettings.java
|
| @@ -5,7 +5,9 @@
|
| package org.chromium.chrome.browser.net.spdyproxy;
|
|
|
| import android.content.Context;
|
| +import android.net.Uri;
|
| import android.preference.PreferenceManager;
|
| +import android.text.TextUtils;
|
|
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.VisibleForTesting;
|
| @@ -55,6 +57,10 @@ public class DataReductionProxySettings {
|
|
|
| private static final String DATA_REDUCTION_ENABLED_PREF = "BANDWIDTH_REDUCTION_PROXY_ENABLED";
|
|
|
| + private static final String WEBLITE_HOSTNAME = "googleweblight.com";
|
| +
|
| + private static final String WEBLITE_QUERY_PARAM = "lite_url";
|
| +
|
| /**
|
| * Returns whether the data reduction proxy is enabled.
|
| *
|
| @@ -269,6 +275,31 @@ public class DataReductionProxySettings {
|
| return map;
|
| }
|
|
|
| + /**
|
| + * If the given URL is a WebLite URL and should be overridden because the Data
|
| + * Reduction Proxy is on, the user is in the Lo-Fi previews experiment, and the scheme of the
|
| + * lite_url param is HTTP, returns the url contained in the lite_url param. Otherwise returns
|
| + * the given URL.
|
| + *
|
| + * @param url The url to evaluate.
|
| + */
|
| + public String maybeExtractWebliteUrl(String url) {
|
| + Uri uri = Uri.parse(url);
|
| + if (uri != null && TextUtils.equals(uri.getHost(), WEBLITE_HOSTNAME)
|
| + && areLoFiPreviewsEnabled() && isDataReductionProxyEnabled()) {
|
| + String liteUrl = uri.getQueryParameter(WEBLITE_QUERY_PARAM);
|
| + if (liteUrl != null && TextUtils.equals(Uri.parse(liteUrl).getScheme(), "http")) {
|
| + return liteUrl;
|
| + }
|
| + }
|
| +
|
| + return url;
|
| + }
|
| +
|
| + private boolean areLoFiPreviewsEnabled() {
|
| + return nativeAreLoFiPreviewsEnabled(mNativeDataReductionProxySettings);
|
| + }
|
| +
|
| private native long nativeInit();
|
| private native boolean nativeIsDataReductionProxyAllowed(
|
| long nativeDataReductionProxySettingsAndroid);
|
| @@ -304,6 +335,8 @@ public class DataReductionProxySettings {
|
| long nativeDataReductionProxySettingsAndroid);
|
| private native boolean nativeIsDataReductionProxyUnreachable(
|
| long nativeDataReductionProxySettingsAndroid);
|
| + private native boolean nativeAreLoFiPreviewsEnabled(
|
| + long nativeDataReductionProxySettingsAndroid);
|
| private native String nativeGetHttpProxyList(long nativeDataReductionProxySettingsAndroid);
|
| private native String nativeGetHttpsProxyList(long nativeDataReductionProxySettingsAndroid);
|
| private native String nativeGetLastBypassEvent(long nativeDataReductionProxySettingsAndroid);
|
|
|