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

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

Issue 2238163002: [MD History] Add UMA stats for switching views and the CBD button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@start_focus_in_search_bar
Patch Set: add test, add grouped history 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 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} */
16 groupedRange: {type: Number, observer: 'groupedRangeChanged_'},
17
15 /** @type {!QueryState} */ 18 /** @type {!QueryState} */
16 queryState: Object, 19 queryState: Object,
17 20
18 /** @type {!QueryResult} */ 21 /** @type {!QueryResult} */
19 queryResult: Object, 22 queryResult: Object,
20 }, 23 },
21 24
22 observers: [
23 'groupedRangeChanged_(queryState.range)',
24 ],
25
26 listeners: { 25 listeners: {
27 'history-list-scrolled': 'closeMenu_', 26 'history-list-scrolled': 'closeMenu_',
28 'load-more-history': 'loadMoreHistory_', 27 'load-more-history': 'loadMoreHistory_',
29 'toggle-menu': 'toggleMenu_', 28 'toggle-menu': 'toggleMenu_',
30 }, 29 },
31 30
32 /** 31 /**
33 * @param {HistoryQuery} info An object containing information about the 32 * @param {HistoryQuery} info An object containing information about the
34 * query. 33 * query.
35 * @param {!Array<HistoryEntry>} results A list of results. 34 * @param {!Array<HistoryEntry>} results A list of results.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 this.set('queryState.querying', true); 71 this.set('queryState.querying', true);
73 this.set('queryState.incremental', incremental); 72 this.set('queryState.incremental', incremental);
74 73
75 var lastVisitTime = 0; 74 var lastVisitTime = 0;
76 if (incremental) { 75 if (incremental) {
77 var lastVisit = this.queryResult.results.slice(-1)[0]; 76 var lastVisit = this.queryResult.results.slice(-1)[0];
78 lastVisitTime = lastVisit ? lastVisit.time : 0; 77 lastVisitTime = lastVisit ? lastVisit.time : 0;
79 } 78 }
80 79
81 var maxResults = 80 var maxResults =
82 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; 81 this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
83 chrome.send('queryHistory', [ 82 chrome.send('queryHistory', [
84 queryState.searchTerm, queryState.groupedOffset, queryState.range, 83 queryState.searchTerm, queryState.groupedOffset, queryState.range,
85 lastVisitTime, maxResults 84 lastVisitTime, maxResults
86 ]); 85 ]);
87 }, 86 },
88 87
89 unselectAllItems: function(count) { 88 unselectAllItems: function(count) {
90 this.getSelectedList_().unselectAllItems(count); 89 this.getSelectedList_().unselectAllItems(count);
91 }, 90 },
92 91
93 /** 92 /**
94 * Delete all the currently selected history items. Will prompt the user with 93 * Delete all the currently selected history items. Will prompt the user with
95 * a dialog to confirm that the deletion should be performed. 94 * a dialog to confirm that the deletion should be performed.
96 */ 95 */
97 deleteSelectedWithPrompt: function() { 96 deleteSelectedWithPrompt: function() {
98 if (!loadTimeData.getBoolean('allowDeletingHistory')) 97 if (!loadTimeData.getBoolean('allowDeletingHistory'))
99 return; 98 return;
100 99
101 this.$.dialog.showModal(); 100 this.$.dialog.showModal();
102 }, 101 },
103 102
104 /** 103 /**
105 * @param {HistoryRange} range 104 * @param {HistoryRange} range
106 * @private 105 * @private
107 */ 106 */
108 groupedRangeChanged_: function(range) { 107 groupedRangeChanged_: function(range, oldRange) {
109 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? 108 this.selectedPage_ = range == HistoryRange.ALL_TIME ?
110 'infinite-list' : 'grouped-list'; 109 'infinite-list' : 'grouped-list';
111 110
111 if (oldRange == undefined)
112 return;
113
112 this.queryHistory(false); 114 this.queryHistory(false);
115 this.fire('history-view-changed');
113 }, 116 },
114 117
115 /** @private */ 118 /** @private */
116 loadMoreHistory_: function() { this.queryHistory(true); }, 119 loadMoreHistory_: function() { this.queryHistory(true); },
117 120
118 /** 121 /**
119 * @param {HistoryQuery} info 122 * @param {HistoryQuery} info
120 * @param {!Array<HistoryEntry>} results 123 * @param {!Array<HistoryEntry>} results
121 * @private 124 * @private
122 */ 125 */
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 }, 195 },
193 196
194 /** 197 /**
195 * @return {HTMLElement} 198 * @return {HTMLElement}
196 * @private 199 * @private
197 */ 200 */
198 getSelectedList_: function() { 201 getSelectedList_: function() {
199 return this.$.content.selectedItem; 202 return this.$.content.selectedItem;
200 }, 203 },
201 }); 204 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698