| 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. | |
| 10 selectedPage_: { | |
| 11 type: String, | |
| 12 computed: 'computeSelectedPage_(queryState.range)', | |
| 13 }, | |
| 14 | |
| 15 // Whether domain-grouped history is enabled. | |
| 16 grouped: Boolean, | |
| 17 | |
| 18 /** @type {!QueryState} */ | 9 /** @type {!QueryState} */ |
| 19 queryState: Object, | 10 queryState: Object, |
| 20 | 11 |
| 21 /** @type {!QueryResult} */ | 12 /** @type {!QueryResult} */ |
| 22 queryResult: Object, | 13 queryResult: Object, |
| 23 | 14 |
| 24 /** | 15 /** |
| 25 * @private {?{ | 16 * @private {?{ |
| 26 * index: number, | 17 * index: number, |
| 27 * item: !HistoryEntry, | 18 * item: !HistoryEntry, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 | 38 |
| 48 if (info.term && !this.queryState.incremental) { | 39 if (info.term && !this.queryState.incremental) { |
| 49 Polymer.IronA11yAnnouncer.requestAvailability(); | 40 Polymer.IronA11yAnnouncer.requestAvailability(); |
| 50 this.fire('iron-announce', { | 41 this.fire('iron-announce', { |
| 51 text: | 42 text: |
| 52 md_history.HistoryItem.searchResultsTitle(results.length, info.term) | 43 md_history.HistoryItem.searchResultsTitle(results.length, info.term) |
| 53 }); | 44 }); |
| 54 } | 45 } |
| 55 | 46 |
| 56 var list = /** @type {HistoryListBehavior} */ this.getSelectedList_(); | 47 var list = /** @type {HistoryListBehavior} */ this.getSelectedList_(); |
| 57 // It is possible for results to arrive for the grouped list before the lazy | 48 list.addNewResults(results, this.queryState.incremental, info.finished); |
| 58 // load has finished and the <history-grouped-list> element exists. In this | |
| 59 // case, add the items to a property on the unresolved element which can be | |
| 60 // read when it upgrades and is attached. | |
| 61 if (Polymer.isInstance(list)) | |
| 62 list.addNewResults(results, this.queryState.incremental, info.finished); | |
| 63 else | |
| 64 list.initialData = results; | |
| 65 }, | 49 }, |
| 66 | 50 |
| 67 historyDeleted: function() { | 51 historyDeleted: function() { |
| 68 // Do not reload the list when there are items checked. | 52 // Do not reload the list when there are items checked. |
| 69 if (this.getSelectedItemCount() > 0) | 53 if (this.getSelectedItemCount() > 0) |
| 70 return; | 54 return; |
| 71 | 55 |
| 72 // Reload the list with current search state. | 56 // Reload the list with current search state. |
| 73 this.fire('query-history', false); | 57 this.fire('query-history', false); |
| 74 }, | 58 }, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 101 browserService.recordAction('RemoveSelected'); | 85 browserService.recordAction('RemoveSelected'); |
| 102 if (this.queryState.searchTerm != '') | 86 if (this.queryState.searchTerm != '') |
| 103 browserService.recordAction('SearchResultRemove'); | 87 browserService.recordAction('SearchResultRemove'); |
| 104 this.$.dialog.get().showModal(); | 88 this.$.dialog.get().showModal(); |
| 105 | 89 |
| 106 // TODO(dbeam): remove focus flicker caused by showModal() + focus(). | 90 // TODO(dbeam): remove focus flicker caused by showModal() + focus(). |
| 107 this.$$('.action-button').focus(); | 91 this.$$('.action-button').focus(); |
| 108 }, | 92 }, |
| 109 | 93 |
| 110 /** | 94 /** |
| 111 * @param {HistoryRange} range | |
| 112 * @return {string} | |
| 113 * @private | |
| 114 */ | |
| 115 computeSelectedPage_: function(range) { | |
| 116 return range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list'; | |
| 117 }, | |
| 118 | |
| 119 /** | |
| 120 * @param {HistoryQuery} info | 95 * @param {HistoryQuery} info |
| 121 * @param {!Array<HistoryEntry>} results | 96 * @param {!Array<HistoryEntry>} results |
| 122 * @private | 97 * @private |
| 123 */ | 98 */ |
| 124 initializeResults_: function(info, results) { | 99 initializeResults_: function(info, results) { |
| 125 if (results.length == 0) | 100 if (results.length == 0) |
| 126 return; | 101 return; |
| 127 | 102 |
| 128 var currentDate = results[0].dateRelativeDay; | 103 var currentDate = results[0].dateRelativeDay; |
| 129 | 104 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 201 } |
| 227 }.bind(this)); | 202 }.bind(this)); |
| 228 this.closeMenu_(); | 203 this.closeMenu_(); |
| 229 }, | 204 }, |
| 230 | 205 |
| 231 /** | 206 /** |
| 232 * @return {Element} | 207 * @return {Element} |
| 233 * @private | 208 * @private |
| 234 */ | 209 */ |
| 235 getSelectedList_: function() { | 210 getSelectedList_: function() { |
| 236 return this.$$('#' + this.selectedPage_); | 211 return this.$['infinite-list']; |
| 237 }, | 212 }, |
| 238 | 213 |
| 239 /** @private */ | 214 /** @private */ |
| 240 canDeleteHistory_: function() { | 215 canDeleteHistory_: function() { |
| 241 return loadTimeData.getBoolean('allowDeletingHistory'); | 216 return loadTimeData.getBoolean('allowDeletingHistory'); |
| 242 } | 217 } |
| 243 }); | 218 }); |
| OLD | NEW |