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

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

Issue 2684693004: MD History: Remove list-container and list-behavior (Closed)
Patch Set: Fix test 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 cr.define('md_history', function() { 5 cr.define('md_history', function() {
6 var lazyLoadPromise = null; 6 var lazyLoadPromise = null;
7 function ensureLazyLoaded() { 7 function ensureLazyLoaded() {
8 if (!lazyLoadPromise) { 8 if (!lazyLoadPromise) {
9 lazyLoadPromise = new Promise(function(resolve, reject) { 9 lazyLoadPromise = new Promise(function(resolve, reject) {
10 Polymer.Base.importHref( 10 Polymer.Base.importHref(
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 this.showMenuPromo_ = false; 169 this.showMenuPromo_ = false;
170 }, 170 },
171 171
172 /** 172 /**
173 * Listens for history-item being selected or deselected (through checkbox) 173 * Listens for history-item being selected or deselected (through checkbox)
174 * and changes the view of the top toolbar. 174 * and changes the view of the top toolbar.
175 * @param {{detail: {countAddition: number}}} e 175 * @param {{detail: {countAddition: number}}} e
176 */ 176 */
177 checkboxSelected: function(e) { 177 checkboxSelected: function(e) {
178 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); 178 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar);
179 toolbar.count = /** @type {HistoryListContainerElement} */ (this.$.history) 179 toolbar.count = /** @type {HistoryListElement} */ (this.$.history)
180 .getSelectedItemCount(); 180 .getSelectedItemCount();
181 }, 181 },
182 182
183 /** 183 /**
184 * Listens for call to cancel selection and loops through all items to set 184 * Listens for call to cancel selection and loops through all items to set
185 * checkbox to be unselected. 185 * checkbox to be unselected.
186 * @private 186 * @private
187 */ 187 */
188 unselectAll: function() { 188 unselectAll: function() {
189 var listContainer = 189 var list = /** @type {HistoryListElement} */ (this.$.history);
190 /** @type {HistoryListContainerElement} */ (this.$.history);
191 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); 190 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar);
192 listContainer.unselectAllItems(toolbar.count); 191 list.unselectAllItems();
193 toolbar.count = 0; 192 toolbar.count = 0;
194 }, 193 },
195 194
196 deleteSelected: function() { 195 deleteSelected: function() {
197 this.$.history.deleteSelectedWithPrompt(); 196 this.$.history.deleteSelectedWithPrompt();
198 }, 197 },
199 198
200 /** 199 /**
201 * @param {HistoryQuery} info An object containing information about the 200 * @param {HistoryQuery} info An object containing information about the
202 * query. 201 * query.
203 * @param {!Array<HistoryEntry>} results A list of results. 202 * @param {!Array<HistoryEntry>} results A list of results.
204 */ 203 */
205 historyResult: function(info, results) { 204 historyResult: function(info, results) {
206 this.set('queryState_.querying', false); 205 this.set('queryState_.querying', false);
207 this.set('queryResult_.info', info); 206 this.set('queryResult_.info', info);
208 this.set('queryResult_.results', results); 207 this.set('queryResult_.results', results);
209 var listContainer = 208 var list = /** @type {HistoryListElement} */ (this.$['history']);
210 /** @type {HistoryListContainerElement} */ (this.$['history']); 209 list.historyResult(info, results);
211 listContainer.historyResult(info, results);
212 }, 210 },
213 211
214 /** 212 /**
215 * Shows and focuses the search bar in the toolbar. 213 * Shows and focuses the search bar in the toolbar.
216 */ 214 */
217 focusToolbarSearchField: function() { 215 focusToolbarSearchField: function() {
218 this.$.toolbar.showSearchField(); 216 this.$.toolbar.showSearchField();
219 }, 217 },
220 218
221 /** 219 /**
(...skipping 13 matching lines...) Expand all
235 } 233 }
236 }, 234 },
237 235
238 /** 236 /**
239 * @param {Event} e 237 * @param {Event} e
240 * @private 238 * @private
241 */ 239 */
242 onCommand_: function(e) { 240 onCommand_: function(e) {
243 if (e.command.id == 'find-command' || e.command.id == 'slash-command') 241 if (e.command.id == 'find-command' || e.command.id == 'slash-command')
244 this.focusToolbarSearchField(); 242 this.focusToolbarSearchField();
245 else if (e.command.id == 'delete-command') 243 if (e.command.id == 'delete-command')
calamity 2017/02/21 02:40:06 nit: Did this change for a reason?
tsergeant 2017/02/21 23:24:12 Oh, just me messing up git. Done.
Dan Beam 2017/02/21 23:26:55 fwiw: I liked this ^ version better.
246 this.deleteSelected(); 244 this.deleteSelected();
247 }, 245 },
248 246
249 /** 247 /**
250 * @param {!Array<!ForeignSession>} sessionList Array of objects describing 248 * @param {!Array<!ForeignSession>} sessionList Array of objects describing
251 * the sessions from other devices. 249 * the sessions from other devices.
252 */ 250 */
253 setForeignSessions: function(sessionList) { 251 setForeignSessions: function(sessionList) {
254 this.set('queryResult_.sessionList', sessionList); 252 this.set('queryResult_.sessionList', sessionList);
255 }, 253 },
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 selectedPageChanged_: function() { 302 selectedPageChanged_: function() {
305 this.unselectAll(); 303 this.unselectAll();
306 this.historyViewChanged_(); 304 this.historyViewChanged_();
307 }, 305 },
308 306
309 /** @private */ 307 /** @private */
310 historyViewChanged_: function() { 308 historyViewChanged_: function() {
311 // This allows the synced-device-manager to render so that it can be set as 309 // This allows the synced-device-manager to render so that it can be set as
312 // the scroll target. 310 // the scroll target.
313 requestAnimationFrame(function() { 311 requestAnimationFrame(function() {
314 md_history.ensureLazyLoaded().then(function() { 312 this._scrollHandler();
315 // <iron-pages> can occasionally end up with no item selected during
316 // tests.
317 if (!this.$.content.selectedItem)
318 return;
calamity 2017/02/21 02:40:06 Do we still need this for synced-device-manager? I
tsergeant 2017/02/21 23:24:12 I'm pretty sure that the new version of this funct
319 this.scrollTarget =
320 this.$.content.selectedItem.getContentScrollTarget();
321 this._scrollHandler();
322 }.bind(this));
323 }.bind(this)); 313 }.bind(this));
324 this.recordHistoryPageView_(); 314 this.recordHistoryPageView_();
325 }, 315 },
326 316
327 /** @private */ 317 /** @private */
328 hasDrawerChanged_: function() { 318 hasDrawerChanged_: function() {
329 var drawer = /** @type {?CrDrawerElement} */ (this.$.drawer.getIfExists()); 319 var drawer = /** @type {?CrDrawerElement} */ (this.$.drawer.getIfExists());
330 if (!this.hasDrawer_ && drawer && drawer.open) 320 if (!this.hasDrawer_ && drawer && drawer.open)
331 drawer.closeDrawer(); 321 drawer.closeDrawer();
332 }, 322 },
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 default: 354 default:
365 histogramValue = HistoryPageViewHistogram.HISTORY; 355 histogramValue = HistoryPageViewHistogram.HISTORY;
366 break; 356 break;
367 } 357 }
368 358
369 md_history.BrowserService.getInstance().recordHistogram( 359 md_history.BrowserService.getInstance().recordHistogram(
370 'History.HistoryPageView', histogramValue, 360 'History.HistoryPageView', histogramValue,
371 HistoryPageViewHistogram.END); 361 HistoryPageViewHistogram.END);
372 }, 362 },
373 }); 363 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698