| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 "socks", CreateProxyServerFromPort( | 261 "socks", CreateProxyServerFromPort( |
| 262 val, | 262 val, |
| 263 config.socks_proxy, | 263 config.socks_proxy, |
| 264 StartsWithASCII(host, "socks5://", false) ? | 264 StartsWithASCII(host, "socks5://", false) ? |
| 265 net::ProxyServer::SCHEME_SOCKS5 : | 265 net::ProxyServer::SCHEME_SOCKS5 : |
| 266 net::ProxyServer::SCHEME_SOCKS4)); | 266 net::ProxyServer::SCHEME_SOCKS4)); |
| 267 } | 267 } |
| 268 } else if (path == kProxyIgnoreList) { | 268 } else if (path == kProxyIgnoreList) { |
| 269 net::ProxyBypassRules bypass_rules; | 269 net::ProxyBypassRules bypass_rules; |
| 270 if (in_value->GetType() == base::Value::TYPE_LIST) { | 270 if (in_value->GetType() == base::Value::TYPE_LIST) { |
| 271 const ListValue* list_value = static_cast<const ListValue*>(in_value); | 271 const base::ListValue* list_value = |
| 272 static_cast<const base::ListValue*>(in_value); |
| 272 for (size_t x = 0; x < list_value->GetSize(); x++) { | 273 for (size_t x = 0; x < list_value->GetSize(); x++) { |
| 273 std::string val; | 274 std::string val; |
| 274 if (list_value->GetString(x, &val)) | 275 if (list_value->GetString(x, &val)) |
| 275 bypass_rules.AddRuleFromString(val); | 276 bypass_rules.AddRuleFromString(val); |
| 276 } | 277 } |
| 277 config.SetBypassRules(bypass_rules); | 278 config.SetBypassRules(bypass_rules); |
| 278 } | 279 } |
| 279 } else { | 280 } else { |
| 280 LOG(WARNING) << "Unknown proxy settings path " << path; | 281 LOG(WARNING) << "Unknown proxy settings path " << path; |
| 281 return; | 282 return; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 data = CreateServerHostValue(config.socks_proxy); | 344 data = CreateServerHostValue(config.socks_proxy); |
| 344 } else if (path == kProxyHttpPort) { | 345 } else if (path == kProxyHttpPort) { |
| 345 data = CreateServerPortValue(config.http_proxy); | 346 data = CreateServerPortValue(config.http_proxy); |
| 346 } else if (path == kProxyHttpsPort) { | 347 } else if (path == kProxyHttpsPort) { |
| 347 data = CreateServerPortValue(config.https_proxy); | 348 data = CreateServerPortValue(config.https_proxy); |
| 348 } else if (path == kProxyFtpPort) { | 349 } else if (path == kProxyFtpPort) { |
| 349 data = CreateServerPortValue(config.ftp_proxy); | 350 data = CreateServerPortValue(config.ftp_proxy); |
| 350 } else if (path == kProxySocksPort) { | 351 } else if (path == kProxySocksPort) { |
| 351 data = CreateServerPortValue(config.socks_proxy); | 352 data = CreateServerPortValue(config.socks_proxy); |
| 352 } else if (path == kProxyIgnoreList) { | 353 } else if (path == kProxyIgnoreList) { |
| 353 ListValue* list = new ListValue(); | 354 base::ListValue* list = new base::ListValue(); |
| 354 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); | 355 net::ProxyBypassRules::RuleList bypass_rules = config.bypass_rules.rules(); |
| 355 for (size_t x = 0; x < bypass_rules.size(); x++) | 356 for (size_t x = 0; x < bypass_rules.size(); x++) |
| 356 list->Append(new base::StringValue(bypass_rules[x]->ToString())); | 357 list->Append(new base::StringValue(bypass_rules[x]->ToString())); |
| 357 data = list; | 358 data = list; |
| 358 } else { | 359 } else { |
| 359 *out_value = NULL; | 360 *out_value = NULL; |
| 360 return false; | 361 return false; |
| 361 } | 362 } |
| 362 | 363 |
| 363 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. | 364 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. |
| 364 DictionaryValue* dict = new DictionaryValue; | 365 base::DictionaryValue* dict = new base::DictionaryValue; |
| 365 if (!data) | 366 if (!data) |
| 366 data = new base::StringValue(""); | 367 data = new base::StringValue(""); |
| 367 dict->Set("value", data); | 368 dict->Set("value", data); |
| 368 if (path == kProxyType) { | 369 if (path == kProxyType) { |
| 369 if (!controlled_by.empty()) | 370 if (!controlled_by.empty()) |
| 370 dict->SetString("controlledBy", controlled_by); | 371 dict->SetString("controlledBy", controlled_by); |
| 371 dict->SetBoolean("disabled", !config.user_modifiable); | 372 dict->SetBoolean("disabled", !config.user_modifiable); |
| 372 } else { | 373 } else { |
| 373 dict->SetBoolean("disabled", false); | 374 dict->SetBoolean("disabled", false); |
| 374 } | 375 } |
| 375 *out_value = dict; | 376 *out_value = dict; |
| 376 return true; | 377 return true; |
| 377 } | 378 } |
| 378 | 379 |
| 379 } // namespace proxy_cros_settings_parser | 380 } // namespace proxy_cros_settings_parser |
| 380 | 381 |
| 381 } // namespace chromeos | 382 } // namespace chromeos |
| OLD | NEW |