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

Unified Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc

Issue 792803007: Make Data Reduction Proxy a best effort proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated tests Created 5 years, 11 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: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
index 163e2eedad3f6cb02ae227805305ced6b9e28109..9598d7d1a1f6383a63e01fb25391e1d4012e13aa 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
@@ -6,11 +6,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
+#include "base/prefs/scoped_user_pref_update.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
-#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h"
+#include "chrome/browser/prefs/proxy_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/pref_names.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
@@ -21,6 +23,33 @@ using data_reduction_proxy::Client;
using data_reduction_proxy::DataReductionProxyParams;
using data_reduction_proxy::DataReductionProxySettings;
+// The Data Reduction Proxy has been turned into a "best effort" proxy,
+// meaning it is used only if the effective proxy configuration resolves to
+// DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference
+// hierarchy. This method removes the Data Reduction Proxy configuration from
+// prefs, if present. |proxy_pref_name| is the name of the proxy pref.
+void MigrateDataReductionProxyOffProxyPrefs(PrefService* prefs) {
+ DictionaryPrefUpdate update(prefs, prefs::kProxy);
+ base::DictionaryValue* dict = update.Get();
+ std::string mode;
+ if (!dict->GetString("mode", &mode))
+ return;
+ if (ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS) != mode)
+ return;
+ std::string proxy_server;
+ if (!dict->GetString("server", &proxy_server))
+ return;
+ net::ProxyConfig::ProxyRules proxy_rules;
+ proxy_rules.ParseFromString(proxy_server);
+ if (!data_reduction_proxy::DataReductionProxyConfigurator::
+ ContainsDataReductionProxy(proxy_rules)) {
+ return;
+ }
+ dict->SetString("mode", ProxyModeToString(ProxyPrefs::MODE_SYSTEM));
+ dict->SetString("server", "");
+ dict->SetString("bypass_list", "");
+}
+
DataReductionProxyChromeSettings::DataReductionProxyChromeSettings(
DataReductionProxyParams* params) : DataReductionProxySettings(params) {
}
@@ -46,6 +75,8 @@ void DataReductionProxyChromeSettings::InitDataReductionProxySettings(
base::Unretained(this)));
SetDataReductionProxyAlternativeEnabled(
DataReductionProxyParams::IsIncludedInAlternativeFieldTrial());
+ // TODO(bengr): Remove after M46. See http://crbug.com/445599.
+ MigrateDataReductionProxyOffProxyPrefs(profile_prefs);
}
void DataReductionProxyChromeSettings::RegisterSyntheticFieldTrial(

Powered by Google App Engine
This is Rietveld 408576698