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

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

Issue 2207323002: [MD History] Factor out a common HistoryListBehavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 var maxResults = 79 var maxResults =
80 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; 80 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
81 chrome.send('queryHistory', [ 81 chrome.send('queryHistory', [
82 queryState.searchTerm, queryState.groupedOffset, queryState.range, 82 queryState.searchTerm, queryState.groupedOffset, queryState.range,
83 lastVisitTime, maxResults 83 lastVisitTime, maxResults
84 ]); 84 ]);
85 }, 85 },
86 86
87 unselectAllItems: function(count) { 87 unselectAllItems: function(count) {
88 /** @type {HistoryListElement} */ (this.$['infinite-list']) 88 this.$.content.selectedItem.unselectAllItems(count);
tsergeant 2016/08/05 01:39:09 Nit: Maybe extract this.$.content.selectedItem int
calamity 2016/08/09 02:56:00 So this is exactly why I was asking how behaviors
tsergeant 2016/08/09 04:37:54 That's unfortunate. I think it would be worthwhile
calamity 2016/08/09 05:28:30 Done.
89 .unselectAllItems(count);
90 }, 89 },
91 90
92 /** 91 /**
93 * Delete all the currently selected history items. Will prompt the user with 92 * Delete all the currently selected history items. Will prompt the user with
94 * a dialog to confirm that the deletion should be performed. 93 * a dialog to confirm that the deletion should be performed.
95 */ 94 */
96 deleteSelectedWithPrompt: function() { 95 deleteSelectedWithPrompt: function() {
97 if (!loadTimeData.getBoolean('allowDeletingHistory')) 96 if (!loadTimeData.getBoolean('allowDeletingHistory'))
98 return; 97 return;
99 98
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort; 132 info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort;
134 133
135 if (results[i].dateRelativeDay != currentDate) { 134 if (results[i].dateRelativeDay != currentDate) {
136 currentDate = results[i].dateRelativeDay; 135 currentDate = results[i].dateRelativeDay;
137 } 136 }
138 } 137 }
139 }, 138 },
140 139
141 /** @private */ 140 /** @private */
142 onDialogConfirmTap_: function() { 141 onDialogConfirmTap_: function() {
143 this.$['infinite-list'].deleteSelected(); 142 this.$.content.selectedItem.deleteSelected();
144 this.$.dialog.close(); 143 this.$.dialog.close();
145 }, 144 },
146 145
147 /** @private */ 146 /** @private */
148 onDialogCancelTap_: function() { 147 onDialogCancelTap_: function() {
149 this.$.dialog.close(); 148 this.$.dialog.close();
150 }, 149 },
151 150
152 /** 151 /**
153 * Closes the overflow menu. 152 * Closes the overflow menu.
(...skipping 21 matching lines...) Expand all
175 this.fire('search-domain', {domain: menu.itemData.domain}); 174 this.fire('search-domain', {domain: menu.itemData.domain});
176 menu.closeMenu(); 175 menu.closeMenu();
177 }, 176 },
178 177
179 /** @private */ 178 /** @private */
180 onRemoveFromHistoryTap_: function() { 179 onRemoveFromHistoryTap_: function() {
181 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu); 180 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu);
182 md_history.BrowserService.getInstance() 181 md_history.BrowserService.getInstance()
183 .deleteItems([menu.itemData]) 182 .deleteItems([menu.itemData])
184 .then(function(items) { 183 .then(function(items) {
185 this.$['infinite-list'].removeDeletedHistory_(items); 184 this.$.content.selectedItem.removeItemsByPath(items[0].path);
186 // This unselect-all is to reset the toolbar when deleting a selected 185 // This unselect-all is to reset the toolbar when deleting a selected
187 // item. TODO(tsergeant): Make this automatic based on observing list 186 // item. TODO(tsergeant): Make this automatic based on observing list
188 // modifications. 187 // modifications.
189 this.fire('unselect-all'); 188 this.fire('unselect-all');
190 }.bind(this)); 189 }.bind(this));
191 menu.closeMenu(); 190 menu.closeMenu();
192 }, 191 },
193 }); 192 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698