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

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

Issue 2237703004: [MD History] Focus the search bar on load. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments 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
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 /** 5 /**
6 * @fileoverview PromiseResolver is a helper class that allows creating a 6 * @fileoverview PromiseResolver is a helper class that allows creating a
7 * Promise that will be fulfilled (resolved or rejected) some time later. 7 * Promise that will be fulfilled (resolved or rejected) some time later.
8 * 8 *
9 * Example: 9 * Example:
10 * var resolver = new PromiseResolver(); 10 * var resolver = new PromiseResolver();
(...skipping 14416 matching lines...) Expand 10 before | Expand all | Expand 10 after
14427 lastVisitTime, maxResults 14427 lastVisitTime, maxResults
14428 ]); 14428 ]);
14429 }, 14429 },
14430 14430
14431 /** @return {number} */ 14431 /** @return {number} */
14432 getSelectedItemCount: function() { 14432 getSelectedItemCount: function() {
14433 return this.getSelectedList_().selectedPaths.size; 14433 return this.getSelectedList_().selectedPaths.size;
14434 }, 14434 },
14435 14435
14436 unselectAllItems: function(count) { 14436 unselectAllItems: function(count) {
14437 this.getSelectedList_().unselectAllItems(count); 14437 if (this.getSelectedList_())
14438 this.getSelectedList_().unselectAllItems(count);
14438 }, 14439 },
14439 14440
14440 /** 14441 /**
14441 * Delete all the currently selected history items. Will prompt the user with 14442 * Delete all the currently selected history items. Will prompt the user with
14442 * a dialog to confirm that the deletion should be performed. 14443 * a dialog to confirm that the deletion should be performed.
14443 */ 14444 */
14444 deleteSelectedWithPrompt: function() { 14445 deleteSelectedWithPrompt: function() {
14445 if (!loadTimeData.getBoolean('allowDeletingHistory')) 14446 if (!loadTimeData.getBoolean('allowDeletingHistory'))
14446 return; 14447 return;
14447 this.$.dialog.get().then(function(dialog) { 14448 this.$.dialog.get().then(function(dialog) {
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
15119 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); 15120 document.addEventListener('canExecute', this.onCanExecute_.bind(this));
15120 document.addEventListener('command', this.onCommand_.bind(this)); 15121 document.addEventListener('command', this.onCommand_.bind(this));
15121 15122
15122 // Redirect legacy search URLs to URLs compatible with material history. 15123 // Redirect legacy search URLs to URLs compatible with material history.
15123 if (window.location.hash) { 15124 if (window.location.hash) {
15124 window.location.href = window.location.href.split('#')[0] + '?' + 15125 window.location.href = window.location.href.split('#')[0] + '?' +
15125 window.location.hash.substr(1); 15126 window.location.hash.substr(1);
15126 } 15127 }
15127 }, 15128 },
15128 15129
15130 onFirstRender: function() {
15131 // requestAnimationFrame allows measurement immediately before the next
15132 // repaint, but after the first page of <iron-list> items has stamped.
15133 requestAnimationFrame(function() {
15134 chrome.send(
15135 'metricsHandler:recordTime',
15136 ['History.ResultsRenderedTime', window.performance.now()]);
15137 });
15138
15139 // Focus the search field on load. Done here to ensure the history page
15140 // is rendered before we try to take focus.
15141 if (!this.hasDrawer_) {
15142 this.focusToolbarSearchField();
15143 }
15144 },
15145
15129 /** @private */ 15146 /** @private */
15130 onMenuTap_: function() { 15147 onMenuTap_: function() {
15131 var drawer = this.$$('#drawer'); 15148 var drawer = this.$$('#drawer');
15132 if (drawer) 15149 if (drawer)
15133 drawer.toggle(); 15150 drawer.toggle();
15134 }, 15151 },
15135 15152
15136 /** 15153 /**
15137 * Listens for history-item being selected or deselected (through checkbox) 15154 * Listens for history-item being selected or deselected (through checkbox)
15138 * and changes the view of the top toolbar. 15155 * and changes the view of the top toolbar.
(...skipping 30 matching lines...) Expand all
15169 historyResult: function(info, results) { 15186 historyResult: function(info, results) {
15170 this.set('queryState_.querying', false); 15187 this.set('queryState_.querying', false);
15171 this.set('queryResult_.info', info); 15188 this.set('queryResult_.info', info);
15172 this.set('queryResult_.results', results); 15189 this.set('queryResult_.results', results);
15173 var listContainer = 15190 var listContainer =
15174 /** @type {HistoryListContainerElement} */ (this.$['history']); 15191 /** @type {HistoryListContainerElement} */ (this.$['history']);
15175 listContainer.historyResult(info, results); 15192 listContainer.historyResult(info, results);
15176 }, 15193 },
15177 15194
15178 /** 15195 /**
15196 * Focuses the search bar in the toolbar.
15197 */
15198 focusToolbarSearchField: function() {
15199 this.$.toolbar.showSearchField();
15200 },
15201
15202 /**
15179 * Fired when the user presses 'More from this site'. 15203 * Fired when the user presses 'More from this site'.
15180 * @param {{detail: {domain: string}}} e 15204 * @param {{detail: {domain: string}}} e
15181 */ 15205 */
15182 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, 15206 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); },
15183 15207
15184 /** 15208 /**
15185 * @param {Event} e 15209 * @param {Event} e
15186 * @private 15210 * @private
15187 */ 15211 */
15188 onCanExecute_: function(e) { 15212 onCanExecute_: function(e) {
(...skipping 27 matching lines...) Expand all
15216 searchQueryParamChanged_: function(searchQuery) { 15240 searchQueryParamChanged_: function(searchQuery) {
15217 this.$.toolbar.setSearchTerm(searchQuery || ''); 15241 this.$.toolbar.setSearchTerm(searchQuery || '');
15218 }, 15242 },
15219 15243
15220 /** 15244 /**
15221 * @param {Event} e 15245 * @param {Event} e
15222 * @private 15246 * @private
15223 */ 15247 */
15224 onCommand_: function(e) { 15248 onCommand_: function(e) {
15225 if (e.command.id == 'find-command' || e.command.id == 'slash-command') 15249 if (e.command.id == 'find-command' || e.command.id == 'slash-command')
15226 this.$.toolbar.showSearchField(); 15250 this.focusToolbarSearchField();
15227 if (e.command.id == 'delete-command') 15251 if (e.command.id == 'delete-command')
15228 this.deleteSelected(); 15252 this.deleteSelected();
15229 }, 15253 },
15230 15254
15231 /** 15255 /**
15232 * @param {!Array<!ForeignSession>} sessionList Array of objects describing 15256 * @param {!Array<!ForeignSession>} sessionList Array of objects describing
15233 * the sessions from other devices. 15257 * the sessions from other devices.
15234 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? 15258 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile?
15235 */ 15259 */
15236 setForeignSessions: function(sessionList, isTabSyncEnabled) { 15260 setForeignSessions: function(sessionList, isTabSyncEnabled) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
15309 return selectedPage; 15333 return selectedPage;
15310 }, 15334 },
15311 15335
15312 /** @private */ 15336 /** @private */
15313 closeDrawer_: function() { 15337 closeDrawer_: function() {
15314 var drawer = this.$$('#drawer'); 15338 var drawer = this.$$('#drawer');
15315 if (drawer) 15339 if (drawer)
15316 drawer.close(); 15340 drawer.close();
15317 }, 15341 },
15318 }); 15342 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698