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 "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 18 matching lines...) Expand all Loading... | |
29 #include "chromeos/network/onc/onc_normalizer.h" | 29 #include "chromeos/network/onc/onc_normalizer.h" |
30 #include "chromeos/network/onc/onc_signature.h" | 30 #include "chromeos/network/onc/onc_signature.h" |
31 #include "chromeos/network/onc/onc_translator.h" | 31 #include "chromeos/network/onc/onc_translator.h" |
32 #include "chromeos/network/onc/onc_utils.h" | 32 #include "chromeos/network/onc/onc_utils.h" |
33 #include "chromeos/network/onc/onc_validator.h" | 33 #include "chromeos/network/onc/onc_validator.h" |
34 #include "components/device_event_log/device_event_log.h" | 34 #include "components/device_event_log/device_event_log.h" |
35 #include "components/onc/onc_pref_names.h" | 35 #include "components/onc/onc_pref_names.h" |
36 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
37 #include "components/proxy_config/proxy_config_dictionary.h" | 37 #include "components/proxy_config/proxy_config_dictionary.h" |
38 #include "components/signin/core/account_id/account_id.h" | 38 #include "components/signin/core/account_id/account_id.h" |
39 #include "components/url_formatter/url_fixer.h" | |
39 #include "components/user_manager/user.h" | 40 #include "components/user_manager/user.h" |
40 #include "components/user_manager/user_manager.h" | 41 #include "components/user_manager/user_manager.h" |
41 #include "crypto/encryptor.h" | 42 #include "crypto/encryptor.h" |
42 #include "crypto/hmac.h" | 43 #include "crypto/hmac.h" |
43 #include "crypto/symmetric_key.h" | 44 #include "crypto/symmetric_key.h" |
44 #include "net/base/host_port_pair.h" | 45 #include "net/base/host_port_pair.h" |
45 #include "net/cert/pem_tokenizer.h" | 46 #include "net/cert/pem_tokenizer.h" |
46 #include "net/cert/x509_certificate.h" | 47 #include "net/cert/x509_certificate.h" |
47 #include "net/proxy/proxy_bypass_rules.h" | 48 #include "net/proxy/proxy_bypass_rules.h" |
48 #include "net/proxy/proxy_config.h" | 49 #include "net/proxy/proxy_config.h" |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 | 925 |
925 if (type == ::onc::proxy::kDirect) { | 926 if (type == ::onc::proxy::kDirect) { |
926 proxy_dict.reset(ProxyConfigDictionary::CreateDirect()); | 927 proxy_dict.reset(ProxyConfigDictionary::CreateDirect()); |
927 } else if (type == ::onc::proxy::kWPAD) { | 928 } else if (type == ::onc::proxy::kWPAD) { |
928 proxy_dict.reset(ProxyConfigDictionary::CreateAutoDetect()); | 929 proxy_dict.reset(ProxyConfigDictionary::CreateAutoDetect()); |
929 } else if (type == ::onc::proxy::kPAC) { | 930 } else if (type == ::onc::proxy::kPAC) { |
930 std::string pac_url; | 931 std::string pac_url; |
931 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kPAC, | 932 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kPAC, |
932 &pac_url); | 933 &pac_url); |
933 GURL url(pac_url); | 934 GURL url(pac_url); |
934 DCHECK(url.is_valid()) << "Invalid URL in ProxySettings.PAC"; | 935 if (!url.is_valid()) { |
Peter Kasting
2017/01/06 01:59:33
Why check for an invalid GURL before running it th
stevenjb
2017/01/06 17:36:14
Done.
| |
936 // Assume the scheme is missing, use http. | |
937 url = GURL(url_formatter::FixupURL(pac_url, std::string())); | |
938 if (!url.is_valid()) { | |
939 LOG(WARNING) << "Invalid URL in ProxySettings.PAC: " << pac_url; | |
Peter Kasting
2017/01/06 01:59:33
Generally, I suggest people avoid LOGs, as they bl
stevenjb
2017/01/06 17:36:14
Done.
| |
940 url = GURL(); | |
Peter Kasting
2017/01/06 01:59:33
Do you need to do this? Is it safe to just call .
stevenjb
2017/01/06 17:36:14
Something later will blow up if this is invalid. A
| |
941 } | |
942 } | |
935 proxy_dict.reset(ProxyConfigDictionary::CreatePacScript(url.spec(), false)); | 943 proxy_dict.reset(ProxyConfigDictionary::CreatePacScript(url.spec(), false)); |
936 } else if (type == ::onc::proxy::kManual) { | 944 } else if (type == ::onc::proxy::kManual) { |
937 const base::DictionaryValue* manual_dict = nullptr; | 945 const base::DictionaryValue* manual_dict = nullptr; |
938 onc_proxy_settings.GetDictionaryWithoutPathExpansion(::onc::proxy::kManual, | 946 onc_proxy_settings.GetDictionaryWithoutPathExpansion(::onc::proxy::kManual, |
939 &manual_dict); | 947 &manual_dict); |
940 std::string manual_spec; | 948 std::string manual_spec; |
941 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kFtp, &manual_spec); | 949 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kFtp, &manual_spec); |
942 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttp, &manual_spec); | 950 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttp, &manual_spec); |
943 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kSocks, | 951 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kSocks, |
944 &manual_spec); | 952 &manual_spec); |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1318 const PrefService* local_state_prefs, | 1326 const PrefService* local_state_prefs, |
1319 const NetworkState& network) { | 1327 const NetworkState& network) { |
1320 ::onc::ONCSource ignored_onc_source; | 1328 ::onc::ONCSource ignored_onc_source; |
1321 const base::DictionaryValue* policy = onc::GetPolicyForNetwork( | 1329 const base::DictionaryValue* policy = onc::GetPolicyForNetwork( |
1322 profile_prefs, local_state_prefs, network, &ignored_onc_source); | 1330 profile_prefs, local_state_prefs, network, &ignored_onc_source); |
1323 return policy != NULL; | 1331 return policy != NULL; |
1324 } | 1332 } |
1325 | 1333 |
1326 } // namespace onc | 1334 } // namespace onc |
1327 } // namespace chromeos | 1335 } // namespace chromeos |
OLD | NEW |