Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(823)

Side by Side Diff: chromeos/network/onc/onc_validator.cc

Issue 2844363003: [CrOS Tether] Add HasConnectedToHost property for Tether networks. (Closed)
Patch Set: Rebased. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 all_required_exist &= RequireField(*result, kPKCS12); 1001 all_required_exist &= RequireField(*result, kPKCS12);
1002 else if (type == kServer || type == kAuthority) 1002 else if (type == kServer || type == kAuthority)
1003 all_required_exist &= RequireField(*result, kX509); 1003 all_required_exist &= RequireField(*result, kX509);
1004 1004
1005 return !error_on_missing_field_ || all_required_exist; 1005 return !error_on_missing_field_ || all_required_exist;
1006 } 1006 }
1007 1007
1008 bool Validator::ValidateTether(base::DictionaryValue* result) { 1008 bool Validator::ValidateTether(base::DictionaryValue* result) {
1009 using namespace ::onc::tether; 1009 using namespace ::onc::tether;
1010 1010
1011 int batteryPercentage; 1011 int battery_percentage;
1012 if (!result->GetIntegerWithoutPathExpansion(kBatteryPercentage, 1012 if (!result->GetIntegerWithoutPathExpansion(kBatteryPercentage,
1013 &batteryPercentage) || 1013 &battery_percentage) ||
1014 batteryPercentage < 0 || batteryPercentage > 100) { 1014 battery_percentage < 0 || battery_percentage > 100) {
1015 // Battery percentage must be present and within [0, 100]. 1015 // Battery percentage must be present and within [0, 100].
1016 error_or_warning_found_ = true; 1016 error_or_warning_found_ = true;
1017 return false; 1017 return false;
1018 } 1018 }
1019 1019
1020 int signalStrength; 1020 int signal_strength;
1021 if (!result->GetIntegerWithoutPathExpansion(kSignalStrength, 1021 if (!result->GetIntegerWithoutPathExpansion(kSignalStrength,
1022 &signalStrength) || 1022 &signal_strength) ||
1023 signalStrength < 0 || signalStrength > 100) { 1023 signal_strength < 0 || signal_strength > 100) {
1024 // Signal strength must be present and within [0, 100]. 1024 // Signal strength must be present and within [0, 100].
1025 error_or_warning_found_ = true; 1025 error_or_warning_found_ = true;
1026 return false; 1026 return false;
1027 } 1027 }
1028 1028
1029 std::string carrier; 1029 std::string carrier;
1030 if (!result->GetStringWithoutPathExpansion(kCarrier, &carrier) || 1030 if (!result->GetStringWithoutPathExpansion(kCarrier, &carrier) ||
1031 carrier.empty()) { 1031 carrier.empty()) {
1032 // Carrier must be a non-empty string. 1032 // Carrier must be a non-empty string.
1033 error_or_warning_found_ = true; 1033 error_or_warning_found_ = true;
1034 return false; 1034 return false;
1035 } 1035 }
1036 1036
1037 // No required fields. 1037 bool all_required_exist = RequireField(*result, kHasConnectedToHost);
1038 return true; 1038 if (!all_required_exist) {
1039 error_or_warning_found_ = true;
1040 }
1041
1042 return !error_on_missing_field_ || all_required_exist;
1039 } 1043 }
1040 1044
1041 std::string Validator::MessageHeader() { 1045 std::string Validator::MessageHeader() {
1042 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, "."); 1046 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, ".");
1043 std::string message = "At " + path + ": "; 1047 std::string message = "At " + path + ": ";
1044 return message; 1048 return message;
1045 } 1049 }
1046 1050
1047 } // namespace onc 1051 } // namespace onc
1048 } // namespace chromeos 1052 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translation_tables.cc ('k') | chromeos/network/onc/onc_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698