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

Side by Side Diff: chrome/browser/net/pref_proxy_config_tracker_impl.cc

Issue 1126413006: Temporary fix to prevent the DRP from being activated improperly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 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/pref_proxy_config_tracker_impl_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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/pref_proxy_config_tracker_impl.h" 5 #include "chrome/browser/net/pref_proxy_config_tracker_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_registry_simple.h" 8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/prefs/proxy_config_dictionary.h" 13 #include "chrome/browser/prefs/proxy_config_dictionary.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "components/pref_registry/pref_registry_syncable.h" 15 #include "components/pref_registry/pref_registry_syncable.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
17 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
19 #include "net/proxy/proxy_list.h"
20 #include "net/proxy/proxy_server.h"
18 21
19 using content::BrowserThread; 22 using content::BrowserThread;
20 23
24 namespace {
25
26 // Determine if |proxy| is of the form "*.googlezip.net".
27 bool IsGooglezipDataReductionProxy(const net::ProxyServer& proxy) {
28 return proxy.is_valid() && !proxy.is_direct() &&
29 EndsWith(proxy.host_port_pair().host(), ".googlezip.net", true);
30 }
31
32 // Removes any Data Reduction Proxies like *.googlezip.net from |proxy_list|.
33 void RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) {
34 if (proxy_list->IsEmpty())
35 return;
36
37 bool found_googlezip_proxy = false;
38 for (const net::ProxyServer& proxy : proxy_list->GetAll()) {
39 if (IsGooglezipDataReductionProxy(proxy)) {
40 found_googlezip_proxy = true;
41 break;
42 }
43 }
44 if (!found_googlezip_proxy)
45 return;
46
47 net::ProxyList replacement_list;
48 for (const net::ProxyServer& proxy : proxy_list->GetAll()) {
49 if (!IsGooglezipDataReductionProxy(proxy))
50 replacement_list.AddProxyServer(proxy);
51 }
52
53 if (replacement_list.IsEmpty())
54 replacement_list.AddProxyServer(net::ProxyServer::Direct());
55 *proxy_list = replacement_list;
56 }
57
58 // Remove any Data Reduction Proxies like *.googlezip.net from |proxy_rules|.
59 // This is to prevent a Data Reduction Proxy from being activated in an
60 // unsupported way, such as from a proxy pref, which could cause Chrome to use
61 // the Data Reduction Proxy without adding any of the necessary authentication
62 // headers or applying the Data Reduction Proxy bypass logic. See
63 // http://crbug.com/476610.
64 // TODO(sclittle): Add UMA to record how often this method is called, and how
65 // often it actually removes a *.googlezip.net proxy. This method should be
66 // removed once it stops actually finding and removing *.googlezip.net proxies
67 // from the proxy rules.
68 void RemoveGooglezipDataReductionProxies(
69 net::ProxyConfig::ProxyRules* proxy_rules) {
70 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->fallback_proxies);
71 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_ftp);
72 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_http);
73 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_https);
74 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies);
75 }
76
77 } // namespace
78
21 //============================= ChromeProxyConfigService ======================= 79 //============================= ChromeProxyConfigService =======================
22 80
23 ChromeProxyConfigService::ChromeProxyConfigService( 81 ChromeProxyConfigService::ChromeProxyConfigService(
24 net::ProxyConfigService* base_service) 82 net::ProxyConfigService* base_service)
25 : base_service_(base_service), 83 : base_service_(base_service),
26 pref_config_state_(ProxyPrefs::CONFIG_UNSET), 84 pref_config_state_(ProxyPrefs::CONFIG_UNSET),
27 pref_config_read_pending_(true), 85 pref_config_read_pending_(true),
28 registered_observer_(false) { 86 registered_observer_(false) {
29 } 87 }
30 88
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // static 230 // static
173 net::ProxyConfigService::ConfigAvailability 231 net::ProxyConfigService::ConfigAvailability
174 PrefProxyConfigTrackerImpl::GetEffectiveProxyConfig( 232 PrefProxyConfigTrackerImpl::GetEffectiveProxyConfig(
175 ProxyPrefs::ConfigState pref_state, 233 ProxyPrefs::ConfigState pref_state,
176 const net::ProxyConfig& pref_config, 234 const net::ProxyConfig& pref_config,
177 net::ProxyConfigService::ConfigAvailability system_availability, 235 net::ProxyConfigService::ConfigAvailability system_availability,
178 const net::ProxyConfig& system_config, 236 const net::ProxyConfig& system_config,
179 bool ignore_fallback_config, 237 bool ignore_fallback_config,
180 ProxyPrefs::ConfigState* effective_config_state, 238 ProxyPrefs::ConfigState* effective_config_state,
181 net::ProxyConfig* effective_config) { 239 net::ProxyConfig* effective_config) {
240 net::ProxyConfigService::ConfigAvailability rv;
182 *effective_config_state = pref_state; 241 *effective_config_state = pref_state;
183 242
184 if (PrefPrecedes(pref_state)) { 243 if (PrefPrecedes(pref_state)) {
185 *effective_config = pref_config; 244 *effective_config = pref_config;
186 return net::ProxyConfigService::CONFIG_VALID; 245 rv = net::ProxyConfigService::CONFIG_VALID;
187 } 246 } else if (system_availability == net::ProxyConfigService::CONFIG_UNSET) {
188 247 // If there's no system proxy config, fall back to prefs or default.
189 // If there's no system proxy config, fall back to prefs or default.
190 if (system_availability == net::ProxyConfigService::CONFIG_UNSET) {
191 if (pref_state == ProxyPrefs::CONFIG_FALLBACK && !ignore_fallback_config) 248 if (pref_state == ProxyPrefs::CONFIG_FALLBACK && !ignore_fallback_config)
192 *effective_config = pref_config; 249 *effective_config = pref_config;
193 else 250 else
194 *effective_config = net::ProxyConfig::CreateDirect(); 251 *effective_config = net::ProxyConfig::CreateDirect();
195 return net::ProxyConfigService::CONFIG_VALID; 252 rv = net::ProxyConfigService::CONFIG_VALID;
253 } else {
254 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM;
255 *effective_config = system_config;
256 rv = system_availability;
196 } 257 }
197 258
198 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM; 259 // Remove any Data Reduction Proxies like *.googlezip.net from the proxy
199 *effective_config = system_config; 260 // config rules, since specifying a DRP in the proxy rules is not a supported
200 return system_availability; 261 // means of activating the DRP, and could cause requests to be sent to the DRP
262 // without the appropriate authentication headers and without using any of the
263 // DRP bypass logic. This prevents the Data Reduction Proxy from being
264 // improperly activated via the proxy pref.
265 // TODO(sclittle): This is a temporary fix for http://crbug.com/476610, and
266 // should be removed once that bug is fixed and verified.
267 if (rv == net::ProxyConfigService::CONFIG_VALID)
268 RemoveGooglezipDataReductionProxies(&effective_config->proxy_rules());
269
270 return rv;
201 } 271 }
202 272
203 // static 273 // static
204 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) { 274 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) {
205 base::DictionaryValue* default_settings = 275 base::DictionaryValue* default_settings =
206 ProxyConfigDictionary::CreateSystem(); 276 ProxyConfigDictionary::CreateSystem();
207 registry->RegisterDictionaryPref(prefs::kProxy, default_settings); 277 registry->RegisterDictionaryPref(prefs::kProxy, default_settings);
208 } 278 }
209 279
210 // static 280 // static
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 (config_state_ != ProxyPrefs::CONFIG_UNSET && 415 (config_state_ != ProxyPrefs::CONFIG_UNSET &&
346 !pref_config_.Equals(new_config))) { 416 !pref_config_.Equals(new_config))) {
347 config_state_ = config_state; 417 config_state_ = config_state;
348 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 418 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
349 pref_config_ = new_config; 419 pref_config_ = new_config;
350 update_pending_ = true; 420 update_pending_ = true;
351 } 421 }
352 if (update_pending_) 422 if (update_pending_)
353 OnProxyConfigChanged(config_state, new_config); 423 OnProxyConfigChanged(config_state, new_config);
354 } 424 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/pref_proxy_config_tracker_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698