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

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

Issue 2718253006: MD Settings: checkbox: Support inverted when setting pref (Closed)
Patch Set: Add test Created 3 years, 10 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_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 85614f97ac4030767af0eda69036eac424ff9c37..fa6a550736a71c7c16e8bf5ec4ebc3e9fa92bfe5 100644
--- a/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
+++ b/chrome/browser/resources/settings/controls/settings_boolean_control_behavior.js
@@ -90,10 +90,11 @@ var SettingsBooleanControlBehaviorImpl = {
// 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) {
+ assert(!this.inverted);
this.set('pref.value', this.checked ? 1 : this.numericUncheckedValue);
return;
}
- this.set('pref.value', this.checked);
+ this.set('pref.value', this.inverted ? !this.checked : this.checked);
},
/**
@@ -113,9 +114,10 @@ var SettingsBooleanControlBehaviorImpl = {
getNewValue_: function(value) {
// For numeric prefs, the control is only false if the value is exactly
// equal to the unchecked-equivalent value.
- if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER)
- value = value != this.numericUncheckedValue;
-
+ if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) {
+ assert(!this.inverted);
+ return value != this.numericUncheckedValue;
+ }
return this.inverted ? !value : !!value;
},

Powered by Google App Engine
This is Rietveld 408576698