| 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 /** @private */ |
| 145 loadMoreHistory_: function() { this.queryHistory(true); }, | 157 loadMoreHistory_: function() { this.queryHistory(true); }, |
| 146 | 158 |
| 147 /** | 159 /** |
| 148 * @param {HistoryQuery} info | 160 * @param {HistoryQuery} info |
| 149 * @param {!Array<HistoryEntry>} results | 161 * @param {!Array<HistoryEntry>} results |
| 150 * @private | 162 * @private |
| 151 */ | 163 */ |
| 152 initializeResults_: function(info, results) { | 164 initializeResults_: function(info, results) { |
| 153 if (results.length == 0) | 165 if (results.length == 0) |
| 154 return; | 166 return; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 var menu = /** @type {CrSharedMenuElement} */this.$.sharedMenu.get(); | 219 var menu = /** @type {CrSharedMenuElement} */this.$.sharedMenu.get(); |
| 208 menu.toggleMenu(target, e.detail); | 220 menu.toggleMenu(target, e.detail); |
| 209 }, | 221 }, |
| 210 | 222 |
| 211 /** @private */ | 223 /** @private */ |
| 212 onMoreFromSiteTap_: function() { | 224 onMoreFromSiteTap_: function() { |
| 213 md_history.BrowserService.getInstance().recordAction( | 225 md_history.BrowserService.getInstance().recordAction( |
| 214 'EntryMenuShowMoreFromSite'); | 226 'EntryMenuShowMoreFromSite'); |
| 215 | 227 |
| 216 var menu = assert(this.$.sharedMenu.getIfExists()); | 228 var menu = assert(this.$.sharedMenu.getIfExists()); |
| 217 this.fire('search-domain', {domain: menu.itemData.item.domain}); | 229 this.set('queryState.searchTerm', menu.itemData.item.domain); |
| 218 menu.closeMenu(); | 230 menu.closeMenu(); |
| 219 }, | 231 }, |
| 220 | 232 |
| 221 /** @private */ | 233 /** @private */ |
| 222 onRemoveFromHistoryTap_: function() { | 234 onRemoveFromHistoryTap_: function() { |
| 223 var browserService = md_history.BrowserService.getInstance(); | 235 var browserService = md_history.BrowserService.getInstance(); |
| 224 browserService.recordAction('EntryMenuRemoveFromHistory'); | 236 browserService.recordAction('EntryMenuRemoveFromHistory'); |
| 225 var menu = assert(this.$.sharedMenu.getIfExists()); | 237 var menu = assert(this.$.sharedMenu.getIfExists()); |
| 226 var itemData = menu.itemData; | 238 var itemData = menu.itemData; |
| 227 browserService.deleteItems([itemData.item]) | 239 browserService.deleteItems([itemData.item]) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 248 }.bind(this)); | 260 }.bind(this)); |
| 249 menu.closeMenu(); | 261 menu.closeMenu(); |
| 250 }, | 262 }, |
| 251 | 263 |
| 252 /** | 264 /** |
| 253 * @return {HTMLElement} | 265 * @return {HTMLElement} |
| 254 * @private | 266 * @private |
| 255 */ | 267 */ |
| 256 getSelectedList_: function() { return this.$.content.selectedItem; }, | 268 getSelectedList_: function() { return this.$.content.selectedItem; }, |
| 257 }); | 269 }); |
| OLD | NEW |