| 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-radio-button', | 6 is: 'controlled-radio-button', |
| 7 | 7 |
| 8 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], | 8 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], |
| 9 | 9 |
| 10 properties: { | 10 properties: { |
| 11 name: { | 11 name: { |
| 12 type: String, | 12 type: String, |
| 13 notify: true, | 13 notify: true, |
| 14 }, | 14 }, |
| 15 | 15 |
| 16 /** @private */ | 16 /** @private */ |
| 17 controlled_: { | 17 controlled_: { |
| 18 type: Boolean, | 18 type: Boolean, |
| 19 computed: 'computeControlled_(pref)', | 19 computed: 'computeControlled_(pref.*)', |
| 20 reflectToAttribute: true, | 20 reflectToAttribute: true, |
| 21 }, | 21 }, |
| 22 }, | 22 }, |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * @param {chrome.settingsPrivate.PrefObject} pref | |
| 26 * @return {boolean} Whether the button is disabled. | 25 * @return {boolean} Whether the button is disabled. |
| 27 * @private | 26 * @private |
| 28 */ | 27 */ |
| 29 computeControlled_: function(pref) { | 28 computeControlled_: function() { |
| 30 var pref = /** @type {!chrome.settingsPrivate.PrefObject} */(this.pref); | 29 return this.isPrefPolicyControlled(assert(this.pref)); |
| 31 return this.isPrefPolicyControlled(pref); | |
| 32 }, | 30 }, |
| 33 | 31 |
| 34 /** | 32 /** |
| 35 * @param {boolean} controlled | 33 * @param {boolean} controlled |
| 36 * @param {string} name | 34 * @param {string} name |
| 37 * @param {chrome.settingsPrivate.PrefObject} pref | 35 * @param {chrome.settingsPrivate.PrefObject} pref |
| 38 * @return {boolean} | 36 * @return {boolean} |
| 39 * @private | 37 * @private |
| 40 */ | 38 */ |
| 41 showIndicator_: function(controlled, name, pref) { | 39 showIndicator_: function(controlled, name, pref) { |
| 42 return controlled && name == Settings.PrefUtil.prefToString(pref); | 40 return controlled && name == Settings.PrefUtil.prefToString(pref); |
| 43 }, | 41 }, |
| 44 | 42 |
| 45 /** | 43 /** |
| 46 * @param {!Event} e | 44 * @param {!Event} e |
| 47 * @private | 45 * @private |
| 48 */ | 46 */ |
| 49 onIndicatorTap_: function(e) { | 47 onIndicatorTap_: function(e) { |
| 50 // Disallow <controlled-radio-button on-tap="..."> when controlled. | 48 // Disallow <controlled-radio-button on-tap="..."> when controlled. |
| 51 e.preventDefault(); | 49 e.preventDefault(); |
| 52 e.stopPropagation(); | 50 e.stopPropagation(); |
| 53 }, | 51 }, |
| 54 }); | 52 }); |
| OLD | NEW |