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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Behavior for policy controlled settings prefs. 6 * @fileoverview Behavior for policy controlled settings prefs.
7 */ 7 */
8 8
9 /** @polymerBehavior */ 9 /** @polymerBehavior */
10 var CrPolicyPrefBehavior = { 10 var CrPolicyPrefBehavior = {
11 /** 11 properties: {
12 * @param {!chrome.settingsPrivate.PrefObject} pref 12 /**
13 * @return {boolean} True if the pref is controlled by an enforced policy. 13 * Showing that an extension is controlling a pref is sometimes done with a
stevenjb 2017/02/28 02:59:33 'In those'
14 */ 14 * different UI (e.g. extension-controlled-indicator). In those cases,
15 isPrefPolicyControlled: function(pref) { 15 * avoid showing an (extra) indicator here.
dschuyler 2017/02/28 00:15:18 This is renamed as isPrefEnforced.
16 return pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED && 16 * @public
17 pref.controlledBy != chrome.settingsPrivate.ControlledBy.EXTENSION; 17 */
18 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
18 }, 19 },
19 20
20 /** 21 /**
22 * Is the |pref| controlled by something that prevents user control of the
23 * preference.
24 * @param {!chrome.settingsPrivate.PrefObject} pref
25 * @return {boolean} True if the pref is enforced.
26 */
27 isPrefEnforced: function(pref) {
28 if (this.ignoreExtensions &&
29 pref.controlledBy == chrome.settingsPrivate.ControlledBy.EXTENSION) {
30 return false;
31 }
32 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
33 },
34
35 /**
21 * @param {!chrome.settingsPrivate.ControlledBy|undefined} controlledBy 36 * @param {!chrome.settingsPrivate.ControlledBy|undefined} controlledBy
22 * @param {!chrome.settingsPrivate.Enforcement|undefined} enforcement 37 * @param {!chrome.settingsPrivate.Enforcement|undefined} enforcement
23 * @return {CrPolicyIndicatorType} The indicator type based on |controlledBy| 38 * @return {CrPolicyIndicatorType} The indicator type based on |controlledBy|
24 * and |enforcement|. 39 * and |enforcement|.
25 */ 40 */
26 getIndicatorType: function(controlledBy, enforcement) { 41 getIndicatorType: function(controlledBy, enforcement) {
42 if (this.ignoreExtensions &&
43 controlledBy == chrome.settingsPrivate.ControlledBy.EXTENSION) {
44 return CrPolicyIndicatorType.NONE;
45 }
27 if (enforcement == chrome.settingsPrivate.Enforcement.RECOMMENDED) 46 if (enforcement == chrome.settingsPrivate.Enforcement.RECOMMENDED)
28 return CrPolicyIndicatorType.RECOMMENDED; 47 return CrPolicyIndicatorType.RECOMMENDED;
29 if (enforcement == chrome.settingsPrivate.Enforcement.ENFORCED) { 48 if (enforcement == chrome.settingsPrivate.Enforcement.ENFORCED) {
30 switch (controlledBy) { 49 switch (controlledBy) {
31 case chrome.settingsPrivate.ControlledBy.PRIMARY_USER: 50 case chrome.settingsPrivate.ControlledBy.PRIMARY_USER:
32 return CrPolicyIndicatorType.PRIMARY_USER; 51 return CrPolicyIndicatorType.PRIMARY_USER;
33 case chrome.settingsPrivate.ControlledBy.OWNER: 52 case chrome.settingsPrivate.ControlledBy.OWNER:
34 return CrPolicyIndicatorType.OWNER; 53 return CrPolicyIndicatorType.OWNER;
35 case chrome.settingsPrivate.ControlledBy.USER_POLICY: 54 case chrome.settingsPrivate.ControlledBy.USER_POLICY:
36 return CrPolicyIndicatorType.USER_POLICY; 55 return CrPolicyIndicatorType.USER_POLICY;
37 case chrome.settingsPrivate.ControlledBy.DEVICE_POLICY: 56 case chrome.settingsPrivate.ControlledBy.DEVICE_POLICY:
38 return CrPolicyIndicatorType.DEVICE_POLICY; 57 return CrPolicyIndicatorType.DEVICE_POLICY;
58 case chrome.settingsPrivate.ControlledBy.EXTENSION:
59 return CrPolicyIndicatorType.EXTENSION;
39 } 60 }
40 } 61 }
41 return CrPolicyIndicatorType.NONE; 62 return CrPolicyIndicatorType.NONE;
42 }, 63 },
43 }; 64 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698