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

Side by Side Diff: chrome/browser/resources/md_history/app.js

Issue 2237703004: [MD History] Focus the search bar on load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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 | « no previous file | chrome/browser/resources/md_history/app.crisper.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Polymer({ 5 Polymer({
6 is: 'history-app', 6 is: 'history-app',
7 7
8 properties: { 8 properties: {
9 showSidebarFooter: Boolean, 9 showSidebarFooter: Boolean,
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); 86 document.addEventListener('canExecute', this.onCanExecute_.bind(this));
87 document.addEventListener('command', this.onCommand_.bind(this)); 87 document.addEventListener('command', this.onCommand_.bind(this));
88 88
89 // Redirect legacy search URLs to URLs compatible with material history. 89 // Redirect legacy search URLs to URLs compatible with material history.
90 if (window.location.hash) { 90 if (window.location.hash) {
91 window.location.href = window.location.href.split('#')[0] + '?' + 91 window.location.href = window.location.href.split('#')[0] + '?' +
92 window.location.hash.substr(1); 92 window.location.hash.substr(1);
93 } 93 }
94 }, 94 },
95 95
96 onFirstRender: function() {
97 // requestAnimationFrame allows measurement immediately before the next
98 // repaint, but after the first page of <iron-list> items has stamped.
99 requestAnimationFrame(function() {
100 chrome.send(
101 'metricsHandler:recordTime',
102 ['History.ResultsRenderedTime', window.performance.now()]);
103 });
104
105 // Focus the search field on load. Done here to ensure the history page
106 // is rendered before we try to take focus.
107 if (!this.hasDrawer_) {
108 this.focusToolbarSearchField();
109 }
110 },
111
96 /** @private */ 112 /** @private */
97 onMenuTap_: function() { 113 onMenuTap_: function() {
98 var drawer = this.$$('#drawer'); 114 var drawer = this.$$('#drawer');
99 if (drawer) 115 if (drawer)
100 drawer.toggle(); 116 drawer.toggle();
101 }, 117 },
102 118
103 /** 119 /**
104 * Listens for history-item being selected or deselected (through checkbox) 120 * Listens for history-item being selected or deselected (through checkbox)
105 * and changes the view of the top toolbar. 121 * and changes the view of the top toolbar.
(...skipping 30 matching lines...) Expand all
136 historyResult: function(info, results) { 152 historyResult: function(info, results) {
137 this.set('queryState_.querying', false); 153 this.set('queryState_.querying', false);
138 this.set('queryResult_.info', info); 154 this.set('queryResult_.info', info);
139 this.set('queryResult_.results', results); 155 this.set('queryResult_.results', results);
140 var listContainer = 156 var listContainer =
141 /** @type {HistoryListContainerElement} */ (this.$['history']); 157 /** @type {HistoryListContainerElement} */ (this.$['history']);
142 listContainer.historyResult(info, results); 158 listContainer.historyResult(info, results);
143 }, 159 },
144 160
145 /** 161 /**
162 * Focuses the search bar in the toolbar.
163 */
164 focusToolbarSearchField: function() {
165 this.$.toolbar.showSearchField();
166 },
167
168 /**
146 * Fired when the user presses 'More from this site'. 169 * Fired when the user presses 'More from this site'.
147 * @param {{detail: {domain: string}}} e 170 * @param {{detail: {domain: string}}} e
148 */ 171 */
149 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, 172 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); },
150 173
151 /** 174 /**
152 * @param {Event} e 175 * @param {Event} e
153 * @private 176 * @private
154 */ 177 */
155 onCanExecute_: function(e) { 178 onCanExecute_: function(e) {
(...skipping 27 matching lines...) Expand all
183 searchQueryParamChanged_: function(searchQuery) { 206 searchQueryParamChanged_: function(searchQuery) {
184 this.$.toolbar.setSearchTerm(searchQuery || ''); 207 this.$.toolbar.setSearchTerm(searchQuery || '');
185 }, 208 },
186 209
187 /** 210 /**
188 * @param {Event} e 211 * @param {Event} e
189 * @private 212 * @private
190 */ 213 */
191 onCommand_: function(e) { 214 onCommand_: function(e) {
192 if (e.command.id == 'find-command' || e.command.id == 'slash-command') 215 if (e.command.id == 'find-command' || e.command.id == 'slash-command')
193 this.$.toolbar.showSearchField(); 216 this.focusToolbarSearchField();
194 if (e.command.id == 'delete-command') 217 if (e.command.id == 'delete-command')
195 this.deleteSelected(); 218 this.deleteSelected();
196 }, 219 },
197 220
198 /** 221 /**
199 * @param {!Array<!ForeignSession>} sessionList Array of objects describing 222 * @param {!Array<!ForeignSession>} sessionList Array of objects describing
200 * the sessions from other devices. 223 * the sessions from other devices.
201 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? 224 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile?
202 */ 225 */
203 setForeignSessions: function(sessionList, isTabSyncEnabled) { 226 setForeignSessions: function(sessionList, isTabSyncEnabled) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return selectedPage; 306 return selectedPage;
284 }, 307 },
285 308
286 /** @private */ 309 /** @private */
287 closeDrawer_: function() { 310 closeDrawer_: function() {
288 var drawer = this.$$('#drawer'); 311 var drawer = this.$$('#drawer');
289 if (drawer) 312 if (drawer)
290 drawer.close(); 313 drawer.close();
291 }, 314 },
292 }); 315 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_history/app.crisper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698