Index: chromeos/network/onc/onc_merger.cc |
diff --git a/chromeos/network/onc/onc_merger.cc b/chromeos/network/onc/onc_merger.cc |
index 52694e505b178ced90db8f3799635821c6c07d59..4dcaae98d0e0d6146ad826cf5ee55ea2a020dc41 100644 |
--- a/chromeos/network/onc/onc_merger.cc |
+++ b/chromeos/network/onc/onc_merger.cc |
@@ -361,80 +361,81 @@ class MergeToAugmented : public MergeToEffective { |
virtual scoped_ptr<base::Value> MergeValues( |
const std::string& key, |
const ValueParams& values) OVERRIDE { |
+ const OncFieldSignature* field = NULL; |
+ if (signature_) |
+ field = GetFieldSignature(*signature_, key); |
+ |
+ 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; |
+ scoped_ptr<base::Value> effective_value = |
+ MergeToEffective::MergeValues(key, values, &which_effective); |
+ |
+ if (IsIdentifierField(*signature_, key)) { |
+ // Don't augment the GUID but write the plain value. |
+ if (!effective_value) { |
+ LOG(ERROR) << "GUID field has no effective value"; |
+ return make_scoped_ptr<base::Value>(NULL); |
+ } |
+ |
+ // DCHECK that all provided GUIDs are identical. |
+ DCHECK(AllPresentValuesEqual(values, *effective_value)); |
+ |
+ // Return the un-augmented GUID. |
+ 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()); |
} |
- const OncFieldSignature* field = NULL; |
- if (signature_) |
- field = GetFieldSignature(*signature_, key); |
- |
- if (field) { |
- // This field is part of the provided ONCSignature, thus it can be |
- // controlled by policy. |
- std::string which_effective; |
- scoped_ptr<base::Value> effective_value = |
- MergeToEffective::MergeValues(key, values, &which_effective); |
- |
- if (IsIdentifierField(*signature_, key)) { |
- // Don't augment the GUID but write the plain value. |
- if (!effective_value) { |
- LOG(ERROR) << "GUID field has no effective value"; |
- return make_scoped_ptr<base::Value>(NULL); |
- } |
- |
- // DCHECK that all provided GUIDs are identical. |
- DCHECK(AllPresentValuesEqual(values, *effective_value)); |
- |
- // Return the un-augmented GUID. |
- return effective_value.Pass(); |
- } |
+ if (!which_effective.empty()) { |
+ augmented_value->SetStringWithoutPathExpansion( |
+ ::onc::kAugmentationEffectiveSetting, which_effective); |
+ } |
- 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. |
- if (!is_credential) { |
- if (values.user_policy) { |
- augmented_value->SetWithoutPathExpansion( |
- ::onc::kAugmentationUserPolicy, values.user_policy->DeepCopy()); |
- } |
- if (values.device_policy) { |
- augmented_value->SetWithoutPathExpansion( |
- ::onc::kAugmentationDevicePolicy, |
- values.device_policy->DeepCopy()); |
- } |
- } |
- if (values.user_setting) { |
+ // 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( |
- ::onc::kAugmentationUserSetting, values.user_setting->DeepCopy()); |
+ ::onc::kAugmentationUserPolicy, values.user_policy->DeepCopy()); |
} |
- if (values.shared_setting) { |
+ if (values.device_policy) { |
augmented_value->SetWithoutPathExpansion( |
- ::onc::kAugmentationSharedSetting, |
- values.shared_setting->DeepCopy()); |
- } |
- if (HasUserPolicy() && values.user_editable) { |
- augmented_value->SetBooleanWithoutPathExpansion( |
- ::onc::kAugmentationUserEditable, true); |
- } |
- if (HasDevicePolicy() && values.device_editable) { |
- augmented_value->SetBooleanWithoutPathExpansion( |
- ::onc::kAugmentationDeviceEditable, true); |
+ ::onc::kAugmentationDevicePolicy, |
+ values.device_policy->DeepCopy()); |
} |
- } 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 (values.user_setting) { |
+ augmented_value->SetWithoutPathExpansion( |
+ ::onc::kAugmentationUserSetting, values.user_setting->DeepCopy()); |
+ } |
+ if (values.shared_setting) { |
+ augmented_value->SetWithoutPathExpansion( |
+ ::onc::kAugmentationSharedSetting, |
+ values.shared_setting->DeepCopy()); |
+ } |
+ if (HasUserPolicy() && values.user_editable) { |
+ augmented_value->SetBooleanWithoutPathExpansion( |
+ ::onc::kAugmentationUserEditable, true); |
+ } |
+ if (HasDevicePolicy() && values.device_editable) { |
+ augmented_value->SetBooleanWithoutPathExpansion( |
+ ::onc::kAugmentationDeviceEditable, true); |
} |
if (augmented_value->empty()) |
augmented_value.reset(); |