Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/browser/resources/settings/search_page/search_page.js

Issue 1714843004: MD Settings: Search page, remove last usage of chrome.searchPrivate API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/settings/search_page/search_page.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Example:
10 *
11 * <iron-animated-pages>
12 * <settings-search-page prefs="{{prefs}}"></settings-search-page>
13 * ... other pages ...
14 * </iron-animated-pages>
15 *
16 * @group Chrome Settings Elements 9 * @group Chrome Settings Elements
17 * @element settings-search-page 10 * @element settings-search-page
18 */ 11 */
19 Polymer({ 12 Polymer({
20 is: 'settings-search-page', 13 is: 'settings-search-page',
21 14
22 properties: { 15 properties: {
23 /** 16 /**
24 * The current active route. 17 * The current active route.
25 */ 18 */
26 currentRoute: { 19 currentRoute: {
27 type: Object, 20 type: Object,
28 notify: true, 21 notify: true,
29 }, 22 },
30 23
31 /** 24 /**
32 * List of default search engines available. 25 * List of default search engines available.
33 * @type {?Array<!SearchEngine>} 26 * @private {!Array<!SearchEngine>}
34 */ 27 */
35 searchEngines: { 28 searchEngines_: {
36 type: Array, 29 type: Array,
37 value: function() { return []; }, 30 value: function() { return []; }
38 }, 31 },
32
33 /** @private {!settings.SearchEnginesBrowserProxy} */
34 browserProxy_: Object,
39 }, 35 },
40 36
41 /** @override */ 37 /** @override */
42 created: function() { 38 created: function() {
43 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener( 39 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance();
44 this.updateSearchEngines_.bind(this));
45 chrome.searchEnginesPrivate.getSearchEngines(
46 this.updateSearchEngines_.bind(this));
47 }, 40 },
48 41
49 /** 42 /** @override */
50 * Persists the new default search engine back to Chrome. Called when the 43 ready: function() {
51 * user selects a new default in the search engines dropdown. 44 var updateSearchEngines = function(searchEngines) {
52 * @private 45 this.set('searchEngines_', searchEngines.defaults);
53 */ 46 }.bind(this);
54 defaultEngineGuidChanged_: function() { 47 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines);
55 chrome.searchEnginesPrivate.setSelectedSearchEngine( 48 cr.addWebUIListener('search-engines-changed', updateSearchEngines);
56 this.$.searchEnginesMenu.value);
57 },
58
59
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
64 */
65 updateSearchEngines_: function(engines) {
66 var defaultEngines = [];
67
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;
74 }
75 }
76 }, this);
77
78 this.searchEngines = defaultEngines;
79 }, 49 },
80 50
81 /** @private */ 51 /** @private */
82 onSearchEnginesTap_: function() { 52 onManageSearchEnginesTap_: function() {
83 this.$.pages.setSubpageChain(['search-engines']); 53 this.$.pages.setSubpageChain(['search-engines']);
84 }, 54 },
55
56 /** @private */
57 onDefaultEngineChanged_: function() {
58 this.browserProxy_.setDefaultSearchEngine(this.$.searchEnginesMenu.value);
59 },
85 }); 60 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/search_page/search_page.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698