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

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

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

Powered by Google App Engine
This is Rietveld 408576698