The plumbing to disable data reduction proxy
Bug: 16011253
Implement the plumbing to opt out from using data reduction proxy. Apps
can only opt-out, only users are allowed to opt-in.
Change-Id: Ic5e04fb52303db66c89819b6a83dda473db85b52
(cherry picked from commit 586bf9dff1ab17a76f9deb4781beae99d0cff9ef)
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index 1343ab3..a1bc335 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -101,6 +101,9 @@
private boolean mStarted;
private DataReductionProxySettingListener mProxySettingListener;
+ // TODO(sgurun) Temporary. Remove this after a corresponding CL to keep this state in
+ // AwContentsStatics is merged to M37.
+ private static boolean sOptedOutDataReductionProxy = false;
public WebViewChromiumFactoryProvider() {
ThreadUtils.setWillOverrideUiThread();
@@ -267,10 +270,22 @@
}
private static boolean isDataReductionProxyEnabled(Context context) {
+ if (sOptedOutDataReductionProxy) {
+ return false;
+ }
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.WEBVIEW_DATA_REDUCTION_PROXY, 0) != 0;
}
+ // TODO(sgurun) Temporary. Remove this logic after a corresponding CL to have this logic
+ // in AwContentsStatics is merged to M37.
+ private static void optOutDataReductionProxy() {
+ if (!sOptedOutDataReductionProxy) {
+ sOptedOutDataReductionProxy = true;
+ AwContentsStatics.setDataReductionProxyEnabled(false);
+ }
+ }
+
boolean hasStarted() {
return mStarted;
}
@@ -353,6 +368,14 @@
ComponentCallbacks2.TRIM_MEMORY_COMPLETE);
}
}
+
+ @Override
+ public void optOutDataReductionProxy() {
+ // TODO(sgurun) Normally I would route this through AwContentsStatics,
+ // however we need to merge it to M37. Due to a conflict in API deadlines vs. M37, wil
+ // route it from WebViewChromiumFactoryProvider for now.
+ WebViewChromiumFactoryProvider.this.optOutDataReductionProxy();
+ }
};
}
}