| Index: chrome/browser/resources/settings/controls/settings_dropdown_menu.js
|
| diff --git a/chrome/browser/resources/settings/controls/settings_dropdown_menu.js b/chrome/browser/resources/settings/controls/settings_dropdown_menu.js
|
| index 28bddf25f5cd52809968372660c5846e359f8733..a5859f835f12054f075e930c6153dceddd27d14f 100644
|
| --- a/chrome/browser/resources/settings/controls/settings_dropdown_menu.js
|
| +++ b/chrome/browser/resources/settings/controls/settings_dropdown_menu.js
|
| @@ -3,6 +3,23 @@
|
| // found in the LICENSE file.
|
|
|
| /**
|
| + * This tuple is made up of a (value, name, attribute). The value and name are
|
| + * used by the dropdown menu. The attribute is optional 'user data' that is
|
| + * ignored by the dropdown menu.
|
| + * @typedef {{
|
| + * 0: (number|string),
|
| + * 1: string,
|
| + * 2: (string|undefined)
|
| + * }}
|
| + */
|
| +var DropdownMenuOption;
|
| +
|
| +/**
|
| + * @typedef {!Array<DropdownMenuOption>}
|
| + */
|
| +var DropdownMenuOptionList;
|
| +
|
| +/**
|
| * 'settings-dropdown-menu' is a control for displaying options
|
| * in the settings.
|
| *
|
| @@ -27,18 +44,15 @@ Polymer({
|
|
|
| /**
|
| * List of options for the drop-down menu.
|
| - * @type {!Array<{0: (Object|number|string), 1: string,
|
| - * 2: (string|undefined)}>}
|
| + * @type {!DropdownMenuOptionList}
|
| */
|
| menuOptions: {
|
| - notify: true,
|
| type: Array,
|
| value: function() { return []; },
|
| },
|
|
|
| /**
|
| * A single Preference object being tracked.
|
| - * @type {?PrefObject}
|
| */
|
| pref: {
|
| type: Object,
|
| @@ -92,7 +106,7 @@ Polymer({
|
| },
|
|
|
| behaviors: [
|
| - I18nBehavior
|
| + I18nBehavior,
|
| ],
|
|
|
| observers: [
|
| @@ -116,13 +130,13 @@ Polymer({
|
| // Create a map from index value [0] back to the index i.
|
| var result = {};
|
| for (var i = 0; i < this.menuOptions.length; ++i)
|
| - result[JSON.stringify(this.menuOptions[i][0])] = i.toString();
|
| + result[String(this.menuOptions[i][0])] = i.toString();
|
| this.menuMap_ = result;
|
| }
|
|
|
| // We need the menuOptions and the selectedValue_. They may arrive
|
| // at different times (each is asynchronous).
|
| - this.selected_ = this.getItemIndex(this.selectedValue_);
|
| + this.selected_ = this.itemIndex(this.selectedValue_);
|
| this.menuLabel_ = this.label;
|
| this.$.dropdownMenu.disabled = false;
|
| },
|
| @@ -132,7 +146,7 @@ Polymer({
|
| * @return {string}
|
| * @private
|
| */
|
| - getItemIndex: function(item) {
|
| + itemIndex: function(item) {
|
| var result = this.menuMap_[item];
|
| if (result)
|
| return result;
|
| @@ -146,7 +160,7 @@ Polymer({
|
| * @return {Object|number|string|undefined}
|
| * @private
|
| */
|
| - getItemValue: function(index) {
|
| + itemValue: function(index) {
|
| if (this.menuOptions.length) {
|
| var result = this.menuOptions[index];
|
| if (result)
|
| @@ -160,9 +174,9 @@ Polymer({
|
| * @private
|
| */
|
| onSelectedChanged_: function() {
|
| - var prefValue = this.getItemValue(this.selected_);
|
| + var prefValue = this.itemValue(this.selected_);
|
| if (prefValue !== undefined) {
|
| - this.selectedValue_ = JSON.stringify(prefValue);
|
| + this.selectedValue_ = String(prefValue);
|
| this.set('pref.value', prefValue);
|
| }
|
| },
|
| @@ -172,6 +186,6 @@ Polymer({
|
| * @private
|
| */
|
| prefChanged_: function(value) {
|
| - this.selectedValue_ = JSON.stringify(value);
|
| + this.selectedValue_ = String(value);
|
| },
|
| });
|
|
|