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

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

Issue 402953004: Correctly translate Cellular Device properties to ONC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix signature Created 6 years, 5 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
« no previous file with comments | « chromeos/network/onc/onc_translation_tables.cc ('k') | components/onc/onc_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/onc/onc_translator_shill_to_onc.cc
diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc
index 3c00e40ec1082881975849179530b5ecd8d9e761..38d3708d236de38ce43f990528cc463970ebe84d 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -66,6 +66,7 @@ class ShillToONCTranslator {
void TranslateVPN();
void TranslateWiFiWithState();
void TranslateCellularWithState();
+ void TranslateCellularDevice();
void TranslateNetworkWithState();
void TranslateIPConfig();
@@ -133,6 +134,8 @@ ShillToONCTranslator::CreateTranslatedONCObject() {
TranslateWiFiWithState();
} else if (onc_signature_ == &kCellularWithStateSignature) {
TranslateCellularWithState();
+ } else if (onc_signature_ == &kCellularDeviceSignature) {
+ TranslateCellularDevice();
} else if (onc_signature_ == &kIPConfigSignature) {
TranslateIPConfig();
} else {
@@ -264,30 +267,26 @@ void ShillToONCTranslator::TranslateCellularWithState() {
TranslateAndAddListOfObjects(::onc::cellular::kAPNList, *shill_apns);
}
+ // Merge the Device dictionary with this one (Cellular) using the
+ // CellularDevice signiture.
const base::DictionaryValue* device_dictionary = NULL;
if (!shill_dictionary_->GetDictionaryWithoutPathExpansion(
shill::kDeviceProperty, &device_dictionary)) {
return;
}
+ ShillToONCTranslator nested_translator(*device_dictionary,
+ kCellularDeviceSignature);
+ scoped_ptr<base::DictionaryValue> nested_object =
+ nested_translator.CreateTranslatedONCObject();
+ onc_object_->MergeDictionary(nested_object.get());
+}
- // Iterate through all fields of the CellularWithState signature and copy
- // values from the device properties according to the separate
- // CellularDeviceTable.
- for (const OncFieldSignature* field_signature = onc_signature_->fields;
- field_signature->onc_field_name != NULL; ++field_signature) {
- const std::string& onc_field_name = field_signature->onc_field_name;
-
- std::string shill_property_name;
- const base::Value* shill_value = NULL;
- if (!GetShillPropertyName(field_signature->onc_field_name,
- kCellularDeviceTable,
- &shill_property_name) ||
- !device_dictionary->GetWithoutPathExpansion(shill_property_name,
- &shill_value)) {
- continue;
- }
- onc_object_->SetWithoutPathExpansion(onc_field_name,
- shill_value->DeepCopy());
+void ShillToONCTranslator::TranslateCellularDevice() {
+ CopyPropertiesAccordingToSignature();
+ const base::DictionaryValue* dictionary = NULL;
+ if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
+ shill::kSIMLockStatusProperty, &dictionary)) {
+ TranslateAndAddNestedObject(::onc::cellular::kSIMLockStatus, *dictionary);
armansito 2014/07/18 21:21:52 I wonder if we should just place all the nested fi
stevenjb 2014/07/18 21:31:50 Fortunately in JS, nested dictionaries are easy to
}
}
« no previous file with comments | « chromeos/network/onc/onc_translation_tables.cc ('k') | components/onc/onc_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698