OLD | NEW |
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_cros_settings_parser.h" | 5 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 9 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 uint16 default_port = net::ProxyServer::GetDefaultPortForScheme(scheme); | 75 uint16 default_port = net::ProxyServer::GetDefaultPortForScheme(scheme); |
76 net::HostPortPair host_port_pair; | 76 net::HostPortPair host_port_pair; |
77 // Check if host is a valid URL or a string of valid format <server>::<port>. | 77 // Check if host is a valid URL or a string of valid format <server>::<port>. |
78 GURL url(host); | 78 GURL url(host); |
79 if (url.is_valid()) // See if host is URL. | 79 if (url.is_valid()) // See if host is URL. |
80 host_port_pair = net::HostPortPair::FromURL(url); | 80 host_port_pair = net::HostPortPair::FromURL(url); |
81 if (host_port_pair.host().empty()) // See if host is <server>::<port>. | 81 if (host_port_pair.host().empty()) // See if host is <server>::<port>. |
82 host_port_pair = net::HostPortPair::FromString(host); | 82 host_port_pair = net::HostPortPair::FromString(host); |
83 if (host_port_pair.host().empty()) // Host is not URL or <server>::<port>. | 83 if (host_port_pair.host().empty()) // Host is not URL or <server>::<port>. |
84 host_port_pair = net::HostPortPair(host, port); | 84 host_port_pair = net::HostPortPair(host, port); |
85 // Formal parameter port overrides what may have been specified in host. | 85 if (host_port_pair.port() == 0) // No port in host, use default. |
86 if (port != 0 && port != default_port) | |
87 host_port_pair.set_port(port); | |
88 else if (host_port_pair.port() == 0) // No port in host, use default. | |
89 host_port_pair.set_port(default_port); | 86 host_port_pair.set_port(default_port); |
90 return net::ProxyServer(scheme, host_port_pair); | 87 return net::ProxyServer(scheme, host_port_pair); |
91 } | 88 } |
92 | 89 |
93 net::ProxyServer CreateProxyServerFromHost( | 90 net::ProxyServer CreateProxyServerFromHost( |
94 const std::string& host, | 91 const std::string& host, |
95 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy, | 92 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy, |
96 net::ProxyServer::Scheme scheme) { | 93 net::ProxyServer::Scheme scheme) { |
97 uint16 port = 0; | 94 uint16 port = 0; |
98 if (proxy.server.is_valid()) | 95 if (proxy.server.is_valid()) |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 } else { | 372 } else { |
376 dict->SetBoolean("disabled", false); | 373 dict->SetBoolean("disabled", false); |
377 } | 374 } |
378 *out_value = dict; | 375 *out_value = dict; |
379 return true; | 376 return true; |
380 } | 377 } |
381 | 378 |
382 } // namespace proxy_cros_settings_parser | 379 } // namespace proxy_cros_settings_parser |
383 | 380 |
384 } // namespace chromeos | 381 } // namespace chromeos |
OLD | NEW |