| 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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 config.SetBypassRules(bypass_rules); | 275 config.SetBypassRules(bypass_rules); |
| 276 } | 276 } |
| 277 } else { | 277 } else { |
| 278 LOG(WARNING) << "Unknown proxy settings path " << path; | 278 LOG(WARNING) << "Unknown proxy settings path " << path; |
| 279 return; | 279 return; |
| 280 } | 280 } |
| 281 | 281 |
| 282 config_service->SetProxyConfig(network_guid, config); | 282 config_service->SetProxyConfig(network_guid, config); |
| 283 } | 283 } |
| 284 | 284 |
| 285 // TODO(crbug.com/697817): Change |out_value| to be |
| 286 // std::unique_ptr<base::Value>*. |
| 285 bool GetProxyPrefValue(const std::string& network_guid, | 287 bool GetProxyPrefValue(const std::string& network_guid, |
| 286 const std::string& path, | 288 const std::string& path, |
| 287 UIProxyConfigService* config_service, | 289 UIProxyConfigService* config_service, |
| 288 std::unique_ptr<base::Value>* out_value) { | 290 base::Value** out_value) { |
| 289 std::string controlled_by; | 291 std::string controlled_by; |
| 290 std::unique_ptr<base::Value> data; | 292 std::unique_ptr<base::Value> data; |
| 291 UIProxyConfig config; | 293 UIProxyConfig config; |
| 292 config_service->GetProxyConfig(network_guid, &config); | 294 config_service->GetProxyConfig(network_guid, &config); |
| 293 | 295 |
| 294 if (path == kProxyPacUrl) { | 296 if (path == kProxyPacUrl) { |
| 295 // Only show pacurl for pac-script mode. | 297 // Only show pacurl for pac-script mode. |
| 296 if (config.mode == UIProxyConfig::MODE_PAC_SCRIPT && | 298 if (config.mode == UIProxyConfig::MODE_PAC_SCRIPT && |
| 297 config.automatic_proxy.pac_url.is_valid()) { | 299 config.automatic_proxy.pac_url.is_valid()) { |
| 298 data = | 300 data = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 data = CreateServerPortValue(config.ftp_proxy); | 351 data = CreateServerPortValue(config.ftp_proxy); |
| 350 } else if (path == kProxySocksPort) { | 352 } else if (path == kProxySocksPort) { |
| 351 data = CreateServerPortValue(config.socks_proxy); | 353 data = CreateServerPortValue(config.socks_proxy); |
| 352 } else if (path == kProxyIgnoreList) { | 354 } else if (path == kProxyIgnoreList) { |
| 353 auto list = base::MakeUnique<base::ListValue>(); | 355 auto list = base::MakeUnique<base::ListValue>(); |
| 354 const auto& bypass_rules = config.bypass_rules.rules(); | 356 const auto& bypass_rules = config.bypass_rules.rules(); |
| 355 for (const auto& rule : bypass_rules) | 357 for (const auto& rule : bypass_rules) |
| 356 list->AppendString(rule->ToString()); | 358 list->AppendString(rule->ToString()); |
| 357 data = std::move(list); | 359 data = std::move(list); |
| 358 } else { | 360 } else { |
| 359 out_value->reset(); | 361 *out_value = NULL; |
| 360 return false; | 362 return false; |
| 361 } | 363 } |
| 362 | 364 |
| 363 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. | 365 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. |
| 364 auto dict = base::MakeUnique<base::DictionaryValue>(); | 366 base::DictionaryValue* dict = new base::DictionaryValue; |
| 365 if (!data) | 367 if (!data) |
| 366 data = base::MakeUnique<base::Value>(base::Value::Type::STRING); | 368 data = base::MakeUnique<base::Value>(base::Value::Type::STRING); |
| 367 dict->Set("value", std::move(data)); | 369 dict->Set("value", std::move(data)); |
| 368 if (path == kProxyType) { | 370 if (path == kProxyType) { |
| 369 if (!controlled_by.empty()) | 371 if (!controlled_by.empty()) |
| 370 dict->SetString("controlledBy", controlled_by); | 372 dict->SetString("controlledBy", controlled_by); |
| 371 dict->SetBoolean("disabled", !config.user_modifiable); | 373 dict->SetBoolean("disabled", !config.user_modifiable); |
| 372 } else { | 374 } else { |
| 373 dict->SetBoolean("disabled", false); | 375 dict->SetBoolean("disabled", false); |
| 374 } | 376 } |
| 375 *out_value = std::move(dict); | 377 *out_value = dict; |
| 376 return true; | 378 return true; |
| 377 } | 379 } |
| 378 | 380 |
| 379 } // namespace proxy_cros_settings_parser | 381 } // namespace proxy_cros_settings_parser |
| 380 | 382 |
| 381 } // namespace chromeos | 383 } // namespace chromeos |
| OLD | NEW |