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',
29 * Whether the page is a subpage.
45 * Title for the page header and navigation menu.
49 value: function() { return loadTimeData.getString('searchPageTitle'); },
53 * Name of the 'iron-icon' to be shown in the settings-page-header.
61 * List of default search engines available.
62 * @type {?Array<!SearchEngine>}
66 value: function() { return []; },
72 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener(
73 this.updateSearchEngines_.bind(this));
74 chrome.searchEnginesPrivate.getSearchEngines(
75 this.updateSearchEngines_.bind(this));
79 * Persists the new default search engine back to Chrome. Called when the
80 * user selects a new default in the search engines dropdown.
83 defaultEngineGuidChanged_: function() {
84 chrome.searchEnginesPrivate.setSelectedSearchEngine(
85 this.$.searchEnginesMenu.value);
90 * Updates the list of default search engines based on the given |engines|.
91 * @param {!Array<!SearchEngine>} engines All the search engines.
94 updateSearchEngines_: function(engines) {
95 var defaultEngines = [];
97 engines.forEach(function(engine) {
99 chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) {
100 defaultEngines.push(engine);
101 if (engine.isSelected) {
102 this.$.searchEnginesMenu.value = engine.guid;
107 this.searchEngines = defaultEngines;
111 manageSearchEngines_: function() {
112 MoreRouting.navigateTo('search-engines');