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_normalizer.h" | 5 #include "chromeos/network/onc/onc_normalizer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 scoped_ptr<base::DictionaryValue> Normalizer::NormalizeObject( | 25 scoped_ptr<base::DictionaryValue> Normalizer::NormalizeObject( |
26 const OncValueSignature* object_signature, | 26 const OncValueSignature* object_signature, |
27 const base::DictionaryValue& onc_object) { | 27 const base::DictionaryValue& onc_object) { |
28 CHECK(object_signature != NULL); | 28 CHECK(object_signature != NULL); |
29 bool error = false; | 29 bool error = false; |
30 scoped_ptr<base::DictionaryValue> result = | 30 scoped_ptr<base::DictionaryValue> result = |
31 MapObject(*object_signature, onc_object, &error); | 31 MapObject(*object_signature, onc_object, &error); |
32 DCHECK(!error); | 32 DCHECK(!error); |
33 return result.Pass(); | 33 return result; |
34 } | 34 } |
35 | 35 |
36 scoped_ptr<base::DictionaryValue> Normalizer::MapObject( | 36 scoped_ptr<base::DictionaryValue> Normalizer::MapObject( |
37 const OncValueSignature& signature, | 37 const OncValueSignature& signature, |
38 const base::DictionaryValue& onc_object, | 38 const base::DictionaryValue& onc_object, |
39 bool* error) { | 39 bool* error) { |
40 scoped_ptr<base::DictionaryValue> normalized = | 40 scoped_ptr<base::DictionaryValue> normalized = |
41 Mapper::MapObject(signature, onc_object, error); | 41 Mapper::MapObject(signature, onc_object, error); |
42 | 42 |
43 if (normalized.get() == NULL) | 43 if (normalized.get() == NULL) |
(...skipping 14 matching lines...) Expand all Loading... |
58 NormalizeNetworkConfiguration(normalized.get()); | 58 NormalizeNetworkConfiguration(normalized.get()); |
59 else if (&signature == &kOpenVPNSignature) | 59 else if (&signature == &kOpenVPNSignature) |
60 NormalizeOpenVPN(normalized.get()); | 60 NormalizeOpenVPN(normalized.get()); |
61 else if (&signature == &kProxySettingsSignature) | 61 else if (&signature == &kProxySettingsSignature) |
62 NormalizeProxySettings(normalized.get()); | 62 NormalizeProxySettings(normalized.get()); |
63 else if (&signature == &kVPNSignature) | 63 else if (&signature == &kVPNSignature) |
64 NormalizeVPN(normalized.get()); | 64 NormalizeVPN(normalized.get()); |
65 else if (&signature == &kWiFiSignature) | 65 else if (&signature == &kWiFiSignature) |
66 NormalizeWiFi(normalized.get()); | 66 NormalizeWiFi(normalized.get()); |
67 | 67 |
68 return normalized.Pass(); | 68 return normalized; |
69 } | 69 } |
70 | 70 |
71 namespace { | 71 namespace { |
72 | 72 |
73 void RemoveEntryUnless(base::DictionaryValue* dict, | 73 void RemoveEntryUnless(base::DictionaryValue* dict, |
74 const std::string& path, | 74 const std::string& path, |
75 bool condition) { | 75 bool condition) { |
76 if (!condition) | 76 if (!condition) |
77 dict->RemoveWithoutPathExpansion(path, NULL); | 77 dict->RemoveWithoutPathExpansion(path, NULL); |
78 } | 78 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 std::string security; | 237 std::string security; |
238 wifi->GetStringWithoutPathExpansion(::onc::wifi::kSecurity, &security); | 238 wifi->GetStringWithoutPathExpansion(::onc::wifi::kSecurity, &security); |
239 RemoveEntryUnless(wifi, kEAP, security == kWEP_8021X || security == kWPA_EAP); | 239 RemoveEntryUnless(wifi, kEAP, security == kWEP_8021X || security == kWPA_EAP); |
240 RemoveEntryUnless(wifi, kPassphrase, | 240 RemoveEntryUnless(wifi, kPassphrase, |
241 security == kWEP_PSK || security == kWPA_PSK); | 241 security == kWEP_PSK || security == kWPA_PSK); |
242 FillInHexSSIDField(wifi); | 242 FillInHexSSIDField(wifi); |
243 } | 243 } |
244 | 244 |
245 } // namespace onc | 245 } // namespace onc |
246 } // namespace chromeos | 246 } // namespace chromeos |
OLD | NEW |