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

Unified Diff: ui/webui/resources/cr_elements/policy/cr_policy_pref_behavior.js

Issue 2708013003: [MD settings] show icon when content settings are controlled by an extension (Closed)
Patch Set: ignore-extensions Created 3 years, 10 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
Index: ui/webui/resources/cr_elements/policy/cr_policy_pref_behavior.js
diff --git a/ui/webui/resources/cr_elements/policy/cr_policy_pref_behavior.js b/ui/webui/resources/cr_elements/policy/cr_policy_pref_behavior.js
index 0fd367c6238f3417266d038abf570cd81053fef5..0db628792f1513fdd85a3c876dabbaf42a2ef9b4 100644
--- a/ui/webui/resources/cr_elements/policy/cr_policy_pref_behavior.js
+++ b/ui/webui/resources/cr_elements/policy/cr_policy_pref_behavior.js
@@ -8,13 +8,28 @@
/** @polymerBehavior */
var CrPolicyPrefBehavior = {
+ properties: {
+ /**
+ * Showing that an extension is controlling a pref is sometimes done with a
stevenjb 2017/02/28 02:59:33 'In those'
+ * different UI (e.g. extension-controlled-indicator). In those cases,
+ * avoid showing an (extra) indicator here.
+ * @public
+ */
+ ignoreExtensions: Boolean,
Dan Beam 2017/02/28 02:30:03 ignoreControllingExtensions?
stevenjb 2017/02/28 02:59:33 FWIW, I kind of prefer just 'ignore-extensions', I
Dan Beam 2017/02/28 03:02:11 the context in this file. but look at other invoc
stevenjb 2017/02/28 19:56:28 I was taking other invocations into consideration.
Dan Beam 2017/02/28 20:00:38 aight, just making sure you saw them
+ },
+
/**
+ * Is the |pref| controlled by something that prevents user control of the
+ * preference.
* @param {!chrome.settingsPrivate.PrefObject} pref
- * @return {boolean} True if the pref is controlled by an enforced policy.
+ * @return {boolean} True if the pref is enforced.
*/
- isPrefPolicyControlled: function(pref) {
dschuyler 2017/02/28 00:15:18 This is renamed as isPrefEnforced.
- return pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED &&
- pref.controlledBy != chrome.settingsPrivate.ControlledBy.EXTENSION;
+ isPrefEnforced: function(pref) {
+ if (this.ignoreExtensions &&
+ pref.controlledBy == chrome.settingsPrivate.ControlledBy.EXTENSION) {
+ return false;
+ }
+ return pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED;
dschuyler 2017/02/28 00:15:18 Lines 28 to 32 can be expressed in one line of log
Dan Beam 2017/02/28 02:30:03 eh, this is fine, it's very clear
stevenjb 2017/02/28 02:59:33 Make sure to merge this with Michael's change (I j
},
/**
@@ -24,6 +39,10 @@ var CrPolicyPrefBehavior = {
* and |enforcement|.
*/
getIndicatorType: function(controlledBy, enforcement) {
+ if (this.ignoreExtensions &&
+ controlledBy == chrome.settingsPrivate.ControlledBy.EXTENSION) {
+ return CrPolicyIndicatorType.NONE;
+ }
if (enforcement == chrome.settingsPrivate.Enforcement.RECOMMENDED)
return CrPolicyIndicatorType.RECOMMENDED;
if (enforcement == chrome.settingsPrivate.Enforcement.ENFORCED) {
@@ -36,6 +55,8 @@ var CrPolicyPrefBehavior = {
return CrPolicyIndicatorType.USER_POLICY;
case chrome.settingsPrivate.ControlledBy.DEVICE_POLICY:
return CrPolicyIndicatorType.DEVICE_POLICY;
+ case chrome.settingsPrivate.ControlledBy.EXTENSION:
+ return CrPolicyIndicatorType.EXTENSION;
}
}
return CrPolicyIndicatorType.NONE;

Powered by Google App Engine
This is Rietveld 408576698