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

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

Issue 669163003: Handle disabling data reduction proxy for all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use IsDataReductionProxy()/ Created 6 years, 2 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_configurator.cc
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc
index cb9e788a19141c70da51ee1a9136e3174f006b5a..b977809c1bc2c88a72db081da5d6340459c00e67 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc
@@ -10,8 +10,10 @@
#include "base/strings/string_util.h"
#include "chrome/browser/prefs/proxy_prefs.h"
#include "chrome/common/pref_names.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_params.h"
#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_info.h"
+#include "net/proxy/proxy_list.h"
#include "net/proxy/proxy_service.h"
DataReductionProxyChromeConfigurator::DataReductionProxyChromeConfigurator(
@@ -23,6 +25,26 @@ DataReductionProxyChromeConfigurator::DataReductionProxyChromeConfigurator(
DataReductionProxyChromeConfigurator::~DataReductionProxyChromeConfigurator() {
}
+// static
+void DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(
+ PrefService* prefs) {
+ DCHECK(prefs);
+ DictionaryPrefUpdate update(prefs, prefs::kProxy);
+ base::DictionaryValue* dict = update.Get();
+ std::string mode;
+ dict->GetString("mode", &mode);
+ std::string server;
+ dict->GetString("server", &server);
+ if (mode != ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS)
+ || !ContainsDataReductionProxy(server)) {
+ return;
+ }
+
+ dict->SetString("mode", ProxyModeToString(ProxyPrefs::MODE_SYSTEM));
+ dict->SetString("server", "");
+ dict->SetString("bypass_list", "");
+}
+
void DataReductionProxyChromeConfigurator::Enable(
bool primary_restricted,
bool fallback_restricted,
@@ -85,12 +107,7 @@ void DataReductionProxyChromeConfigurator::Enable(
}
void DataReductionProxyChromeConfigurator::Disable() {
- DCHECK(prefs_);
- DictionaryPrefUpdate update(prefs_, prefs::kProxy);
- base::DictionaryValue* dict = update.Get();
- dict->SetString("mode", ProxyModeToString(ProxyPrefs::MODE_SYSTEM));
- dict->SetString("server", "");
- dict->SetString("bypass_list", "");
+ DisableInProxyConfigPref(prefs_);
net::ProxyConfig config = net::ProxyConfig::CreateDirect();
network_task_runner_->PostTask(
FROM_HERE,
@@ -120,6 +137,35 @@ void DataReductionProxyChromeConfigurator::AddURLPatternToBypass(
AddHostPatternToBypass(host_pattern);
}
+// static
+bool DataReductionProxyChromeConfigurator::ContainsDataReductionProxy(
+ const std::string& server) {
+ data_reduction_proxy::DataReductionProxyParams params(0);
bengr 2014/10/29 20:58:46 How does this work? Nothing is allowed, so IsDataR
Not at Google. Contact bengr 2014/10/29 22:30:14 You are right. Added the correct parameters. This
+ net::ProxyConfig::ProxyRules proxy_rules;
+ proxy_rules.ParseFromString(server);
+ if (proxy_rules.type != net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME) {
+ return false;
+ }
+
+ const net::ProxyList* https_proxy_list =
+ proxy_rules.MapUrlSchemeToProxyList("https");
+ if (https_proxy_list && !https_proxy_list->IsEmpty() &&
+ params.IsDataReductionProxy(https_proxy_list->Get().host_port_pair(),
+ NULL)) {
+ return true;
+ }
+
+ const net::ProxyList* http_proxy_list =
+ proxy_rules.MapUrlSchemeToProxyList("http");
+ if (http_proxy_list && !http_proxy_list->IsEmpty() &&
bengr 2014/10/29 20:58:46 // It is sufficient to check only the first proxy
Not at Google. Contact bengr 2014/10/29 22:30:14 Done.
+ params.IsDataReductionProxy(http_proxy_list->Get().host_port_pair(),
+ NULL)) {
+ return true;
+ }
+
+ return false;
+}
+
void DataReductionProxyChromeConfigurator::UpdateProxyConfigOnIO(
const net::ProxyConfig& config) {
config_ = config;

Powered by Google App Engine
This is Rietveld 408576698