| 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 {!QueryState} */ | 15 /** @type {!QueryState} */ |
| 16 queryState: Object, | 16 queryState: Object, |
| 17 | 17 |
| 18 /** @type {!QueryResult} */ | 18 /** @type {!QueryResult} */ |
| 19 queryResult: Object, | 19 queryResult: Object, |
| 20 }, | 20 }, |
| 21 | 21 |
| 22 observers: [ | 22 observers: [ |
| 23 'searchTermChanged_(queryState.searchTerm)', | |
| 24 'groupedRangeChanged_(queryState.range)', | 23 'groupedRangeChanged_(queryState.range)', |
| 25 ], | 24 ], |
| 26 | 25 |
| 27 listeners: { | 26 listeners: { |
| 28 'load-more-history': 'loadMoreHistory_', | 27 'load-more-history': 'loadMoreHistory_', |
| 29 }, | 28 }, |
| 30 | 29 |
| 31 /** | 30 /** |
| 32 * @param {HistoryQuery} info An object containing information about the | 31 * @param {HistoryQuery} info An object containing information about the |
| 33 * query. | 32 * query. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 47 list.disableResultLoading(); | 46 list.disableResultLoading(); |
| 48 }, | 47 }, |
| 49 | 48 |
| 50 /** | 49 /** |
| 51 * Queries the history backend for results based on queryState. | 50 * Queries the history backend for results based on queryState. |
| 52 * @param {boolean} incremental Whether the new query should continue where | 51 * @param {boolean} incremental Whether the new query should continue where |
| 53 * the previous query stopped. | 52 * the previous query stopped. |
| 54 */ | 53 */ |
| 55 queryHistory: function(incremental) { | 54 queryHistory: function(incremental) { |
| 56 var queryState = this.queryState; | 55 var queryState = this.queryState; |
| 57 // Disable querying until the first set of results have been returned. | 56 // Disable querying until the first set of results have been returned. If |
| 58 if (!this.queryResult || this.queryResult.results == null || | 57 // there is a search, query immediately to support search query params from |
| 59 queryState.queryingDisabled) { | 58 // the URL. |
| 59 var noResults = !this.queryResult || this.queryResult.results == null; |
| 60 if (queryState.queryingDisabled || |
| 61 (!this.queryState.searchTerm && noResults)) { |
| 60 return; | 62 return; |
| 61 } | 63 } |
| 62 | 64 |
| 63 this.set('queryState.querying', true); | 65 this.set('queryState.querying', true); |
| 64 this.set('queryState.incremental', incremental); | 66 this.set('queryState.incremental', incremental); |
| 65 | 67 |
| 66 | 68 |
| 67 var lastVisitTime = 0; | 69 var lastVisitTime = 0; |
| 68 if (incremental) { | 70 if (incremental) { |
| 69 var lastVisit = this.queryResult.results.slice(-1)[0]; | 71 var lastVisit = this.queryResult.results.slice(-1)[0]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 * a dialog to confirm that the deletion should be performed. | 90 * a dialog to confirm that the deletion should be performed. |
| 89 */ | 91 */ |
| 90 deleteSelectedWithPrompt: function() { | 92 deleteSelectedWithPrompt: function() { |
| 91 if (!loadTimeData.getBoolean('allowDeletingHistory')) | 93 if (!loadTimeData.getBoolean('allowDeletingHistory')) |
| 92 return; | 94 return; |
| 93 | 95 |
| 94 this.$.dialog.open(); | 96 this.$.dialog.open(); |
| 95 }, | 97 }, |
| 96 | 98 |
| 97 /** | 99 /** |
| 98 * @param {string} searchTerm | |
| 99 * @private | |
| 100 */ | |
| 101 searchTermChanged_: function(searchTerm) { this.queryHistory(false); }, | |
| 102 | |
| 103 /** | |
| 104 * @param {HistoryRange} range | 100 * @param {HistoryRange} range |
| 105 * @private | 101 * @private |
| 106 */ | 102 */ |
| 107 groupedRangeChanged_: function(range) { | 103 groupedRangeChanged_: function(range) { |
| 108 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? | 104 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? |
| 109 'infinite-list' : 'grouped-list'; | 105 'infinite-list' : 'grouped-list'; |
| 110 | 106 |
| 111 this.queryHistory(false); | 107 this.queryHistory(false); |
| 112 }, | 108 }, |
| 113 | 109 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 142 onDialogConfirmTap_: function() { | 138 onDialogConfirmTap_: function() { |
| 143 this.$['infinite-list'].deleteSelected(); | 139 this.$['infinite-list'].deleteSelected(); |
| 144 this.$.dialog.close(); | 140 this.$.dialog.close(); |
| 145 }, | 141 }, |
| 146 | 142 |
| 147 /** @private */ | 143 /** @private */ |
| 148 onDialogCancelTap_: function() { | 144 onDialogCancelTap_: function() { |
| 149 this.$.dialog.close(); | 145 this.$.dialog.close(); |
| 150 } | 146 } |
| 151 }); | 147 }); |
| OLD | NEW |