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 <stdint.h> |
| 8 |
| 9 #include "base/macros.h" |
7 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
8 #include "base/values.h" | 11 #include "base/values.h" |
9 #include "chrome/browser/chromeos/ui_proxy_config.h" | 12 #include "chrome/browser/chromeos/ui_proxy_config.h" |
10 #include "chrome/browser/chromeos/ui_proxy_config_service.h" | 13 #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
11 | 14 |
12 namespace chromeos { | 15 namespace chromeos { |
13 | 16 |
14 // Common prefix of all proxy prefs. | 17 // Common prefix of all proxy prefs. |
15 const char kProxyPrefsPrefix[] = "cros.session.proxy"; | 18 const char kProxyPrefsPrefix[] = "cros.session.proxy"; |
16 | 19 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 NULL; | 64 NULL; |
62 } | 65 } |
63 | 66 |
64 base::Value* CreateServerPortValue(const UIProxyConfig::ManualProxy& proxy) { | 67 base::Value* CreateServerPortValue(const UIProxyConfig::ManualProxy& proxy) { |
65 return proxy.server.is_valid() | 68 return proxy.server.is_valid() |
66 ? new base::FundamentalValue(proxy.server.host_port_pair().port()) | 69 ? new base::FundamentalValue(proxy.server.host_port_pair().port()) |
67 : NULL; | 70 : NULL; |
68 } | 71 } |
69 | 72 |
70 net::ProxyServer CreateProxyServer(std::string host, | 73 net::ProxyServer CreateProxyServer(std::string host, |
71 uint16 port, | 74 uint16_t port, |
72 net::ProxyServer::Scheme scheme) { | 75 net::ProxyServer::Scheme scheme) { |
73 if (host.empty() && port == 0) | 76 if (host.empty() && port == 0) |
74 return net::ProxyServer(); | 77 return net::ProxyServer(); |
75 uint16 default_port = net::ProxyServer::GetDefaultPortForScheme(scheme); | 78 uint16_t default_port = net::ProxyServer::GetDefaultPortForScheme(scheme); |
76 net::HostPortPair host_port_pair; | 79 net::HostPortPair host_port_pair; |
77 // Check if host is a valid URL or a string of valid format <server>::<port>. | 80 // Check if host is a valid URL or a string of valid format <server>::<port>. |
78 GURL url(host); | 81 GURL url(host); |
79 if (url.is_valid()) // See if host is URL. | 82 if (url.is_valid()) // See if host is URL. |
80 host_port_pair = net::HostPortPair::FromURL(url); | 83 host_port_pair = net::HostPortPair::FromURL(url); |
81 if (host_port_pair.host().empty()) // See if host is <server>::<port>. | 84 if (host_port_pair.host().empty()) // See if host is <server>::<port>. |
82 host_port_pair = net::HostPortPair::FromString(host); | 85 host_port_pair = net::HostPortPair::FromString(host); |
83 if (host_port_pair.host().empty()) // Host is not URL or <server>::<port>. | 86 if (host_port_pair.host().empty()) // Host is not URL or <server>::<port>. |
84 host_port_pair = net::HostPortPair(host, port); | 87 host_port_pair = net::HostPortPair(host, port); |
85 if (host_port_pair.port() == 0) // No port in host, use default. | 88 if (host_port_pair.port() == 0) // No port in host, use default. |
86 host_port_pair.set_port(default_port); | 89 host_port_pair.set_port(default_port); |
87 return net::ProxyServer(scheme, host_port_pair); | 90 return net::ProxyServer(scheme, host_port_pair); |
88 } | 91 } |
89 | 92 |
90 net::ProxyServer CreateProxyServerFromHost( | 93 net::ProxyServer CreateProxyServerFromHost( |
91 const std::string& host, | 94 const std::string& host, |
92 const UIProxyConfig::ManualProxy& proxy, | 95 const UIProxyConfig::ManualProxy& proxy, |
93 net::ProxyServer::Scheme scheme) { | 96 net::ProxyServer::Scheme scheme) { |
94 uint16 port = 0; | 97 uint16_t port = 0; |
95 if (proxy.server.is_valid()) | 98 if (proxy.server.is_valid()) |
96 port = proxy.server.host_port_pair().port(); | 99 port = proxy.server.host_port_pair().port(); |
97 return CreateProxyServer(host, port, scheme); | 100 return CreateProxyServer(host, port, scheme); |
98 } | 101 } |
99 | 102 |
100 net::ProxyServer CreateProxyServerFromPort( | 103 net::ProxyServer CreateProxyServerFromPort( |
101 uint16 port, | 104 uint16_t port, |
102 const UIProxyConfig::ManualProxy& proxy, | 105 const UIProxyConfig::ManualProxy& proxy, |
103 net::ProxyServer::Scheme scheme) { | 106 net::ProxyServer::Scheme scheme) { |
104 std::string host; | 107 std::string host; |
105 if (proxy.server.is_valid()) | 108 if (proxy.server.is_valid()) |
106 host = proxy.server.host_port_pair().host(); | 109 host = proxy.server.host_port_pair().host(); |
107 return CreateProxyServer(host, port, scheme); | 110 return CreateProxyServer(host, port, scheme); |
108 } | 111 } |
109 | 112 |
110 } // namespace | 113 } // namespace |
111 | 114 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } else { | 377 } else { |
375 dict->SetBoolean("disabled", false); | 378 dict->SetBoolean("disabled", false); |
376 } | 379 } |
377 *out_value = dict; | 380 *out_value = dict; |
378 return true; | 381 return true; |
379 } | 382 } |
380 | 383 |
381 } // namespace proxy_cros_settings_parser | 384 } // namespace proxy_cros_settings_parser |
382 | 385 |
383 } // namespace chromeos | 386 } // namespace chromeos |
OLD | NEW |