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

Unified Diff: chromeos/network/onc/onc_validator.cc

Issue 11962048: This adds Cellular to the Shill to ONC translation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review changes Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/network/onc/onc_validator.cc
diff --git a/chromeos/network/onc/onc_validator.cc b/chromeos/network/onc/onc_validator.cc
index a57aeca2d6e77608b5532f9f853e2a33c7f4f2fa..178343c371909213724e3f5278567bf32aa25f15 100644
--- a/chromeos/network/onc/onc_validator.cc
+++ b/chromeos/network/onc/onc_validator.cc
@@ -386,23 +386,28 @@ bool Validator::ValidateToplevelConfiguration(
}
static const char* kValidTypes[] =
- { kUnencryptedConfiguration, kEncryptedConfiguration, NULL };
- if (FieldExistsAndHasNoValidValue(*result, kType, kValidTypes))
+ { toplevel_config::kUnencryptedConfiguration,
+ toplevel_config::kEncryptedConfiguration,
+ NULL };
+ if (FieldExistsAndHasNoValidValue(*result,
+ network_config::kType,
+ kValidTypes))
return false;
bool allRequiredExist = true;
// Not part of the ONC spec yet:
// We don't require the type field and default to UnencryptedConfiguration.
- std::string type = kUnencryptedConfiguration;
- result->GetStringWithoutPathExpansion(kType, &type);
- if (type == kUnencryptedConfiguration &&
- !result->HasKey(kNetworkConfigurations) &&
- !result->HasKey(kCertificates)) {
+ std::string type = toplevel_config::kUnencryptedConfiguration;
+ result->GetStringWithoutPathExpansion(network_config::kType, &type);
+ if (type == toplevel_config::kUnencryptedConfiguration &&
+ !result->HasKey(toplevel_config::kNetworkConfigurations) &&
+ !result->HasKey(toplevel_config::kCertificates)) {
error_or_warning_found_ = true;
std::string message = MessageHeader(error_on_missing_field_) +
- "Neither the field '" + kNetworkConfigurations + "' nor '" +
- kCertificates + "is present, but at least one is required.";
+ "Neither the field '" + toplevel_config::kNetworkConfigurations +
+ "' nor '" + toplevel_config::kCertificates +
+ "is present, but at least one is required.";
if (error_on_missing_field_)
LOG(ERROR) << message;
else
@@ -421,26 +426,31 @@ bool Validator::ValidateNetworkConfiguration(
return false;
}
- static const char* kValidTypes[] = { kEthernet, kVPN, kWiFi, NULL };
- if (FieldExistsAndHasNoValidValue(*result, kType, kValidTypes))
+ static const char* kValidTypes[] = { network_type::kEthernet,
+ network_type::kVPN,
+ network_type::kWiFi,
+ NULL };
+ if (FieldExistsAndHasNoValidValue(*result,
+ network_config::kType,
+ kValidTypes))
return false;
- bool allRequiredExist = RequireField(*result, kGUID);
+ bool allRequiredExist = RequireField(*result, network_config::kGUID);
bool remove = false;
result->GetBooleanWithoutPathExpansion(kRemove, &remove);
if (!remove) {
- allRequiredExist &= RequireField(*result, kName);
- allRequiredExist &= RequireField(*result, kType);
+ allRequiredExist &= RequireField(*result, network_config::kName);
+ allRequiredExist &= RequireField(*result, network_config::kType);
std::string type;
- result->GetStringWithoutPathExpansion(kType, &type);
+ result->GetStringWithoutPathExpansion(network_config::kType, &type);
// Prohibit anything but WiFi and Ethernet for device-level policy (which
// corresponds to shared networks). See also http://crosbug.com/28741.
if (onc_source_ == ONC_SOURCE_DEVICE_POLICY &&
- type != kWiFi &&
- type != kEthernet) {
+ type != network_type::kWiFi &&
+ type != network_type::kEthernet) {
error_or_warning_found_ = true;
LOG(ERROR) << ErrorHeader() << "Networks of type '"
<< type << "' are prohibited in ONC device policies.";
@@ -739,7 +749,7 @@ bool Validator::ValidateCertificate(
if (FieldExistsAndHasNoValidValue(*result, certificate::kType, kValidTypes))
return false;
- bool allRequiredExist = RequireField(*result, kGUID);
+ bool allRequiredExist = RequireField(*result, certificate::kGUID);
bool remove = false;
result->GetBooleanWithoutPathExpansion(kRemove, &remove);
« chromeos/network/onc/onc_translator_shill_to_onc.cc ('K') | « chromeos/network/onc/onc_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698