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

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

Issue 2696903005: Move common cr-policy-indicator behavior into CrPolicyIndicatorBehavior (Closed)
Patch Set: rebase 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..ad393b95b2e21fa3784d71ace175efbc4cc70a50 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
@@ -9,35 +9,20 @@
/** @polymerBehavior */
var CrPolicyPrefBehavior = {
/**
- * @param {!chrome.settingsPrivate.PrefObject} pref
- * @return {boolean} True if the pref is controlled by an enforced policy.
+ * @return {boolean} True if |this.pref| is controlled by an enforced policy.
*/
- isPrefPolicyControlled: function(pref) {
- return pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED &&
- pref.controlledBy != chrome.settingsPrivate.ControlledBy.EXTENSION;
+ isPrefPolicyControlled: function() {
+ return (
+ this.pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED &&
+ this.pref.controlledBy !=
+ chrome.settingsPrivate.ControlledBy.EXTENSION);
},
/**
- * @param {!chrome.settingsPrivate.ControlledBy|undefined} controlledBy
- * @param {!chrome.settingsPrivate.Enforcement|undefined} enforcement
- * @return {CrPolicyIndicatorType} The indicator type based on |controlledBy|
- * and |enforcement|.
+ * @return {boolean} True if |this.pref| has a recommended or enforced policy.
*/
- getIndicatorType: function(controlledBy, enforcement) {
- if (enforcement == chrome.settingsPrivate.Enforcement.RECOMMENDED)
- return CrPolicyIndicatorType.RECOMMENDED;
- if (enforcement == chrome.settingsPrivate.Enforcement.ENFORCED) {
- switch (controlledBy) {
- case chrome.settingsPrivate.ControlledBy.PRIMARY_USER:
- return CrPolicyIndicatorType.PRIMARY_USER;
- case chrome.settingsPrivate.ControlledBy.OWNER:
- return CrPolicyIndicatorType.OWNER;
- case chrome.settingsPrivate.ControlledBy.USER_POLICY:
- return CrPolicyIndicatorType.USER_POLICY;
- case chrome.settingsPrivate.ControlledBy.DEVICE_POLICY:
- return CrPolicyIndicatorType.DEVICE_POLICY;
- }
- }
- return CrPolicyIndicatorType.NONE;
+ hasPrefPolicyIndicator: function() {
+ return this.isPrefPolicyControlled() ||
+ this.pref.enforcement == chrome.settingsPrivate.Enforcement.RECOMMENDED;
},
};

Powered by Google App Engine
This is Rietveld 408576698