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

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

Issue 2481693002: [MD History] Make forward/backward work in grouped mode. (Closed)
Patch Set: rebase Created 4 years 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 Polymer({ 5 Polymer({
6 is: 'history-list-container', 6 is: 'history-list-container',
7 7
8 properties: { 8 properties: {
9 // The path of the currently selected page. 9 // The path of the currently selected page.
10 selectedPage_: String, 10 selectedPage_: String,
11 11
12 // Whether domain-grouped history is enabled. 12 // Whether domain-grouped history is enabled.
13 grouped: Boolean, 13 grouped: Boolean,
14 14
15 /** @type {HistoryRange} */ 15 /** @type {HistoryRange} */
16 groupedRange: {type: Number, observer: 'groupedRangeChanged_'}, 16 groupedRange: {type: Number, observer: 'groupedRangeChanged_'},
17 17
18 /** @type {!QueryState} */ 18 /** @type {!QueryState} */
19 queryState: Object, 19 queryState: Object,
20 20
21 /** @type {!QueryResult} */ 21 /** @type {!QueryResult} */
22 queryResult: Object, 22 queryResult: Object,
23 }, 23 },
24 24
25 observers: [ 25 observers: [
26 'searchTermChanged_(queryState.searchTerm)', 26 'searchTermChanged_(queryState.searchTerm)',
27 'groupedOffsetChanged_(queryState.groupedOffset)',
27 ], 28 ],
28 29
29 listeners: { 30 listeners: {
30 'history-list-scrolled': 'closeMenu_', 31 'history-list-scrolled': 'closeMenu_',
31 'load-more-history': 'loadMoreHistory_', 32 'load-more-history': 'loadMoreHistory_',
32 'toggle-menu': 'toggleMenu_', 33 'toggle-menu': 'toggleMenu_',
33 }, 34 },
34 35
35 /** 36 /**
36 * @param {HistoryQuery} info An object containing information about the 37 * @param {HistoryQuery} info An object containing information about the
37 * query. 38 * query.
38 * @param {!Array<HistoryEntry>} results A list of results. 39 * @param {!Array<!HistoryEntry>} results A list of results.
39 */ 40 */
40 historyResult: function(info, results) { 41 historyResult: function(info, results) {
41 this.initializeResults_(info, results); 42 this.initializeResults_(info, results);
42 this.closeMenu_(); 43 this.closeMenu_();
43 44
44 if (info.term && !this.queryState.incremental) { 45 if (info.term && !this.queryState.incremental) {
45 Polymer.IronA11yAnnouncer.requestAvailability(); 46 Polymer.IronA11yAnnouncer.requestAvailability();
46 this.fire('iron-announce', { 47 this.fire('iron-announce', {
47 text: 48 text:
48 md_history.HistoryItem.searchResultsTitle(results.length, info.term) 49 md_history.HistoryItem.searchResultsTitle(results.length, info.term)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 * @param {HistoryRange} range 146 * @param {HistoryRange} range
146 * @private 147 * @private
147 */ 148 */
148 groupedRangeChanged_: function(range, oldRange) { 149 groupedRangeChanged_: function(range, oldRange) {
149 this.selectedPage_ = range == HistoryRange.ALL_TIME ? 150 this.selectedPage_ = range == HistoryRange.ALL_TIME ?
150 'infinite-list' : 'grouped-list'; 151 'infinite-list' : 'grouped-list';
151 152
152 if (oldRange == undefined) 153 if (oldRange == undefined)
153 return; 154 return;
154 155
156 this.set('queryState.groupedOffset', 0);
157
158 // Reset the results on range change to prevent stale results from being
159 // processed into the incoming range's UI.
160 if (this.queryResult.info) {
161 this.set('queryResult.results', []);
162 this.historyResult(this.queryResult.info, []);
163 }
164
155 this.queryHistory(false); 165 this.queryHistory(false);
156 this.fire('history-view-changed'); 166 this.fire('history-view-changed');
157 }, 167 },
158 168
159 /** @private */ 169 /** @private */
160 searchTermChanged_: function() { 170 searchTermChanged_: function() {
161 this.queryHistory(false); 171 this.queryHistory(false);
162 // TODO(tsergeant): Ignore incremental searches in this metric. 172 // TODO(tsergeant): Ignore incremental searches in this metric.
163 if (this.queryState.searchTerm) 173 if (this.queryState.searchTerm)
164 md_history.BrowserService.getInstance().recordAction('Search'); 174 md_history.BrowserService.getInstance().recordAction('Search');
165 }, 175 },
166 176
167 /** @private */ 177 /** @private */
178 groupedOffsetChanged_: function() {
179 this.queryHistory(false);
180 },
181
182 /** @private */
168 loadMoreHistory_: function() { this.queryHistory(true); }, 183 loadMoreHistory_: function() { this.queryHistory(true); },
169 184
170 /** 185 /**
171 * @param {HistoryQuery} info 186 * @param {HistoryQuery} info
172 * @param {!Array<HistoryEntry>} results 187 * @param {!Array<HistoryEntry>} results
173 * @private 188 * @private
174 */ 189 */
175 initializeResults_: function(info, results) { 190 initializeResults_: function(info, results) {
176 if (results.length == 0) 191 if (results.length == 0)
177 return; 192 return;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 * @return {HTMLElement} 293 * @return {HTMLElement}
279 * @private 294 * @private
280 */ 295 */
281 getSelectedList_: function() { return this.$.content.selectedItem; }, 296 getSelectedList_: function() { return this.$.content.selectedItem; },
282 297
283 /** @private */ 298 /** @private */
284 canDeleteHistory_: function() { 299 canDeleteHistory_: function() {
285 return loadTimeData.getBoolean('allowDeletingHistory'); 300 return loadTimeData.getBoolean('allowDeletingHistory');
286 } 301 }
287 }); 302 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698