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

Unified Diff: chrome/browser/resources/md_history/app.js

Issue 1993613002: [MD History] Implement grouped history UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@privatize
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_history/app.js
diff --git a/chrome/browser/resources/md_history/app.js b/chrome/browser/resources/md_history/app.js
index d58fcfdab7c06a8f7add679dc7801ff72f42bb3c..dad0f9b05600dc9da43773838f06c43f8a190e47 100644
--- a/chrome/browser/resources/md_history/app.js
+++ b/chrome/browser/resources/md_history/app.js
@@ -15,11 +15,15 @@ Polymer({
properties: {
// The id of the currently selected page.
- selectedPage: {
+ selectedPage_: {
type: String,
- value: 'history-list'
},
+ // Whether domain-grouped history is enabled.
+ grouped_: Boolean,
+
+ firstLoad_: { type: Boolean, value: true },
+
/** @type {!QueryState} */
queryState_: {
type: Object,
@@ -30,6 +34,9 @@ Polymer({
searchTerm: '',
results: null,
info: null,
+ range: HistoryRange.ALL_TIME,
+ // TODO(calamity): Make history toolbar buttons change the offset.
+ groupedOffset: 0,
};
}
},
@@ -37,6 +44,7 @@ Polymer({
observers: [
'searchTermChanged_(queryState_.searchTerm)',
+ 'groupedRangeChanged_(queryState_.range)',
],
// TODO(calamity): Replace these event listeners with data bound properties.
@@ -49,7 +57,7 @@ Polymer({
},
ready: function() {
- this.$.toolbar.isGroupedMode = loadTimeData.getBoolean('groupByDomain');
+ this.grouped_ = loadTimeData.getBoolean('groupByDomain');
},
/**
@@ -97,9 +105,31 @@ Polymer({
* @param {!Array<HistoryEntry>} results A list of results.
*/
historyResult: function(info, results) {
- this.set('queryState_.querying', false);
- this.set('queryState_.results', results);
+ this.firstLoad_ = false;
this.set('queryState_.info', info);
+ this.set('queryState_.results', results);
+ this.set('queryState_.querying', false);
+
+ if (results.length == 0)
+ return;
+
+ var currentDate = results[0].dateRelativeDay;
+
+ for (var i = 0; i < results.length; i++) {
+ // Sets the default values for these fields to prevent undefined types.
+ results[i].selected = false;
+ results[i].readableTimestamp =
+ info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort;
+
+ if (results[i].dateRelativeDay != currentDate) {
+ currentDate = results[i].dateRelativeDay;
+ }
+ }
+
+ if (this.grouped_ && this.queryState_.range != HistoryRange.ALL_TIME) {
+ this.$$('history-grouped-list').historyData = results;
+ return;
+ }
var list = /** @type {HistoryListElement} */(this.$['history-list']);
list.addNewResults(results);
@@ -115,21 +145,39 @@ Polymer({
this.$.toolbar.setSearchTerm(e.detail.domain);
},
- searchTermChanged_: function() {
- this.queryHistory(false);
+ searchTermChanged_: function(searchTerm) {
+ if (!this.firstLoad_)
+ this.queryHistory(false);
+ },
+
+
+ groupedRangeChanged_: function(range) {
+ if (!this.firstLoad_)
+ this.queryHistory(false);
},
+ /**
+ * Queries the history backend for results based on queryState_.
+ * @param {boolean} incremental Whether the new query should continue where
+ * the previous query stopped.
+ */
queryHistory: function(incremental) {
+ this.set('queryState_.querying', true);
+
+ var queryState = this.queryState_;
+
var lastVisitTime = 0;
if (incremental) {
- var lastVisit = this.queryState_.results.slice(-1)[0];
+ var lastVisit = queryState.results.slice(-1)[0];
lastVisitTime = lastVisit ? lastVisit.time : 0;
}
- this.set('queryState_.querying', true);
- chrome.send(
- 'queryHistory',
- [this.queryState_.searchTerm, 0, 0, lastVisitTime, RESULTS_PER_PAGE]);
+ var maxResults =
+ queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
+ chrome.send('queryHistory', [
+ queryState.searchTerm, queryState.groupedOffset, Number(queryState.range),
+ lastVisitTime, maxResults
tsergeant 2016/05/19 05:38:17 It looks like the old history page sets maxResults
calamity 2016/05/20 06:51:58 That's done here for cargo-culty reasons. It does
+ ]);
},
/**
@@ -147,5 +195,12 @@ Polymer({
var syncedDeviceManager =
/** @type {HistorySyncedDeviceManagerElement} */(syncedDeviceElem);
syncedDeviceManager.setSyncedHistory(sessionList);
- }
+ },
+
+ getSelectedPage: function(selectedPage, range) {
+ if (selectedPage == 'history-list' && range != HistoryRange.ALL_TIME)
+ return 'history-grouped-list';
+
+ return selectedPage;
+ },
});

Powered by Google App Engine
This is Rietveld 408576698