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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); | 44 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); |
45 cr.addWebUIListener('search-engines-changed', updateSearchEngines); | 45 cr.addWebUIListener('search-engines-changed', updateSearchEngines); |
46 }, | 46 }, |
47 | 47 |
48 /** @private */ | 48 /** @private */ |
49 onManageSearchEnginesTap_: function() { | 49 onManageSearchEnginesTap_: function() { |
50 this.$.pages.setSubpageChain(['search-engines']); | 50 this.$.pages.setSubpageChain(['search-engines']); |
51 }, | 51 }, |
52 | 52 |
53 /** @private */ | 53 /** @private */ |
54 onDefaultEngineChanged_: function() { | 54 onIronSelect_: function() { |
55 this.browserProxy_.setDefaultSearchEngine(this.$.searchEnginesMenu.value); | 55 var searchEngine = this.searchEngines_[this.$$('paper-listbox').selected]; |
| 56 if (searchEngine.default) { |
| 57 // If the selected search engine is already marked as the default one, |
| 58 // this change originated in some other tab, and nothing should be done |
| 59 // here. |
| 60 return; |
| 61 } |
| 62 |
| 63 // Otherwise, this change originated by an explicit user action in this tab. |
| 64 // Submit the default search engine change. |
| 65 this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex); |
| 66 }, |
| 67 |
| 68 /** |
| 69 * @return {number} |
| 70 * @private |
| 71 */ |
| 72 getSelectedSearchEngineIndex_: function() { |
| 73 return this.searchEngines_.findIndex(function(searchEngine) { |
| 74 return searchEngine.default; |
| 75 }); |
56 }, | 76 }, |
57 }); | 77 }); |
OLD | NEW |