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

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

Issue 749013003: ONC: Add IPAddressConfigType and NameServersConfigType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Alywas use empty dictionary to clear StaticIPConfig properties Created 5 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_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 cfce26a3f5ce272033273e9ec667db0804dac24f..9ef19e9f0aa934e59a94abce4453c52e695049aa 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -486,11 +486,30 @@ void ShillToONCTranslator::TranslateNetworkWithState() {
*saved_ipconfig);
}
+ // Translate the StaticIPConfig object and set the IP config types.
const base::DictionaryValue* static_ipconfig = nullptr;
if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
- shill::kStaticIPConfigProperty, &static_ipconfig)) {
- TranslateAndAddNestedObject(::onc::network_config::kStaticIPConfig,
- *static_ipconfig);
+ shill::kStaticIPConfigProperty, &static_ipconfig)) {
+ std::string ip_address;
+ if (static_ipconfig->GetStringWithoutPathExpansion(shill::kAddressProperty,
+ &ip_address) &&
+ !ip_address.empty()) {
+ onc_object_->SetStringWithoutPathExpansion(
+ ::onc::network_config::kIPAddressConfigType,
+ ::onc::network_config::kIPConfigTypeStatic);
+ }
+ const base::ListValue* name_servers = nullptr;
+ if (static_ipconfig->GetListWithoutPathExpansion(
+ shill::kNameServersProperty, &name_servers) &&
+ !name_servers->empty()) {
+ onc_object_->SetStringWithoutPathExpansion(
+ ::onc::network_config::kNameServersConfigType,
+ ::onc::network_config::kIPConfigTypeStatic);
+ }
+ if (!ip_address.empty() || (name_servers && !name_servers->empty())) {
+ TranslateAndAddNestedObject(::onc::network_config::kStaticIPConfig,
+ *static_ipconfig);
+ }
}
}
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/network/onc/onc_translator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698