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 Polymer({ | 5 Polymer({ |
6 is: 'history-list-container', | 6 is: 'history-list-container', |
7 | 7 |
8 properties: { | 8 properties: { |
9 // The path of the currently selected page. | 9 // The path of the currently selected page. |
10 selectedPage_: String, | 10 selectedPage_: String, |
11 | 11 |
12 // Whether domain-grouped history is enabled. | 12 // Whether domain-grouped history is enabled. |
13 grouped: Boolean, | 13 grouped: Boolean, |
14 | 14 |
15 /** @type {HistoryRange} */ | 15 /** @type {HistoryRange} */ |
16 groupedRange: {type: Number, observer: 'groupedRangeChanged_'}, | 16 groupedRange: {type: Number, observer: 'groupedRangeChanged_'}, |
17 | 17 |
18 /** @type {!QueryState} */ | 18 /** @type {!QueryState} */ |
19 queryState: Object, | 19 queryState: Object, |
20 | 20 |
21 /** @type {!QueryResult} */ | 21 /** @type {!QueryResult} */ |
22 queryResult: Object, | 22 queryResult: Object, |
23 }, | 23 }, |
24 | 24 |
| 25 observers: [ |
| 26 'searchTermChanged_(queryState.searchTerm)', |
| 27 ], |
| 28 |
25 listeners: { | 29 listeners: { |
26 'history-list-scrolled': 'closeMenu_', | 30 'history-list-scrolled': 'closeMenu_', |
27 'load-more-history': 'loadMoreHistory_', | 31 'load-more-history': 'loadMoreHistory_', |
28 'toggle-menu': 'toggleMenu_', | 32 'toggle-menu': 'toggleMenu_', |
29 }, | 33 }, |
30 | 34 |
31 /** | 35 /** |
32 * @param {HistoryQuery} info An object containing information about the | 36 * @param {HistoryQuery} info An object containing information about the |
33 * query. | 37 * query. |
34 * @param {!Array<HistoryEntry>} results A list of results. | 38 * @param {!Array<HistoryEntry>} results A list of results. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 'infinite-list' : 'grouped-list'; | 139 'infinite-list' : 'grouped-list'; |
136 | 140 |
137 if (oldRange == undefined) | 141 if (oldRange == undefined) |
138 return; | 142 return; |
139 | 143 |
140 this.queryHistory(false); | 144 this.queryHistory(false); |
141 this.fire('history-view-changed'); | 145 this.fire('history-view-changed'); |
142 }, | 146 }, |
143 | 147 |
144 /** @private */ | 148 /** @private */ |
| 149 searchTermChanged_: function() { |
| 150 this.queryHistory(false); |
| 151 // TODO(tsergeant): Ignore incremental searches in this metric. |
| 152 if (this.queryState.searchTerm) |
| 153 md_history.BrowserService.getInstance().recordAction('Search'); |
| 154 }, |
| 155 |
| 156 |
| 157 /** @private */ |
145 loadMoreHistory_: function() { this.queryHistory(true); }, | 158 loadMoreHistory_: function() { this.queryHistory(true); }, |
146 | 159 |
147 /** | 160 /** |
148 * @param {HistoryQuery} info | 161 * @param {HistoryQuery} info |
149 * @param {!Array<HistoryEntry>} results | 162 * @param {!Array<HistoryEntry>} results |
150 * @private | 163 * @private |
151 */ | 164 */ |
152 initializeResults_: function(info, results) { | 165 initializeResults_: function(info, results) { |
153 if (results.length == 0) | 166 if (results.length == 0) |
154 return; | 167 return; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 var menu = /** @type {CrSharedMenuElement} */this.$.sharedMenu.get(); | 220 var menu = /** @type {CrSharedMenuElement} */this.$.sharedMenu.get(); |
208 menu.toggleMenu(target, e.detail); | 221 menu.toggleMenu(target, e.detail); |
209 }, | 222 }, |
210 | 223 |
211 /** @private */ | 224 /** @private */ |
212 onMoreFromSiteTap_: function() { | 225 onMoreFromSiteTap_: function() { |
213 md_history.BrowserService.getInstance().recordAction( | 226 md_history.BrowserService.getInstance().recordAction( |
214 'EntryMenuShowMoreFromSite'); | 227 'EntryMenuShowMoreFromSite'); |
215 | 228 |
216 var menu = assert(this.$.sharedMenu.getIfExists()); | 229 var menu = assert(this.$.sharedMenu.getIfExists()); |
217 this.fire('search-domain', {domain: menu.itemData.item.domain}); | 230 this.set('queryState.searchTerm', menu.itemData.item.domain); |
218 menu.closeMenu(); | 231 menu.closeMenu(); |
219 }, | 232 }, |
220 | 233 |
221 /** @private */ | 234 /** @private */ |
222 onRemoveFromHistoryTap_: function() { | 235 onRemoveFromHistoryTap_: function() { |
223 var browserService = md_history.BrowserService.getInstance(); | 236 var browserService = md_history.BrowserService.getInstance(); |
224 browserService.recordAction('EntryMenuRemoveFromHistory'); | 237 browserService.recordAction('EntryMenuRemoveFromHistory'); |
225 var menu = assert(this.$.sharedMenu.getIfExists()); | 238 var menu = assert(this.$.sharedMenu.getIfExists()); |
226 var itemData = menu.itemData; | 239 var itemData = menu.itemData; |
227 browserService.deleteItems([itemData.item]) | 240 browserService.deleteItems([itemData.item]) |
(...skipping 20 matching lines...) Expand all Loading... |
248 }.bind(this)); | 261 }.bind(this)); |
249 menu.closeMenu(); | 262 menu.closeMenu(); |
250 }, | 263 }, |
251 | 264 |
252 /** | 265 /** |
253 * @return {HTMLElement} | 266 * @return {HTMLElement} |
254 * @private | 267 * @private |
255 */ | 268 */ |
256 getSelectedList_: function() { return this.$.content.selectedItem; }, | 269 getSelectedList_: function() { return this.$.content.selectedItem; }, |
257 }); | 270 }); |
OLD | NEW |