Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1155)

Unified Diff: chrome/browser/resources/settings/controls/settings_checkbox.js

Issue 2437183002: [MD settings] content site list toggles (Closed)
Patch Set: review changes Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/controls/settings_checkbox.js
diff --git a/chrome/browser/resources/settings/controls/settings_checkbox.js b/chrome/browser/resources/settings/controls/settings_checkbox.js
index 7dabd988baf2a41c04b32c49eded167d94c02cf7..6528fec6279a0880637b60aa0aacccd443b3e8ed 100644
--- a/chrome/browser/resources/settings/controls/settings_checkbox.js
+++ b/chrome/browser/resources/settings/controls/settings_checkbox.js
@@ -5,100 +5,9 @@
/**
* @fileoverview
* `settings-checkbox` is a checkbox that controls a supplied preference.
- *
- * Example:
- * <settings-checkbox pref="{{prefs.settings.enableFoo}}"
- * label="Enable foo setting." subLabel="(bar also)">
- * </settings-checkbox>
*/
Polymer({
is: 'settings-checkbox',
- behaviors: [CrPolicyPrefBehavior, PrefControlBehavior],
-
- properties: {
- /** Whether the checkbox should represent the inverted value. */
- inverted: {
- type: Boolean,
- value: false,
- },
-
- /** Whether the checkbox is checked. */
- checked: {
- type: Boolean,
- value: false,
- notify: true,
- observer: 'checkedChanged_',
- reflectToAttribute: true
- },
-
- /** Disabled property for the element. */
- disabled: {
- type: Boolean,
- value: false,
- notify: true,
- reflectToAttribute: true
- },
-
- /** Checkbox label. */
- label: {
- type: String,
- value: '',
- },
-
- /** Additional sub-label for the checkbox. */
- subLabel: {
- type: String,
- value: '',
- },
- },
-
- observers: [
- 'prefValueChanged_(pref.value)'
- ],
-
- /**
- * Polymer observer for pref.value.
- * @param {*} prefValue
- * @private
- */
- prefValueChanged_: function(prefValue) {
- this.checked = this.getNewValue_(prefValue);
- },
-
- /**
- * Polymer observer for checked.
- * @private
- */
- checkedChanged_: function() {
- if (!this.pref)
- return;
- /** @type {boolean} */ var newValue = this.getNewValue_(this.checked);
- // Ensure that newValue is the correct type for the pref type, either
- // a boolean or a number.
- if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) {
- this.set('pref.value', newValue ? 1 : 0);
- return;
- }
- this.set('pref.value', newValue);
- },
-
- /**
- * @param {*} value
- * @return {boolean} The value as a boolean, inverted if |inverted| is true.
- * @private
- */
- getNewValue_: function(value) {
- return this.inverted ? !value : !!value;
- },
-
- /**
- * @param {boolean} disabled
- * @param {!chrome.settingsPrivate.PrefObject} pref
- * @return {boolean} Whether the checkbox should be disabled.
- * @private
- */
- checkboxDisabled_: function(disabled, pref) {
- return disabled || this.isPrefPolicyControlled(pref);
- },
+ behaviors: [SettingsBooleanControlBehavior],
});

Powered by Google App Engine
This is Rietveld 408576698