| 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 * @fileoverview PromiseResolver is a helper class that allows creating a | 6 * @fileoverview PromiseResolver is a helper class that allows creating a |
| 7 * Promise that will be fulfilled (resolved or rejected) some time later. | 7 * Promise that will be fulfilled (resolved or rejected) some time later. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * var resolver = new PromiseResolver(); | 10 * var resolver = new PromiseResolver(); |
| (...skipping 14062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14073 | 14073 |
| 14074 behaviors: [HistoryListBehavior], | 14074 behaviors: [HistoryListBehavior], |
| 14075 | 14075 |
| 14076 properties: { | 14076 properties: { |
| 14077 // The search term for the current query. Set when the query returns. | 14077 // The search term for the current query. Set when the query returns. |
| 14078 searchedTerm: { | 14078 searchedTerm: { |
| 14079 type: String, | 14079 type: String, |
| 14080 value: '', | 14080 value: '', |
| 14081 }, | 14081 }, |
| 14082 | 14082 |
| 14083 lastSearchedTerm_: String, | |
| 14084 | |
| 14085 querying: Boolean, | 14083 querying: Boolean, |
| 14086 | 14084 |
| 14087 // An array of history entries in reverse chronological order. | 14085 // An array of history entries in reverse chronological order. |
| 14088 historyData_: Array, | 14086 historyData_: Array, |
| 14089 | 14087 |
| 14090 resultLoadingDisabled_: { | 14088 resultLoadingDisabled_: { |
| 14091 type: Boolean, | 14089 type: Boolean, |
| 14092 value: false, | 14090 value: false, |
| 14093 }, | 14091 }, |
| 14094 }, | 14092 }, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14129 * Disables history result loading when there are no more history results. | 14127 * Disables history result loading when there are no more history results. |
| 14130 */ | 14128 */ |
| 14131 disableResultLoading: function() { | 14129 disableResultLoading: function() { |
| 14132 this.resultLoadingDisabled_ = true; | 14130 this.resultLoadingDisabled_ = true; |
| 14133 }, | 14131 }, |
| 14134 | 14132 |
| 14135 /** | 14133 /** |
| 14136 * Adds the newly updated history results into historyData_. Adds new fields | 14134 * Adds the newly updated history results into historyData_. Adds new fields |
| 14137 * for each result. | 14135 * for each result. |
| 14138 * @param {!Array<!HistoryEntry>} historyResults The new history results. | 14136 * @param {!Array<!HistoryEntry>} historyResults The new history results. |
| 14137 * @param {boolean} incremental Whether the result is from loading more |
| 14138 * history, or a new search/list reload. |
| 14139 */ | 14139 */ |
| 14140 addNewResults: function(historyResults) { | 14140 addNewResults: function(historyResults, incremental) { |
| 14141 var results = historyResults.slice(); | 14141 var results = historyResults.slice(); |
| 14142 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold']) | 14142 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold']) |
| 14143 .clearTriggers(); | 14143 .clearTriggers(); |
| 14144 | 14144 |
| 14145 if (this.lastSearchedTerm_ != this.searchedTerm) { | 14145 if (!incremental) { |
| 14146 this.resultLoadingDisabled_ = false; | 14146 this.resultLoadingDisabled_ = false; |
| 14147 if (this.historyData_) | 14147 if (this.historyData_) |
| 14148 this.splice('historyData_', 0, this.historyData_.length); | 14148 this.splice('historyData_', 0, this.historyData_.length); |
| 14149 this.fire('unselect-all'); | 14149 this.fire('unselect-all'); |
| 14150 this.lastSearchedTerm_ = this.searchedTerm; | |
| 14151 } | 14150 } |
| 14152 | 14151 |
| 14153 if (this.historyData_) { | 14152 if (this.historyData_) { |
| 14154 // If we have previously received data, push the new items onto the | 14153 // If we have previously received data, push the new items onto the |
| 14155 // existing array. | 14154 // existing array. |
| 14156 results.unshift('historyData_'); | 14155 results.unshift('historyData_'); |
| 14157 this.push.apply(this, results); | 14156 this.push.apply(this, results); |
| 14158 } else { | 14157 } else { |
| 14159 // The first time we receive data, use set() to ensure the iron-list is | 14158 // The first time we receive data, use set() to ensure the iron-list is |
| 14160 // initialized correctly. | 14159 // initialized correctly. |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14378 historyResult: function(info, results) { | 14377 historyResult: function(info, results) { |
| 14379 this.initializeResults_(info, results); | 14378 this.initializeResults_(info, results); |
| 14380 this.closeMenu_(); | 14379 this.closeMenu_(); |
| 14381 | 14380 |
| 14382 if (this.selectedPage_ == 'grouped-list') { | 14381 if (this.selectedPage_ == 'grouped-list') { |
| 14383 this.$$('#grouped-list').historyData = results; | 14382 this.$$('#grouped-list').historyData = results; |
| 14384 return; | 14383 return; |
| 14385 } | 14384 } |
| 14386 | 14385 |
| 14387 var list = /** @type {HistoryListElement} */(this.$['infinite-list']); | 14386 var list = /** @type {HistoryListElement} */(this.$['infinite-list']); |
| 14388 list.addNewResults(results); | 14387 list.addNewResults(results, this.queryState.incremental); |
| 14389 if (info.finished) | 14388 if (info.finished) |
| 14390 list.disableResultLoading(); | 14389 list.disableResultLoading(); |
| 14391 }, | 14390 }, |
| 14392 | 14391 |
| 14393 /** | 14392 /** |
| 14394 * Queries the history backend for results based on queryState. | 14393 * Queries the history backend for results based on queryState. |
| 14395 * @param {boolean} incremental Whether the new query should continue where | 14394 * @param {boolean} incremental Whether the new query should continue where |
| 14396 * the previous query stopped. | 14395 * the previous query stopped. |
| 14397 */ | 14396 */ |
| 14398 queryHistory: function(incremental) { | 14397 queryHistory: function(incremental) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 14421 } | 14420 } |
| 14422 | 14421 |
| 14423 var maxResults = | 14422 var maxResults = |
| 14424 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; | 14423 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; |
| 14425 chrome.send('queryHistory', [ | 14424 chrome.send('queryHistory', [ |
| 14426 queryState.searchTerm, queryState.groupedOffset, queryState.range, | 14425 queryState.searchTerm, queryState.groupedOffset, queryState.range, |
| 14427 lastVisitTime, maxResults | 14426 lastVisitTime, maxResults |
| 14428 ]); | 14427 ]); |
| 14429 }, | 14428 }, |
| 14430 | 14429 |
| 14430 historyDeleted: function() { |
| 14431 // Do not reload the list when there are items checked. |
| 14432 if (this.getSelectedItemCount() > 0) |
| 14433 return; |
| 14434 |
| 14435 // Reload the list with current search state. |
| 14436 this.queryHistory(false); |
| 14437 }, |
| 14438 |
| 14431 /** @return {number} */ | 14439 /** @return {number} */ |
| 14432 getSelectedItemCount: function() { | 14440 getSelectedItemCount: function() { |
| 14433 return this.getSelectedList_().selectedPaths.size; | 14441 return this.getSelectedList_().selectedPaths.size; |
| 14434 }, | 14442 }, |
| 14435 | 14443 |
| 14436 unselectAllItems: function(count) { | 14444 unselectAllItems: function(count) { |
| 14437 this.getSelectedList_().unselectAllItems(count); | 14445 this.getSelectedList_().unselectAllItems(count); |
| 14438 }, | 14446 }, |
| 14439 | 14447 |
| 14440 /** | 14448 /** |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15240 .$$('history-synced-device-manager'); | 15248 .$$('history-synced-device-manager'); |
| 15241 if (syncedDeviceManagerElem) | 15249 if (syncedDeviceManagerElem) |
| 15242 syncedDeviceManagerElem.tabSyncDisabled(); | 15250 syncedDeviceManagerElem.tabSyncDisabled(); |
| 15243 return; | 15251 return; |
| 15244 } | 15252 } |
| 15245 | 15253 |
| 15246 this.set('queryResult_.sessionList', sessionList); | 15254 this.set('queryResult_.sessionList', sessionList); |
| 15247 }, | 15255 }, |
| 15248 | 15256 |
| 15249 /** | 15257 /** |
| 15258 * Called when browsing data is cleared. |
| 15259 */ |
| 15260 historyDeleted: function() { |
| 15261 this.$.history.historyDeleted(); |
| 15262 }, |
| 15263 |
| 15264 /** |
| 15250 * Update sign in state of synced device manager after user logs in or out. | 15265 * Update sign in state of synced device manager after user logs in or out. |
| 15251 * @param {boolean} isUserSignedIn | 15266 * @param {boolean} isUserSignedIn |
| 15252 */ | 15267 */ |
| 15253 updateSignInState: function(isUserSignedIn) { | 15268 updateSignInState: function(isUserSignedIn) { |
| 15254 var syncedDeviceManagerElem = | 15269 var syncedDeviceManagerElem = |
| 15255 /** @type {HistorySyncedDeviceManagerElement} */this | 15270 /** @type {HistorySyncedDeviceManagerElement} */this |
| 15256 .$$('history-synced-device-manager'); | 15271 .$$('history-synced-device-manager'); |
| 15257 if (syncedDeviceManagerElem) | 15272 if (syncedDeviceManagerElem) |
| 15258 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); | 15273 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); |
| 15259 }, | 15274 }, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15309 return selectedPage; | 15324 return selectedPage; |
| 15310 }, | 15325 }, |
| 15311 | 15326 |
| 15312 /** @private */ | 15327 /** @private */ |
| 15313 closeDrawer_: function() { | 15328 closeDrawer_: function() { |
| 15314 var drawer = this.$$('#drawer'); | 15329 var drawer = this.$$('#drawer'); |
| 15315 if (drawer) | 15330 if (drawer) |
| 15316 drawer.close(); | 15331 drawer.close(); |
| 15317 }, | 15332 }, |
| 15318 }); | 15333 }); |
| OLD | NEW |