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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 522 |
523 if (IsGlobalNetworkConfigInUserImport(*result)) | 523 if (IsGlobalNetworkConfigInUserImport(*result)) |
524 return false; | 524 return false; |
525 | 525 |
526 return true; | 526 return true; |
527 } | 527 } |
528 | 528 |
529 bool Validator::ValidateNetworkConfiguration(base::DictionaryValue* result) { | 529 bool Validator::ValidateNetworkConfiguration(base::DictionaryValue* result) { |
530 using namespace ::onc::network_config; | 530 using namespace ::onc::network_config; |
531 | 531 |
532 const char* const kValidTypes[] = { | 532 const char* const kValidTypes[] = {::onc::network_type::kEthernet, |
533 ::onc::network_type::kEthernet, ::onc::network_type::kVPN, | 533 ::onc::network_type::kVPN, |
534 ::onc::network_type::kWiFi, ::onc::network_type::kCellular}; | 534 ::onc::network_type::kWiFi, |
| 535 ::onc::network_type::kCellular, |
| 536 ::onc::network_type::kWimax}; |
535 const std::vector<const char*> valid_types(toVector(kValidTypes)); | 537 const std::vector<const char*> valid_types(toVector(kValidTypes)); |
536 const char* const kValidIPConfigTypes[] = {kIPConfigTypeDHCP, | 538 const char* const kValidIPConfigTypes[] = {kIPConfigTypeDHCP, |
537 kIPConfigTypeStatic}; | 539 kIPConfigTypeStatic}; |
538 const std::vector<const char*> valid_ipconfig_types( | 540 const std::vector<const char*> valid_ipconfig_types( |
539 toVector(kValidIPConfigTypes)); | 541 toVector(kValidIPConfigTypes)); |
540 if (FieldExistsAndHasNoValidValue(*result, kType, valid_types) || | 542 if (FieldExistsAndHasNoValidValue(*result, kType, valid_types) || |
541 FieldExistsAndHasNoValidValue(*result, kIPAddressConfigType, | 543 FieldExistsAndHasNoValidValue(*result, kIPAddressConfigType, |
542 valid_ipconfig_types) || | 544 valid_ipconfig_types) || |
543 FieldExistsAndHasNoValidValue(*result, kNameServersConfigType, | 545 FieldExistsAndHasNoValidValue(*result, kNameServersConfigType, |
544 valid_ipconfig_types) || | 546 valid_ipconfig_types) || |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 } | 586 } |
585 | 587 |
586 if (type == ::onc::network_type::kWiFi) { | 588 if (type == ::onc::network_type::kWiFi) { |
587 all_required_exist &= RequireField(*result, ::onc::network_config::kWiFi); | 589 all_required_exist &= RequireField(*result, ::onc::network_config::kWiFi); |
588 } else if (type == ::onc::network_type::kEthernet) { | 590 } else if (type == ::onc::network_type::kEthernet) { |
589 all_required_exist &= | 591 all_required_exist &= |
590 RequireField(*result, ::onc::network_config::kEthernet); | 592 RequireField(*result, ::onc::network_config::kEthernet); |
591 } else if (type == ::onc::network_type::kCellular) { | 593 } else if (type == ::onc::network_type::kCellular) { |
592 all_required_exist &= | 594 all_required_exist &= |
593 RequireField(*result, ::onc::network_config::kCellular); | 595 RequireField(*result, ::onc::network_config::kCellular); |
| 596 } else if (type == ::onc::network_type::kWimax) { |
| 597 all_required_exist &= |
| 598 RequireField(*result, ::onc::network_config::kWimax); |
594 } else if (type == ::onc::network_type::kVPN) { | 599 } else if (type == ::onc::network_type::kVPN) { |
595 all_required_exist &= RequireField(*result, ::onc::network_config::kVPN); | 600 all_required_exist &= RequireField(*result, ::onc::network_config::kVPN); |
596 } | 601 } |
597 } | 602 } |
598 | 603 |
599 return !error_on_missing_field_ || all_required_exist; | 604 return !error_on_missing_field_ || all_required_exist; |
600 } | 605 } |
601 | 606 |
602 bool Validator::ValidateEthernet(base::DictionaryValue* result) { | 607 bool Validator::ValidateEthernet(base::DictionaryValue* result) { |
603 using namespace ::onc::ethernet; | 608 using namespace ::onc::ethernet; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 } | 941 } |
937 | 942 |
938 std::string Validator::MessageHeader() { | 943 std::string Validator::MessageHeader() { |
939 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); | 944 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); |
940 std::string message = "At " + path + ": "; | 945 std::string message = "At " + path + ": "; |
941 return message; | 946 return message; |
942 } | 947 } |
943 | 948 |
944 } // namespace onc | 949 } // namespace onc |
945 } // namespace chromeos | 950 } // namespace chromeos |
OLD | NEW |