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

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

Issue 509643003: Use GetManagedProperties in InternetOptionsHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_8a
Patch Set: Created 6 years, 4 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 9c6052f1e4dda0f6d8e15d7a183b4b3266732b8e..2bd1ebf43b4e788ac870789f8201e0116ed30f10 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -115,6 +115,12 @@ class ShillToONCTranslator {
// entry from |shill_dictionary_| to |onc_object_| if it exists.
void CopyProperty(const OncFieldSignature* field_signature);
+ // If |shill_property_name| exists in |shill_dictionary_|, copy it to
+ // |dictionary|.
pneubeck (no reviews) 2014/09/03 15:14:29 nit: mention that it copies to the key |onc_proper
stevenjb 2014/09/03 21:28:06 Done, and renamed -> onc_field_name for consistenc
+ void CopyPropertyToDictionary(const std::string& shill_property_name,
+ const std::string& onc_property_name,
+ base::DictionaryValue* dictionary);
+
// If existent, translates the entry at |shill_property_name| in
// |shill_dictionary_| using |table|. It is an error if no matching table
// entry is found. Writes the result as entry at |onc_field_name| in
@@ -377,8 +383,7 @@ void ShillToONCTranslator::TranslateNetworkWithState() {
// Since Name is a read only field in Shill unless it's a VPN, it is copied
// here, but not when going the other direction (if it's not a VPN).
std::string name;
- shill_dictionary_->GetStringWithoutPathExpansion(shill::kNameProperty,
- &name);
+ shill_dictionary_->GetStringWithoutPathExpansion(shill::kNameProperty, &name);
onc_object_->SetStringWithoutPathExpansion(::onc::network_config::kName,
name);
@@ -418,6 +423,43 @@ void ShillToONCTranslator::TranslateNetworkWithState() {
TranslateAndAddListOfObjects(::onc::network_config::kIPConfigs,
*shill_ipconfigs);
}
+
+ // Convert StaticIP and SavedIP properties to dictionary format.
+ scoped_ptr<base::DictionaryValue> static_ip(new base::DictionaryValue);
pneubeck (no reviews) 2014/09/03 15:14:28 I think if you can save most of this code by suppo
stevenjb 2014/09/03 21:28:06 I'll... try doing this in a separate CL. I think I
pneubeck (no reviews) 2014/09/04 14:54:13 Thanks
+ CopyPropertyToDictionary(shill::kStaticIPAddressProperty,
+ ::onc::ipconfig::kIPAddress,
+ static_ip.get());
+ CopyPropertyToDictionary(shill::kStaticIPGatewayProperty,
+ ::onc::ipconfig::kGateway,
+ static_ip.get());
+ CopyPropertyToDictionary(shill::kStaticIPNameServersProperty,
+ ::onc::ipconfig::kNameServers,
+ static_ip.get());
+ CopyPropertyToDictionary(shill::kStaticIPPrefixlenProperty,
+ ::onc::ipconfig::kRoutingPrefix,
+ static_ip.get());
+ if (!static_ip->empty()) {
+ onc_object_->SetWithoutPathExpansion(::onc::network_config::kStaticIPConfig,
+ static_ip.release());
+ }
+
+ scoped_ptr<base::DictionaryValue> saved_ip(new base::DictionaryValue);
+ CopyPropertyToDictionary(shill::kSavedIPAddressProperty,
+ ::onc::ipconfig::kIPAddress,
+ saved_ip.get());
+ CopyPropertyToDictionary(shill::kSavedIPGatewayProperty,
+ ::onc::ipconfig::kGateway,
+ saved_ip.get());
+ CopyPropertyToDictionary(shill::kSavedIPNameServersProperty,
+ ::onc::ipconfig::kNameServers,
+ saved_ip.get());
+ CopyPropertyToDictionary(shill::kSavedIPPrefixlenProperty,
+ ::onc::ipconfig::kRoutingPrefix,
+ saved_ip.get());
+ if (!saved_ip->empty()) {
+ onc_object_->SetWithoutPathExpansion(::onc::network_config::kSavedIPConfig,
+ saved_ip.release());
+ }
}
void ShillToONCTranslator::TranslateIPConfig() {
@@ -551,6 +593,19 @@ void ShillToONCTranslator::CopyProperty(
shill_value->DeepCopy());
}
+void ShillToONCTranslator::CopyPropertyToDictionary(
+ const std::string& shill_property_name,
+ const std::string& onc_property_name,
+ base::DictionaryValue* dictionary) {
+ const base::Value* shill_value;
+ if (!shill_dictionary_->GetWithoutPathExpansion(shill_property_name,
+ &shill_value)) {
+ return;
+ }
+ dictionary->SetWithoutPathExpansion(onc_property_name,
+ shill_value->DeepCopy());
+}
+
void ShillToONCTranslator::TranslateWithTableAndSet(
const std::string& shill_property_name,
const StringTranslationEntry table[],

Powered by Google App Engine
This is Rietveld 408576698