Commit 49d77fc2 authored by pneubeck's avatar pneubeck Committed by Commit bot

ONC: Remove augmentation of unmanaged network properties.

Before read-only properties which cannot be set by the user or policy, were explicitly marked as 'unmanaged' in the augmented dictionary returned by getManagedProperties.

Now, instead these properties are returned as plain values, which simplifies the consumer side, especially of Array typed properties like IPConfigs (compare this with SavedIPConfig).

BUG=410877

Review URL: https://codereview.chromium.org/551753002

Cr-Commit-Position: refs/heads/master@{#293931}
parent 4c2d33ac
......@@ -316,14 +316,8 @@ var availableTests = [
"stub_wifi2",
callbackPass(function(result) {
assertEq({
"Connectable": {
"Active": true,
"Effective": "Unmanaged"
},
"ConnectionState": {
"Active": "NotConnected",
"Effective": "Unmanaged"
},
"Connectable": true,
"ConnectionState": "NotConnected",
"GUID": "stub_wifi2",
"Name": {
"Active": "wifi2_PSK",
......@@ -340,14 +334,8 @@ var availableTests = [
"Active": false,
"UserEditable": true
},
"Frequency" : {
"Active": 5000,
"Effective": "Unmanaged"
},
"FrequencyList" : {
"Active": [2400, 5000],
"Effective": "Unmanaged"
},
"Frequency" : 5000,
"FrequencyList" : [2400, 5000],
"Passphrase": {
"Effective": "UserSetting",
"UserEditable": true,
......@@ -363,10 +351,7 @@ var availableTests = [
"Effective": "UserPolicy",
"UserPolicy": "WPA-PSK"
},
"SignalStrength": {
"Active": 80,
"Effective": "Unmanaged"
}
"SignalStrength": 80,
}
}, result);
}));
......
......@@ -361,18 +361,17 @@ class MergeToAugmented : public MergeToEffective {
virtual scoped_ptr<base::Value> MergeValues(
const std::string& key,
const ValueParams& values) OVERRIDE {
scoped_ptr<base::DictionaryValue> augmented_value(
new base::DictionaryValue);
if (values.active_setting) {
augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationActiveSetting, values.active_setting->DeepCopy());
}
const OncFieldSignature* field = NULL;
if (signature_)
field = GetFieldSignature(*signature_, key);
if (field) {
if (!field) {
// This field is not part of the provided ONCSignature, thus it cannot be
// controlled by policy. Return the plain active value instead of an
// augmented dictionary.
return make_scoped_ptr(values.active_setting->DeepCopy());
}
// This field is part of the provided ONCSignature, thus it can be
// controlled by policy.
std::string which_effective;
......@@ -393,15 +392,23 @@ class MergeToAugmented : public MergeToEffective {
return effective_value.Pass();
}
scoped_ptr<base::DictionaryValue> augmented_value(
new base::DictionaryValue);
if (values.active_setting) {
augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationActiveSetting, values.active_setting->DeepCopy());
}
if (!which_effective.empty()) {
augmented_value->SetStringWithoutPathExpansion(
::onc::kAugmentationEffectiveSetting, which_effective);
}
bool is_credential = onc::FieldIsCredential(*signature_, key);
// Prevent credentials from being forwarded in cleartext to
// UI. User/shared credentials are not stored separately, so they cannot
// leak here.
bool is_credential = onc::FieldIsCredential(*signature_, key);
if (!is_credential) {
if (values.user_policy) {
augmented_value->SetWithoutPathExpansion(
......@@ -430,12 +437,6 @@ class MergeToAugmented : public MergeToEffective {
augmented_value->SetBooleanWithoutPathExpansion(
::onc::kAugmentationDeviceEditable, true);
}
} else {
// This field is not part of the provided ONCSignature, thus it cannot be
// controlled by policy.
augmented_value->SetStringWithoutPathExpansion(
::onc::kAugmentationEffectiveSetting, ::onc::kAugmentationUnmanaged);
}
if (augmented_value->empty())
augmented_value.reset();
return augmented_value.PassAs<base::Value>();
......
{
"ConnectionState": {
"Active": "Connected",
"Effective": "Unmanaged"
},
"ConnectionState": "Connected",
"GUID": "123",
"IPConfigs": {
"Active": [ {
"IPConfigs": [ {
"Gateway": "2001:db8:85a3::7a2e:370:7331",
"IPAddress": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"NameServers": [ ],
"RoutingPrefix": 12,
"Type": "IPv6"
} ],
"Effective": "Unmanaged"
},
"SavedIPConfig": {
"Gateway": {
"Active": "1.1.1.4",
"Effective": "Unmanaged"
},
"IPAddress": {
"Active": "124.124.124.124",
"Effective": "Unmanaged"
},
"NameServers": {
"Active": [ "1.1.1.5", "1.1.1.6" ],
"Effective": "Unmanaged"
},
"RoutingPrefix": {
"Active": 25,
"Effective": "Unmanaged"
},
"Type": {
"Active": "IPv4",
"Effective": "Unmanaged"
}
"Gateway": "1.1.1.4",
"IPAddress": "124.124.124.124",
"NameServers": [ "1.1.1.5", "1.1.1.6" ],
"RoutingPrefix": 25,
"Type": "IPv4",
},
"StaticIPConfig": {
"IPAddress": {
......
......@@ -9,7 +9,6 @@ namespace onc {
const char kAugmentationActiveSetting[] = "Active";
const char kAugmentationEffectiveSetting[] = "Effective";
const char kAugmentationUnmanaged[] = "Unmanaged";
const char kAugmentationUserPolicy[] = "UserPolicy";
const char kAugmentationDevicePolicy[] = "DevicePolicy";
const char kAugmentationUserSetting[] = "UserSetting";
......
......@@ -29,7 +29,6 @@ ONC_EXPORT extern const char kAugmentationActiveSetting[];
// The one of different setting sources (user/device policy, user/shared
// settings) that has highest priority over the others.
ONC_EXPORT extern const char kAugmentationEffectiveSetting[];
ONC_EXPORT extern const char kAugmentationUnmanaged[];
ONC_EXPORT extern const char kAugmentationUserPolicy[];
ONC_EXPORT extern const char kAugmentationDevicePolicy[];
ONC_EXPORT extern const char kAugmentationUserSetting[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment