OLD | NEW |
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 properties: { | 11 properties: { |
12 /** | 12 /** |
13 * Showing that an extension is controlling a pref is sometimes done with a | 13 * Showing that an extension is controlling a pref is sometimes done with a |
14 * different UI (e.g. extension-controlled-indicator). In those cases, | 14 * different UI (e.g. extension-controlled-indicator). In those cases, |
15 * avoid showing an (extra) indicator here. | 15 * avoid showing an (extra) indicator here. |
16 * @public | 16 * @public |
17 */ | 17 */ |
18 ignoreExtensions: Boolean, | 18 ignoreExtensions: Boolean, |
19 }, | 19 }, |
20 | 20 |
21 /** | 21 /** |
22 * Is the |pref| controlled by something that prevents user control of the | 22 * Is the |pref| controlled by something that prevents user control of the |
23 * preference. | 23 * preference. |
24 * @return {boolean} True if |this.pref| is controlled by an enforced policy. | 24 * @return {boolean} True if |this.pref| is controlled by an enforced policy. |
25 */ | 25 */ |
26 isPrefEnforced: function() { | 26 isPrefEnforced: function() { |
| 27 if (!this.pref) { |
| 28 return false; |
| 29 } |
27 if (this.ignoreExtensions && | 30 if (this.ignoreExtensions && |
28 this.pref.controlledBy == | 31 this.pref.controlledBy == |
29 chrome.settingsPrivate.ControlledBy.EXTENSION) { | 32 chrome.settingsPrivate.ControlledBy.EXTENSION) { |
30 return false; | 33 return false; |
31 } | 34 } |
32 return this.pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED; | 35 return this.pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED; |
33 }, | 36 }, |
34 | 37 |
35 /** | 38 /** |
36 * @return {boolean} True if |this.pref| has a recommended or enforced policy. | 39 * @return {boolean} True if |this.pref| has a recommended or enforced policy. |
37 */ | 40 */ |
38 hasPrefPolicyIndicator: function() { | 41 hasPrefPolicyIndicator: function() { |
39 return this.isPrefEnforced() || | 42 return this.isPrefEnforced() || |
40 this.pref.enforcement == chrome.settingsPrivate.Enforcement.RECOMMENDED; | 43 this.pref.enforcement == chrome.settingsPrivate.Enforcement.RECOMMENDED; |
41 }, | 44 }, |
42 }; | 45 }; |
OLD | NEW |