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

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

Issue 762243002: Change to Shill's IPConfig objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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_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 fb5fcdd29cb353bebbfda2a82866262a40858815..a3c962397cd0e8006b411832d56264b4142c1db8 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -84,7 +84,7 @@ class ShillToONCTranslator {
void TranslateCellularDevice();
void TranslateNetworkWithState();
void TranslateIPConfig();
- void TranslateSavedOrStaticIPConfig(const std::string& nameserver_property);
+ void TranslateSavedOrStaticIPConfig();
void TranslateSavedIPConfig();
void TranslateStaticIPConfig();
@@ -479,8 +479,19 @@ void ShillToONCTranslator::TranslateNetworkWithState() {
*shill_ipconfigs);
}
- TranslateAndAddNestedObject(::onc::network_config::kSavedIPConfig);
- TranslateAndAddNestedObject(::onc::network_config::kStaticIPConfig);
+ const base::DictionaryValue* saved_ipconfig = nullptr;
+ if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
+ shill::kSavedIPConfigProperty, &saved_ipconfig)) {
+ TranslateAndAddNestedObject(::onc::network_config::kSavedIPConfig,
+ *saved_ipconfig);
+ }
+
+ const base::DictionaryValue* static_ipconfig = nullptr;
+ if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
+ shill::kStaticIPConfigProperty, &static_ipconfig)) {
+ TranslateAndAddNestedObject(::onc::network_config::kStaticIPConfig,
+ *static_ipconfig);
+ }
}
void ShillToONCTranslator::TranslateIPConfig() {
@@ -502,24 +513,9 @@ void ShillToONCTranslator::TranslateIPConfig() {
onc_object_->SetStringWithoutPathExpansion(::onc::ipconfig::kType, type);
}
-void ShillToONCTranslator::TranslateSavedOrStaticIPConfig(
- const std::string& nameserver_property) {
+void ShillToONCTranslator::TranslateSavedOrStaticIPConfig() {
CopyPropertiesAccordingToSignature();
- // Saved/Static IP config nameservers are stored as a comma separated list.
- std::string shill_nameservers;
- shill_dictionary_->GetStringWithoutPathExpansion(
- nameserver_property, &shill_nameservers);
- std::vector<std::string> onc_nameserver_vector;
- if (Tokenize(shill_nameservers, ",", &onc_nameserver_vector) > 0) {
- scoped_ptr<base::ListValue> onc_nameservers(new base::ListValue);
- for (std::vector<std::string>::iterator iter =
- onc_nameserver_vector.begin();
- iter != onc_nameserver_vector.end(); ++iter) {
- onc_nameservers->AppendString(*iter);
- }
- onc_object_->SetWithoutPathExpansion(::onc::ipconfig::kNameServers,
- onc_nameservers.release());
- }
+
// Static and Saved IPConfig in Shill are always of type IPv4. Set this type
// in ONC, but not if the object would be empty except the type.
if (!onc_object_->empty()) {
@@ -529,11 +525,11 @@ void ShillToONCTranslator::TranslateSavedOrStaticIPConfig(
}
void ShillToONCTranslator::TranslateSavedIPConfig() {
- TranslateSavedOrStaticIPConfig(shill::kSavedIPNameServersProperty);
+ TranslateSavedOrStaticIPConfig();
}
void ShillToONCTranslator::TranslateStaticIPConfig() {
- TranslateSavedOrStaticIPConfig(shill::kStaticIPNameServersProperty);
+ TranslateSavedOrStaticIPConfig();
}
void ShillToONCTranslator::TranslateAndAddNestedObject(

Powered by Google App Engine
This is Rietveld 408576698