| Index: chrome/browser/chromeos/proxy_cros_settings_parser.cc
|
| diff --git a/chrome/browser/chromeos/proxy_cros_settings_parser.cc b/chrome/browser/chromeos/proxy_cros_settings_parser.cc
|
| index 72dd4964754e45a2cfc8f24df608e4c49d6eb091..be6d08fefc4689a5ecc195d6971e3397b2498875 100644
|
| --- a/chrome/browser/chromeos/proxy_cros_settings_parser.cc
|
| +++ b/chrome/browser/chromeos/proxy_cros_settings_parser.cc
|
| @@ -7,6 +7,7 @@
|
| #include <stdint.h>
|
|
|
| #include "base/macros.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/values.h"
|
| #include "chromeos/network/proxy/ui_proxy_config.h"
|
| @@ -16,16 +17,18 @@ namespace chromeos {
|
|
|
| namespace {
|
|
|
| -base::Value* CreateServerHostValue(const UIProxyConfig::ManualProxy& proxy) {
|
| - return proxy.server.is_valid()
|
| - ? new base::Value(proxy.server.host_port_pair().host())
|
| - : NULL;
|
| +std::unique_ptr<base::Value> CreateServerHostValue(
|
| + const UIProxyConfig::ManualProxy& proxy) {
|
| + return proxy.server.is_valid() ? base::MakeUnique<base::Value>(
|
| + proxy.server.host_port_pair().host())
|
| + : nullptr;
|
| }
|
|
|
| -base::Value* CreateServerPortValue(const UIProxyConfig::ManualProxy& proxy) {
|
| - return proxy.server.is_valid()
|
| - ? new base::Value(proxy.server.host_port_pair().port())
|
| - : NULL;
|
| +std::unique_ptr<base::Value> CreateServerPortValue(
|
| + const UIProxyConfig::ManualProxy& proxy) {
|
| + return proxy.server.is_valid() ? base::MakeUnique<base::Value>(
|
| + proxy.server.host_port_pair().port())
|
| + : nullptr;
|
| }
|
|
|
| net::ProxyServer CreateProxyServer(std::string host,
|
| @@ -279,12 +282,14 @@ void SetProxyPrefValue(const std::string& network_guid,
|
| config_service->SetProxyConfig(network_guid, config);
|
| }
|
|
|
| +// TODO(crbug.com/697817): Change |out_value| to be
|
| +// std::unique_ptr<base::Value>*.
|
| bool GetProxyPrefValue(const std::string& network_guid,
|
| const std::string& path,
|
| UIProxyConfigService* config_service,
|
| base::Value** out_value) {
|
| std::string controlled_by;
|
| - base::Value* data = NULL;
|
| + std::unique_ptr<base::Value> data;
|
| UIProxyConfig config;
|
| config_service->GetProxyConfig(network_guid, &config);
|
|
|
| @@ -292,7 +297,8 @@ bool GetProxyPrefValue(const std::string& network_guid,
|
| // Only show pacurl for pac-script mode.
|
| if (config.mode == UIProxyConfig::MODE_PAC_SCRIPT &&
|
| config.automatic_proxy.pac_url.is_valid()) {
|
| - data = new base::Value(config.automatic_proxy.pac_url.spec());
|
| + data =
|
| + base::MakeUnique<base::Value>(config.automatic_proxy.pac_url.spec());
|
| }
|
| } else if (path == kProxySingleHttp) {
|
| data = CreateServerHostValue(config.single_proxy);
|
| @@ -305,12 +311,12 @@ bool GetProxyPrefValue(const std::string& network_guid,
|
| } else if (path == kProxyType) {
|
| if (config.mode == UIProxyConfig::MODE_AUTO_DETECT ||
|
| config.mode == UIProxyConfig::MODE_PAC_SCRIPT) {
|
| - data = new base::Value(3);
|
| + data = base::MakeUnique<base::Value>(3);
|
| } else if (config.mode == UIProxyConfig::MODE_SINGLE_PROXY ||
|
| config.mode == UIProxyConfig::MODE_PROXY_PER_SCHEME) {
|
| - data = new base::Value(2);
|
| + data = base::MakeUnique<base::Value>(2);
|
| } else {
|
| - data = new base::Value(1);
|
| + data = base::MakeUnique<base::Value>(1);
|
| }
|
| switch (config.state) {
|
| case ProxyPrefs::CONFIG_POLICY:
|
| @@ -328,9 +334,11 @@ bool GetProxyPrefValue(const std::string& network_guid,
|
| break;
|
| }
|
| } else if (path == kProxySingle) {
|
| - data = new base::Value(config.mode == UIProxyConfig::MODE_SINGLE_PROXY);
|
| + data = base::MakeUnique<base::Value>(config.mode ==
|
| + UIProxyConfig::MODE_SINGLE_PROXY);
|
| } else if (path == kProxyUsePacUrl) {
|
| - data = new base::Value(config.mode == UIProxyConfig::MODE_PAC_SCRIPT);
|
| + data = base::MakeUnique<base::Value>(config.mode ==
|
| + UIProxyConfig::MODE_PAC_SCRIPT);
|
| } else if (path == kProxyFtpUrl) {
|
| data = CreateServerHostValue(config.ftp_proxy);
|
| } else if (path == kProxySocks) {
|
| @@ -344,11 +352,11 @@ bool GetProxyPrefValue(const std::string& network_guid,
|
| } else if (path == kProxySocksPort) {
|
| data = CreateServerPortValue(config.socks_proxy);
|
| } else if (path == kProxyIgnoreList) {
|
| - base::ListValue* list = new base::ListValue();
|
| + auto list = base::MakeUnique<base::ListValue>();
|
| const auto& bypass_rules = config.bypass_rules.rules();
|
| for (const auto& rule : bypass_rules)
|
| list->AppendString(rule->ToString());
|
| - data = list;
|
| + data = std::move(list);
|
| } else {
|
| *out_value = NULL;
|
| return false;
|
| @@ -357,8 +365,8 @@ bool GetProxyPrefValue(const std::string& network_guid,
|
| // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does.
|
| base::DictionaryValue* dict = new base::DictionaryValue;
|
| if (!data)
|
| - data = new base::Value("");
|
| - dict->Set("value", data);
|
| + data = base::MakeUnique<base::Value>(base::Value::Type::STRING);
|
| + dict->Set("value", std::move(data));
|
| if (path == kProxyType) {
|
| if (!controlled_by.empty())
|
| dict->SetString("controlledBy", controlled_by);
|
|
|