| Index: chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
|
| diff --git a/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js b/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
|
| index c33553b68b6d6fabe226f6be2493f17aac81d4e3..0a2a053d663f33919ecdb85785c4df58ba3add1a 100644
|
| --- a/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
|
| +++ b/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
|
| @@ -23,7 +23,7 @@ var SettingsBooleanControlBehaviorImpl = {
|
| value: false,
|
| notify: true,
|
| observer: 'checkedChanged_',
|
| - reflectToAttribute: true
|
| + reflectToAttribute: true,
|
| },
|
|
|
| /** Disabled property for the element. */
|
| @@ -31,7 +31,17 @@ var SettingsBooleanControlBehaviorImpl = {
|
| type: Boolean,
|
| value: false,
|
| notify: true,
|
| - reflectToAttribute: true
|
| + reflectToAttribute: true,
|
| + },
|
| +
|
| + /**
|
| + * If true, do not automatically set the preference value. This allows the
|
| + * container to confirm the change first then call either sendPrefChange
|
| + * or resetToPrefValue accordingly.
|
| + */
|
| + noSetPref: {
|
| + type: Boolean,
|
| + value: false,
|
| },
|
|
|
| /** The main label. */
|
| @@ -48,9 +58,26 @@ var SettingsBooleanControlBehaviorImpl = {
|
| },
|
|
|
| observers: [
|
| - 'prefValueChanged_(pref.value)'
|
| + 'prefValueChanged_(pref.value)',
|
| ],
|
|
|
| + /** Reset the checked state to match the current pref value. */
|
| + resetToPrefValue: function() {
|
| + this.checked = this.getNewValue_(this.pref.value);
|
| + },
|
| +
|
| + /** Update the pref to the current |checked| value. */
|
| + sendPrefChange: function() {
|
| + /** @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);
|
| + },
|
| +
|
| /**
|
| * Polymer observer for pref.value.
|
| * @param {*} prefValue
|
| @@ -65,16 +92,9 @@ var SettingsBooleanControlBehaviorImpl = {
|
| * @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);
|
| + if (!this.pref || this.noSetPref)
|
| return;
|
| - }
|
| - this.set('pref.value', newValue);
|
| + this.sendPrefChange();
|
| },
|
|
|
| /**
|
|
|