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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 // We have to explicitly export this because the arraysize macro doesn't like | 50 // We have to explicitly export this because the arraysize macro doesn't like |
51 // extern arrays as their size is not known on compile time. | 51 // extern arrays as their size is not known on compile time. |
52 const size_t kProxySettingsCount = arraysize(kProxySettings); | 52 const size_t kProxySettingsCount = arraysize(kProxySettings); |
53 | 53 |
54 namespace { | 54 namespace { |
55 | 55 |
56 base::Value* CreateServerHostValue( | 56 base::Value* CreateServerHostValue( |
57 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) { | 57 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) { |
58 return proxy.server.is_valid() ? | 58 return proxy.server.is_valid() ? |
59 new base::StringValue(proxy.server.host_port_pair().host()) : | 59 base::Value::CreateStringValue(proxy.server.host_port_pair().host()) : |
60 NULL; | 60 NULL; |
61 } | 61 } |
62 | 62 |
63 base::Value* CreateServerPortValue( | 63 base::Value* CreateServerPortValue( |
64 const ProxyConfigServiceImpl::ProxyConfig::ManualProxy& proxy) { | 64 const ProxyConfigServiceImpl::ProxyConfig::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 base::Value::CreateIntegerValue(proxy.server.host_port_pair().port()) : |
67 NULL; | 67 NULL; |
68 } | 68 } |
69 | 69 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 chromeos::ProxyConfigServiceImpl* config_service = | 291 chromeos::ProxyConfigServiceImpl* config_service = |
292 profile->GetProxyConfigTracker(); | 292 profile->GetProxyConfigTracker(); |
293 chromeos::ProxyConfigServiceImpl::ProxyConfig config; | 293 chromeos::ProxyConfigServiceImpl::ProxyConfig config; |
294 config_service->UIGetProxyConfig(&config); | 294 config_service->UIGetProxyConfig(&config); |
295 | 295 |
296 if (path == kProxyPacUrl) { | 296 if (path == kProxyPacUrl) { |
297 // Only show pacurl for pac-script mode. | 297 // Only show pacurl for pac-script mode. |
298 if (config.mode == | 298 if (config.mode == |
299 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT && | 299 chromeos::ProxyConfigServiceImpl::ProxyConfig::MODE_PAC_SCRIPT && |
300 config.automatic_proxy.pac_url.is_valid()) { | 300 config.automatic_proxy.pac_url.is_valid()) { |
301 data = new base::StringValue(config.automatic_proxy.pac_url.spec()); | 301 data = |
| 302 base::Value::CreateStringValue(config.automatic_proxy.pac_url.spec()); |
302 } | 303 } |
303 } else if (path == kProxySingleHttp) { | 304 } else if (path == kProxySingleHttp) { |
304 data = CreateServerHostValue(config.single_proxy); | 305 data = CreateServerHostValue(config.single_proxy); |
305 } else if (path == kProxySingleHttpPort) { | 306 } else if (path == kProxySingleHttpPort) { |
306 data = CreateServerPortValue(config.single_proxy); | 307 data = CreateServerPortValue(config.single_proxy); |
307 } else if (path == kProxyHttpUrl) { | 308 } else if (path == kProxyHttpUrl) { |
308 data = CreateServerHostValue(config.http_proxy); | 309 data = CreateServerHostValue(config.http_proxy); |
309 } else if (path == kProxyHttpsUrl) { | 310 } else if (path == kProxyHttpsUrl) { |
310 data = CreateServerHostValue(config.https_proxy); | 311 data = CreateServerHostValue(config.https_proxy); |
311 } else if (path == kProxyType) { | 312 } else if (path == kProxyType) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } else if (path == kProxyHttpsPort) { | 350 } else if (path == kProxyHttpsPort) { |
350 data = CreateServerPortValue(config.https_proxy); | 351 data = CreateServerPortValue(config.https_proxy); |
351 } else if (path == kProxyFtpPort) { | 352 } else if (path == kProxyFtpPort) { |
352 data = CreateServerPortValue(config.ftp_proxy); | 353 data = CreateServerPortValue(config.ftp_proxy); |
353 } else if (path == kProxySocksPort) { | 354 } else if (path == kProxySocksPort) { |
354 data = CreateServerPortValue(config.socks_proxy); | 355 data = CreateServerPortValue(config.socks_proxy); |
355 } else if (path == kProxyIgnoreList) { | 356 } else if (path == kProxyIgnoreList) { |
356 ListValue* list = new ListValue(); | 357 ListValue* list = new ListValue(); |
357 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); | 358 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); |
358 for (size_t x = 0; x < bypass_rules.size(); x++) { | 359 for (size_t x = 0; x < bypass_rules.size(); x++) { |
359 list->Append(new base::StringValue(bypass_rules[x]->ToString())); | 360 list->Append(base::Value::CreateStringValue(bypass_rules[x]->ToString())); |
360 } | 361 } |
361 data = list; | 362 data = list; |
362 } else { | 363 } else { |
363 *out_value = NULL; | 364 *out_value = NULL; |
364 return false; | 365 return false; |
365 } | 366 } |
366 | 367 |
367 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. | 368 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. |
368 DictionaryValue* dict = new DictionaryValue; | 369 DictionaryValue* dict = new DictionaryValue; |
369 if (!data) | 370 if (!data) |
370 data = new base::StringValue(""); | 371 data = base::Value::CreateStringValue(""); |
371 dict->Set("value", data); | 372 dict->Set("value", data); |
372 if (path == kProxyType) { | 373 if (path == kProxyType) { |
373 dict->SetString("controlledBy", controlled_by); | 374 dict->SetString("controlledBy", controlled_by); |
374 dict->SetBoolean("disabled", !config.user_modifiable); | 375 dict->SetBoolean("disabled", !config.user_modifiable); |
375 } else { | 376 } else { |
376 dict->SetBoolean("disabled", false); | 377 dict->SetBoolean("disabled", false); |
377 } | 378 } |
378 *out_value = dict; | 379 *out_value = dict; |
379 return true; | 380 return true; |
380 } | 381 } |
381 | 382 |
382 } // namespace proxy_cros_settings_parser | 383 } // namespace proxy_cros_settings_parser |
383 | 384 |
384 } // namespace chromeos | 385 } // namespace chromeos |
OLD | NEW |