| 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 #ifndef CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ | 5 #ifndef CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ |
| 6 #define CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ | 6 #define CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 const OncValueSignature* object_signature, | 95 const OncValueSignature* object_signature, |
| 96 const base::DictionaryValue& onc_object, | 96 const base::DictionaryValue& onc_object, |
| 97 Result* result); | 97 Result* result); |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 // Overridden from Mapper: | 100 // Overridden from Mapper: |
| 101 // Compare |onc_value|s type with |onc_type| and validate/repair according to | 101 // Compare |onc_value|s type with |onc_type| and validate/repair according to |
| 102 // |signature|. On error returns NULL. | 102 // |signature|. On error returns NULL. |
| 103 virtual scoped_ptr<base::Value> MapValue(const OncValueSignature& signature, | 103 virtual scoped_ptr<base::Value> MapValue(const OncValueSignature& signature, |
| 104 const base::Value& onc_value, | 104 const base::Value& onc_value, |
| 105 bool* error) OVERRIDE; | 105 bool* error) override; |
| 106 | 106 |
| 107 // Dispatch to the right validation function according to | 107 // Dispatch to the right validation function according to |
| 108 // |signature|. Iterates over all fields and recursively validates/repairs | 108 // |signature|. Iterates over all fields and recursively validates/repairs |
| 109 // these. All valid fields are added to the result dictionary. Returns the | 109 // these. All valid fields are added to the result dictionary. Returns the |
| 110 // repaired dictionary. Only on error returns NULL. | 110 // repaired dictionary. Only on error returns NULL. |
| 111 virtual scoped_ptr<base::DictionaryValue> MapObject( | 111 virtual scoped_ptr<base::DictionaryValue> MapObject( |
| 112 const OncValueSignature& signature, | 112 const OncValueSignature& signature, |
| 113 const base::DictionaryValue& onc_object, | 113 const base::DictionaryValue& onc_object, |
| 114 bool* error) OVERRIDE; | 114 bool* error) override; |
| 115 | 115 |
| 116 // Pushes/pops the |field_name| to |path_|, otherwise like |Mapper::MapField|. | 116 // Pushes/pops the |field_name| to |path_|, otherwise like |Mapper::MapField|. |
| 117 virtual scoped_ptr<base::Value> MapField( | 117 virtual scoped_ptr<base::Value> MapField( |
| 118 const std::string& field_name, | 118 const std::string& field_name, |
| 119 const OncValueSignature& object_signature, | 119 const OncValueSignature& object_signature, |
| 120 const base::Value& onc_value, | 120 const base::Value& onc_value, |
| 121 bool* found_unknown_field, | 121 bool* found_unknown_field, |
| 122 bool* error) OVERRIDE; | 122 bool* error) override; |
| 123 | 123 |
| 124 // Ignores nested errors in NetworkConfigurations and Certificates, otherwise | 124 // Ignores nested errors in NetworkConfigurations and Certificates, otherwise |
| 125 // like |Mapper::MapArray|. | 125 // like |Mapper::MapArray|. |
| 126 virtual scoped_ptr<base::ListValue> MapArray( | 126 virtual scoped_ptr<base::ListValue> MapArray( |
| 127 const OncValueSignature& array_signature, | 127 const OncValueSignature& array_signature, |
| 128 const base::ListValue& onc_array, | 128 const base::ListValue& onc_array, |
| 129 bool* nested_error) OVERRIDE; | 129 bool* nested_error) override; |
| 130 | 130 |
| 131 // Pushes/pops the index to |path_|, otherwise like |Mapper::MapEntry|. | 131 // Pushes/pops the index to |path_|, otherwise like |Mapper::MapEntry|. |
| 132 virtual scoped_ptr<base::Value> MapEntry(int index, | 132 virtual scoped_ptr<base::Value> MapEntry(int index, |
| 133 const OncValueSignature& signature, | 133 const OncValueSignature& signature, |
| 134 const base::Value& onc_value, | 134 const base::Value& onc_value, |
| 135 bool* error) OVERRIDE; | 135 bool* error) override; |
| 136 | 136 |
| 137 // This is the default validation of objects/dictionaries. Validates | 137 // This is the default validation of objects/dictionaries. Validates |
| 138 // |onc_object| according to |object_signature|. |result| must point to a | 138 // |onc_object| according to |object_signature|. |result| must point to a |
| 139 // dictionary into which the repaired fields are written. | 139 // dictionary into which the repaired fields are written. |
| 140 bool ValidateObjectDefault(const OncValueSignature& object_signature, | 140 bool ValidateObjectDefault(const OncValueSignature& object_signature, |
| 141 const base::DictionaryValue& onc_object, | 141 const base::DictionaryValue& onc_object, |
| 142 base::DictionaryValue* result); | 142 base::DictionaryValue* result); |
| 143 | 143 |
| 144 // Validates/repairs the kRecommended array in |result| according to | 144 // Validates/repairs the kRecommended array in |result| according to |
| 145 // |object_signature| of the enclosing object. | 145 // |object_signature| of the enclosing object. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // function ValidateAndRepairObject. | 222 // function ValidateAndRepairObject. |
| 223 bool error_or_warning_found_; | 223 bool error_or_warning_found_; |
| 224 | 224 |
| 225 DISALLOW_COPY_AND_ASSIGN(Validator); | 225 DISALLOW_COPY_AND_ASSIGN(Validator); |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 } // namespace onc | 228 } // namespace onc |
| 229 } // namespace chromeos | 229 } // namespace chromeos |
| 230 | 230 |
| 231 #endif // CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ | 231 #endif // CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ |
| OLD | NEW |