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

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

Issue 1422023012: MD Settings: Simplify settings-dropdown-menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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_radio_group.js
diff --git a/chrome/browser/resources/settings/controls/settings_radio_group.js b/chrome/browser/resources/settings/controls/settings_radio_group.js
index 11c224bb85762981f946e1097c1d56701e24a752..239faf6becf12e9bd55d1400b7acce803e9c69d1 100644
--- a/chrome/browser/resources/settings/controls/settings_radio_group.js
+++ b/chrome/browser/resources/settings/controls/settings_radio_group.js
@@ -17,6 +17,8 @@
Polymer({
is: 'settings-radio-group',
+ behaviors: [SelectablePrefBehavior],
+
properties: {
/**
* The preference object to control.
@@ -25,47 +27,29 @@ Polymer({
pref: {
type: Object,
notify: true,
- observer: 'prefChanged_'
},
/**
- * IronSelectableBehavior selected attribute
+ * IronSelectableBehavior selected attribute.
*/
selected: {
type: String,
+ notify: true,
observer: 'selectedChanged_'
},
},
+ observers: [
+ 'prefChanged_(pref.*)',
+ ],
+
/** @private */
prefChanged_: function() {
- if (!this.pref)
- return;
- if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER ||
- this.pref.type == chrome.settingsPrivate.PrefType.BOOLEAN) {
- this.selected = this.pref.value.toString();
- } else {
- assert(this.pref.type != chrome.settingsPrivate.PrefType.LIST);
- this.selected = /** @type {string} */(this.pref.value);
- }
+ this.selected = this.prefToString();
},
/** @private */
stevenjb 2015/11/11 02:04:22 @type selected
- selectedChanged_: function() {
- if (!this.pref)
- return;
- if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) {
- var n = parseInt(this.selected, 10);
- if (isNaN(n)) {
- console.error('Bad selected name for numerical pref: ' + this.selected);
- return;
- }
- this.set('pref.value', n);
- } else if (this.pref.type == chrome.settingsPrivate.PrefType.BOOLEAN) {
- this.set('pref.value', this.selected == 'true');
- } else {
- assert(this.pref.type != chrome.settingsPrivate.PrefType.LIST);
- this.set('pref.value', this.selected);
- }
+ selectedChanged_: function(selected) {
+ this.set('pref.value', this.toPrefValue(selected));
},
});

Powered by Google App Engine
This is Rietveld 408576698