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 base::Value::CreateStringValue(proxy.server.host_port_pair().host()) : | 59 new base::StringValue(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 = | 301 data = new base::StringValue(config.automatic_proxy.pac_url.spec()); |
302 base::Value::CreateStringValue(config.automatic_proxy.pac_url.spec()); | |
303 } | 302 } |
304 } else if (path == kProxySingleHttp) { | 303 } else if (path == kProxySingleHttp) { |
305 data = CreateServerHostValue(config.single_proxy); | 304 data = CreateServerHostValue(config.single_proxy); |
306 } else if (path == kProxySingleHttpPort) { | 305 } else if (path == kProxySingleHttpPort) { |
307 data = CreateServerPortValue(config.single_proxy); | 306 data = CreateServerPortValue(config.single_proxy); |
308 } else if (path == kProxyHttpUrl) { | 307 } else if (path == kProxyHttpUrl) { |
309 data = CreateServerHostValue(config.http_proxy); | 308 data = CreateServerHostValue(config.http_proxy); |
310 } else if (path == kProxyHttpsUrl) { | 309 } else if (path == kProxyHttpsUrl) { |
311 data = CreateServerHostValue(config.https_proxy); | 310 data = CreateServerHostValue(config.https_proxy); |
312 } else if (path == kProxyType) { | 311 } else if (path == kProxyType) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } else if (path == kProxyHttpsPort) { | 349 } else if (path == kProxyHttpsPort) { |
351 data = CreateServerPortValue(config.https_proxy); | 350 data = CreateServerPortValue(config.https_proxy); |
352 } else if (path == kProxyFtpPort) { | 351 } else if (path == kProxyFtpPort) { |
353 data = CreateServerPortValue(config.ftp_proxy); | 352 data = CreateServerPortValue(config.ftp_proxy); |
354 } else if (path == kProxySocksPort) { | 353 } else if (path == kProxySocksPort) { |
355 data = CreateServerPortValue(config.socks_proxy); | 354 data = CreateServerPortValue(config.socks_proxy); |
356 } else if (path == kProxyIgnoreList) { | 355 } else if (path == kProxyIgnoreList) { |
357 ListValue* list = new ListValue(); | 356 ListValue* list = new ListValue(); |
358 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); | 357 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); |
359 for (size_t x = 0; x < bypass_rules.size(); x++) { | 358 for (size_t x = 0; x < bypass_rules.size(); x++) { |
360 list->Append(base::Value::CreateStringValue(bypass_rules[x]->ToString())); | 359 list->Append(new base::StringValue(bypass_rules[x]->ToString())); |
361 } | 360 } |
362 data = list; | 361 data = list; |
363 } else { | 362 } else { |
364 *out_value = NULL; | 363 *out_value = NULL; |
365 return false; | 364 return false; |
366 } | 365 } |
367 | 366 |
368 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. | 367 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. |
369 DictionaryValue* dict = new DictionaryValue; | 368 DictionaryValue* dict = new DictionaryValue; |
370 if (!data) | 369 if (!data) |
371 data = base::Value::CreateStringValue(""); | 370 data = new base::StringValue(""); |
372 dict->Set("value", data); | 371 dict->Set("value", data); |
373 if (path == kProxyType) { | 372 if (path == kProxyType) { |
374 dict->SetString("controlledBy", controlled_by); | 373 dict->SetString("controlledBy", controlled_by); |
375 dict->SetBoolean("disabled", !config.user_modifiable); | 374 dict->SetBoolean("disabled", !config.user_modifiable); |
376 } else { | 375 } else { |
377 dict->SetBoolean("disabled", false); | 376 dict->SetBoolean("disabled", false); |
378 } | 377 } |
379 *out_value = dict; | 378 *out_value = dict; |
380 return true; | 379 return true; |
381 } | 380 } |
382 | 381 |
383 } // namespace proxy_cros_settings_parser | 382 } // namespace proxy_cros_settings_parser |
384 | 383 |
385 } // namespace chromeos | 384 } // namespace chromeos |
OLD | NEW |