Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2200233003: MD History: Refresh the list when clearing browsing data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test and vulcanize Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 14066 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 14083 lastSearchedTerm_: String,
14084 14084
14085 querying: Boolean, 14085 querying: Boolean,
14086 14086
14087 clearingHistory_: {
14088 type: Boolean,
14089 value: false,
14090 },
14091
14087 // An array of history entries in reverse chronological order. 14092 // An array of history entries in reverse chronological order.
14088 historyData_: Array, 14093 historyData_: Array,
14089 14094
14090 resultLoadingDisabled_: { 14095 resultLoadingDisabled_: {
14091 type: Boolean, 14096 type: Boolean,
14092 value: false, 14097 value: false,
14093 }, 14098 },
14094 }, 14099 },
14095 14100
14096 listeners: { 14101 listeners: {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
14129 * Disables history result loading when there are no more history results. 14134 * Disables history result loading when there are no more history results.
14130 */ 14135 */
14131 disableResultLoading: function() { 14136 disableResultLoading: function() {
14132 this.resultLoadingDisabled_ = true; 14137 this.resultLoadingDisabled_ = true;
14133 }, 14138 },
14134 14139
14135 /** 14140 /**
14136 * Adds the newly updated history results into historyData_. Adds new fields 14141 * Adds the newly updated history results into historyData_. Adds new fields
14137 * for each result. 14142 * for each result.
14138 * @param {!Array<!HistoryEntry>} historyResults The new history results. 14143 * @param {!Array<!HistoryEntry>} historyResults The new history results.
14144 * @param {boolean} incremental Whether the result is from loading more
14145 * history, or a new search/list reload.
14146 * @param {number} selectedCount Number of selected items.
14139 */ 14147 */
14140 addNewResults: function(historyResults) { 14148 addNewResults: function(historyResults, incremental, selectedCount) {
14141 var results = historyResults.slice(); 14149 var results = historyResults.slice();
14142 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold']) 14150 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold'])
14143 .clearTriggers(); 14151 .clearTriggers();
14144 14152
14145 if (this.lastSearchedTerm_ != this.searchedTerm) { 14153 // Do not reload the list when clearing browsing data and there are items
14154 // checked.
14155 if (this.clearingHistory_) {
14156 this.clearingHistory_ = false;
14157 if (selectedCount > 0)
14158 return;
14159 }
14160
14161 if (!incremental) {
14146 this.resultLoadingDisabled_ = false; 14162 this.resultLoadingDisabled_ = false;
14147 if (this.historyData_) 14163 if (this.historyData_)
14148 this.splice('historyData_', 0, this.historyData_.length); 14164 this.splice('historyData_', 0, this.historyData_.length);
14149 this.fire('unselect-all'); 14165 this.fire('unselect-all');
14150 this.lastSearchedTerm_ = this.searchedTerm; 14166 this.lastSearchedTerm_ = this.searchedTerm;
14151 } 14167 }
14152 14168
14153 if (this.historyData_) { 14169 if (this.historyData_) {
14154 // If we have previously received data, push the new items onto the 14170 // If we have previously received data, push the new items onto the
14155 // existing array. 14171 // existing array.
14156 results.unshift('historyData_'); 14172 results.unshift('historyData_');
14157 this.push.apply(this, results); 14173 this.push.apply(this, results);
14158 } else { 14174 } else {
14159 // The first time we receive data, use set() to ensure the iron-list is 14175 // The first time we receive data, use set() to ensure the iron-list is
14160 // initialized correctly. 14176 // initialized correctly.
14161 this.set('historyData_', results); 14177 this.set('historyData_', results);
14162 } 14178 }
14163 }, 14179 },
14164 14180
14181 clearingHistory: function() {
14182 this.clearingHistory_ = true;
14183 },
14184
14165 /** 14185 /**
14166 * Called when the page is scrolled to near the bottom of the list. 14186 * Called when the page is scrolled to near the bottom of the list.
14167 * @private 14187 * @private
14168 */ 14188 */
14169 loadMoreData_: function() { 14189 loadMoreData_: function() {
14170 if (this.resultLoadingDisabled_ || this.querying) 14190 if (this.resultLoadingDisabled_ || this.querying)
14171 return; 14191 return;
14172 14192
14173 this.fire('load-more-history'); 14193 this.fire('load-more-history');
14174 }, 14194 },
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
14378 historyResult: function(info, results) { 14398 historyResult: function(info, results) {
14379 this.initializeResults_(info, results); 14399 this.initializeResults_(info, results);
14380 this.closeMenu_(); 14400 this.closeMenu_();
14381 14401
14382 if (this.selectedPage_ == 'grouped-list') { 14402 if (this.selectedPage_ == 'grouped-list') {
14383 this.$$('#grouped-list').historyData = results; 14403 this.$$('#grouped-list').historyData = results;
14384 return; 14404 return;
14385 } 14405 }
14386 14406
14387 var list = /** @type {HistoryListElement} */(this.$['infinite-list']); 14407 var list = /** @type {HistoryListElement} */(this.$['infinite-list']);
14388 list.addNewResults(results); 14408 list.addNewResults(results, this.queryState.incremental,
14409 this.getSelectedItemCount());
14389 if (info.finished) 14410 if (info.finished)
14390 list.disableResultLoading(); 14411 list.disableResultLoading();
14391 }, 14412 },
14392 14413
14393 /** 14414 /**
14394 * Queries the history backend for results based on queryState. 14415 * Queries the history backend for results based on queryState.
14395 * @param {boolean} incremental Whether the new query should continue where 14416 * @param {boolean} incremental Whether the new query should continue where
14396 * the previous query stopped. 14417 * the previous query stopped.
14397 */ 14418 */
14398 queryHistory: function(incremental) { 14419 queryHistory: function(incremental) {
(...skipping 22 matching lines...) Expand all
14421 } 14442 }
14422 14443
14423 var maxResults = 14444 var maxResults =
14424 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; 14445 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
14425 chrome.send('queryHistory', [ 14446 chrome.send('queryHistory', [
14426 queryState.searchTerm, queryState.groupedOffset, queryState.range, 14447 queryState.searchTerm, queryState.groupedOffset, queryState.range,
14427 lastVisitTime, maxResults 14448 lastVisitTime, maxResults
14428 ]); 14449 ]);
14429 }, 14450 },
14430 14451
14452 clearingHistory: function() {
14453 /** @type {HistoryListElement} */ (this.$['infinite-list'])
14454 .clearingHistory();
14455 },
14456
14431 /** @return {number} */ 14457 /** @return {number} */
14432 getSelectedItemCount: function() { 14458 getSelectedItemCount: function() {
14433 return this.getSelectedList_().selectedPaths.size; 14459 return this.getSelectedList_().selectedPaths.size;
14434 }, 14460 },
14435 14461
14436 unselectAllItems: function(count) { 14462 unselectAllItems: function(count) {
14437 this.getSelectedList_().unselectAllItems(count); 14463 this.getSelectedList_().unselectAllItems(count);
14438 }, 14464 },
14439 14465
14440 /** 14466 /**
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
15240 .$$('history-synced-device-manager'); 15266 .$$('history-synced-device-manager');
15241 if (syncedDeviceManagerElem) 15267 if (syncedDeviceManagerElem)
15242 syncedDeviceManagerElem.tabSyncDisabled(); 15268 syncedDeviceManagerElem.tabSyncDisabled();
15243 return; 15269 return;
15244 } 15270 }
15245 15271
15246 this.set('queryResult_.sessionList', sessionList); 15272 this.set('queryResult_.sessionList', sessionList);
15247 }, 15273 },
15248 15274
15249 /** 15275 /**
15276 * Called when browsing data is cleared.
15277 */
15278 historyDeleted: function() {
15279 this.$['history'].clearingHistory();
15280 // Call into list-container to restore search state.
15281 this.$['history'].queryHistory(false);
15282 },
15283
15284 /**
15250 * Update sign in state of synced device manager after user logs in or out. 15285 * Update sign in state of synced device manager after user logs in or out.
15251 * @param {boolean} isUserSignedIn 15286 * @param {boolean} isUserSignedIn
15252 */ 15287 */
15253 updateSignInState: function(isUserSignedIn) { 15288 updateSignInState: function(isUserSignedIn) {
15254 var syncedDeviceManagerElem = 15289 var syncedDeviceManagerElem =
15255 /** @type {HistorySyncedDeviceManagerElement} */this 15290 /** @type {HistorySyncedDeviceManagerElement} */this
15256 .$$('history-synced-device-manager'); 15291 .$$('history-synced-device-manager');
15257 if (syncedDeviceManagerElem) 15292 if (syncedDeviceManagerElem)
15258 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); 15293 syncedDeviceManagerElem.updateSignInState(isUserSignedIn);
15259 }, 15294 },
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
15309 return selectedPage; 15344 return selectedPage;
15310 }, 15345 },
15311 15346
15312 /** @private */ 15347 /** @private */
15313 closeDrawer_: function() { 15348 closeDrawer_: function() {
15314 var drawer = this.$$('#drawer'); 15349 var drawer = this.$$('#drawer');
15315 if (drawer) 15350 if (drawer)
15316 drawer.close(); 15351 drawer.close();
15317 }, 15352 },
15318 }); 15353 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698