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
3 // found in the LICENSE file.
7 * 'cr-settings-search-page' is the settings page containing search settings.
11 * <iron-animated-pages>
12 * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page>
14 * </iron-animated-pages>
16 * @group Chrome Settings Elements
17 * @element cr-settings-search-page
20 is
: 'cr-settings-search-page',
24 * The current active route.
32 * List of default search engines available.
33 * @type {?Array<!SearchEngine>}
37 value: function() { return []; },
43 chrome
.searchEnginesPrivate
.onSearchEnginesChanged
.addListener(
44 this.updateSearchEngines_
.bind(this));
45 chrome
.searchEnginesPrivate
.getSearchEngines(
46 this.updateSearchEngines_
.bind(this));
50 * Persists the new default search engine back to Chrome. Called when the
51 * user selects a new default in the search engines dropdown.
54 defaultEngineGuidChanged_: function() {
55 chrome
.searchEnginesPrivate
.setSelectedSearchEngine(
56 this.$.searchEnginesMenu
.value
);
61 * Updates the list of default search engines based on the given |engines|.
62 * @param {!Array<!SearchEngine>} engines All the search engines.
65 updateSearchEngines_: function(engines
) {
66 var defaultEngines
= [];
68 engines
.forEach(function(engine
) {
70 chrome
.searchEnginesPrivate
.SearchEngineType
.DEFAULT
) {
71 defaultEngines
.push(engine
);
72 if (engine
.isSelected
) {
73 this.$.searchEnginesMenu
.value
= engine
.guid
;
78 this.searchEngines
= defaultEngines
;
82 onSearchEnginesTap_: function() {
83 this.$.pages
.setSubpageChain(['search-engines']);
87 onSearchEnginesAdvancedTap_: function() {
88 this.$.pages
.setSubpageChain(['search-engines', 'search-engines-advanced']);