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

Unified Diff: android_webview/browser/aw_browser_context.cc

Issue 271523002: Add the plumbing to enable DRP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cache the initial value Created 6 years, 7 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
Index: android_webview/browser/aw_browser_context.cc
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index e4a2a1d08a700ae9d93eb84d36710a02014a3059..248ade1d2d3dd8506354167950bd43057e21adc2 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -41,6 +41,9 @@ AwBrowserContext* g_browser_context = NULL;
} // namespace
+// Data reduction proxy is disabled by default.
+bool AwBrowserContext::data_reduction_proxy_enabled_ = false;
+
AwBrowserContext::AwBrowserContext(
const FilePath path,
JniDependencyFactory* native_factory)
@@ -73,6 +76,22 @@ AwBrowserContext* AwBrowserContext::FromWebContents(
return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext());
}
+// static
+void AwBrowserContext::SetDataReductionProxyEnabled(bool enabled) {
+ // Cache the setting value. It is possible that data reduction proxy is
+ // not created yet.
+ data_reduction_proxy_enabled_ = enabled;
+ AwBrowserContext* context = AwBrowserContext::GetDefault();
+ // Can't enable Data reduction proxy if user pref service is not ready.
+ if (context == NULL || context->user_pref_service_.get() == NULL)
+ return;
+ DataReductionProxySettings* proxy_settings =
+ context->GetDataReductionProxySettings();
+ if (proxy_settings == NULL)
+ return;
+ proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_);
+}
+
void AwBrowserContext::PreMainMessageLoopRun() {
cookie_store_ = CreateCookieStore(this);
DataReductionProxySettings::SetAllowed(true);
@@ -169,9 +188,8 @@ void AwBrowserContext::CreateUserPrefServiceIfNecessary() {
user_pref_service_.get(),
GetRequestContext());
- //TODO(sgurun): Attach this to the API. It is currently hard coded in a
- // disabled state.
- data_reduction_proxy_settings_->SetDataReductionProxyEnabled(false);
+ data_reduction_proxy_settings_->SetDataReductionProxyEnabled(
+ data_reduction_proxy_enabled_);
}
base::FilePath AwBrowserContext::GetPath() const {

Powered by Google App Engine
This is Rietveld 408576698