| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * A behavior to help controls that handle a boolean preference, such as | 7 * A behavior to help controls that handle a boolean preference, such as |
| 8 * checkbox and toggle button. | 8 * checkbox and toggle button. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 subLabel: { | 54 subLabel: { |
| 55 type: String, | 55 type: String, |
| 56 value: '', | 56 value: '', |
| 57 }, | 57 }, |
| 58 }, | 58 }, |
| 59 | 59 |
| 60 observers: [ | 60 observers: [ |
| 61 'prefValueChanged_(pref.value)', | 61 'prefValueChanged_(pref.value)', |
| 62 ], | 62 ], |
| 63 | 63 |
| 64 notifyChangedByUserInteraction: function() { |
| 65 this.fire('settings-boolean-control-change'); |
| 66 }, |
| 67 |
| 64 /** Reset the checked state to match the current pref value. */ | 68 /** Reset the checked state to match the current pref value. */ |
| 65 resetToPrefValue: function() { | 69 resetToPrefValue: function() { |
| 66 this.checked = this.getNewValue_(this.pref.value); | 70 this.checked = this.getNewValue_(this.pref.value); |
| 67 }, | 71 }, |
| 68 | 72 |
| 69 /** Update the pref to the current |checked| value. */ | 73 /** Update the pref to the current |checked| value. */ |
| 70 sendPrefChange: function() { | 74 sendPrefChange: function() { |
| 71 /** @type {boolean} */ var newValue = this.getNewValue_(this.checked); | 75 /** @type {boolean} */ var newValue = this.getNewValue_(this.checked); |
| 72 // Ensure that newValue is the correct type for the pref type, either | 76 // Ensure that newValue is the correct type for the pref type, either |
| 73 // a boolean or a number. | 77 // a boolean or a number. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return this.disabled || this.isPrefPolicyControlled(assert(this.pref)); | 118 return this.disabled || this.isPrefPolicyControlled(assert(this.pref)); |
| 115 }, | 119 }, |
| 116 }; | 120 }; |
| 117 | 121 |
| 118 /** @polymerBehavior */ | 122 /** @polymerBehavior */ |
| 119 var SettingsBooleanControlBehavior = [ | 123 var SettingsBooleanControlBehavior = [ |
| 120 CrPolicyPrefBehavior, | 124 CrPolicyPrefBehavior, |
| 121 PrefControlBehavior, | 125 PrefControlBehavior, |
| 122 SettingsBooleanControlBehaviorImpl, | 126 SettingsBooleanControlBehaviorImpl, |
| 123 ]; | 127 ]; |
| OLD | NEW |