Chromium Code Reviews| 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 |
| 11 /** @polymerBehavior SettingsBooleanControlBehavior */ | 11 /** @polymerBehavior SettingsBooleanControlBehavior */ |
| 12 var SettingsBooleanControlBehaviorImpl = { | 12 var SettingsBooleanControlBehaviorImpl = { |
|
dschuyler
2016/12/02 21:20:51
Optional:
This my be my (prior) bad, but if we use
dschuyler
2016/12/02 23:17:07
Whoops, yeah, it's already being added below
on li
| |
| 13 properties: { | 13 properties: { |
| 14 /** Whether the control should represent the inverted value. */ | 14 /** Whether the control should represent the inverted value. */ |
| 15 inverted: { | 15 inverted: { |
| 16 type: Boolean, | 16 type: Boolean, |
| 17 value: false, | 17 value: false, |
| 18 }, | 18 }, |
| 19 | 19 |
| 20 /** Whether the control is checked. */ | 20 /** Whether the control is checked. */ |
| 21 checked: { | 21 checked: { |
| 22 type: Boolean, | 22 type: Boolean, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 /** | 100 /** |
| 101 * @param {*} value | 101 * @param {*} value |
| 102 * @return {boolean} The value as a boolean, inverted if |inverted| is true. | 102 * @return {boolean} The value as a boolean, inverted if |inverted| is true. |
| 103 * @private | 103 * @private |
| 104 */ | 104 */ |
| 105 getNewValue_: function(value) { | 105 getNewValue_: function(value) { |
| 106 return this.inverted ? !value : !!value; | 106 return this.inverted ? !value : !!value; |
| 107 }, | 107 }, |
| 108 | 108 |
| 109 /** | 109 /** |
| 110 * @param {boolean} disabled | |
| 111 * @param {!chrome.settingsPrivate.PrefObject} pref | |
| 112 * @return {boolean} Whether the checkbox should be disabled. | 110 * @return {boolean} Whether the checkbox should be disabled. |
| 113 * @private | 111 * @private |
| 114 */ | 112 */ |
| 115 controlDisabled_: function(disabled, pref) { | 113 controlDisabled_: function() { |
| 116 return disabled || this.isPrefPolicyControlled(pref); | 114 return this.disabled || this.isPrefPolicyControlled(assert(this.pref)); |
|
dschuyler
2016/12/02 21:20:51
Is the error within isPrefPolicyControlled unclear
Dan Beam
2016/12/02 23:09:10
it's required to closure compile. this.pref shoul
dschuyler
2016/12/02 23:17:08
Okay. I wonder if an if() or something could check
Dan Beam
2016/12/02 23:21:28
we are doing both of those things, BUT:
a) assert
| |
| 117 }, | 115 }, |
| 118 }; | 116 }; |
| 119 | 117 |
| 120 /** @polymerBehavior */ | 118 /** @polymerBehavior */ |
| 121 var SettingsBooleanControlBehavior = [ | 119 var SettingsBooleanControlBehavior = [ |
| 122 CrPolicyPrefBehavior, | 120 CrPolicyPrefBehavior, |
|
Dan Beam
2016/12/02 23:09:10
^ do you mean add this behavior?
dschuyler
2016/12/02 23:17:07
I totally do.
| |
| 123 PrefControlBehavior, | 121 PrefControlBehavior, |
| 124 SettingsBooleanControlBehaviorImpl, | 122 SettingsBooleanControlBehaviorImpl, |
| 125 ]; | 123 ]; |
| OLD | NEW |