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

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

Issue 1125343005: Convert search page to Polymer 0.8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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
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 * 'cr-settings-search-page' is the settings page containing search settings. 7 * 'cr-settings-search-page' is the settings page containing search settings.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
11 * <core-animated-pages> 11 * <iron-animated-pages>
12 * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page> 12 * <cr-settings-search-page prefs="{{prefs}}"></cr-settings-search-page>
13 * ... other pages ... 13 * ... other pages ...
14 * </core-animated-pages> 14 * </iron-animated-pages>
15 * 15 *
16 * @group Chrome Settings Elements 16 * @group Chrome Settings Elements
17 * @element cr-settings-search-page 17 * @element cr-settings-search-page
18 */ 18 */
19 Polymer('cr-settings-search-page', { 19 Polymer({
20 publish: { 20 is: 'cr-settings-search-page',
21
22 properties: {
21 /** 23 /**
22 * Preferences state. 24 * Preferences state.
23 * 25 * @type {?CrSettingsPrefsElement}
24 * @attribute prefs
25 * @type {CrSettingsPrefsElement}
26 * @default null
27 */ 26 */
28 prefs: null, 27 prefs: {
28 type: Object,
29 notify: true,
30 },
29 31
30 /** 32 /**
31 * Route for the page. 33 * Route for the page.
32 *
33 * @attribute route
34 * @type {string}
35 * @default ''
36 */ 34 */
37 route: '', 35 route: String,
38 36
39 /** 37 /**
40 * Whether the page is a subpage. 38 * Whether the page is a subpage.
41 *
42 * @attribute subpage
43 * @type {boolean}
44 * @default false
45 */ 39 */
46 subpage: false, 40 subpage: {
41 type: Boolean,
42 value: false,
43 },
47 44
48 /** 45 /**
49 * ID of the page. 46 * ID of the page.
50 *
51 * @attribute PAGE_ID
52 * @const {string}
53 * @default 'search'
54 */ 47 */
55 PAGE_ID: 'search', 48 PAGE_ID: {
49 type: String,
50 value: 'search',
51 },
56 52
57 /** 53 /**
58 * Title for the page header and navigation menu. 54 * Title for the page header and navigation menu.
59 *
60 * @attribute pageTitle
61 * @type {string}
62 */ 55 */
63 pageTitle: loadTimeData.getString('searchPageTitle'), 56 pageTitle: {
57 type: String,
58 value: function() { return loadTimeData.getString('searchPageTitle'); },
59 },
64 60
65 /** 61 /**
66 * Name of the 'core-icon' to be shown in the settings-page-header. 62 * Name of the 'iron-icon' to be shown in the settings-page-header.
67 *
68 * @attribute icon
69 * @type {string}
70 * @default 'search'
71 */ 63 */
72 icon: 'search', 64 icon: {
65 type: Boolean,
66 value: 'search',
67 },
73 68
74 /** 69 /**
75 * List of default search engines available. 70 * List of default search engines available.
76 * 71 * @type {?Array<!SearchEngine>}
77 * @attribute searchEngines
78 * @type {Array<!SearchEngine>}
79 * @default null
80 */ 72 */
81 searchEngines: null, 73 searchEngines: {
82 74 type: Array,
83 /** 75 value: function() { return []; },
84 * GUID of the currently selected default search engine. 76 },
85 *
86 * @attribute defaultEngineGuid
87 * @type {string}
88 * @default ''
89 */
90 defaultEngineGuid: '',
91 }, 77 },
92 78
93 /** @override */ 79 /** @override */
94 created: function() { 80 created: function() {
95 this.searchEngines = [];
96 },
97
98 /** @override */
99 domReady: function() {
100 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener( 81 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener(
101 this.updateSearchEngines_.bind(this)); 82 this.updateSearchEngines_.bind(this));
102 chrome.searchEnginesPrivate.getSearchEngines( 83 chrome.searchEnginesPrivate.getSearchEngines(
103 this.updateSearchEngines_.bind(this)); 84 this.updateSearchEngines_.bind(this));
104 }, 85 },
105 86
106 /** 87 /**
107 * Persists the new default search engine back to Chrome. Called when the 88 * Persists the new default search engine back to Chrome. Called when the
108 * user selects a new default in the search engines dropdown. 89 * user selects a new default in the search engines dropdown.
90 * @private
109 */ 91 */
110 defaultEngineGuidChanged: function() { 92 defaultEngineGuidChanged_: function() {
111 chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid); 93 chrome.searchEnginesPrivate.setSelectedSearchEngine(
94 this.$.searchEnginesMenu.value);
112 }, 95 },
113 96
114 97
115 /** 98 /**
116 * Updates the list of default search engines based on the given |engines|. 99 * Updates the list of default search engines based on the given |engines|.
117 * @param {!Array<!SearchEngine>} engines All the search engines. 100 * @param {!Array<!SearchEngine>} engines All the search engines.
118 * @private 101 * @private
119 */ 102 */
120 updateSearchEngines_: function(engines) { 103 updateSearchEngines_: function(engines) {
121 var defaultEngines = []; 104 var defaultEngines = [];
122 105
123 engines.forEach(function(engine) { 106 engines.forEach(function(engine) {
124 if (engine.type == 107 if (engine.type ==
125 chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) { 108 chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) {
126 defaultEngines.push(engine); 109 defaultEngines.push(engine);
127 if (engine.isSelected) { 110 if (engine.isSelected) {
128 this.defaultEngineGuid = engine.guid; 111 this.$.searchEnginesMenu.value = engine.guid;
129 } 112 }
130 } 113 }
131 }, this); 114 }, this);
132 115
133 this.searchEngines = defaultEngines; 116 this.searchEngines = defaultEngines;
134 }, 117 },
135 118
136 /** @private */ 119 /** @private */
137 manageSearchEngines_: function() { 120 manageSearchEngines_: function() {
138 MoreRouting.navigateTo('search-engines'); 121 MoreRouting.navigateTo('search-engines');
139 }, 122 },
140 }); 123 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698