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

Side by Side Diff: chrome/browser/resources/md_history/app.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 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 15 matching lines...) Expand all
26 Polymer.IronScrollTargetBehavior, 26 Polymer.IronScrollTargetBehavior,
27 ], 27 ],
28 28
29 properties: { 29 properties: {
30 // The id of the currently selected page. 30 // The id of the currently selected page.
31 selectedPage_: { 31 selectedPage_: {
32 type: String, 32 type: String,
33 observer: 'selectedPageChanged_', 33 observer: 'selectedPageChanged_',
34 }, 34 },
35 35
36 // Whether domain-grouped history is enabled.
37 grouped_: {
38 type: Boolean,
39 reflectToAttribute: true,
40 },
41
42 /** @type {!QueryResult} */ 36 /** @type {!QueryResult} */
43 queryResult_: { 37 queryResult_: {
44 type: Object, 38 type: Object,
45 value: function() { 39 value: function() {
46 return { 40 return {
47 info: null, 41 info: null,
48 results: null, 42 results: null,
49 sessionList: null, 43 sessionList: null,
50 }; 44 };
51 } 45 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 }, 93 },
100 94
101 /** @private {?function(!Event)} */ 95 /** @private {?function(!Event)} */
102 boundOnCanExecute_: null, 96 boundOnCanExecute_: null,
103 97
104 /** @private {?function(!Event)} */ 98 /** @private {?function(!Event)} */
105 boundOnCommand_: null, 99 boundOnCommand_: null,
106 100
107 /** @override */ 101 /** @override */
108 attached: function() { 102 attached: function() {
109 this.grouped_ = loadTimeData.getBoolean('groupByDomain');
110
111 cr.ui.decorate('command', cr.ui.Command); 103 cr.ui.decorate('command', cr.ui.Command);
112 this.boundOnCanExecute_ = this.onCanExecute_.bind(this); 104 this.boundOnCanExecute_ = this.onCanExecute_.bind(this);
113 this.boundOnCommand_ = this.onCommand_.bind(this); 105 this.boundOnCommand_ = this.onCommand_.bind(this);
114 106
115 document.addEventListener('canExecute', this.boundOnCanExecute_); 107 document.addEventListener('canExecute', this.boundOnCanExecute_);
116 document.addEventListener('command', this.boundOnCommand_); 108 document.addEventListener('command', this.boundOnCommand_);
117 }, 109 },
118 110
119 /** @override */ 111 /** @override */
120 detached: function() { 112 detached: function() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 }, 219 },
228 220
229 /** 221 /**
230 * @param {Event} e 222 * @param {Event} e
231 * @private 223 * @private
232 */ 224 */
233 onCanExecute_: function(e) { 225 onCanExecute_: function(e) {
234 e = /** @type {cr.ui.CanExecuteEvent} */ (e); 226 e = /** @type {cr.ui.CanExecuteEvent} */ (e);
235 switch (e.command.id) { 227 switch (e.command.id) {
236 case 'find-command': 228 case 'find-command':
237 case 'toggle-grouped':
238 e.canExecute = true;
239 break;
240 case 'slash-command': 229 case 'slash-command':
241 e.canExecute = !this.$.toolbar.searchField.isSearchFocused(); 230 e.canExecute = !this.$.toolbar.searchField.isSearchFocused();
242 break; 231 break;
243 case 'delete-command': 232 case 'delete-command':
244 e.canExecute = this.$.toolbar.count > 0; 233 e.canExecute = this.$.toolbar.count > 0;
245 break; 234 break;
246 } 235 }
247 }, 236 },
248 237
249 /** 238 /**
250 * @param {Event} e 239 * @param {Event} e
251 * @private 240 * @private
252 */ 241 */
253 onCommand_: function(e) { 242 onCommand_: function(e) {
254 if (e.command.id == 'find-command' || e.command.id == 'slash-command') 243 if (e.command.id == 'find-command' || e.command.id == 'slash-command')
255 this.focusToolbarSearchField(); 244 this.focusToolbarSearchField();
256 if (e.command.id == 'delete-command') 245 else if (e.command.id == 'delete-command')
257 this.deleteSelected(); 246 this.deleteSelected();
258 if (e.command.id == 'toggle-grouped')
259 this.grouped_ = !this.grouped_;
260 }, 247 },
261 248
262 /** 249 /**
263 * @param {!Array<!ForeignSession>} sessionList Array of objects describing 250 * @param {!Array<!ForeignSession>} sessionList Array of objects describing
264 * the sessions from other devices. 251 * the sessions from other devices.
265 */ 252 */
266 setForeignSessions: function(sessionList) { 253 setForeignSessions: function(sessionList) {
267 this.set('queryResult_.sessionList', sessionList); 254 this.set('queryResult_.sessionList', sessionList);
268 }, 255 },
269 256
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 /** 293 /**
307 * @param {boolean} hasSyncedResults 294 * @param {boolean} hasSyncedResults
308 * @param {string} selectedPage 295 * @param {string} selectedPage
309 * @return {boolean} Whether the (i) synced results notice should be shown. 296 * @return {boolean} Whether the (i) synced results notice should be shown.
310 * @private 297 * @private
311 */ 298 */
312 showSyncNotice_: function(hasSyncedResults, selectedPage) { 299 showSyncNotice_: function(hasSyncedResults, selectedPage) {
313 return hasSyncedResults && selectedPage != 'syncedTabs'; 300 return hasSyncedResults && selectedPage != 'syncedTabs';
314 }, 301 },
315 302
316 /** 303 /** @private */
317 * @private
318 */
319 selectedPageChanged_: function() { 304 selectedPageChanged_: function() {
320 this.unselectAll(); 305 this.unselectAll();
321 this.historyViewChanged_(); 306 this.historyViewChanged_();
322 }, 307 },
323 308
324 /** @private */ 309 /** @private */
325 historyViewChanged_: function() { 310 historyViewChanged_: function() {
326 // This allows the synced-device-manager to render so that it can be set as 311 // This allows the synced-device-manager to render so that it can be set as
327 // the scroll target. 312 // the scroll target.
328 requestAnimationFrame(function() { 313 requestAnimationFrame(function() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 /** @private */ 355 /** @private */
371 recordHistoryPageView_: function() { 356 recordHistoryPageView_: function() {
372 var histogramValue = HistoryPageViewHistogram.END; 357 var histogramValue = HistoryPageViewHistogram.END;
373 switch (this.selectedPage_) { 358 switch (this.selectedPage_) {
374 case 'syncedTabs': 359 case 'syncedTabs':
375 histogramValue = this.isUserSignedIn_ ? 360 histogramValue = this.isUserSignedIn_ ?
376 HistoryPageViewHistogram.SYNCED_TABS : 361 HistoryPageViewHistogram.SYNCED_TABS :
377 HistoryPageViewHistogram.SIGNIN_PROMO; 362 HistoryPageViewHistogram.SIGNIN_PROMO;
378 break; 363 break;
379 default: 364 default:
380 switch (this.queryState_.range) { 365 histogramValue = HistoryPageViewHistogram.HISTORY;
381 case HistoryRange.ALL_TIME:
382 histogramValue = HistoryPageViewHistogram.HISTORY;
383 break;
384 case HistoryRange.WEEK:
385 histogramValue = HistoryPageViewHistogram.GROUPED_WEEK;
386 break;
387 case HistoryRange.MONTH:
388 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH;
389 break;
390 }
391 break; 366 break;
392 } 367 }
393 368
394 md_history.BrowserService.getInstance().recordHistogram( 369 md_history.BrowserService.getInstance().recordHistogram(
395 'History.HistoryPageView', histogramValue, 370 'History.HistoryPageView', histogramValue,
396 HistoryPageViewHistogram.END); 371 HistoryPageViewHistogram.END);
397 }, 372 },
398 }); 373 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/app.html ('k') | chrome/browser/resources/md_history/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698