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