Chromium Code Reviews| 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 900ec21c705bea688f1b62e4d85b3d1888de5303..e3c7c8bb2df0f17b65420eedc55e78b0e4241e79 100644 |
| --- a/chromeos/network/onc/onc_translator_shill_to_onc.cc |
| +++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/logging.h" |
| #include "base/strings/string_util.h" |
| #include "base/values.h" |
| +#include "chromeos/network/network_profile_handler.h" |
| #include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_util.h" |
| #include "chromeos/network/onc/onc_signature.h" |
| @@ -50,16 +51,20 @@ scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, |
| class ShillToONCTranslator { |
| public: |
| ShillToONCTranslator(const base::DictionaryValue& shill_dictionary, |
| + ::onc::ONCSource onc_source, |
| const OncValueSignature& onc_signature) |
| : shill_dictionary_(&shill_dictionary), |
| + onc_source_(onc_source), |
| onc_signature_(&onc_signature) { |
| field_translation_table_ = GetFieldTranslationTable(onc_signature); |
| } |
| ShillToONCTranslator(const base::DictionaryValue& shill_dictionary, |
| + ::onc::ONCSource onc_source, |
| const OncValueSignature& onc_signature, |
| const FieldTranslationEntry* field_translation_table) |
| : shill_dictionary_(&shill_dictionary), |
| + onc_source_(onc_source), |
| onc_signature_(&onc_signature), |
| field_translation_table_(field_translation_table) { |
| } |
| @@ -132,6 +137,7 @@ class ShillToONCTranslator { |
| std::string GetName(); |
| const base::DictionaryValue* shill_dictionary_; |
| + ::onc::ONCSource onc_source_; |
| const OncValueSignature* onc_signature_; |
| const FieldTranslationEntry* field_translation_table_; |
| scoped_ptr<base::DictionaryValue> onc_object_; |
| @@ -342,6 +348,7 @@ void ShillToONCTranslator::TranslateCellularWithState() { |
| return; |
| } |
| ShillToONCTranslator nested_translator(*device_dictionary, |
| + onc_source_, |
| kCellularWithStateSignature, |
| kCellularDeviceTable); |
| scoped_ptr<base::DictionaryValue> nested_object = |
| @@ -415,6 +422,24 @@ void ShillToONCTranslator::TranslateNetworkWithState() { |
| } |
| } |
| + std::string profile_path; |
| + if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kProfileProperty, |
| + &profile_path)) { |
| + std::string source; |
| + if (onc_source_ == ::onc::ONC_SOURCE_DEVICE_POLICY) |
| + source = ::onc::network_config::kSourceDevicePolicy; |
| + else if (onc_source_ == ::onc::ONC_SOURCE_USER_POLICY) |
| + source = ::onc::network_config::kSourceUserPolicy; |
| + else if (profile_path == NetworkProfileHandler::GetSharedProfilePath()) |
| + source = ::onc::network_config::kSourceDevice; |
| + else if (!profile_path.empty()) |
| + source = ::onc::network_config::kSourceUser; |
| + else |
|
pneubeck (no reviews)
2014/09/10 10:49:38
please add a comment that ONC_SOURCE_USER_IMPORT (
stevenjb
2014/09/10 17:32:15
Yeah, I have no clue what USER_IMPORT is even for.
pneubeck (no reviews)
2014/09/10 20:22:38
USER_IMPORT is set if a user imports an ONC file f
|
| + source = ::onc::network_config::kSourceNone; |
| + onc_object_->SetStringWithoutPathExpansion( |
| + ::onc::network_config::kSource, source); |
| + } |
| + |
| // Use a human-readable aa:bb format for any hardware MAC address. Note: |
| // this property is provided by the caller but is not part of the Shill |
| // Service properties (it is copied from the Device properties). |
| @@ -507,8 +532,8 @@ void ShillToONCTranslator::TranslateAndAddNestedObject( |
| NOTREACHED() << "Unable to find signature for field: " << onc_field_name; |
| return; |
| } |
| - ShillToONCTranslator nested_translator(dictionary, |
| - *field_signature->value_signature); |
| + ShillToONCTranslator nested_translator( |
| + dictionary, onc_source_, *field_signature->value_signature); |
| scoped_ptr<base::DictionaryValue> nested_object = |
| nested_translator.CreateTranslatedONCObject(); |
| if (nested_object->empty()) |
| @@ -549,6 +574,7 @@ void ShillToONCTranslator::TranslateAndAddListOfObjects( |
| continue; |
| ShillToONCTranslator nested_translator( |
| *shill_value, |
| + onc_source_, |
| *field_signature->value_signature->onc_array_entry_signature); |
| scoped_ptr<base::DictionaryValue> nested_object = |
| nested_translator.CreateTranslatedONCObject(); |
| @@ -636,10 +662,11 @@ std::string ShillToONCTranslator::GetName() { |
| scoped_ptr<base::DictionaryValue> TranslateShillServiceToONCPart( |
| const base::DictionaryValue& shill_dictionary, |
| + ::onc::ONCSource onc_source, |
| const OncValueSignature* onc_signature) { |
| CHECK(onc_signature != NULL); |
| - ShillToONCTranslator translator(shill_dictionary, *onc_signature); |
| + ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature); |
| return translator.CreateTranslatedONCObject(); |
| } |