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

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

Issue 1486953003: Support numbers in settings-checkbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure type of boolean pref also Created 5 years 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 e892fb96f4558da4cc6a74c347366da705ffc505..d0bbebc2507522effac0b694d9548d7ad596280c 100644
--- a/chrome/browser/resources/settings/controls/settings_checkbox.js
+++ b/chrome/browser/resources/settings/controls/settings_checkbox.js
@@ -87,7 +87,16 @@ Polymer({
* @private
*/
checkedChanged_: function() {
- this.set('pref.value', this.getNewValue_(this.checked));
+ if (!this.pref)
+ return;
+ /** @type {boolean} */ var newValue = this.getNewValue_(this.checked);
michaelpg 2015/12/02 18:54:50 looks like @type is redundant with @return of getN
stevenjb 2015/12/02 18:59:02 It is. I added it strictly as a comment to remind
+ // 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);
},
/**
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/checkbox_tests.js » ('j') | chrome/test/data/webui/settings/checkbox_tests.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698