OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 /** |
| 6 * @fileoverview |
| 7 * 'cr-settings-search-page' is the settings page containing search settings. |
| 8 * |
| 9 * Example: |
| 10 * |
| 11 * <core-animated-pages> |
| 12 * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page> |
| 13 * ... other pages ... |
| 14 * </core-animated-pages> |
| 15 * |
| 16 * @group Chrome Settings Elements |
| 17 * @element cr-settings-search-page |
| 18 */ |
| 19 Polymer('cr-settings-search-page', { |
| 20 publish: { |
| 21 /** |
| 22 * Preferences state. |
| 23 * |
| 24 * @attribute prefs |
| 25 * @type {CrSettingsPrefsElement} |
| 26 * @default null |
| 27 */ |
| 28 prefs: null, |
| 29 |
| 30 /** |
| 31 * Whether the page is a subpage. |
| 32 * |
| 33 * @attribute subpage |
| 34 * @type {boolean} |
| 35 * @default false |
| 36 */ |
| 37 subpage: false, |
| 38 |
| 39 /** |
| 40 * ID of the page. |
| 41 * |
| 42 * @attribute PAGE_ID |
| 43 * @const {string} |
| 44 * @default 'search' |
| 45 */ |
| 46 PAGE_ID: 'search', |
| 47 |
| 48 /** |
| 49 * Title for the page header and navigation menu. |
| 50 * |
| 51 * @attribute pageTitle |
| 52 * @type {string} |
| 53 */ |
| 54 pageTitle: loadTimeData.getString('searchPageTitle'), |
| 55 |
| 56 /** |
| 57 * Name of the 'core-icon' to be shown in the settings-page-header. |
| 58 * |
| 59 * @attribute icon |
| 60 * @type {string} |
| 61 * @default 'search' |
| 62 */ |
| 63 icon: 'search', |
| 64 |
| 65 /** |
| 66 * List of default search engines available. |
| 67 * |
| 68 * @attribute searchEngines |
| 69 * @type {Array<!SearchEngine} |
| 70 * @default null |
| 71 */ |
| 72 searchEngines: null, |
| 73 |
| 74 /** |
| 75 * GUID of the currently selected default search engine. |
| 76 * |
| 77 * @attribute defaultEngineGuid |
| 78 * @type {string} |
| 79 * @default '' |
| 80 */ |
| 81 defaultEngineGuid: '', |
| 82 }, |
| 83 |
| 84 /** @override */ |
| 85 created: function() { |
| 86 this.searchEngines = []; |
| 87 }, |
| 88 |
| 89 /** @override */ |
| 90 domReady: function() { |
| 91 chrome.searchEnginesPrivate.onDefaultSearchEnginesChanged.addListener( |
| 92 this.updateSearchEngines_.bind(this)); |
| 93 chrome.searchEnginesPrivate.getDefaultSearchEngines( |
| 94 this.updateSearchEngines_.bind(this)); |
| 95 }, |
| 96 |
| 97 /** |
| 98 * Persists the new default search engine back to Chrome. Called when the |
| 99 * user selects a new default in the search engines dropdown. |
| 100 */ |
| 101 defaultEngineGuidChanged: function() { |
| 102 chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid); |
| 103 }, |
| 104 |
| 105 |
| 106 /** |
| 107 * Updates the list of search engines with the given |engines|. |
| 108 * @param {!Array<!SearchEngine>} engines |
| 109 * @private |
| 110 */ |
| 111 updateSearchEngines_: function(engines) { |
| 112 this.searchEngines = engines; |
| 113 for (var i = 0; i < engines.length; i++) { |
| 114 if (engines[i].isSelected) { |
| 115 this.defaultEngineGuid = engines[i].guid; |
| 116 } |
| 117 } |
| 118 } |
| 119 }); |
OLD | NEW |