Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chromeos/network/onc/onc_utils.cc

Issue 2785883003: Use unique_ptr<DictionaryValue> in ProxyConfigDictionary (Closed)
Patch Set: Fix compilation Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chromeos/network/onc/onc_utils.h" 5 #include "chromeos/network/onc/onc_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 917
918 } // namespace 918 } // namespace
919 919
920 std::unique_ptr<base::DictionaryValue> ConvertOncProxySettingsToProxyConfig( 920 std::unique_ptr<base::DictionaryValue> ConvertOncProxySettingsToProxyConfig(
921 const base::DictionaryValue& onc_proxy_settings) { 921 const base::DictionaryValue& onc_proxy_settings) {
922 std::string type; 922 std::string type;
923 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kType, &type); 923 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kType, &type);
924 std::unique_ptr<base::DictionaryValue> proxy_dict; 924 std::unique_ptr<base::DictionaryValue> proxy_dict;
925 925
926 if (type == ::onc::proxy::kDirect) { 926 if (type == ::onc::proxy::kDirect) {
927 proxy_dict.reset(ProxyConfigDictionary::CreateDirect()); 927 proxy_dict = ProxyConfigDictionary::CreateDirect();
928 } else if (type == ::onc::proxy::kWPAD) { 928 } else if (type == ::onc::proxy::kWPAD) {
929 proxy_dict.reset(ProxyConfigDictionary::CreateAutoDetect()); 929 proxy_dict = ProxyConfigDictionary::CreateAutoDetect();
930 } else if (type == ::onc::proxy::kPAC) { 930 } else if (type == ::onc::proxy::kPAC) {
931 std::string pac_url; 931 std::string pac_url;
932 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kPAC, 932 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kPAC,
933 &pac_url); 933 &pac_url);
934 GURL url(url_formatter::FixupURL(pac_url, std::string())); 934 GURL url(url_formatter::FixupURL(pac_url, std::string()));
935 proxy_dict.reset(ProxyConfigDictionary::CreatePacScript( 935 proxy_dict = ProxyConfigDictionary::CreatePacScript(
936 url.is_valid() ? url.spec() : std::string(), false)); 936 url.is_valid() ? url.spec() : std::string(), false);
937 } else if (type == ::onc::proxy::kManual) { 937 } else if (type == ::onc::proxy::kManual) {
938 const base::DictionaryValue* manual_dict = nullptr; 938 const base::DictionaryValue* manual_dict = nullptr;
939 onc_proxy_settings.GetDictionaryWithoutPathExpansion(::onc::proxy::kManual, 939 onc_proxy_settings.GetDictionaryWithoutPathExpansion(::onc::proxy::kManual,
940 &manual_dict); 940 &manual_dict);
941 std::string manual_spec; 941 std::string manual_spec;
942 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kFtp, &manual_spec); 942 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kFtp, &manual_spec);
943 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttp, &manual_spec); 943 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttp, &manual_spec);
944 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kSocks, 944 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kSocks,
945 &manual_spec); 945 &manual_spec);
946 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttps, 946 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttps,
947 &manual_spec); 947 &manual_spec);
948 948
949 const base::ListValue* exclude_domains = nullptr; 949 const base::ListValue* exclude_domains = nullptr;
950 net::ProxyBypassRules bypass_rules; 950 net::ProxyBypassRules bypass_rules;
951 if (onc_proxy_settings.GetListWithoutPathExpansion( 951 if (onc_proxy_settings.GetListWithoutPathExpansion(
952 ::onc::proxy::kExcludeDomains, &exclude_domains)) { 952 ::onc::proxy::kExcludeDomains, &exclude_domains)) {
953 bypass_rules.AssignFrom( 953 bypass_rules.AssignFrom(
954 ConvertOncExcludeDomainsToBypassRules(*exclude_domains)); 954 ConvertOncExcludeDomainsToBypassRules(*exclude_domains));
955 } 955 }
956 proxy_dict.reset(ProxyConfigDictionary::CreateFixedServers( 956 proxy_dict = ProxyConfigDictionary::CreateFixedServers(
957 manual_spec, bypass_rules.ToString())); 957 manual_spec, bypass_rules.ToString());
958 } else { 958 } else {
959 NOTREACHED(); 959 NOTREACHED();
960 } 960 }
961 return proxy_dict; 961 return proxy_dict;
962 } 962 }
963 963
964 std::unique_ptr<base::DictionaryValue> ConvertProxyConfigToOncProxySettings( 964 std::unique_ptr<base::DictionaryValue> ConvertProxyConfigToOncProxySettings(
965 const base::DictionaryValue& proxy_config_value) { 965 std::unique_ptr<base::DictionaryValue> proxy_config_value) {
966 // Create a ProxyConfigDictionary from the DictionaryValue. 966 // Create a ProxyConfigDictionary from the DictionaryValue.
967 std::unique_ptr<ProxyConfigDictionary> proxy_config( 967 auto proxy_config =
968 new ProxyConfigDictionary(&proxy_config_value)); 968 base::MakeUnique<ProxyConfigDictionary>(std::move(proxy_config_value));
969 969
970 // Create the result DictionaryValue and populate it. 970 // Create the result DictionaryValue and populate it.
971 std::unique_ptr<base::DictionaryValue> proxy_settings( 971 std::unique_ptr<base::DictionaryValue> proxy_settings(
972 new base::DictionaryValue); 972 new base::DictionaryValue);
973 ProxyPrefs::ProxyMode mode; 973 ProxyPrefs::ProxyMode mode;
974 if (!proxy_config->GetMode(&mode)) 974 if (!proxy_config->GetMode(&mode))
975 return nullptr; 975 return nullptr;
976 switch (mode) { 976 switch (mode) {
977 case ProxyPrefs::MODE_DIRECT: { 977 case ProxyPrefs::MODE_DIRECT: {
978 proxy_settings->SetStringWithoutPathExpansion(::onc::proxy::kType, 978 proxy_settings->SetStringWithoutPathExpansion(::onc::proxy::kType,
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 const PrefService* local_state_prefs, 1319 const PrefService* local_state_prefs,
1320 const NetworkState& network) { 1320 const NetworkState& network) {
1321 ::onc::ONCSource ignored_onc_source; 1321 ::onc::ONCSource ignored_onc_source;
1322 const base::DictionaryValue* policy = onc::GetPolicyForNetwork( 1322 const base::DictionaryValue* policy = onc::GetPolicyForNetwork(
1323 profile_prefs, local_state_prefs, network, &ignored_onc_source); 1323 profile_prefs, local_state_prefs, network, &ignored_onc_source);
1324 return policy != NULL; 1324 return policy != NULL;
1325 } 1325 }
1326 1326
1327 } // namespace onc 1327 } // namespace onc
1328 } // namespace chromeos 1328 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698