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

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

Issue 2656443004: MD History: Add routing for grouped history mode. (Closed)
Patch Set: Review comments Created 3 years, 10 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 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_: { 10 selectedPage_: {
(...skipping 14 matching lines...) Expand all
25 * @private {?{ 25 * @private {?{
26 * index: number, 26 * index: number,
27 * item: !HistoryEntry, 27 * item: !HistoryEntry,
28 * path: string, 28 * path: string,
29 * target: !HTMLElement 29 * target: !HTMLElement
30 * }} 30 * }}
31 */ 31 */
32 actionMenuModel_: Object, 32 actionMenuModel_: Object,
33 }, 33 },
34 34
35 observers: [
36 'groupedRangeChanged_(queryState.range)',
37 ],
38
39 listeners: { 35 listeners: {
40 'open-menu': 'openMenu_', 36 'open-menu': 'openMenu_',
41 }, 37 },
42 38
43 /** 39 /**
44 * @param {HistoryQuery} info An object containing information about the 40 * @param {HistoryQuery} info An object containing information about the
45 * query. 41 * query.
46 * @param {!Array<!HistoryEntry>} results A list of results. 42 * @param {!Array<!HistoryEntry>} results A list of results.
47 */ 43 */
48 historyResult: function(info, results) { 44 historyResult: function(info, results) {
49 this.initializeResults_(info, results); 45 this.initializeResults_(info, results);
50 this.closeMenu_(); 46 this.closeMenu_();
51 47
52 if (info.term && !this.queryState.incremental) { 48 if (info.term && !this.queryState.incremental) {
53 Polymer.IronA11yAnnouncer.requestAvailability(); 49 Polymer.IronA11yAnnouncer.requestAvailability();
54 this.fire('iron-announce', { 50 this.fire('iron-announce', {
55 text: 51 text:
56 md_history.HistoryItem.searchResultsTitle(results.length, info.term) 52 md_history.HistoryItem.searchResultsTitle(results.length, info.term)
57 }); 53 });
58 } 54 }
59 55
60 var list = /** @type {HistoryListBehavior} */ this.getSelectedList_(); 56 var list = /** @type {HistoryListBehavior} */ this.getSelectedList_();
61 list.addNewResults(results, this.queryState.incremental, info.finished); 57 // It is possible for results to arrive for the grouped list before the lazy
58 // load has finished and the <history-grouped-list> element exists. In this
59 // case, add the items to a property on the unresolved element which can be
60 // read when it upgrades and is attached.
61 if (Polymer.isInstance(list))
62 list.addNewResults(results, this.queryState.incremental, info.finished);
63 else
64 list.initialData = results;
62 }, 65 },
63 66
64 historyDeleted: function() { 67 historyDeleted: function() {
65 // Do not reload the list when there are items checked. 68 // Do not reload the list when there are items checked.
66 if (this.getSelectedItemCount() > 0) 69 if (this.getSelectedItemCount() > 0)
67 return; 70 return;
68 71
69 // Reload the list with current search state. 72 // Reload the list with current search state.
70 this.fire('query-history', false); 73 this.fire('query-history', false);
71 }, 74 },
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 /** 110 /**
108 * @param {HistoryRange} range 111 * @param {HistoryRange} range
109 * @return {string} 112 * @return {string}
110 * @private 113 * @private
111 */ 114 */
112 computeSelectedPage_: function(range) { 115 computeSelectedPage_: function(range) {
113 return range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list'; 116 return range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list';
114 }, 117 },
115 118
116 /** 119 /**
117 * @param {HistoryRange} range
118 * @private
119 */
120 groupedRangeChanged_: function(range) {
121 // Reset the results on range change to prevent stale results from being
122 // processed into the incoming range's UI.
123 if (range != HistoryRange.ALL_TIME && this.queryResult.info) {
124 this.set('queryResult.results', []);
125 this.historyResult(this.queryResult.info, []);
126 }
127 },
128
129 /**
130 * @param {HistoryQuery} info 120 * @param {HistoryQuery} info
131 * @param {!Array<HistoryEntry>} results 121 * @param {!Array<HistoryEntry>} results
132 * @private 122 * @private
133 */ 123 */
134 initializeResults_: function(info, results) { 124 initializeResults_: function(info, results) {
135 if (results.length == 0) 125 if (results.length == 0)
136 return; 126 return;
137 127
138 var currentDate = results[0].dateRelativeDay; 128 var currentDate = results[0].dateRelativeDay;
139 129
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 */ 234 */
245 getSelectedList_: function() { 235 getSelectedList_: function() {
246 return this.$$('#' + this.selectedPage_); 236 return this.$$('#' + this.selectedPage_);
247 }, 237 },
248 238
249 /** @private */ 239 /** @private */
250 canDeleteHistory_: function() { 240 canDeleteHistory_: function() {
251 return loadTimeData.getBoolean('allowDeletingHistory'); 241 return loadTimeData.getBoolean('allowDeletingHistory');
252 } 242 }
253 }); 243 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/list_container.html ('k') | chrome/browser/resources/md_history/query_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698