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

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

Issue 552113002: Add ONC 'Source' configuration property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_9a
Patch Set: Rebase Created 6 years, 3 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
« no previous file with comments | « chromeos/network/onc/onc_translator.h ('k') | chromeos/network/onc/onc_translator_unittest.cc » ('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 900ec21c705bea688f1b62e4d85b3d1888de5303..d7bc265e0ceeb9de0d75f9f703239e96c2a6a3e9 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,25 @@ void ShillToONCTranslator::TranslateNetworkWithState() {
}
}
+ std::string profile_path;
+ if (onc_source_ != ::onc::ONC_SOURCE_UNKNOWN &&
+ 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
+ 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 +533,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 +575,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 +663,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();
}
« no previous file with comments | « chromeos/network/onc/onc_translator.h ('k') | chromeos/network/onc/onc_translator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698