OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // The id of the currently selected page. | 35 // The id of the currently selected page. |
36 selectedPage_: {type: String, observer: 'selectedPageChanged_'}, | 36 selectedPage_: {type: String, observer: 'selectedPageChanged_'}, |
37 | 37 |
38 // Whether domain-grouped history is enabled. | 38 // Whether domain-grouped history is enabled. |
39 grouped_: {type: Boolean, reflectToAttribute: true}, | 39 grouped_: {type: Boolean, reflectToAttribute: true}, |
40 | 40 |
41 /** @type {!QueryState} */ | 41 /** @type {!QueryState} */ |
42 queryState_: { | 42 queryState_: { |
43 type: Object, | 43 type: Object, |
44 value: function() { | 44 value: () => ({ |
45 return { | 45 // Whether the most recent query was incremental. |
46 // Whether the most recent query was incremental. | 46 incremental: false, |
47 incremental: false, | 47 // A query is initiated by page load. |
48 // A query is initiated by page load. | 48 querying: true, |
49 querying: true, | 49 queryingDisabled: false, |
50 queryingDisabled: false, | 50 _range: HistoryRange.ALL_TIME, |
51 _range: HistoryRange.ALL_TIME, | 51 searchTerm: '', |
52 searchTerm: '', | 52 groupedOffset: 0, |
53 groupedOffset: 0, | |
54 | 53 |
55 set range(val) { this._range = Number(val); }, | 54 set range(val) { this._range = Number(val); }, |
56 get range() { return this._range; }, | 55 get range() { return this._range; }, |
57 }; | 56 }), |
58 } | |
59 }, | 57 }, |
60 | 58 |
61 /** @type {!QueryResult} */ | 59 /** @type {!QueryResult} */ |
62 queryResult_: { | 60 queryResult_: { |
63 type: Object, | 61 type: Object, |
64 value: function() { | 62 value: () => ({ |
65 return { | 63 info: null, |
66 info: null, | 64 results: null, |
67 results: null, | 65 sessionList: null, |
68 sessionList: null, | 66 }), |
69 }; | |
70 } | |
71 }, | 67 }, |
72 | 68 |
73 // True if the window is narrow enough for the page to have a drawer. | 69 // True if the window is narrow enough for the page to have a drawer. |
74 hasDrawer_: Boolean, | 70 hasDrawer_: Boolean, |
75 | 71 |
76 isUserSignedIn_: { | 72 isUserSignedIn_: { |
77 type: Boolean, | 73 type: Boolean, |
78 // Updated on synced-device-manager attach by chrome.sending | 74 // Updated on synced-device-manager attach by chrome.sending |
79 // 'otherDevicesInitialized'. | 75 // 'otherDevicesInitialized'. |
80 value: loadTimeData.getBoolean('isUserSignedIn'), | 76 value: loadTimeData.getBoolean('isUserSignedIn'), |
81 }, | 77 }, |
82 | 78 |
83 toolbarShadow_: { | 79 toolbarShadow_: { |
84 type: Boolean, | 80 type: Boolean, |
85 reflectToAttribute: true, | 81 reflectToAttribute: true, |
86 notify: true, | 82 notify: true, |
87 }, | 83 }, |
88 | 84 |
89 showMenuPromo_: { | 85 showMenuPromo_: { |
90 type: Boolean, | 86 type: Boolean, |
91 value: function() { | 87 value: () => loadTimeData.getBoolean('showMenuPromo'), |
92 return loadTimeData.getBoolean('showMenuPromo'); | |
93 }, | |
94 }, | 88 }, |
95 }, | 89 }, |
96 | 90 |
97 listeners: { | 91 listeners: { |
98 'cr-toolbar-menu-promo-close': 'onCrToolbarMenuPromoClose_', | 92 'cr-toolbar-menu-promo-close': 'onCrToolbarMenuPromoClose_', |
99 'cr-toolbar-menu-promo-shown': 'onCrToolbarMenuPromoShown_', | 93 'cr-toolbar-menu-promo-shown': 'onCrToolbarMenuPromoShown_', |
100 'cr-toolbar-menu-tap': 'onCrToolbarMenuTap_', | 94 'cr-toolbar-menu-tap': 'onCrToolbarMenuTap_', |
101 'delete-selected': 'deleteSelected', | 95 'delete-selected': 'deleteSelected', |
102 'history-checkbox-select': 'checkboxSelected', | 96 'history-checkbox-select': 'checkboxSelected', |
103 'history-close-drawer': 'closeDrawer_', | 97 'history-close-drawer': 'closeDrawer_', |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 */ | 316 */ |
323 selectedPageChanged_: function() { | 317 selectedPageChanged_: function() { |
324 this.unselectAll(); | 318 this.unselectAll(); |
325 this.historyViewChanged_(); | 319 this.historyViewChanged_(); |
326 }, | 320 }, |
327 | 321 |
328 /** @private */ | 322 /** @private */ |
329 historyViewChanged_: function() { | 323 historyViewChanged_: function() { |
330 // This allows the synced-device-manager to render so that it can be set as | 324 // This allows the synced-device-manager to render so that it can be set as |
331 // the scroll target. | 325 // the scroll target. |
332 requestAnimationFrame(function() { | 326 requestAnimationFrame(() => { |
333 md_history.ensureLazyLoaded().then(function() { | 327 md_history.ensureLazyLoaded().then(() => { |
334 // <iron-pages> can occasionally end up with no item selected during | 328 // <iron-pages> can occasionally end up with no item selected during |
335 // tests. | 329 // tests. |
336 if (!this.$.content.selectedItem) | 330 if (!this.$.content.selectedItem) |
337 return; | 331 return; |
338 this.scrollTarget = | 332 this.scrollTarget = |
339 this.$.content.selectedItem.getContentScrollTarget(); | 333 this.$.content.selectedItem.getContentScrollTarget(); |
340 this._scrollHandler(); | 334 this._scrollHandler(); |
341 }.bind(this)); | 335 }); |
342 }.bind(this)); | 336 }); |
343 this.recordHistoryPageView_(); | 337 this.recordHistoryPageView_(); |
344 }, | 338 }, |
345 | 339 |
346 /** | 340 /** |
347 * This computed binding is needed to make the iron-pages selector update when | 341 * This computed binding is needed to make the iron-pages selector update when |
348 * the synced-device-manager is instantiated for the first time. Otherwise the | 342 * the synced-device-manager is instantiated for the first time. Otherwise the |
349 * fallback selection will continue to be used after the corresponding item is | 343 * fallback selection will continue to be used after the corresponding item is |
350 * added as a child of iron-pages. | 344 * added as a child of iron-pages. |
351 * @param {string} selectedPage | 345 * @param {string} selectedPage |
352 * @param {Array} items | 346 * @param {Array} items |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 break; | 378 break; |
385 } | 379 } |
386 break; | 380 break; |
387 } | 381 } |
388 | 382 |
389 md_history.BrowserService.getInstance().recordHistogram( | 383 md_history.BrowserService.getInstance().recordHistogram( |
390 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END | 384 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END |
391 ); | 385 ); |
392 }, | 386 }, |
393 }); | 387 }); |
OLD | NEW |