Index: chrome/browser/resources/settings/checkbox/checkbox.js |
diff --git a/chrome/browser/resources/settings/checkbox/checkbox.js b/chrome/browser/resources/settings/checkbox/checkbox.js |
index d8c1a1f2ededd0b2ea0ec83aa6748a159471f085..cb2abe7c1f77348fd0693ae946acc54cc323fc7b 100644 |
--- a/chrome/browser/resources/settings/checkbox/checkbox.js |
+++ b/chrome/browser/resources/settings/checkbox/checkbox.js |
@@ -26,22 +26,32 @@ Polymer({ |
notify: true, |
}, |
+ /** Whether the checkbox should represent the inverted value. */ |
inverted: { |
type: Boolean, |
- value: false |
+ value: false, |
}, |
+ /** Whether the checkbox is checked. */ |
checked: { |
type: Boolean, |
value: false, |
- observer: 'checkedChanged_' |
+ observer: 'checkedChanged_', |
+ }, |
+ |
+ /** Disabled property for the element. */ |
+ disabled: { |
+ type: Boolean, |
+ value: false, |
}, |
+ /** Checkbox label. */ |
label: { |
type: String, |
value: '', |
}, |
+ /** Additional sub-label for the checkbox. */ |
subLabel: { |
type: String, |
value: '', |
@@ -57,20 +67,41 @@ Polymer({ |
this.$.events.forward(this.$.checkbox, ['change']); |
}, |
- /** @private */ |
+ /** |
+ * Polymer observer for pref.value |
michaelpg
2015/09/17 02:19:25
nit: append "."
stevenjb
2015/09/17 17:33:31
Done.
|
+ * @param {*} prefValue |
+ * @private |
+ */ |
prefValueChanged_: function(prefValue) { |
this.checked = this.getNewValue_(prefValue); |
}, |
- /** @private */ |
+ /** |
+ * Polymer observer for checked. |
+ * @private |
+ */ |
checkedChanged_: function() { |
- if (this.pref) { |
- this.set('pref.value', this.getNewValue_(this.checked)); |
- } |
+ this.set('pref.value', this.getNewValue_(this.checked)); |
+ }, |
+ |
+ /** |
+ * @param {*} value |
+ * @return {boolean} The value as a boolean, inverted if |inverted| is true. |
+ * @private |
+ */ |
+ getNewValue_: function(value) { |
+ return this.inverted ? !value : !!value; |
}, |
- /** @private */ |
- getNewValue_: function(val) { |
- return this.inverted ? !val : val; |
- } |
+ /** |
+ * @param {boolean} disabled |
+ * @param {?chrome.settingsPrivate.PrefObject} pref |
+ * @return {boolean} Whether the checkbox should be disabled. |
+ * @private |
+ */ |
+ checkboxDisabled_: function(disabled, pref) { |
+ return disabled || (!!pref && |
michaelpg
2015/09/17 02:19:25
!!pref -> pref (no need to convert null to boolean
stevenjb
2015/09/17 17:33:31
Actually, closure will complain without the !!.
|
+ pref.policyEnforcement == |
+ chrome.settingsPrivate.PolicyEnforcement.ENFORCED); |
+ }, |
}); |