| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'settings-search-page' is the settings page containing search settings. | 7 * 'settings-search-page' is the settings page containing search settings. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-search-page', | 10 is: 'settings-search-page', |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); | 36 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); |
| 37 cr.addWebUIListener('search-engines-changed', updateSearchEngines); | 37 cr.addWebUIListener('search-engines-changed', updateSearchEngines); |
| 38 }, | 38 }, |
| 39 | 39 |
| 40 /** @private */ | 40 /** @private */ |
| 41 onManageSearchEnginesTap_: function() { | 41 onManageSearchEnginesTap_: function() { |
| 42 settings.navigateTo(settings.Route.SEARCH_ENGINES); | 42 settings.navigateTo(settings.Route.SEARCH_ENGINES); |
| 43 }, | 43 }, |
| 44 | 44 |
| 45 /** @private */ | 45 /** @private */ |
| 46 onIronSelect_: function() { | 46 onChange_: function(e) { |
| 47 var searchEngine = this.searchEngines_[this.$$('paper-listbox').selected]; | 47 var select = /** @type {!HTMLSelectElement} */ (this.$$('select')); |
| 48 if (searchEngine.default) { | 48 var searchEngine = this.searchEngines_[select.selectedIndex]; |
| 49 // If the selected search engine is already marked as the default one, | |
| 50 // this change originated in some other tab, and nothing should be done | |
| 51 // here. | |
| 52 return; | |
| 53 } | |
| 54 | |
| 55 // Otherwise, this change originated by an explicit user action in this tab. | |
| 56 // Submit the default search engine change. | |
| 57 this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex); | 49 this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex); |
| 58 }, | 50 }, |
| 59 | |
| 60 /** | |
| 61 * @return {number} | |
| 62 * @private | |
| 63 */ | |
| 64 getSelectedSearchEngineIndex_: function() { | |
| 65 return this.searchEngines_.findIndex(function(searchEngine) { | |
| 66 return searchEngine.default; | |
| 67 }); | |
| 68 }, | |
| 69 }); | 51 }); |
| OLD | NEW |