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