Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @typedef {{querying: boolean, | 6 * @typedef {{querying: boolean, |
| 7 * searchTerm: string, | 7 * searchTerm: string, |
| 8 * results: ?Array<!HistoryEntry>, | 8 * results: ?Array<!HistoryEntry>, |
| 9 * info: ?HistoryQuery, | 9 * info: ?HistoryQuery, |
| 10 * range: HistoryRange, | 10 * range: HistoryRange, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 // TODO(calamity): Split out readOnly data into a separate property which is | 33 // TODO(calamity): Split out readOnly data into a separate property which is |
| 34 // only set on result return. | 34 // only set on result return. |
| 35 queryState_: { | 35 queryState_: { |
| 36 type: Object, | 36 type: Object, |
| 37 value: function() { | 37 value: function() { |
| 38 return { | 38 return { |
| 39 // A query is initiated by page load. | 39 // A query is initiated by page load. |
| 40 querying: true, | 40 querying: true, |
| 41 searchTerm: '', | 41 searchTerm: '', |
| 42 results: null, | 42 results: null, |
| 43 // Whether the most recent query was incremental. | |
| 44 incremental: false, | |
|
dpapad
2016/06/08 00:07:35
Shouldn't the QueryState typedef also be upadated?
tsergeant
2016/06/08 02:53:54
Done.
| |
| 43 info: null, | 45 info: null, |
| 44 range: HistoryRange.ALL_TIME, | 46 range: HistoryRange.ALL_TIME, |
| 45 // TODO(calamity): Make history toolbar buttons change the offset. | 47 // TODO(calamity): Make history toolbar buttons change the offset. |
| 46 groupedOffset: 0, | 48 groupedOffset: 0, |
| 47 sessionList: null, | 49 sessionList: null, |
| 48 }; | 50 }; |
| 49 } | 51 } |
| 50 }, | 52 }, |
| 51 }, | 53 }, |
| 52 | 54 |
| 53 observers: [ | 55 observers: [ |
| 54 'searchTermChanged_(queryState_.searchTerm)', | 56 'searchTermChanged_(queryState_.searchTerm)', |
| 55 'groupedRangeChanged_(queryState_.range)', | 57 'groupedRangeChanged_(queryState_.range)', |
| 56 ], | 58 ], |
| 57 | 59 |
| 58 // TODO(calamity): Replace these event listeners with data bound properties. | 60 // TODO(calamity): Replace these event listeners with data bound properties. |
| 59 listeners: { | 61 listeners: { |
| 60 'history-checkbox-select': 'checkboxSelected', | 62 'history-checkbox-select': 'checkboxSelected', |
| 61 'unselect-all': 'unselectAll', | 63 'unselect-all': 'unselectAll', |
| 62 'delete-selected': 'deleteSelected', | 64 'delete-selected': 'deleteSelected', |
| 63 'search-domain': 'searchDomain_', | 65 'search-domain': 'searchDomain_', |
| 64 'load-more-history': 'loadMoreHistory_', | 66 'load-more-history': 'loadMoreHistory_', |
| 65 }, | 67 }, |
| 66 | 68 |
| 67 ready: function() { | 69 ready: function() { |
|
dpapad
2016/06/08 00:07:35
Nit:
/** @override */
tsergeant
2016/06/08 02:53:54
Done.
| |
| 68 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 70 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 69 }, | 71 }, |
| 70 | 72 |
| 71 /** | 73 /** |
| 72 * Listens for history-item being selected or deselected (through checkbox) | 74 * Listens for history-item being selected or deselected (through checkbox) |
| 73 * and changes the view of the top toolbar. | 75 * and changes the view of the top toolbar. |
| 74 * @param {{detail: {countAddition: number}}} e | 76 * @param {{detail: {countAddition: number}}} e |
| 75 */ | 77 */ |
| 76 checkboxSelected: function(e) { | 78 checkboxSelected: function(e) { |
| 77 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); | 79 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 /** | 170 /** |
| 169 * Queries the history backend for results based on queryState_. | 171 * Queries the history backend for results based on queryState_. |
| 170 * @param {boolean} incremental Whether the new query should continue where | 172 * @param {boolean} incremental Whether the new query should continue where |
| 171 * the previous query stopped. | 173 * the previous query stopped. |
| 172 */ | 174 */ |
| 173 queryHistory: function(incremental) { | 175 queryHistory: function(incremental) { |
| 174 if (this.queryingDisabled_ || this.firstLoad_) | 176 if (this.queryingDisabled_ || this.firstLoad_) |
| 175 return; | 177 return; |
| 176 | 178 |
| 177 this.set('queryState_.querying', true); | 179 this.set('queryState_.querying', true); |
| 180 this.set('queryState_.incremental', incremental); | |
| 178 | 181 |
| 179 var queryState = this.queryState_; | 182 var queryState = this.queryState_; |
| 180 | 183 |
| 181 var lastVisitTime = 0; | 184 var lastVisitTime = 0; |
| 182 if (incremental) { | 185 if (incremental) { |
| 183 var lastVisit = queryState.results.slice(-1)[0]; | 186 var lastVisit = queryState.results.slice(-1)[0]; |
| 184 lastVisitTime = lastVisit ? lastVisit.time : 0; | 187 lastVisitTime = lastVisit ? lastVisit.time : 0; |
| 185 } | 188 } |
| 186 | 189 |
| 187 var maxResults = | 190 var maxResults = |
| 188 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; | 191 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; |
| 189 chrome.send('queryHistory', [ | 192 chrome.send('queryHistory', [ |
| 190 queryState.searchTerm, queryState.groupedOffset, Number(queryState.range), | 193 queryState.searchTerm, queryState.groupedOffset, Number(queryState.range), |
| 191 lastVisitTime, maxResults | 194 lastVisitTime, maxResults |
| 192 ]); | 195 ]); |
| 193 }, | 196 }, |
| 194 | 197 |
| 195 /** | 198 /** |
| 196 * @param {!Array<!ForeignSession>} sessionList Array of objects describing | 199 * @param {!Array<!ForeignSession>} sessionList Array of objects describing |
| 197 * the sessions from other devices. | 200 * the sessions from other devices. |
| 198 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? | 201 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? |
| 199 */ | 202 */ |
| 200 setForeignSessions: function(sessionList, isTabSyncEnabled) { | 203 setForeignSessions: function(sessionList, isTabSyncEnabled) { |
| 201 if (!isTabSyncEnabled) | 204 if (!isTabSyncEnabled) |
| 202 return; | 205 return; |
| 203 | 206 |
| 204 this.set('queryState_.sessionList', sessionList); | 207 this.set('queryState_.sessionList', sessionList); |
| 205 }, | 208 }, |
| 206 | 209 |
| 207 getSelectedPage: function(selectedPage, range) { | 210 getSelectedPage: function(selectedPage, range) { |
|
dpapad
2016/06/08 00:07:35
@param, @return missing
tsergeant
2016/06/08 02:53:54
Done.
| |
| 208 if (selectedPage == 'history-list' && range != HistoryRange.ALL_TIME) | 211 if (selectedPage == 'history-list' && range != HistoryRange.ALL_TIME) |
| 209 return 'history-grouped-list'; | 212 return 'history-grouped-list'; |
| 210 | 213 |
| 211 return selectedPage; | 214 return selectedPage; |
| 212 }, | 215 }, |
| 213 | 216 |
| 214 syncedTabsSelected_(selectedPage) { | 217 syncedTabsSelected_: function(selectedPage) { |
|
dpapad
2016/06/08 00:07:35
Same here.
tsergeant
2016/06/08 02:53:54
Done.
| |
| 215 return selectedPage == 'history-synced-device-manager'; | 218 return selectedPage == 'history-synced-device-manager'; |
| 219 }, | |
| 220 | |
| 221 /** | |
| 222 * True if the toolbar should show a loading spinner. True when the backend is | |
| 223 * querying a new search term. | |
| 224 * @param {boolean} querying | |
| 225 * @param {boolean} incremental | |
| 226 * @param {string} searchTerm | |
| 227 * @return {boolean} | |
|
dpapad
2016/06/08 00:07:36
Nit: Move the comment at lines 222-223 here, as fo
tsergeant
2016/06/08 02:53:54
Done.
| |
| 228 * @private | |
| 229 */ | |
| 230 shouldShowSpinner_: function(querying, incremental, searchTerm) { | |
| 231 return querying && !incremental && searchTerm != ''; | |
| 216 } | 232 } |
| 217 }); | 233 }); |
| OLD | NEW |