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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/prefs/scoped_user_pref_update.h" 11 #include "base/prefs/scoped_user_pref_update.h"
12 #include "base/strings/string_util.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" 15 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
15 #include "chrome/browser/prefs/proxy_prefs.h" 16 #include "chrome/browser/prefs/proxy_prefs.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h" 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h"
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h" 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig.h"
21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h" 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h"
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
26 #include "net/base/host_port_pair.h"
27 #include "net/proxy/proxy_config.h"
28 #include "net/proxy/proxy_list.h"
29 #include "net/proxy/proxy_server.h"
25 #include "net/url_request/url_request_context_getter.h" 30 #include "net/url_request/url_request_context_getter.h"
26 31
32 namespace {
33
34 // Assume that any proxy host ending with this suffix is a Data Reduction Proxy.
35 const char kDataReductionProxyDefaultHostSuffix[] = ".googlezip.net";
36
37 // Searches |proxy_list| for any Data Reduction Proxies, even if they don't
38 // match a currently configured Data Reduction Proxy.
39 bool ContainsDataReductionProxyDefaultHostSuffix(
40 const net::ProxyList& proxy_list) {
41 for (const net::ProxyServer& proxy : proxy_list.GetAll()) {
42 if (proxy.is_valid() && !proxy.is_direct() &&
43 EndsWith(proxy.host_port_pair().host(),
44 kDataReductionProxyDefaultHostSuffix, true)) {
45 return true;
46 }
47 }
48 return false;
49 }
50
51 // Searches |proxy_rules| for any Data Reduction Proxies, even if they don't
52 // match a currently configured Data Reduction Proxy.
53 bool ContainsDataReductionProxyDefaultHostSuffix(
54 const net::ProxyConfig::ProxyRules& proxy_rules) {
55 return ContainsDataReductionProxyDefaultHostSuffix(
56 proxy_rules.proxies_for_http) ||
57 ContainsDataReductionProxyDefaultHostSuffix(
58 proxy_rules.proxies_for_https);
59 }
60
61 } // namespace
62
27 // The Data Reduction Proxy has been turned into a "best effort" proxy, 63 // The Data Reduction Proxy has been turned into a "best effort" proxy,
28 // meaning it is used only if the effective proxy configuration resolves to 64 // meaning it is used only if the effective proxy configuration resolves to
29 // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference 65 // DIRECT for a URL. It no longer can be a ProxyConfig in the proxy preference
30 // hierarchy. This method removes the Data Reduction Proxy configuration from 66 // hierarchy. This method removes the Data Reduction Proxy configuration from
31 // prefs, if present. |proxy_pref_name| is the name of the proxy pref. 67 // prefs, if present. |proxy_pref_name| is the name of the proxy pref.
32 void DataReductionProxyChromeSettings::MigrateDataReductionProxyOffProxyPrefs( 68 void DataReductionProxyChromeSettings::MigrateDataReductionProxyOffProxyPrefs(
33 PrefService* prefs) { 69 PrefService* prefs) {
34 base::DictionaryValue* dict = 70 base::DictionaryValue* dict =
35 (base::DictionaryValue*) prefs->GetUserPrefValue(prefs::kProxy); 71 (base::DictionaryValue*) prefs->GetUserPrefValue(prefs::kProxy);
36 if (!dict) 72 if (!dict)
(...skipping 14 matching lines...) Expand all
51 prefs->ClearPref(prefs::kProxy); 87 prefs->ClearPref(prefs::kProxy);
52 return; 88 return;
53 } 89 }
54 if (ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS) != mode) 90 if (ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS) != mode)
55 return; 91 return;
56 std::string proxy_server; 92 std::string proxy_server;
57 if (!dict->GetString("server", &proxy_server)) 93 if (!dict->GetString("server", &proxy_server))
58 return; 94 return;
59 net::ProxyConfig::ProxyRules proxy_rules; 95 net::ProxyConfig::ProxyRules proxy_rules;
60 proxy_rules.ParseFromString(proxy_server); 96 proxy_rules.ParseFromString(proxy_server);
61 if (!Config()->ContainsDataReductionProxy(proxy_rules)) { 97 // Clear the proxy pref if it matches a currently configured Data Reduction
98 // Proxy, or if the proxy host ends with ".googlezip.net", in order to ensure
99 // that any DRP in the pref is cleared even if the DRP configuration was
100 // changed. See http://crbug.com/476610.
101 if (!Config()->ContainsDataReductionProxy(proxy_rules) &&
102 !ContainsDataReductionProxyDefaultHostSuffix(proxy_rules)) {
62 return; 103 return;
63 } 104 }
64 prefs->ClearPref(prefs::kProxy); 105 prefs->ClearPref(prefs::kProxy);
65 } 106 }
66 107
67 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings() 108 DataReductionProxyChromeSettings::DataReductionProxyChromeSettings()
68 : data_reduction_proxy::DataReductionProxySettings() { 109 : data_reduction_proxy::DataReductionProxySettings() {
69 } 110 }
70 111
71 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() { 112 DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 #elif defined(OS_OPENBSD) 175 #elif defined(OS_OPENBSD)
135 return data_reduction_proxy::Client::CHROME_OPENBSD; 176 return data_reduction_proxy::Client::CHROME_OPENBSD;
136 #elif defined(OS_SOLARIS) 177 #elif defined(OS_SOLARIS)
137 return data_reduction_proxy::Client::CHROME_SOLARIS; 178 return data_reduction_proxy::Client::CHROME_SOLARIS;
138 #elif defined(OS_QNX) 179 #elif defined(OS_QNX)
139 return data_reduction_proxy::Client::CHROME_QNX; 180 return data_reduction_proxy::Client::CHROME_QNX;
140 #else 181 #else
141 return data_reduction_proxy::Client::UNKNOWN; 182 return data_reduction_proxy::Client::UNKNOWN;
142 #endif 183 #endif
143 } 184 }
OLDNEW
« 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