Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / resources / settings / search_page / search_page.js
blob34983d08ada866a2368913f0c47ee951478d37c5
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.
5 /**
6 * @fileoverview
7 * 'cr-settings-search-page' is the settings page containing search settings.
9 * Example:
11 * <iron-animated-pages>
12 * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page>
13 * ... other pages ...
14 * </iron-animated-pages>
16 * @group Chrome Settings Elements
17 * @element cr-settings-search-page
19 Polymer({
20 is: 'cr-settings-search-page',
22 properties: {
23 /**
24 * The current active route.
26 currentRoute: {
27 type: Object,
28 notify: true,
31 /**
32 * List of default search engines available.
33 * @type {?Array<!SearchEngine>}
35 searchEngines: {
36 type: Array,
37 value: function() { return []; },
41 /** @override */
42 created: function() {
43 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener(
44 this.updateSearchEngines_.bind(this));
45 chrome.searchEnginesPrivate.getSearchEngines(
46 this.updateSearchEngines_.bind(this));
49 /**
50 * Persists the new default search engine back to Chrome. Called when the
51 * user selects a new default in the search engines dropdown.
52 * @private
54 defaultEngineGuidChanged_: function() {
55 chrome.searchEnginesPrivate.setSelectedSearchEngine(
56 this.$.searchEnginesMenu.value);
60 /**
61 * Updates the list of default search engines based on the given |engines|.
62 * @param {!Array<!SearchEngine>} engines All the search engines.
63 * @private
65 updateSearchEngines_: function(engines) {
66 var defaultEngines = [];
68 engines.forEach(function(engine) {
69 if (engine.type ==
70 chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) {
71 defaultEngines.push(engine);
72 if (engine.isSelected) {
73 this.$.searchEnginesMenu.value = engine.guid;
76 }, this);
78 this.searchEngines = defaultEngines;
81 /** @private */
82 onSearchEnginesTap_: function() {
83 this.$.pages.setSubpageChain(['search-engines']);
86 /** @private */
87 onSearchEnginesAdvancedTap_: function() {
88 this.$.pages.setSubpageChain(['search-engines', 'search-engines-advanced']);
90 });