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> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chromeos/network/proxy/ui_proxy_config.h" | 12 #include "chromeos/network/proxy/ui_proxy_config.h" |
13 #include "chromeos/network/proxy/ui_proxy_config_service.h" | 13 #include "chromeos/network/proxy/ui_proxy_config_service.h" |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 base::Value* CreateServerHostValue(const UIProxyConfig::ManualProxy& proxy) { | 19 base::Value* CreateServerHostValue(const UIProxyConfig::ManualProxy& proxy) { |
20 return proxy.server.is_valid() ? | 20 return proxy.server.is_valid() ? |
21 new base::StringValue(proxy.server.host_port_pair().host()) : | 21 new base::StringValue(proxy.server.host_port_pair().host()) : |
22 NULL; | 22 NULL; |
23 } | 23 } |
24 | 24 |
25 base::Value* CreateServerPortValue(const UIProxyConfig::ManualProxy& proxy) { | 25 base::Value* CreateServerPortValue(const UIProxyConfig::ManualProxy& proxy) { |
26 return proxy.server.is_valid() | 26 return proxy.server.is_valid() |
27 ? new base::FundamentalValue(proxy.server.host_port_pair().port()) | 27 ? new base::Value(proxy.server.host_port_pair().port()) |
28 : NULL; | 28 : NULL; |
29 } | 29 } |
30 | 30 |
31 net::ProxyServer CreateProxyServer(std::string host, | 31 net::ProxyServer CreateProxyServer(std::string host, |
32 uint16_t port, | 32 uint16_t port, |
33 net::ProxyServer::Scheme scheme) { | 33 net::ProxyServer::Scheme scheme) { |
34 if (host.empty() && port == 0) | 34 if (host.empty() && port == 0) |
35 return net::ProxyServer(); | 35 return net::ProxyServer(); |
36 uint16_t default_port = net::ProxyServer::GetDefaultPortForScheme(scheme); | 36 uint16_t default_port = net::ProxyServer::GetDefaultPortForScheme(scheme); |
37 net::HostPortPair host_port_pair; | 37 net::HostPortPair host_port_pair; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 data = CreateServerHostValue(config.single_proxy); | 298 data = CreateServerHostValue(config.single_proxy); |
299 } else if (path == kProxySingleHttpPort) { | 299 } else if (path == kProxySingleHttpPort) { |
300 data = CreateServerPortValue(config.single_proxy); | 300 data = CreateServerPortValue(config.single_proxy); |
301 } else if (path == kProxyHttpUrl) { | 301 } else if (path == kProxyHttpUrl) { |
302 data = CreateServerHostValue(config.http_proxy); | 302 data = CreateServerHostValue(config.http_proxy); |
303 } else if (path == kProxyHttpsUrl) { | 303 } else if (path == kProxyHttpsUrl) { |
304 data = CreateServerHostValue(config.https_proxy); | 304 data = CreateServerHostValue(config.https_proxy); |
305 } else if (path == kProxyType) { | 305 } else if (path == kProxyType) { |
306 if (config.mode == UIProxyConfig::MODE_AUTO_DETECT || | 306 if (config.mode == UIProxyConfig::MODE_AUTO_DETECT || |
307 config.mode == UIProxyConfig::MODE_PAC_SCRIPT) { | 307 config.mode == UIProxyConfig::MODE_PAC_SCRIPT) { |
308 data = new base::FundamentalValue(3); | 308 data = new base::Value(3); |
309 } else if (config.mode == UIProxyConfig::MODE_SINGLE_PROXY || | 309 } else if (config.mode == UIProxyConfig::MODE_SINGLE_PROXY || |
310 config.mode == UIProxyConfig::MODE_PROXY_PER_SCHEME) { | 310 config.mode == UIProxyConfig::MODE_PROXY_PER_SCHEME) { |
311 data = new base::FundamentalValue(2); | 311 data = new base::Value(2); |
312 } else { | 312 } else { |
313 data = new base::FundamentalValue(1); | 313 data = new base::Value(1); |
314 } | 314 } |
315 switch (config.state) { | 315 switch (config.state) { |
316 case ProxyPrefs::CONFIG_POLICY: | 316 case ProxyPrefs::CONFIG_POLICY: |
317 controlled_by = "policy"; | 317 controlled_by = "policy"; |
318 break; | 318 break; |
319 case ProxyPrefs::CONFIG_EXTENSION: | 319 case ProxyPrefs::CONFIG_EXTENSION: |
320 controlled_by = "extension"; | 320 controlled_by = "extension"; |
321 break; | 321 break; |
322 case ProxyPrefs::CONFIG_OTHER_PRECEDE: | 322 case ProxyPrefs::CONFIG_OTHER_PRECEDE: |
323 controlled_by = "other"; | 323 controlled_by = "other"; |
324 break; | 324 break; |
325 default: | 325 default: |
326 if (!config.user_modifiable) | 326 if (!config.user_modifiable) |
327 controlled_by = "shared"; | 327 controlled_by = "shared"; |
328 break; | 328 break; |
329 } | 329 } |
330 } else if (path == kProxySingle) { | 330 } else if (path == kProxySingle) { |
331 data = new base::FundamentalValue(config.mode == | 331 data = new base::Value(config.mode == UIProxyConfig::MODE_SINGLE_PROXY); |
332 UIProxyConfig::MODE_SINGLE_PROXY); | |
333 } else if (path == kProxyUsePacUrl) { | 332 } else if (path == kProxyUsePacUrl) { |
334 data = new base::FundamentalValue(config.mode == | 333 data = new base::Value(config.mode == UIProxyConfig::MODE_PAC_SCRIPT); |
335 UIProxyConfig::MODE_PAC_SCRIPT); | |
336 } else if (path == kProxyFtpUrl) { | 334 } else if (path == kProxyFtpUrl) { |
337 data = CreateServerHostValue(config.ftp_proxy); | 335 data = CreateServerHostValue(config.ftp_proxy); |
338 } else if (path == kProxySocks) { | 336 } else if (path == kProxySocks) { |
339 data = CreateServerHostValue(config.socks_proxy); | 337 data = CreateServerHostValue(config.socks_proxy); |
340 } else if (path == kProxyHttpPort) { | 338 } else if (path == kProxyHttpPort) { |
341 data = CreateServerPortValue(config.http_proxy); | 339 data = CreateServerPortValue(config.http_proxy); |
342 } else if (path == kProxyHttpsPort) { | 340 } else if (path == kProxyHttpsPort) { |
343 data = CreateServerPortValue(config.https_proxy); | 341 data = CreateServerPortValue(config.https_proxy); |
344 } else if (path == kProxyFtpPort) { | 342 } else if (path == kProxyFtpPort) { |
345 data = CreateServerPortValue(config.ftp_proxy); | 343 data = CreateServerPortValue(config.ftp_proxy); |
(...skipping 22 matching lines...) Expand all Loading... |
368 } else { | 366 } else { |
369 dict->SetBoolean("disabled", false); | 367 dict->SetBoolean("disabled", false); |
370 } | 368 } |
371 *out_value = dict; | 369 *out_value = dict; |
372 return true; | 370 return true; |
373 } | 371 } |
374 | 372 |
375 } // namespace proxy_cros_settings_parser | 373 } // namespace proxy_cros_settings_parser |
376 | 374 |
377 } // namespace chromeos | 375 } // namespace chromeos |
OLD | NEW |