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

Side by Side Diff: chrome/browser/resources/md_history/list_container.js

Issue 2084843002: [MD History] Add history-list-container between app and history lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tim_toolbar
Patch Set: address comments Created 4 years, 6 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
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @typedef {{results: ?Array<!HistoryEntry>,
7 * info: ?HistoryQuery}}
8 */
9 var QueryResult;
10
11 Polymer({
12 is: 'history-list-container',
13
14 properties: {
15 // The path of the currently selected page.
16 selectedPage_: String,
17
18 // Whether domain-grouped history is enabled.
19 grouped: Boolean,
20
21 /** @type {!QueryState} */
22 queryState: {
23 type: Object,
24 },
25
26 /** @type {!QueryResult} */
27 queryResult_: {
28 type: Object,
29 readOnly: true,
30 value: function() {
31 return {
32 info: null,
33 results: null,
34 };
35 }
36 },
37 },
38
39 observers: [
40 'searchTermChanged_(queryState.searchTerm)',
41 'groupedRangeChanged_(queryState.range)',
42 ],
43
44 listeners: {
45 'load-more-history': 'loadMoreHistory_',
46 },
47
48 /** @private */
49 initializeResults_: function(info, results) {
tsergeant 2016/06/27 03:58:15 Nit: This private function got left behind when th
calamity 2016/06/29 07:52:49 Done.
50 if (results.length == 0)
51 return;
52
53 var currentDate = results[0].dateRelativeDay;
54
55 for (var i = 0; i < results.length; i++) {
56 // Sets the default values for these fields to prevent undefined types.
57 results[i].selected = false;
58 results[i].readableTimestamp =
59 info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort;
60
61 if (results[i].dateRelativeDay != currentDate) {
62 currentDate = results[i].dateRelativeDay;
63 }
64 }
65 },
66
67 /**
68 * @param {HistoryQuery} info An object containing information about the
69 * query.
70 * @param {!Array<HistoryEntry>} results A list of results.
71 */
72 historyResult: function(info, results) {
73 this.initializeResults_(info, results);
74
75 this.set('queryResult_.info', info);
76 this.set('queryResult_.results', results);
77
78 if (this.selectedPage_ == 'grouped-list') {
79 this.$$('#grouped-list').historyData = results;
80 return;
81 }
82
83 var list = /** @type {HistoryListElement} */(this.$['infinite-list']);
84 list.addNewResults(results);
85 if (info.finished)
86 list.disableResultLoading();
87 },
88
89 /**
90 * Queries the history backend for results based on queryState.
91 * @param {boolean} incremental Whether the new query should continue where
92 * the previous query stopped.
93 */
94 queryHistory: function(incremental) {
95 var queryState = this.queryState;
96 // Disable querying until the first set of results have been returned.
97 if (this.queryResult_.results == null || queryState.queryingDisabled)
98 return;
99
100 this.set('queryState.querying', true);
101 this.set('queryState.incremental', incremental);
102
103
104 var lastVisitTime = 0;
105 if (incremental) {
106 var lastVisit = this.queryResult_.results.slice(-1)[0];
107 lastVisitTime = lastVisit ? lastVisit.time : 0;
108 }
109
110 var maxResults =
111 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
112 chrome.send('queryHistory', [
113 queryState.searchTerm, queryState.groupedOffset, queryState.range,
114 lastVisitTime, maxResults
115 ]);
116 },
117
118 unselectAllItems: function(count) {
119 /** @type {HistoryListElement} */ (this.$['infinite-list'])
120 .unselectAllItems(count);
121 },
122
123 deleteSelected: function() {
124 /** @type {HistoryListElement} */ (this.$['infinite-list'])
125 .deleteSelected();
126 },
127
128 /** @private */
129 searchTermChanged_: function(searchTerm) { this.queryHistory(false); },
130
131 /** @private */
132 groupedRangeChanged_: function(range) {
133 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ?
134 'infinite-list' : 'grouped-list';
135
136 this.queryHistory(false);
137 },
138
139 /** @private */
140 loadMoreHistory_: function() { this.queryHistory(true); },
141 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/list_container.html ('k') | chrome/browser/resources/md_history/side_bar.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698