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 2109aba704b116f176e0fb79a4e7f9dc2c25dd2f..12edb099ea68b2d8626a92c7bbb94e40c9a982d7 100644 |
--- a/chrome/browser/resources/settings/checkbox/checkbox.js |
+++ b/chrome/browser/resources/settings/checkbox/checkbox.js |
@@ -24,25 +24,35 @@ Polymer({ |
pref: { |
type: Object, |
notify: true, |
- value: null |
+ value: null, |
}, |
+ /** 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: '', |
@@ -58,23 +68,43 @@ Polymer({ |
this.$.events.forward(this.$.checkbox, ['change']); |
}, |
- /** @private */ |
+ /** |
+ * Polymer observer for pref.value |
+ * @param {?chrome.settingsPrivate.PrefObject} prefValue |
michaelpg
2015/09/16 18:58:52
the type of value is {*} -- pref is the PrefObject
stevenjb
2015/09/16 21:45:53
Ah, right, pref.value.
Done.
|
+ * @private |
+ */ |
prefValueChanged_: function(prefValue) { |
// prefValue is initially undefined when Polymer initializes pref. |
- if (prefValue !== undefined) { |
+ if (prefValue !== undefined) |
michaelpg
2015/09/16 18:58:52
should be able to remove this upon rebase
stevenjb
2015/09/16 21:45:53
Done.
|
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 && |
+ pref.policyEnforcement == |
+ chrome.settingsPrivate.PolicyEnforcement.ENFORCED); |
+ }, |
}); |