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_validator.h" | 5 #include "chromeos/network/onc/onc_validator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 + "Field name '" + field_name + "' is unknown."; | 170 + "Field name '" + field_name + "' is unknown."; |
171 if (error_on_unknown_field_) | 171 if (error_on_unknown_field_) |
172 LOG(ERROR) << message; | 172 LOG(ERROR) << message; |
173 else | 173 else |
174 LOG(WARNING) << message; | 174 LOG(WARNING) << message; |
175 } | 175 } |
176 | 176 |
177 return result.Pass(); | 177 return result.Pass(); |
178 } | 178 } |
179 | 179 |
180 scoped_ptr<base::ListValue> Validator::MapArray( | |
181 const OncValueSignature& array_signature, | |
182 const base::ListValue& onc_array, | |
183 bool* nested_error) { | |
184 bool nested_error_in_current_array = false; | |
185 scoped_ptr<base::ListValue> result = Mapper::MapArray( | |
186 array_signature, onc_array, &nested_error_in_current_array); | |
187 | |
188 // Drop individual networks and certificates instead of rejecting all of | |
189 // the configuration. | |
190 if (nested_error_in_current_array && | |
191 &array_signature != &kNetworkConfigurationListSignature && | |
192 &array_signature != &kCertificateListSignature) { | |
193 *nested_error = nested_error_in_current_array; | |
stevenjb
2012/12/14 01:06:36
It seems odd that nested_error is only sometimes s
pneubeck (no reviews)
2012/12/14 18:55:46
That's currently the behavior of all other methods
stevenjb
2012/12/14 20:21:40
OK, as long as the comment is clear that's fine.
| |
194 } | |
195 return result.Pass(); | |
196 } | |
197 | |
180 scoped_ptr<base::Value> Validator::MapEntry(int index, | 198 scoped_ptr<base::Value> Validator::MapEntry(int index, |
181 const OncValueSignature& signature, | 199 const OncValueSignature& signature, |
182 const base::Value& onc_value, | 200 const base::Value& onc_value, |
183 bool* error) { | 201 bool* error) { |
184 std::string str = base::IntToString(index); | 202 std::string str = base::IntToString(index); |
185 path_.push_back(str); | 203 path_.push_back(str); |
186 scoped_ptr<base::Value> result = Mapper::MapEntry(index, signature, | 204 scoped_ptr<base::Value> result = Mapper::MapEntry(index, signature, |
187 onc_value, error); | 205 onc_value, error); |
188 DCHECK_EQ(str, path_.back()); | 206 DCHECK_EQ(str, path_.back()); |
189 path_.pop_back(); | 207 path_.pop_back(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 &recommended_value)) { | 240 &recommended_value)) { |
223 return true; | 241 return true; |
224 } | 242 } |
225 base::ListValue* recommended_list; | 243 base::ListValue* recommended_list; |
226 recommended_value->GetAsList(&recommended_list); | 244 recommended_value->GetAsList(&recommended_list); |
227 CHECK(recommended_list != NULL); | 245 CHECK(recommended_list != NULL); |
228 | 246 |
229 recommended.reset(recommended_list); | 247 recommended.reset(recommended_list); |
230 | 248 |
231 if (!managed_onc_) { | 249 if (!managed_onc_) { |
250 error_or_warning_found_ = true; | |
232 LOG(WARNING) << WarningHeader() << "Found the field '" << onc::kRecommended | 251 LOG(WARNING) << WarningHeader() << "Found the field '" << onc::kRecommended |
233 << "' in an unmanaged ONC. Removing it."; | 252 << "' in an unmanaged ONC. Removing it."; |
234 return true; | 253 return true; |
235 } | 254 } |
236 | 255 |
237 scoped_ptr<base::ListValue> repaired_recommended(new base::ListValue); | 256 scoped_ptr<base::ListValue> repaired_recommended(new base::ListValue); |
238 for (base::ListValue::iterator it = recommended->begin(); | 257 for (base::ListValue::iterator it = recommended->begin(); |
239 it != recommended->end(); ++it) { | 258 it != recommended->end(); ++it) { |
240 std::string field_name; | 259 std::string field_name; |
241 if (!(*it)->GetAsString(&field_name)) { | 260 if (!(*it)->GetAsString(&field_name)) { |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
702 } | 721 } |
703 | 722 |
704 std::string Validator::MessageHeader(bool is_error) { | 723 std::string Validator::MessageHeader(bool is_error) { |
705 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); | 724 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); |
706 std::string message = "At " + path + ": "; | 725 std::string message = "At " + path + ": "; |
707 return message; | 726 return message; |
708 } | 727 } |
709 | 728 |
710 } // namespace onc | 729 } // namespace onc |
711 } // namespace chromeos | 730 } // namespace chromeos |
OLD | NEW |