Commit 3ccb0b9c authored by Julian Pastarmov's avatar Julian Pastarmov Committed by Chromium LUCI CQ

Add a mutator for the MetricReportingEnabled policy

This changes the level of the policy to recommended if it is set to
enabled and the level isn't recommended to make the policy compliant
with the privacy expectations of the browser.

Bug: 1155602
Change-Id: I133a7cd58a729fae06c151c742569cf5c80cb500
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575056
Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarYann Dago <ydago@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835346}
parent 2165133a
...@@ -156,6 +156,18 @@ void RemapRenamedPolicies(PolicyMap* policies) { ...@@ -156,6 +156,18 @@ void RemapRenamedPolicies(PolicyMap* policies) {
} }
} }
// Metrics should not be enforced so if this policy is set as mandatory
// downgrade it to a recommended level policy.
void DowngradeMetricsReportingToRecommendedPolicy(PolicyMap* policies) {
PolicyMap::Entry* policy =
policies->GetMutable(policy::key::kMetricsReportingEnabled);
if (policy && policy->level != POLICY_LEVEL_RECOMMENDED && policy->value() &&
policy->value()->is_bool() && policy->value()->GetBool()) {
policy->level = POLICY_LEVEL_RECOMMENDED;
policy->AddError(IDS_POLICY_IGNORED_MANDATORY_REPORTING_POLICY);
}
}
// Returns the string values of |policy|. Returns an empty set if the values are // Returns the string values of |policy|. Returns an empty set if the values are
// not strings. // not strings.
base::flat_set<std::string> GetStringListPolicyItems( base::flat_set<std::string> GetStringListPolicyItems(
...@@ -357,6 +369,8 @@ void PolicyServiceImpl::MergeAndTriggerUpdates() { ...@@ -357,6 +369,8 @@ void PolicyServiceImpl::MergeAndTriggerUpdates() {
provided_bundle.CopyFrom(provider->policies()); provided_bundle.CopyFrom(provider->policies());
RemapProxyPolicies(&provided_bundle.Get(chrome_namespace)); RemapProxyPolicies(&provided_bundle.Get(chrome_namespace));
RemapRenamedPolicies(&provided_bundle.Get(chrome_namespace)); RemapRenamedPolicies(&provided_bundle.Get(chrome_namespace));
DowngradeMetricsReportingToRecommendedPolicy(
&provided_bundle.Get(chrome_namespace));
bundle.MergeFrom(provided_bundle); bundle.MergeFrom(provided_bundle);
} }
......
...@@ -528,6 +528,9 @@ Additional details: ...@@ -528,6 +528,9 @@ Additional details:
<message name="IDS_POLICY_INVALID_VALUE" desc="Text explaining that the policy value is invalid"> <message name="IDS_POLICY_INVALID_VALUE" desc="Text explaining that the policy value is invalid">
Policy value is not valid. Policy value is not valid.
</message> </message>
<message name="IDS_POLICY_IGNORED_MANDATORY_REPORTING_POLICY" desc="Text explaining that the policy MetricsReportingEnabled can not be forced to enabled anymore">
This policy cannot be set to "True" and be mandatory, therefore it was changed to recommended.
</message>
<if expr="not is_macosx"> <if expr="not is_macosx">
<message name="IDS_POLICY_SPELLCHECK_UNKNOWN_LANGUAGE" desc="Warning message in the policy summary page for the spellcheck policies when a language is unrecognized or unsupported."> <message name="IDS_POLICY_SPELLCHECK_UNKNOWN_LANGUAGE" desc="Warning message in the policy summary page for the spellcheck policies when a language is unrecognized or unsupported.">
List entry "<ph name="LANGUAGE_ID">$1<ex>xx-YY</ex></ph>": Unknown or unsupported language. List entry "<ph name="LANGUAGE_ID">$1<ex>xx-YY</ex></ph>": Unknown or unsupported language.
......
3e564aab90fac31f292882920b85070a7cfa3fd2
\ No newline at end of file
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