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

Side by Side Diff: chrome/browser/chromeos/proxy_config_service_impl.cc

Issue 12315019: Change ProxyRules to handle ProxyLists rather than just single ProxyServer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 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/extensions/api/proxy/proxy_api_helpers.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/proxy_config_service_impl.h" 5 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } else if (net_config.auto_detect()) { 195 } else if (net_config.auto_detect()) {
196 mode = ProxyConfig::MODE_AUTO_DETECT; 196 mode = ProxyConfig::MODE_AUTO_DETECT;
197 } else if (net_config.has_pac_url()) { 197 } else if (net_config.has_pac_url()) {
198 mode = ProxyConfig::MODE_PAC_SCRIPT; 198 mode = ProxyConfig::MODE_PAC_SCRIPT;
199 automatic_proxy.pac_url = net_config.pac_url(); 199 automatic_proxy.pac_url = net_config.pac_url();
200 } else { 200 } else {
201 return false; 201 return false;
202 } 202 }
203 return true; 203 return true;
204 case net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY: 204 case net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY:
205 if (!rules.single_proxy.is_valid()) 205 if (rules.single_proxies.IsEmpty())
206 return false; 206 return false;
207 mode = MODE_SINGLE_PROXY; 207 mode = MODE_SINGLE_PROXY;
208 single_proxy.server = rules.single_proxy; 208 single_proxy.server = rules.single_proxies.Get();
209 bypass_rules = rules.bypass_rules; 209 bypass_rules = rules.bypass_rules;
210 return true; 210 return true;
211 case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME: 211 case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME:
212 // Make sure we have valid server for at least one of the protocols. 212 // Make sure we have valid server for at least one of the protocols.
213 if (!rules.proxy_for_http.is_valid() && 213 if (rules.proxies_for_http.IsEmpty() &&
214 !rules.proxy_for_https.is_valid() && 214 rules.proxies_for_https.IsEmpty() &&
215 !rules.proxy_for_ftp.is_valid() && 215 rules.proxies_for_ftp.IsEmpty() &&
216 !rules.fallback_proxy.is_valid()) { 216 rules.fallback_proxies.IsEmpty()) {
217 return false; 217 return false;
218 } 218 }
219 mode = MODE_PROXY_PER_SCHEME; 219 mode = MODE_PROXY_PER_SCHEME;
220 if (rules.proxy_for_http.is_valid()) 220 if (!rules.proxies_for_http.IsEmpty())
221 http_proxy.server = rules.proxy_for_http; 221 http_proxy.server = rules.proxies_for_http.Get();
222 if (rules.proxy_for_https.is_valid()) 222 if (!rules.proxies_for_https.IsEmpty())
223 https_proxy.server = rules.proxy_for_https; 223 https_proxy.server = rules.proxies_for_https.Get();
224 if (rules.proxy_for_ftp.is_valid()) 224 if (!rules.proxies_for_ftp.IsEmpty())
225 ftp_proxy.server = rules.proxy_for_ftp; 225 ftp_proxy.server = rules.proxies_for_ftp.Get();
226 if (rules.fallback_proxy.is_valid()) 226 if (!rules.fallback_proxies.IsEmpty())
227 socks_proxy.server = rules.fallback_proxy; 227 socks_proxy.server = rules.fallback_proxies.Get();
228 bypass_rules = rules.bypass_rules; 228 bypass_rules = rules.bypass_rules;
229 return true; 229 return true;
230 default: 230 default:
231 NOTREACHED() << "Unrecognized proxy config mode"; 231 NOTREACHED() << "Unrecognized proxy config mode";
232 break; 232 break;
233 } 233 }
234 return false; 234 return false;
235 } 235 }
236 236
237 DictionaryValue* ProxyConfigServiceImpl::ProxyConfig::ToPrefProxyConfig() { 237 DictionaryValue* ProxyConfigServiceImpl::ProxyConfig::ToPrefProxyConfig() {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 mode = MODE_PAC_SCRIPT; 299 mode = MODE_PAC_SCRIPT;
300 if (proxy_proto.has_proxy_pac_url()) 300 if (proxy_proto.has_proxy_pac_url())
301 automatic_proxy.pac_url = GURL(proxy_proto.proxy_pac_url()); 301 automatic_proxy.pac_url = GURL(proxy_proto.proxy_pac_url());
302 } else if (mode_string == ProxyPrefs::kFixedServersProxyModeName) { 302 } else if (mode_string == ProxyPrefs::kFixedServersProxyModeName) {
303 net::ProxyConfig::ProxyRules rules; 303 net::ProxyConfig::ProxyRules rules;
304 rules.ParseFromString(proxy_proto.proxy_server()); 304 rules.ParseFromString(proxy_proto.proxy_server());
305 switch (rules.type) { 305 switch (rules.type) {
306 case net::ProxyConfig::ProxyRules::TYPE_NO_RULES: 306 case net::ProxyConfig::ProxyRules::TYPE_NO_RULES:
307 return false; 307 return false;
308 case net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY: 308 case net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY:
309 if (!rules.single_proxy.is_valid()) 309 if (rules.single_proxies.IsEmpty())
310 return false; 310 return false;
311 mode = MODE_SINGLE_PROXY; 311 mode = MODE_SINGLE_PROXY;
312 single_proxy.server = rules.single_proxy; 312 single_proxy.server = rules.single_proxies.Get();
313 break; 313 return true;
314 case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME: 314 case net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME:
315 // Make sure we have valid server for at least one of the protocols. 315 // Make sure we have valid server for at least one of the protocols.
316 if (!rules.proxy_for_http.is_valid() && 316 if (rules.proxies_for_http.IsEmpty() &&
317 !rules.proxy_for_https.is_valid() && 317 rules.proxies_for_https.IsEmpty() &&
318 !rules.proxy_for_ftp.is_valid() && 318 rules.proxies_for_ftp.IsEmpty() &&
319 !rules.fallback_proxy.is_valid()) { 319 rules.fallback_proxies.IsEmpty()) {
320 return false; 320 return false;
321 } 321 }
322 mode = MODE_PROXY_PER_SCHEME; 322 mode = MODE_PROXY_PER_SCHEME;
323 if (rules.proxy_for_http.is_valid()) 323 if (!rules.proxies_for_http.IsEmpty())
324 http_proxy.server = rules.proxy_for_http; 324 http_proxy.server = rules.proxies_for_http.Get();
325 if (rules.proxy_for_https.is_valid()) 325 if (!rules.proxies_for_https.IsEmpty())
326 https_proxy.server = rules.proxy_for_https; 326 https_proxy.server = rules.proxies_for_https.Get();
327 if (rules.proxy_for_ftp.is_valid()) 327 if (!rules.proxies_for_ftp.IsEmpty())
328 ftp_proxy.server = rules.proxy_for_ftp; 328 ftp_proxy.server = rules.proxies_for_ftp.Get();
329 if (rules.fallback_proxy.is_valid()) 329 if (!rules.fallback_proxies.IsEmpty())
330 socks_proxy.server = rules.fallback_proxy; 330 socks_proxy.server = rules.fallback_proxies.Get();
331 break; 331 break;
332 } 332 }
333 } else { 333 } else {
334 NOTREACHED() << "Unrecognized proxy config mode"; 334 NOTREACHED() << "Unrecognized proxy config mode";
335 return false; 335 return false;
336 } 336 }
337 337
338 if (proxy_proto.has_proxy_bypass_list()) 338 if (proxy_proto.has_proxy_bypass_list())
339 bypass_rules.ParseFromString(proxy_proto.proxy_bypass_list()); 339 bypass_rules.ParseFromString(proxy_proto.proxy_bypass_list());
340 340
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 device_config_.clear(); 847 device_config_.clear();
848 return; 848 return;
849 } 849 }
850 if (!active_network_.empty()) { 850 if (!active_network_.empty()) {
851 VLOG(1) << "Try migrating device config to " << active_network_; 851 VLOG(1) << "Try migrating device config to " << active_network_;
852 SetProxyConfigForNetwork(active_network_, device_config_, true); 852 SetProxyConfigForNetwork(active_network_, device_config_, true);
853 } 853 }
854 } 854 }
855 855
856 } // namespace chromeos 856 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/proxy/proxy_api_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698