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

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

Issue 1104413003: Check for *.googlezip.net proxies when migrating proxy pref for DRP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test for http://googlezip.net Created 5 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d819d78abac955e3c631593d0534b995f522480a..431881843bde5e5403d9aa45921c5294b1504283 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
@@ -9,6 +9,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
+#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
@@ -22,8 +23,43 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
+#include "net/base/host_port_pair.h"
+#include "net/proxy/proxy_config.h"
+#include "net/proxy/proxy_list.h"
+#include "net/proxy/proxy_server.h"
#include "net/url_request/url_request_context_getter.h"
+namespace {
+
+// Assume that any proxy host ending with this suffix is a Data Reduction Proxy.
+const char kDataReductionProxyDefaultHostSuffix[] = ".googlezip.net";
+
+// Searches |proxy_list| for any Data Reduction Proxies, even if they don't
+// match a currently configured Data Reduction Proxy.
+bool ContainsDataReductionProxyDefaultHostSuffix(
+ const net::ProxyList& proxy_list) {
+ for (const net::ProxyServer& proxy : proxy_list.GetAll()) {
+ if (proxy.is_valid() && !proxy.is_direct() &&
+ EndsWith(proxy.host_port_pair().host(),
+ kDataReductionProxyDefaultHostSuffix, true)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Searches |proxy_rules| for any Data Reduction Proxies, even if they don't
+// match a currently configured Data Reduction Proxy.
+bool ContainsDataReductionProxyDefaultHostSuffix(
+ const net::ProxyConfig::ProxyRules& proxy_rules) {
+ return ContainsDataReductionProxyDefaultHostSuffix(
+ proxy_rules.proxies_for_http) ||
+ ContainsDataReductionProxyDefaultHostSuffix(
+ proxy_rules.proxies_for_https);
+}
+
+} // namespace
+
// 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
@@ -58,7 +94,12 @@ void DataReductionProxyChromeSettings::MigrateDataReductionProxyOffProxyPrefs(
return;
net::ProxyConfig::ProxyRules proxy_rules;
proxy_rules.ParseFromString(proxy_server);
- if (!Config()->ContainsDataReductionProxy(proxy_rules)) {
+ // Clear the proxy pref if it matches a currently configured Data Reduction
+ // Proxy, or if the proxy host ends with ".googlezip.net", in order to ensure
+ // that any DRP in the pref is cleared even if the DRP configuration was
+ // changed. See http://crbug.com/476610.
+ if (!Config()->ContainsDataReductionProxy(proxy_rules) &&
+ !ContainsDataReductionProxyDefaultHostSuffix(proxy_rules)) {
return;
}
prefs->ClearPref(prefs::kProxy);
« no previous file with comments | « no previous file | chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698