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

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: Fixed comment 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 // Removes any Data Reduction Proxies like *.googlezip.net from |proxy_list|.
eroman 2015/05/12 00:43:01 Please add more context on why this is being done,
sclittle 2015/05/12 01:13:59 Done, added to the comment of the RemoveGooglezipD
27 void RemoveGooglezipDataReductionProxiesFromList(net::ProxyList* proxy_list) {
28 if (proxy_list->IsEmpty())
29 return;
30
31 net::ProxyList replacement_list;
eroman 2015/05/12 00:43:01 Please do this in two phases: (1) Scan the list
sclittle 2015/05/12 01:13:59 Done.
32 for (const net::ProxyServer& proxy : proxy_list->GetAll()) {
33 if (!proxy.is_valid() || proxy.is_direct() ||
34 !EndsWith(proxy.host_port_pair().host(), ".googlezip.net", true)) {
35 replacement_list.AddProxyServer(proxy);
36 }
37 }
38
39 if (replacement_list.IsEmpty())
40 replacement_list.AddProxyServer(net::ProxyServer::Direct());
41 if (replacement_list.size() != proxy_list->size())
eroman 2015/05/12 00:43:01 This doesn't look correct. What if the list were:
sclittle 2015/05/12 01:13:59 Thanks, I just noticed this as well when testing n
42 *proxy_list = replacement_list;
43 }
44
45 // Remove any Data Reduction Proxies like *.googlezip.net from |proxy_rules|.
46 // TODO(sclittle): Add UMA to record how often this method is called, and how
eroman 2015/05/12 00:43:01 When to do you plan on doing this? If we are going
sclittle 2015/05/12 01:13:59 I'm planning on adding the measurements in M44. I'
47 // often it actually removes a *.googlezip.net proxy. This method should be
48 // removed once it stops actually finding and removing *.googlezip.net proxies
49 // from the proxy rules.
50 void RemoveGooglezipDataReductionProxies(
51 net::ProxyConfig::ProxyRules* proxy_rules) {
52 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->fallback_proxies);
53 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_ftp);
54 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_http);
55 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->proxies_for_https);
56 RemoveGooglezipDataReductionProxiesFromList(&proxy_rules->single_proxies);
57 }
58
59 } // namespace
60
21 //============================= ChromeProxyConfigService ======================= 61 //============================= ChromeProxyConfigService =======================
22 62
23 ChromeProxyConfigService::ChromeProxyConfigService( 63 ChromeProxyConfigService::ChromeProxyConfigService(
24 net::ProxyConfigService* base_service) 64 net::ProxyConfigService* base_service)
25 : base_service_(base_service), 65 : base_service_(base_service),
26 pref_config_state_(ProxyPrefs::CONFIG_UNSET), 66 pref_config_state_(ProxyPrefs::CONFIG_UNSET),
27 pref_config_read_pending_(true), 67 pref_config_read_pending_(true),
28 registered_observer_(false) { 68 registered_observer_(false) {
29 } 69 }
30 70
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // static 212 // static
173 net::ProxyConfigService::ConfigAvailability 213 net::ProxyConfigService::ConfigAvailability
174 PrefProxyConfigTrackerImpl::GetEffectiveProxyConfig( 214 PrefProxyConfigTrackerImpl::GetEffectiveProxyConfig(
175 ProxyPrefs::ConfigState pref_state, 215 ProxyPrefs::ConfigState pref_state,
176 const net::ProxyConfig& pref_config, 216 const net::ProxyConfig& pref_config,
177 net::ProxyConfigService::ConfigAvailability system_availability, 217 net::ProxyConfigService::ConfigAvailability system_availability,
178 const net::ProxyConfig& system_config, 218 const net::ProxyConfig& system_config,
179 bool ignore_fallback_config, 219 bool ignore_fallback_config,
180 ProxyPrefs::ConfigState* effective_config_state, 220 ProxyPrefs::ConfigState* effective_config_state,
181 net::ProxyConfig* effective_config) { 221 net::ProxyConfig* effective_config) {
222 net::ProxyConfigService::ConfigAvailability rv;
182 *effective_config_state = pref_state; 223 *effective_config_state = pref_state;
183 224
184 if (PrefPrecedes(pref_state)) { 225 if (PrefPrecedes(pref_state)) {
185 *effective_config = pref_config; 226 *effective_config = pref_config;
186 return net::ProxyConfigService::CONFIG_VALID; 227 rv = net::ProxyConfigService::CONFIG_VALID;
187 } 228 } else if (system_availability == net::ProxyConfigService::CONFIG_UNSET) {
eroman 2015/05/12 00:43:01 OK. alternately you could have extracted it to a h
sclittle 2015/05/12 01:13:59 Acknowledged. I'll leave it this way unless you'd
188 229 // 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) 230 if (pref_state == ProxyPrefs::CONFIG_FALLBACK && !ignore_fallback_config)
192 *effective_config = pref_config; 231 *effective_config = pref_config;
193 else 232 else
194 *effective_config = net::ProxyConfig::CreateDirect(); 233 *effective_config = net::ProxyConfig::CreateDirect();
195 return net::ProxyConfigService::CONFIG_VALID; 234 rv = net::ProxyConfigService::CONFIG_VALID;
235 } else {
236 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM;
237 *effective_config = system_config;
238 rv = system_availability;
196 } 239 }
197 240
198 *effective_config_state = ProxyPrefs::CONFIG_SYSTEM; 241 // Remove any Data Reduction Proxies like *.googlezip.net from the proxy
199 *effective_config = system_config; 242 // config rules, since specifying a DRP in the proxy rules is not a supported
200 return system_availability; 243 // means of activating the DRP, and could cause requests to be sent to the DRP
244 // without the appropriate authentication headers and without using any of the
245 // DRP bypass logic. This prevents the Data Reduction Proxy from being
246 // improperly activated via the proxy pref.
247 // TODO(sclittle): This is a temporary hotfix for http://crbug.com/476610, and
248 // should be removed once that bug is fixed and verified.
249 if (rv == net::ProxyConfigService::CONFIG_VALID)
250 RemoveGooglezipDataReductionProxies(&effective_config->proxy_rules());
251
252 return rv;
201 } 253 }
202 254
203 // static 255 // static
204 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) { 256 void PrefProxyConfigTrackerImpl::RegisterPrefs(PrefRegistrySimple* registry) {
205 base::DictionaryValue* default_settings = 257 base::DictionaryValue* default_settings =
206 ProxyConfigDictionary::CreateSystem(); 258 ProxyConfigDictionary::CreateSystem();
207 registry->RegisterDictionaryPref(prefs::kProxy, default_settings); 259 registry->RegisterDictionaryPref(prefs::kProxy, default_settings);
208 } 260 }
209 261
210 // static 262 // static
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 (config_state_ != ProxyPrefs::CONFIG_UNSET && 397 (config_state_ != ProxyPrefs::CONFIG_UNSET &&
346 !pref_config_.Equals(new_config))) { 398 !pref_config_.Equals(new_config))) {
347 config_state_ = config_state; 399 config_state_ = config_state;
348 if (config_state_ != ProxyPrefs::CONFIG_UNSET) 400 if (config_state_ != ProxyPrefs::CONFIG_UNSET)
349 pref_config_ = new_config; 401 pref_config_ = new_config;
350 update_pending_ = true; 402 update_pending_ = true;
351 } 403 }
352 if (update_pending_) 404 if (update_pending_)
353 OnProxyConfigChanged(config_state, new_config); 405 OnProxyConfigChanged(config_state, new_config);
354 } 406 }
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