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

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

Issue 2684493002: MD History: Delete Grouped History (Closed)
Patch Set: Rebase 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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-query-manager', 6 is: 'history-query-manager',
7 7
8 properties: { 8 properties: {
9 /** @type {QueryState} */ 9 /** @type {QueryState} */
10 queryState: { 10 queryState: {
11 type: Object, 11 type: Object,
12 notify: true, 12 notify: true,
13 value: function() { 13 value: function() {
14 return { 14 return {
15 // Whether the most recent query was incremental. 15 // Whether the most recent query was incremental.
16 incremental: false, 16 incremental: false,
17 // A query is initiated by page load. 17 // A query is initiated by page load.
18 querying: true, 18 querying: true,
19 queryingDisabled: false, 19 queryingDisabled: false,
20 _range: HistoryRange.ALL_TIME,
21 searchTerm: '', 20 searchTerm: '',
22 groupedOffset: 0,
23
24 set range(val) {
25 this._range = Number(val);
26 },
27 get range() {
28 return this._range;
29 },
30 }; 21 };
31 }, 22 },
32 }, 23 },
33 24
34 /** @type {QueryResult} */ 25 /** @type {QueryResult} */
35 queryResult: Object, 26 queryResult: Object,
36 27
37 /** @type {?HistoryRouterElement} */ 28 /** @type {?HistoryRouterElement} */
38 router: Object, 29 router: Object,
39 }, 30 },
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 63
73 this.set('queryState.querying', true); 64 this.set('queryState.querying', true);
74 this.set('queryState.incremental', incremental); 65 this.set('queryState.incremental', incremental);
75 66
76 var lastVisitTime = 0; 67 var lastVisitTime = 0;
77 if (incremental) { 68 if (incremental) {
78 var lastVisit = this.queryResult.results.slice(-1)[0]; 69 var lastVisit = this.queryResult.results.slice(-1)[0];
79 lastVisitTime = lastVisit ? Math.floor(lastVisit.time) : 0; 70 lastVisitTime = lastVisit ? Math.floor(lastVisit.time) : 0;
80 } 71 }
81 72
82 var maxResults =
83 this.queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
84
85 chrome.send('queryHistory', [ 73 chrome.send('queryHistory', [
86 queryState.searchTerm, 74 queryState.searchTerm,
87 queryState.groupedOffset, 75 0, // No grouped offset.
88 queryState.range, 76 0, // Disable grouping.
89 lastVisitTime, 77 lastVisitTime,
90 maxResults, 78 RESULTS_PER_PAGE,
91 ]); 79 ]);
92 }, 80 },
93 81
94 /** 82 /**
95 * @param {!Event} e 83 * @param {!Event} e
96 * @private 84 * @private
97 */ 85 */
98 onChangeQuery_: function(e) { 86 onChangeQuery_: function(e) {
99 var changes = 87 var changes = /** @type {{search: ?string}} */ (e.detail);
100 /** @type {{range: ?HistoryRange, offset: ?number, search: ?string}} */
101 (e.detail);
102 var needsUpdate = false; 88 var needsUpdate = false;
103 89
104 if (changes.range != null && changes.range != this.queryState.range) {
105 this.set('queryState.range', changes.range);
106 needsUpdate = true;
107
108 // Reset back to page 0 of the results, unless changing to a specific
109 // page.
110 if (!changes.offset)
111 this.set('queryState.groupedOffset', 0);
112
113 this.fire('history-view-changed');
114 }
115
116 if (changes.offset != null &&
117 changes.offset != this.queryState.groupedOffset) {
118 this.set('queryState.groupedOffset', changes.offset);
119 needsUpdate = true;
120 }
121
122 if (changes.search != null && 90 if (changes.search != null &&
123 changes.search != this.queryState.searchTerm) { 91 changes.search != this.queryState.searchTerm) {
124 this.set('queryState.searchTerm', changes.search); 92 this.set('queryState.searchTerm', changes.search);
125 needsUpdate = true; 93 needsUpdate = true;
126 } 94 }
127 95
128 if (needsUpdate) { 96 if (needsUpdate) {
129 this.queryHistory_(false); 97 this.queryHistory_(false);
130 if (this.router) 98 if (this.router)
131 this.router.serializeUrl(); 99 this.router.serializeUrl();
132 } 100 }
133 }, 101 },
134 102
135 /** 103 /**
136 * @param {!Event} e 104 * @param {!Event} e
137 * @private 105 * @private
138 */ 106 */
139 onQueryHistory_: function(e) { 107 onQueryHistory_: function(e) {
140 this.queryHistory_(/** @type {boolean} */ e.detail); 108 this.queryHistory_(/** @type {boolean} */ e.detail);
141 return false; 109 return false;
142 }, 110 },
143 111
144 /** @private */ 112 /** @private */
145 searchTermChanged_: function() { 113 searchTermChanged_: function() {
146 // TODO(tsergeant): Ignore incremental searches in this metric. 114 // TODO(tsergeant): Ignore incremental searches in this metric.
147 if (this.queryState.searchTerm) 115 if (this.queryState.searchTerm)
148 md_history.BrowserService.getInstance().recordAction('Search'); 116 md_history.BrowserService.getInstance().recordAction('Search');
149 }, 117 },
150 }); 118 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/list_container.js ('k') | chrome/browser/resources/md_history/router.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698