OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Polymer({ | 5 Polymer({ |
6 is: 'controlled-button', | 6 is: 'controlled-button', |
7 | 7 |
8 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], | 8 behaviors: [ |
| 9 CrPolicyIndicatorBehavior, |
| 10 CrPolicyPrefBehavior, |
| 11 PrefControlBehavior, |
| 12 ], |
9 | 13 |
10 properties: { | 14 properties: { |
11 /** @private */ | 15 /** @private */ |
12 controlled_: { | 16 controlled_: { |
13 type: Boolean, | 17 type: Boolean, |
14 computed: 'computeControlled_(pref.*)', | 18 computed: 'computeControlled_(pref.*)', |
15 reflectToAttribute: true, | 19 reflectToAttribute: true, |
16 }, | 20 }, |
17 }, | 21 }, |
18 | 22 |
19 /** | 23 /** |
20 * @return {boolean} Whether the button is disabled. | 24 * @return {boolean} Whether the button is disabled. |
21 * @private | 25 * @private |
22 */ | 26 */ |
23 computeControlled_: function() { | 27 computeControlled_: function() { |
24 return this.pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED; | 28 return this.pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED; |
25 }, | 29 }, |
26 | 30 |
27 /** | 31 /** |
28 * @param {!Event} e | 32 * @param {!Event} e |
29 * @private | 33 * @private |
30 */ | 34 */ |
31 onIndicatorTap_: function(e) { | 35 onIndicatorTap_: function(e) { |
32 // Disallow <controlled-button on-tap="..."> when controlled. | 36 // Disallow <controlled-button on-tap="..."> when controlled. |
33 e.preventDefault(); | 37 e.preventDefault(); |
34 e.stopPropagation(); | 38 e.stopPropagation(); |
35 }, | 39 }, |
| 40 |
| 41 /** |
| 42 * @param {!chrome.settingsPrivate.PrefObject} pref |
| 43 * @return {boolean} Whether to show a controlled by indicator. |
| 44 * @private |
| 45 */ |
| 46 showIndicator_: function(pref) { |
| 47 if (!pref.controlledBy || !pref.enforcement) |
| 48 return false; |
| 49 var indicator = this.getIndicatorType(pref.controlledBy, pref.enforcement); |
| 50 return this.isIndicatorVisible(indicator); |
| 51 }, |
36 }); | 52 }); |
OLD | NEW |