Chromium Code Reviews| 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)); |
| }, |
| }); |