Chromium Code Reviews| Index: chromeos/network/onc/onc_utils.cc |
| diff --git a/chromeos/network/onc/onc_utils.cc b/chromeos/network/onc/onc_utils.cc |
| index fdff42dbd9d3983db5ebf1aa68f7dfc5ee2fdb30..93e7629b26548909aa1febc3d8433194a3227358 100644 |
| --- a/chromeos/network/onc/onc_utils.cc |
| +++ b/chromeos/network/onc/onc_utils.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/json/json_reader.h" |
| #include "base/logging.h" |
| #include "base/metrics/histogram.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| #include "base/values.h" |
| #include "chromeos/network/network_event_log.h" |
| @@ -240,6 +241,39 @@ void ExpandStringsInNetworks(const StringSubstitution& substitution, |
| } |
| } |
| +void FillInHexSSIDFieldsInOncObject(const OncValueSignature& signature, |
| + base::DictionaryValue* onc_object) { |
| + if (&signature == &kWiFiSignature) |
| + FillInHexSSIDField(onc_object); |
| + |
| + // Recurse into nested objects. |
| + for (base::DictionaryValue::Iterator it(*onc_object); !it.IsAtEnd(); |
| + it.Advance()) { |
| + base::DictionaryValue* inner_object = NULL; |
|
pneubeck (no reviews)
2014/11/27 14:49:02
nit: NULL -> nullptr (please check in the whole CL
cschuet (SLOW)
2014/11/27 15:44:31
Done.
|
| + if (!onc_object->GetDictionaryWithoutPathExpansion(it.key(), &inner_object)) |
| + continue; |
| + |
| + const OncFieldSignature* field_signature = |
| + GetFieldSignature(signature, it.key()); |
| + if (!field_signature) |
| + continue; |
| + |
| + FillInHexSSIDFieldsInOncObject(*field_signature->value_signature, |
| + inner_object); |
| + } |
| +} |
| + |
| +void FillInHexSSIDField(base::DictionaryValue* wifi_fields) { |
| + if (!wifi_fields->HasKey(::onc::wifi::kHexSSID)) { |
| + std::string ssid_string; |
| + wifi_fields->GetStringWithoutPathExpansion(::onc::wifi::kSSID, |
| + &ssid_string); |
| + wifi_fields->SetStringWithoutPathExpansion( |
| + ::onc::wifi::kHexSSID, |
| + base::HexEncode(ssid_string.c_str(), ssid_string.size())); |
| + } |
| +} |
| + |
| namespace { |
| class OncMaskValues : public Mapper { |
| @@ -398,6 +432,9 @@ bool ParseAndValidateOncForImport(const std::string& onc_blob, |
| *toplevel_onc, |
| &validation_result); |
| + FillInHexSSIDFieldsInOncObject(kToplevelConfigurationSignature, |
| + toplevel_onc.get()); |
| + |
| if (from_policy) { |
| UMA_HISTOGRAM_BOOLEAN("Enterprise.ONC.PolicyValidation", |
| validation_result == Validator::VALID); |