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

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

Issue 776603002: Revert of Change to Shill's IPConfig objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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_translator_onc_to_shill.cc ('k') | chromeos/test/data/network/shill_ethernet.json » ('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 a3c962397cd0e8006b411832d56264b4142c1db8..fb5fcdd29cb353bebbfda2a82866262a40858815 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 @@
void TranslateCellularDevice();
void TranslateNetworkWithState();
void TranslateIPConfig();
- void TranslateSavedOrStaticIPConfig();
+ void TranslateSavedOrStaticIPConfig(const std::string& nameserver_property);
void TranslateSavedIPConfig();
void TranslateStaticIPConfig();
@@ -479,19 +479,8 @@
*shill_ipconfigs);
}
- 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);
- }
+ TranslateAndAddNestedObject(::onc::network_config::kSavedIPConfig);
+ TranslateAndAddNestedObject(::onc::network_config::kStaticIPConfig);
}
void ShillToONCTranslator::TranslateIPConfig() {
@@ -513,9 +502,24 @@
onc_object_->SetStringWithoutPathExpansion(::onc::ipconfig::kType, type);
}
-void ShillToONCTranslator::TranslateSavedOrStaticIPConfig() {
- CopyPropertiesAccordingToSignature();
-
+void ShillToONCTranslator::TranslateSavedOrStaticIPConfig(
+ const std::string& nameserver_property) {
+ 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()) {
@@ -525,11 +529,11 @@
}
void ShillToONCTranslator::TranslateSavedIPConfig() {
- TranslateSavedOrStaticIPConfig();
+ TranslateSavedOrStaticIPConfig(shill::kSavedIPNameServersProperty);
}
void ShillToONCTranslator::TranslateStaticIPConfig() {
- TranslateSavedOrStaticIPConfig();
+ TranslateSavedOrStaticIPConfig(shill::kStaticIPNameServersProperty);
}
void ShillToONCTranslator::TranslateAndAddNestedObject(
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/test/data/network/shill_ethernet.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698