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::Value(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::Value(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, |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 base::Value** out_value) { | 285 base::Value** out_value) { |
286 std::string controlled_by; | 286 std::string controlled_by; |
287 base::Value* data = NULL; | 287 base::Value* data = NULL; |
288 UIProxyConfig config; | 288 UIProxyConfig config; |
289 config_service->GetProxyConfig(network_guid, &config); | 289 config_service->GetProxyConfig(network_guid, &config); |
290 | 290 |
291 if (path == kProxyPacUrl) { | 291 if (path == kProxyPacUrl) { |
292 // Only show pacurl for pac-script mode. | 292 // Only show pacurl for pac-script mode. |
293 if (config.mode == UIProxyConfig::MODE_PAC_SCRIPT && | 293 if (config.mode == UIProxyConfig::MODE_PAC_SCRIPT && |
294 config.automatic_proxy.pac_url.is_valid()) { | 294 config.automatic_proxy.pac_url.is_valid()) { |
295 data = new base::StringValue(config.automatic_proxy.pac_url.spec()); | 295 data = new base::Value(config.automatic_proxy.pac_url.spec()); |
296 } | 296 } |
297 } else if (path == kProxySingleHttp) { | 297 } else if (path == kProxySingleHttp) { |
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) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 list->AppendString(rule->ToString()); | 350 list->AppendString(rule->ToString()); |
351 data = list; | 351 data = list; |
352 } else { | 352 } else { |
353 *out_value = NULL; | 353 *out_value = NULL; |
354 return false; | 354 return false; |
355 } | 355 } |
356 | 356 |
357 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. | 357 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. |
358 base::DictionaryValue* dict = new base::DictionaryValue; | 358 base::DictionaryValue* dict = new base::DictionaryValue; |
359 if (!data) | 359 if (!data) |
360 data = new base::StringValue(""); | 360 data = new base::Value(""); |
361 dict->Set("value", data); | 361 dict->Set("value", data); |
362 if (path == kProxyType) { | 362 if (path == kProxyType) { |
363 if (!controlled_by.empty()) | 363 if (!controlled_by.empty()) |
364 dict->SetString("controlledBy", controlled_by); | 364 dict->SetString("controlledBy", controlled_by); |
365 dict->SetBoolean("disabled", !config.user_modifiable); | 365 dict->SetBoolean("disabled", !config.user_modifiable); |
366 } else { | 366 } else { |
367 dict->SetBoolean("disabled", false); | 367 dict->SetBoolean("disabled", false); |
368 } | 368 } |
369 *out_value = dict; | 369 *out_value = dict; |
370 return true; | 370 return true; |
371 } | 371 } |
372 | 372 |
373 } // namespace proxy_cros_settings_parser | 373 } // namespace proxy_cros_settings_parser |
374 | 374 |
375 } // namespace chromeos | 375 } // namespace chromeos |
OLD | NEW |