| 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/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chromeos/ui_proxy_config.h" | 9 #include "chrome/browser/chromeos/ui_proxy_config.h" |
| 10 #include "chrome/browser/chromeos/ui_proxy_config_service.h" | 10 #include "chrome/browser/chromeos/ui_proxy_config_service.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 namespace { | 56 namespace { |
| 57 | 57 |
| 58 base::Value* CreateServerHostValue(const UIProxyConfig::ManualProxy& proxy) { | 58 base::Value* CreateServerHostValue(const UIProxyConfig::ManualProxy& proxy) { |
| 59 return proxy.server.is_valid() ? | 59 return proxy.server.is_valid() ? |
| 60 new base::StringValue(proxy.server.host_port_pair().host()) : | 60 new base::StringValue(proxy.server.host_port_pair().host()) : |
| 61 NULL; | 61 NULL; |
| 62 } | 62 } |
| 63 | 63 |
| 64 base::Value* CreateServerPortValue(const UIProxyConfig::ManualProxy& proxy) { | 64 base::Value* CreateServerPortValue(const UIProxyConfig::ManualProxy& proxy) { |
| 65 return proxy.server.is_valid() ? | 65 return proxy.server.is_valid() |
| 66 base::Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : | 66 ? new base::FundamentalValue(proxy.server.host_port_pair().port()) |
| 67 NULL; | 67 : NULL; |
| 68 } | 68 } |
| 69 | 69 |
| 70 net::ProxyServer CreateProxyServer(std::string host, | 70 net::ProxyServer CreateProxyServer(std::string host, |
| 71 uint16 port, | 71 uint16 port, |
| 72 net::ProxyServer::Scheme scheme) { | 72 net::ProxyServer::Scheme scheme) { |
| 73 if (host.empty() && port == 0) | 73 if (host.empty() && port == 0) |
| 74 return net::ProxyServer(); | 74 return net::ProxyServer(); |
| 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>. |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 data = CreateServerHostValue(config.single_proxy); | 303 data = CreateServerHostValue(config.single_proxy); |
| 304 } else if (path == kProxySingleHttpPort) { | 304 } else if (path == kProxySingleHttpPort) { |
| 305 data = CreateServerPortValue(config.single_proxy); | 305 data = CreateServerPortValue(config.single_proxy); |
| 306 } else if (path == kProxyHttpUrl) { | 306 } else if (path == kProxyHttpUrl) { |
| 307 data = CreateServerHostValue(config.http_proxy); | 307 data = CreateServerHostValue(config.http_proxy); |
| 308 } else if (path == kProxyHttpsUrl) { | 308 } else if (path == kProxyHttpsUrl) { |
| 309 data = CreateServerHostValue(config.https_proxy); | 309 data = CreateServerHostValue(config.https_proxy); |
| 310 } else if (path == kProxyType) { | 310 } else if (path == kProxyType) { |
| 311 if (config.mode == UIProxyConfig::MODE_AUTO_DETECT || | 311 if (config.mode == UIProxyConfig::MODE_AUTO_DETECT || |
| 312 config.mode == UIProxyConfig::MODE_PAC_SCRIPT) { | 312 config.mode == UIProxyConfig::MODE_PAC_SCRIPT) { |
| 313 data = base::Value::CreateIntegerValue(3); | 313 data = new base::FundamentalValue(3); |
| 314 } else if (config.mode == UIProxyConfig::MODE_SINGLE_PROXY || | 314 } else if (config.mode == UIProxyConfig::MODE_SINGLE_PROXY || |
| 315 config.mode == UIProxyConfig::MODE_PROXY_PER_SCHEME) { | 315 config.mode == UIProxyConfig::MODE_PROXY_PER_SCHEME) { |
| 316 data = base::Value::CreateIntegerValue(2); | 316 data = new base::FundamentalValue(2); |
| 317 } else { | 317 } else { |
| 318 data = base::Value::CreateIntegerValue(1); | 318 data = new base::FundamentalValue(1); |
| 319 } | 319 } |
| 320 switch (config.state) { | 320 switch (config.state) { |
| 321 case ProxyPrefs::CONFIG_POLICY: | 321 case ProxyPrefs::CONFIG_POLICY: |
| 322 controlled_by = "policy"; | 322 controlled_by = "policy"; |
| 323 break; | 323 break; |
| 324 case ProxyPrefs::CONFIG_EXTENSION: | 324 case ProxyPrefs::CONFIG_EXTENSION: |
| 325 controlled_by = "extension"; | 325 controlled_by = "extension"; |
| 326 break; | 326 break; |
| 327 case ProxyPrefs::CONFIG_OTHER_PRECEDE: | 327 case ProxyPrefs::CONFIG_OTHER_PRECEDE: |
| 328 controlled_by = "other"; | 328 controlled_by = "other"; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } else { | 373 } else { |
| 374 dict->SetBoolean("disabled", false); | 374 dict->SetBoolean("disabled", false); |
| 375 } | 375 } |
| 376 *out_value = dict; | 376 *out_value = dict; |
| 377 return true; | 377 return true; |
| 378 } | 378 } |
| 379 | 379 |
| 380 } // namespace proxy_cros_settings_parser | 380 } // namespace proxy_cros_settings_parser |
| 381 | 381 |
| 382 } // namespace chromeos | 382 } // namespace chromeos |
| OLD | NEW |