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

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

Issue 708563005: Use setProperties for IP Config. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_430113_internet_options_1
Patch Set: Fix mock expectation 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_onc_to_shill.cc
diff --git a/chromeos/network/onc/onc_translator_onc_to_shill.cc b/chromeos/network/onc/onc_translator_onc_to_shill.cc
index 5300a9d424b5e003ceb66a2c5c9b62c3922b06d1..b073d25e5938709dc834e885a14b252bd57f7ba3 100644
--- a/chromeos/network/onc/onc_translator_onc_to_shill.cc
+++ b/chromeos/network/onc/onc_translator_onc_to_shill.cc
@@ -142,17 +142,39 @@ void LocalTranslator::TranslateEthernet() {
void LocalTranslator::TranslateStaticIPConfig() {
- const base::ListValue* onc_nameservers = NULL;
- if (onc_object_->GetListWithoutPathExpansion(::onc::ipconfig::kNameServers,
- &onc_nameservers)) {
- std::vector<std::string> onc_nameservers_vector;
- ConvertListValueToStringVector(*onc_nameservers, &onc_nameservers_vector);
- std::string shill_nameservers = JoinString(onc_nameservers_vector, ',');
- shill_dictionary_->SetStringWithoutPathExpansion(
- shill::kStaticIPNameServersProperty, shill_nameservers);
+ const base::ListValue* onc_nameservers_list = NULL;
+ onc_object_->GetListWithoutPathExpansion(::onc::ipconfig::kNameServers,
+ &onc_nameservers_list);
+ if (onc_nameservers_list) {
+ if (!onc_nameservers_list->empty()) {
+ std::vector<std::string> onc_nameservers_vector;
+ ConvertListValueToStringVector(*onc_nameservers_list,
+ &onc_nameservers_vector);
+ std::string shill_nameservers = JoinString(onc_nameservers_vector, ',');
+ shill_dictionary_->SetStringWithoutPathExpansion(
+ shill::kStaticIPNameServersProperty, shill_nameservers);
+ } else {
+ // Empty NameServers entry clears the value.
+ shill_dictionary_->SetWithoutPathExpansion(
+ shill::kStaticIPNameServersProperty, base::Value::CreateNullValue());
+ }
}
CopyFieldsAccordingToSignature();
+
+ // An empty IP Address string indicates 'automatic' configuration; clear all
+ // Static IP config properties in Shill.
+ std::string address_value;
+ if (onc_object_->GetStringWithoutPathExpansion(::onc::ipconfig::kIPAddress,
+ &address_value) &&
+ address_value.empty()) {
+ shill_dictionary_->SetWithoutPathExpansion(shill::kStaticIPAddressProperty,
+ base::Value::CreateNullValue());
+ shill_dictionary_->SetWithoutPathExpansion(shill::kStaticIPGatewayProperty,
+ base::Value::CreateNullValue());
+ shill_dictionary_->SetWithoutPathExpansion(
+ shill::kStaticIPPrefixlenProperty, base::Value::CreateNullValue());
+ }
}
void LocalTranslator::TranslateOpenVPN() {

Powered by Google App Engine
This is Rietveld 408576698