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

Unified Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 115029: Making command-line specified proxy settings more flexible - allowing for set... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/chrome_url_request_context.cc
===================================================================
--- chrome/browser/net/chrome_url_request_context.cc (revision 15852)
+++ chrome/browser/net/chrome_url_request_context.cc (working copy)
@@ -23,26 +23,68 @@
#include "net/proxy/proxy_service.h"
#include "webkit/glue/webkit_glue.h"
-// Sets up proxy info if overrides were specified on the command line.
-// Otherwise returns NULL (meaning we should use the system defaults).
-// The caller is responsible for deleting returned pointer.
-static net::ProxyInfo* CreateProxyInfo(const CommandLine& command_line) {
- net::ProxyInfo* proxy_info = NULL;
+net::ProxyConfig* CreateProxyConfig(const CommandLine& command_line) {
+ // Scan for all "enable" type proxy switches.
+ static const wchar_t* proxy_switches[] = {
+ switches::kProxyServer,
+ switches::kProxyServerPacUrl,
+ switches::kProxyServerAutoDetect,
+ switches::kProxyServerBypassUrls
+ };
+ bool found_enable_proxy_switch = false;
+ for (size_t i = 0; i < arraysize(proxy_switches); i++) {
+ if (command_line.HasSwitch(proxy_switches[i])) {
+ found_enable_proxy_switch = true;
+ break;
+ }
+ }
+
+ if (!found_enable_proxy_switch &&
+ !command_line.HasSwitch(switches::kNoProxyServer)) {
+ return NULL;
+ }
+
+ net::ProxyConfig* proxy_config = new net::ProxyConfig();
+ if (command_line.HasSwitch(switches::kNoProxyServer)) {
+ // Ignore (and warn about) all the other proxy config switches we get if
+ // the no-proxy-server command line argument is present.
+ if (found_enable_proxy_switch) {
+ LOG(WARNING) << "Additional command line proxy switches found when --"
+ << switches::kNoProxyServer << " was specified.";
+ }
+ return proxy_config;
+ }
+
if (command_line.HasSwitch(switches::kProxyServer)) {
- proxy_info = new net::ProxyInfo();
const std::wstring& proxy_server =
command_line.GetSwitchValue(switches::kProxyServer);
- proxy_info->UseNamedProxy(WideToASCII(proxy_server));
+ proxy_config->proxy_rules.ParseFromString(WideToASCII(proxy_server));
}
- return proxy_info;
+ if (command_line.HasSwitch(switches::kProxyServerPacUrl)) {
+ proxy_config->pac_url =
+ GURL(WideToASCII(command_line.GetSwitchValue(
+ switches::kProxyServerPacUrl)));
+ }
+
+ if (command_line.HasSwitch(switches::kProxyServerAutoDetect)) {
+ proxy_config->auto_detect = true;
+ }
+
+ if (command_line.HasSwitch(switches::kProxyServerBypassUrls)) {
+ proxy_config->ParseNoProxyList(
+ WideToASCII(command_line.GetSwitchValue(
+ switches::kProxyServerBypassUrls)));
+ }
+
+ return proxy_config;
}
// Create a proxy service according to the options on command line.
static net::ProxyService* CreateProxyService(URLRequestContext* context,
const CommandLine& command_line) {
- scoped_ptr<net::ProxyInfo> proxy_info(CreateProxyInfo(command_line));
+ scoped_ptr<net::ProxyConfig> proxy_config(CreateProxyConfig(command_line));
bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver);
if (use_v8 && command_line.HasSwitch(switches::kSingleProcess)) {
@@ -53,8 +95,8 @@
}
return use_v8 ?
- net::ProxyService::CreateUsingV8Resolver(proxy_info.get(), context) :
- net::ProxyService::Create(proxy_info.get());
+ net::ProxyService::CreateUsingV8Resolver(proxy_config.get(), context) :
+ net::ProxyService::Create(proxy_config.get());
}
// static
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | chrome/browser/net/chrome_url_request_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698