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 <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
13 #include "chromeos/network/onc/onc_mapper.h" | 14 #include "chromeos/network/onc/onc_mapper.h" |
14 #include "components/onc/onc_constants.h" | 15 #include "components/onc/onc_constants.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class DictionaryValue; | 18 class DictionaryValue; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 bool FieldExistsAndIsNotInRange(const base::DictionaryValue& object, | 168 bool FieldExistsAndIsNotInRange(const base::DictionaryValue& object, |
168 const std::string &field_name, | 169 const std::string &field_name, |
169 int lower_bound, | 170 int lower_bound, |
170 int upper_bound); | 171 int upper_bound); |
171 | 172 |
172 bool FieldExistsAndIsEmpty(const base::DictionaryValue& object, | 173 bool FieldExistsAndIsEmpty(const base::DictionaryValue& object, |
173 const std::string& field_name); | 174 const std::string& field_name); |
174 | 175 |
175 bool RequireField(const base::DictionaryValue& dict, const std::string& key); | 176 bool RequireField(const base::DictionaryValue& dict, const std::string& key); |
176 | 177 |
178 // The function checks if the GUID is unique. It returns true if the GUID is | |
pneubeck (no reviews)
2014/02/17 16:07:40
nit: remove first sentence. Start with "Returns tr
| |
179 // unique or if the GUID is empty (error handled elsewhere) and false | |
pneubeck (no reviews)
2014/02/17 16:07:40
empty GUID isn't handled specially in this functio
| |
180 // otherwise. The function also adds the GUID to a set in order to identify | |
pneubeck (no reviews)
2014/02/17 16:26:20
... or if the field |kGUID| doesn't exist in |dict
| |
181 // duplicates. | |
182 bool CheckGuidIsUniqueAndAddToSet(const base::DictionaryValue& dict, | |
183 const std::string& kGUID, | |
184 std::set<std::string> *guids); | |
185 | |
177 // Prohibit certificate patterns for device policy ONC so that an unmanaged | 186 // Prohibit certificate patterns for device policy ONC so that an unmanaged |
178 // user won't have a certificate presented for them involuntarily. | 187 // user won't have a certificate presented for them involuntarily. |
179 bool IsCertPatternInDevicePolicy(const std::string& cert_type); | 188 bool IsCertPatternInDevicePolicy(const std::string& cert_type); |
180 | 189 |
181 // Prohibit global network configuration in user ONC imports. | 190 // Prohibit global network configuration in user ONC imports. |
182 bool IsGlobalNetworkConfigInUserImport( | 191 bool IsGlobalNetworkConfigInUserImport( |
183 const base::DictionaryValue& onc_object); | 192 const base::DictionaryValue& onc_object); |
184 | 193 |
185 std::string MessageHeader(); | 194 std::string MessageHeader(); |
186 | 195 |
187 const bool error_on_unknown_field_; | 196 const bool error_on_unknown_field_; |
188 const bool error_on_wrong_recommended_; | 197 const bool error_on_wrong_recommended_; |
189 const bool error_on_missing_field_; | 198 const bool error_on_missing_field_; |
190 const bool managed_onc_; | 199 const bool managed_onc_; |
191 | 200 |
192 ::onc::ONCSource onc_source_; | 201 ::onc::ONCSource onc_source_; |
193 | 202 |
194 // The path of field names and indices to the current value. Indices | 203 // The path of field names and indices to the current value. Indices |
195 // are stored as strings in decimal notation. | 204 // are stored as strings in decimal notation. |
196 std::vector<std::string> path_; | 205 std::vector<std::string> path_; |
197 | 206 |
207 // Accumulates all network GUIDs during validation. Used to identify | |
208 // duplicate GUIDs. | |
209 std::set<std::string> network_guids_; | |
210 | |
211 // Accumulates all certificate GUIDs during validation. Used to identify | |
212 // duplicate GUIDs. | |
213 std::set<std::string> certificate_guids_; | |
214 | |
198 // Tracks if an error or warning occurred within validation initiated by | 215 // Tracks if an error or warning occurred within validation initiated by |
199 // function ValidateAndRepairObject. | 216 // function ValidateAndRepairObject. |
200 bool error_or_warning_found_; | 217 bool error_or_warning_found_; |
201 | 218 |
202 DISALLOW_COPY_AND_ASSIGN(Validator); | 219 DISALLOW_COPY_AND_ASSIGN(Validator); |
203 }; | 220 }; |
204 | 221 |
205 } // namespace onc | 222 } // namespace onc |
206 } // namespace chromeos | 223 } // namespace chromeos |
207 | 224 |
208 #endif // CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ | 225 #endif // CHROMEOS_NETWORK_ONC_ONC_VALIDATOR_H_ |
OLD | NEW |