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