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

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: Rebase 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
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/settings_toggle_button_tests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b22619ae1e5919ab0daa12d38d74d287d2feec86..340c3806092f8f674863b11629d7204980b6966e 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;
},
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/settings_toggle_button_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698