| 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', |
| 11 | 11 |
| 12 properties: { | 12 properties: { |
| 13 prefs: Object, |
| 14 |
| 13 /** | 15 /** |
| 14 * List of default search engines available. | 16 * List of default search engines available. |
| 15 * @private {!Array<!SearchEngine>} | 17 * @private {!Array<!SearchEngine>} |
| 16 */ | 18 */ |
| 17 searchEngines_: { | 19 searchEngines_: { |
| 18 type: Array, | 20 type: Array, |
| 19 value: function() { return []; } | 21 value: function() { return []; } |
| 20 }, | 22 }, |
| 23 }, |
| 21 | 24 |
| 22 /** @private {!settings.SearchEnginesBrowserProxy} */ | 25 /** @private {?settings.SearchEnginesBrowserProxy} */ |
| 23 browserProxy_: Object, | 26 browserProxy_: null, |
| 24 }, | |
| 25 | 27 |
| 26 /** @override */ | 28 /** @override */ |
| 27 created: function() { | 29 created: function() { |
| 28 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); | 30 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); |
| 29 }, | 31 }, |
| 30 | 32 |
| 31 /** @override */ | 33 /** @override */ |
| 32 ready: function() { | 34 ready: function() { |
| 33 var updateSearchEngines = function(searchEngines) { | 35 var updateSearchEngines = function(searchEngines) { |
| 34 this.set('searchEngines_', searchEngines.defaults); | 36 this.set('searchEngines_', searchEngines.defaults); |
| 35 }.bind(this); | 37 }.bind(this); |
| 36 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); | 38 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); |
| 37 cr.addWebUIListener('search-engines-changed', updateSearchEngines); | 39 cr.addWebUIListener('search-engines-changed', updateSearchEngines); |
| 38 }, | 40 }, |
| 39 | 41 |
| 40 /** @private */ | 42 /** @private */ |
| 43 onChange_: function() { |
| 44 var select = /** @type {!HTMLSelectElement} */ (this.$$('select')); |
| 45 var searchEngine = this.searchEngines_[select.selectedIndex]; |
| 46 this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex); |
| 47 }, |
| 48 |
| 49 /** @private */ |
| 50 onDisableExtension_: function() { |
| 51 this.fire('refresh-pref', 'default_search_provider.enabled'); |
| 52 }, |
| 53 |
| 54 /** @private */ |
| 41 onManageSearchEnginesTap_: function() { | 55 onManageSearchEnginesTap_: function() { |
| 42 settings.navigateTo(settings.Route.SEARCH_ENGINES); | 56 settings.navigateTo(settings.Route.SEARCH_ENGINES); |
| 43 }, | 57 }, |
| 44 | |
| 45 /** @private */ | |
| 46 onChange_: function(e) { | |
| 47 var select = /** @type {!HTMLSelectElement} */ (this.$$('select')); | |
| 48 var searchEngine = this.searchEngines_[select.selectedIndex]; | |
| 49 this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex); | |
| 50 }, | |
| 51 }); | 58 }); |
| OLD | NEW |