summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/proxy_cros_settings_parser.cc
diff options
context:
space:
mode:
authorkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 23:19:28 +0000
committerkuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 23:19:28 +0000
commitf8178c6043f691d77c141462c5653e47a2aff02a (patch)
treef6d2dabc797626a47c33a5e2bf3de923336ec56c /chrome/browser/chromeos/proxy_cros_settings_parser.cc
parentd0be63774699f502698daeb829c724fecd37f41e (diff)
downloadchromium_src-f8178c6043f691d77c141462c5653e47a2aff02a.zip
chromium_src-f8178c6043f691d77c141462c5653e47a2aff02a.tar.gz
chromium_src-f8178c6043f691d77c141462c5653e47a2aff02a.tar.bz2
cros proxy: fix bug to accept http:// prefix and :<port> suffix for host in
manual configuration BUG=chromium-os:22777 TEST=verify per bug report. Review URL: http://codereview.chromium.org/8974021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/proxy_cros_settings_parser.cc')
-rw-r--r--chrome/browser/chromeos/proxy_cros_settings_parser.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/proxy_cros_settings_parser.cc b/chrome/browser/chromeos/proxy_cros_settings_parser.cc
index 1f5e8c1..7ec1bf2 100644
--- a/chrome/browser/chromeos/proxy_cros_settings_parser.cc
+++ b/chrome/browser/chromeos/proxy_cros_settings_parser.cc
@@ -70,11 +70,23 @@ base::Value* CreateServerPortValue(
net::ProxyServer CreateProxyServer(std::string host,
uint16 port,
net::ProxyServer::Scheme scheme) {
- if (host.length() == 0 && port == 0)
+ if (host.empty() && port == 0)
return net::ProxyServer();
- if (port == 0)
- port = net::ProxyServer::GetDefaultPortForScheme(scheme);
- net::HostPortPair host_port_pair(host, port);
+ uint16 default_port = net::ProxyServer::GetDefaultPortForScheme(scheme);
+ net::HostPortPair host_port_pair;
+ // Check if host is a valid URL or a string of valid format <server>::<port>.
+ GURL url(host);
+ if (url.is_valid()) // See if host is URL.
+ host_port_pair = net::HostPortPair::FromURL(url);
+ if (host_port_pair.host().empty()) // See if host is <server>::<port>.
+ host_port_pair = net::HostPortPair::FromString(host);
+ if (host_port_pair.host().empty()) // Host is not URL or <server>::<port>.
+ host_port_pair = net::HostPortPair(host, port);
+ // Formal parameter port overrides what may have been specified in host.
+ if (port != 0 && port != default_port)
+ host_port_pair.set_port(port);
+ else if (host_port_pair.port() == 0) // No port in host, use default.
+ host_port_pair.set_port(default_port);
return net::ProxyServer(scheme, host_port_pair);
}