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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_piece.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chromeos/network/onc/onc_signature.h" | 19 #include "chromeos/network/onc/onc_signature.h" |
19 | 20 |
20 namespace chromeos { | 21 namespace chromeos { |
21 namespace onc { | 22 namespace onc { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // According to the IEEE 802.11 standard the SSID is a series of 0 to 32 octets. | 26 // According to the IEEE 802.11 standard the SSID is a series of 0 to 32 octets. |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 else if (cert_type == kRef) | 309 else if (cert_type == kRef) |
309 all_required_exist &= RequireField(*result, kClientCertRef); | 310 all_required_exist &= RequireField(*result, kClientCertRef); |
310 | 311 |
311 return !error_on_missing_field_ || all_required_exist; | 312 return !error_on_missing_field_ || all_required_exist; |
312 } | 313 } |
313 | 314 |
314 namespace { | 315 namespace { |
315 | 316 |
316 std::string JoinStringRange(const std::vector<const char*>& strings, | 317 std::string JoinStringRange(const std::vector<const char*>& strings, |
317 const std::string& separator) { | 318 const std::string& separator) { |
318 std::vector<std::string> string_vector; | 319 std::vector<base::StringPiece> string_vector(strings.begin(), strings.end()); |
319 std::copy(strings.begin(), strings.end(), std::back_inserter(string_vector)); | |
320 return base::JoinString(string_vector, separator); | 320 return base::JoinString(string_vector, separator); |
321 } | 321 } |
322 | 322 |
323 } // namespace | 323 } // namespace |
324 | 324 |
325 bool Validator::IsValidValue(const std::string& field_value, | 325 bool Validator::IsValidValue(const std::string& field_value, |
326 const std::vector<const char*>& valid_values) { | 326 const std::vector<const char*>& valid_values) { |
327 for (const char* it : valid_values) { | 327 for (const char* it : valid_values) { |
328 if (field_value == it) | 328 if (field_value == it) |
329 return true; | 329 return true; |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 } | 1016 } |
1017 | 1017 |
1018 std::string Validator::MessageHeader() { | 1018 std::string Validator::MessageHeader() { |
1019 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, "."); | 1019 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, "."); |
1020 std::string message = "At " + path + ": "; | 1020 std::string message = "At " + path + ": "; |
1021 return message; | 1021 return message; |
1022 } | 1022 } |
1023 | 1023 |
1024 } // namespace onc | 1024 } // namespace onc |
1025 } // namespace chromeos | 1025 } // namespace chromeos |
OLD | NEW |