| OLD | NEW |
| 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 cr.define('md_history', function() { | 5 cr.define('md_history', function() { |
| 6 var lazyLoadPromise = null; | 6 var lazyLoadPromise = null; |
| 7 function ensureLazyLoaded() { | 7 function ensureLazyLoaded() { |
| 8 if (!lazyLoadPromise) { | 8 if (!lazyLoadPromise) { |
| 9 lazyLoadPromise = new Promise(function(resolve, reject) { | 9 lazyLoadPromise = new Promise(function(resolve, reject) { |
| 10 Polymer.Base.importHref( | 10 Polymer.Base.importHref( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 onFirstRender: function() { | 108 onFirstRender: function() { |
| 109 setTimeout(function() { | 109 setTimeout(function() { |
| 110 chrome.send( | 110 chrome.send( |
| 111 'metricsHandler:recordTime', | 111 'metricsHandler:recordTime', |
| 112 ['History.ResultsRenderedTime', window.performance.now()]); | 112 ['History.ResultsRenderedTime', window.performance.now()]); |
| 113 }); | 113 }); |
| 114 | 114 |
| 115 // Focus the search field on load. Done here to ensure the history page | 115 // Focus the search field on load. Done here to ensure the history page |
| 116 // is rendered before we try to take focus. | 116 // is rendered before we try to take focus. |
| 117 if (!this.hasDrawer_) { | 117 var searchField = |
| 118 this.focusToolbarSearchField(); | 118 /** @type {HistoryToolbarElement} */ (this.$.toolbar).searchField; |
| 119 if (!searchField.narrow) { |
| 120 searchField.getSearchInput().focus(); |
| 119 } | 121 } |
| 120 | 122 |
| 121 // Lazily load the remainder of the UI. | 123 // Lazily load the remainder of the UI. |
| 122 md_history.ensureLazyLoaded(); | 124 md_history.ensureLazyLoaded(); |
| 123 }, | 125 }, |
| 124 | 126 |
| 125 /** Overridden from IronScrollTargetBehavior */ | 127 /** Overridden from IronScrollTargetBehavior */ |
| 126 _scrollHandler: function() { | 128 _scrollHandler: function() { |
| 127 if (this.scrollTarget) | 129 if (this.scrollTarget) |
| 128 this.toolbarShadow_ = this.scrollTarget.scrollTop != 0; | 130 this.toolbarShadow_ = this.scrollTarget.scrollTop != 0; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 historyResult: function(info, results) { | 171 historyResult: function(info, results) { |
| 170 this.set('queryState_.querying', false); | 172 this.set('queryState_.querying', false); |
| 171 this.set('queryResult_.info', info); | 173 this.set('queryResult_.info', info); |
| 172 this.set('queryResult_.results', results); | 174 this.set('queryResult_.results', results); |
| 173 var listContainer = | 175 var listContainer = |
| 174 /** @type {HistoryListContainerElement} */ (this.$['history']); | 176 /** @type {HistoryListContainerElement} */ (this.$['history']); |
| 175 listContainer.historyResult(info, results); | 177 listContainer.historyResult(info, results); |
| 176 }, | 178 }, |
| 177 | 179 |
| 178 /** | 180 /** |
| 179 * Focuses the search bar in the toolbar. | 181 * Shows and focuses the search bar in the toolbar. |
| 180 */ | 182 */ |
| 181 focusToolbarSearchField: function() { this.$.toolbar.showSearchField(); }, | 183 focusToolbarSearchField: function() { this.$.toolbar.showSearchField(); }, |
| 182 | 184 |
| 183 /** | 185 /** |
| 184 * @param {Event} e | 186 * @param {Event} e |
| 185 * @private | 187 * @private |
| 186 */ | 188 */ |
| 187 onCanExecute_: function(e) { | 189 onCanExecute_: function(e) { |
| 188 e = /** @type {cr.ui.CanExecuteEvent} */(e); | 190 e = /** @type {cr.ui.CanExecuteEvent} */(e); |
| 189 switch (e.command.id) { | 191 switch (e.command.id) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 break; | 341 break; |
| 340 } | 342 } |
| 341 break; | 343 break; |
| 342 } | 344 } |
| 343 | 345 |
| 344 md_history.BrowserService.getInstance().recordHistogram( | 346 md_history.BrowserService.getInstance().recordHistogram( |
| 345 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END | 347 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END |
| 346 ); | 348 ); |
| 347 }, | 349 }, |
| 348 }); | 350 }); |
| OLD | NEW |