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

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

Issue 2871653002: Remove raw base::DictionaryValue::SetWithoutPathExpansion in //chromeos (Closed)
Patch Set: Minor Fix Created 3 years, 7 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
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/network/policy_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <utility>
9 10
10 #include "base/base64.h" 11 #include "base/base64.h"
11 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
16 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 DCHECK(entry_is_string); 610 DCHECK(entry_is_string);
610 611
611 std::string pem_encoded; 612 std::string pem_encoded;
612 if (!GUIDRefToPEMEncoding(certs_by_guid, guid_ref, &pem_encoded)) 613 if (!GUIDRefToPEMEncoding(certs_by_guid, guid_ref, &pem_encoded))
613 return false; 614 return false;
614 615
615 pem_list->AppendString(pem_encoded); 616 pem_list->AppendString(pem_encoded);
616 } 617 }
617 618
618 onc_object->RemoveWithoutPathExpansion(key_guid_ref_list, nullptr); 619 onc_object->RemoveWithoutPathExpansion(key_guid_ref_list, nullptr);
619 onc_object->SetWithoutPathExpansion(key_pem_list, pem_list.release()); 620 onc_object->SetWithoutPathExpansion(key_pem_list, std::move(pem_list));
620 return true; 621 return true;
621 } 622 }
622 623
623 bool ResolveSingleCertRefToList(const CertPEMsByGUIDMap& certs_by_guid, 624 bool ResolveSingleCertRefToList(const CertPEMsByGUIDMap& certs_by_guid,
624 const std::string& key_guid_ref, 625 const std::string& key_guid_ref,
625 const std::string& key_pem_list, 626 const std::string& key_pem_list,
626 base::DictionaryValue* onc_object) { 627 base::DictionaryValue* onc_object) {
627 std::string guid_ref; 628 std::string guid_ref;
628 if (!onc_object->GetStringWithoutPathExpansion(key_guid_ref, &guid_ref)) 629 if (!onc_object->GetStringWithoutPathExpansion(key_guid_ref, &guid_ref))
629 return true; 630 return true;
630 631
631 std::string pem_encoded; 632 std::string pem_encoded;
632 if (!GUIDRefToPEMEncoding(certs_by_guid, guid_ref, &pem_encoded)) 633 if (!GUIDRefToPEMEncoding(certs_by_guid, guid_ref, &pem_encoded))
633 return false; 634 return false;
634 635
635 std::unique_ptr<base::ListValue> pem_list(new base::ListValue); 636 std::unique_ptr<base::ListValue> pem_list(new base::ListValue);
636 pem_list->AppendString(pem_encoded); 637 pem_list->AppendString(pem_encoded);
637 onc_object->RemoveWithoutPathExpansion(key_guid_ref, nullptr); 638 onc_object->RemoveWithoutPathExpansion(key_guid_ref, nullptr);
638 onc_object->SetWithoutPathExpansion(key_pem_list, pem_list.release()); 639 onc_object->SetWithoutPathExpansion(key_pem_list, std::move(pem_list));
639 return true; 640 return true;
640 } 641 }
641 642
642 // Resolves the reference list at |key_guid_refs| if present and otherwise the 643 // Resolves the reference list at |key_guid_refs| if present and otherwise the
643 // single reference at |key_guid_ref|. Returns whether the respective resolving 644 // single reference at |key_guid_ref|. Returns whether the respective resolving
644 // was successful. 645 // was successful.
645 bool ResolveCertRefsOrRefToList(const CertPEMsByGUIDMap& certs_by_guid, 646 bool ResolveCertRefsOrRefToList(const CertPEMsByGUIDMap& certs_by_guid,
646 const std::string& key_guid_refs, 647 const std::string& key_guid_refs,
647 const std::string& key_guid_ref, 648 const std::string& key_guid_ref,
648 const std::string& key_pem_list, 649 const std::string& key_pem_list,
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 // HTTP. 910 // HTTP.
910 net::ProxyServer::Scheme default_scheme = 911 net::ProxyServer::Scheme default_scheme =
911 (onc_scheme == ::onc::proxy::kSocks) ? net::ProxyServer::SCHEME_SOCKS4 912 (onc_scheme == ::onc::proxy::kSocks) ? net::ProxyServer::SCHEME_SOCKS4
912 : net::ProxyServer::SCHEME_HTTP; 913 : net::ProxyServer::SCHEME_HTTP;
913 // Only prefix the host with a non-default scheme. 914 // Only prefix the host with a non-default scheme.
914 if (server.scheme() != default_scheme) 915 if (server.scheme() != default_scheme)
915 host = SchemeToString(server.scheme()) + "://" + host; 916 host = SchemeToString(server.scheme()) + "://" + host;
916 url_dict->SetStringWithoutPathExpansion(::onc::proxy::kHost, host); 917 url_dict->SetStringWithoutPathExpansion(::onc::proxy::kHost, host);
917 url_dict->SetIntegerWithoutPathExpansion(::onc::proxy::kPort, 918 url_dict->SetIntegerWithoutPathExpansion(::onc::proxy::kPort,
918 server.host_port_pair().port()); 919 server.host_port_pair().port());
919 dict->SetWithoutPathExpansion(onc_scheme, url_dict.release()); 920 dict->SetWithoutPathExpansion(onc_scheme, std::move(url_dict));
920 } 921 }
921 922
922 } // namespace 923 } // namespace
923 924
924 std::unique_ptr<base::DictionaryValue> ConvertOncProxySettingsToProxyConfig( 925 std::unique_ptr<base::DictionaryValue> ConvertOncProxySettingsToProxyConfig(
925 const base::DictionaryValue& onc_proxy_settings) { 926 const base::DictionaryValue& onc_proxy_settings) {
926 std::string type; 927 std::string type;
927 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kType, &type); 928 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kType, &type);
928 std::unique_ptr<base::DictionaryValue> proxy_dict; 929 std::unique_ptr<base::DictionaryValue> proxy_dict;
929 930
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 SetProxyForScheme(proxy_rules, url::kFtpScheme, ::onc::proxy::kFtp, 1008 SetProxyForScheme(proxy_rules, url::kFtpScheme, ::onc::proxy::kFtp,
1008 manual.get()); 1009 manual.get());
1009 SetProxyForScheme(proxy_rules, url::kHttpScheme, ::onc::proxy::kHttp, 1010 SetProxyForScheme(proxy_rules, url::kHttpScheme, ::onc::proxy::kHttp,
1010 manual.get()); 1011 manual.get());
1011 SetProxyForScheme(proxy_rules, url::kHttpsScheme, ::onc::proxy::kHttps, 1012 SetProxyForScheme(proxy_rules, url::kHttpsScheme, ::onc::proxy::kHttps,
1012 manual.get()); 1013 manual.get());
1013 SetProxyForScheme(proxy_rules, kSocksScheme, ::onc::proxy::kSocks, 1014 SetProxyForScheme(proxy_rules, kSocksScheme, ::onc::proxy::kSocks,
1014 manual.get()); 1015 manual.get());
1015 } 1016 }
1016 proxy_settings->SetWithoutPathExpansion(::onc::proxy::kManual, 1017 proxy_settings->SetWithoutPathExpansion(::onc::proxy::kManual,
1017 manual.release()); 1018 std::move(manual));
1018 1019
1019 // Convert the 'bypass_list' string into dictionary entries. 1020 // Convert the 'bypass_list' string into dictionary entries.
1020 std::string bypass_rules_string; 1021 std::string bypass_rules_string;
1021 if (proxy_config->GetBypassList(&bypass_rules_string)) { 1022 if (proxy_config->GetBypassList(&bypass_rules_string)) {
1022 net::ProxyBypassRules bypass_rules; 1023 net::ProxyBypassRules bypass_rules;
1023 bypass_rules.ParseFromString(bypass_rules_string); 1024 bypass_rules.ParseFromString(bypass_rules_string);
1024 std::unique_ptr<base::ListValue> exclude_domains(new base::ListValue); 1025 std::unique_ptr<base::ListValue> exclude_domains(new base::ListValue);
1025 for (const auto& rule : bypass_rules.rules()) 1026 for (const auto& rule : bypass_rules.rules())
1026 exclude_domains->AppendString(rule->ToString()); 1027 exclude_domains->AppendString(rule->ToString());
1027 if (!exclude_domains->empty()) { 1028 if (!exclude_domains->empty()) {
1028 proxy_settings->SetWithoutPathExpansion(::onc::proxy::kExcludeDomains, 1029 proxy_settings->SetWithoutPathExpansion(::onc::proxy::kExcludeDomains,
1029 exclude_domains.release()); 1030 std::move(exclude_domains));
1030 } 1031 }
1031 } 1032 }
1032 break; 1033 break;
1033 } 1034 }
1034 default: { 1035 default: {
1035 LOG(ERROR) << "Unexpected proxy mode in Shill config: " << mode; 1036 LOG(ERROR) << "Unexpected proxy mode in Shill config: " << mode;
1036 return nullptr; 1037 return nullptr;
1037 } 1038 }
1038 } 1039 }
1039 return proxy_settings; 1040 return proxy_settings;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 const PrefService* local_state_prefs, 1324 const PrefService* local_state_prefs,
1324 const NetworkState& network) { 1325 const NetworkState& network) {
1325 ::onc::ONCSource ignored_onc_source; 1326 ::onc::ONCSource ignored_onc_source;
1326 const base::DictionaryValue* policy = onc::GetPolicyForNetwork( 1327 const base::DictionaryValue* policy = onc::GetPolicyForNetwork(
1327 profile_prefs, local_state_prefs, network, &ignored_onc_source); 1328 profile_prefs, local_state_prefs, network, &ignored_onc_source);
1328 return policy != NULL; 1329 return policy != NULL;
1329 } 1330 }
1330 1331
1331 } // namespace onc 1332 } // namespace onc
1332 } // namespace chromeos 1333 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/network/policy_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698