| 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( |
| 11 'chrome://history/lazy_load.html', resolve, reject, true); | 11 'chrome://history/lazy_load.html', resolve, reject, true); |
| 12 }); | 12 }); |
| 13 } | 13 } |
| 14 return lazyLoadPromise; | 14 return lazyLoadPromise; |
| 15 } | 15 } |
| 16 | 16 |
| 17 return { | 17 return { |
| 18 ensureLazyLoaded: ensureLazyLoaded, | 18 ensureLazyLoaded: ensureLazyLoaded, |
| 19 }; | 19 }; |
| 20 }); | 20 }); |
| 21 | 21 |
| 22 Polymer({ | 22 Polymer({ |
| 23 is: 'history-app', | 23 is: 'history-app', |
| 24 | 24 |
| 25 behaviors: [ | 25 behaviors: [ |
| 26 Polymer.IronScrollTargetBehavior, | 26 Polymer.IronScrollTargetBehavior, |
| 27 WebUIListenerBehavior, | |
| 28 ], | 27 ], |
| 29 | 28 |
| 30 properties: { | 29 properties: { |
| 31 // Used to display notices for profile sign-in status. | 30 // Used to display notices for profile sign-in status. |
| 32 showSidebarFooter: Boolean, | 31 showSidebarFooter: Boolean, |
| 33 | 32 |
| 34 hasSyncedResults: Boolean, | 33 hasSyncedResults: Boolean, |
| 35 | 34 |
| 36 // The id of the currently selected page. | 35 // The id of the currently selected page. |
| 37 selectedPage_: {type: String, observer: 'selectedPageChanged_'}, | 36 selectedPage_: {type: String, observer: 'selectedPageChanged_'}, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 109 |
| 111 /** @override */ | 110 /** @override */ |
| 112 ready: function() { | 111 ready: function() { |
| 113 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 112 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 114 | 113 |
| 115 cr.ui.decorate('command', cr.ui.Command); | 114 cr.ui.decorate('command', cr.ui.Command); |
| 116 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 115 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
| 117 document.addEventListener('command', this.onCommand_.bind(this)); | 116 document.addEventListener('command', this.onCommand_.bind(this)); |
| 118 }, | 117 }, |
| 119 | 118 |
| 120 /** @override */ | |
| 121 attached: function() { | |
| 122 this.addWebUIListener('sign-in-state-updated', | |
| 123 this.updateSignInState.bind(this)); | |
| 124 }, | |
| 125 | |
| 126 onFirstRender: function() { | 119 onFirstRender: function() { |
| 127 setTimeout(function() { | 120 setTimeout(function() { |
| 128 chrome.send( | 121 chrome.send( |
| 129 'metricsHandler:recordTime', | 122 'metricsHandler:recordTime', |
| 130 ['History.ResultsRenderedTime', window.performance.now()]); | 123 ['History.ResultsRenderedTime', window.performance.now()]); |
| 131 }); | 124 }); |
| 132 | 125 |
| 133 // Focus the search field on load. Done here to ensure the history page | 126 // Focus the search field on load. Done here to ensure the history page |
| 134 // is rendered before we try to take focus. | 127 // is rendered before we try to take focus. |
| 135 var searchField = | 128 var searchField = |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 /** | 245 /** |
| 253 * @param {!Array<!ForeignSession>} sessionList Array of objects describing | 246 * @param {!Array<!ForeignSession>} sessionList Array of objects describing |
| 254 * the sessions from other devices. | 247 * the sessions from other devices. |
| 255 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? | 248 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? |
| 256 */ | 249 */ |
| 257 setForeignSessions: function(sessionList, isTabSyncEnabled) { | 250 setForeignSessions: function(sessionList, isTabSyncEnabled) { |
| 258 if (!isTabSyncEnabled) { | 251 if (!isTabSyncEnabled) { |
| 259 var syncedDeviceManagerElem = | 252 var syncedDeviceManagerElem = |
| 260 /** @type {HistorySyncedDeviceManagerElement} */this | 253 /** @type {HistorySyncedDeviceManagerElement} */this |
| 261 .$$('history-synced-device-manager'); | 254 .$$('history-synced-device-manager'); |
| 262 if (syncedDeviceManagerElem) | 255 if (syncedDeviceManagerElem) { |
| 263 syncedDeviceManagerElem.tabSyncDisabled(); | 256 md_history.ensureLazyLoaded().then(function() { |
| 257 syncedDeviceManagerElem.tabSyncDisabled(); |
| 258 }); |
| 259 } |
| 264 return; | 260 return; |
| 265 } | 261 } |
| 266 | 262 |
| 267 this.set('queryResult_.sessionList', sessionList); | 263 this.set('queryResult_.sessionList', sessionList); |
| 268 }, | 264 }, |
| 269 | 265 |
| 270 /** | 266 /** |
| 271 * Called when browsing data is cleared. | 267 * Called when browsing data is cleared. |
| 272 */ | 268 */ |
| 273 historyDeleted: function() { | 269 historyDeleted: function() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 selectedPageChanged_: function() { | 315 selectedPageChanged_: function() { |
| 320 this.unselectAll(); | 316 this.unselectAll(); |
| 321 this.historyViewChanged_(); | 317 this.historyViewChanged_(); |
| 322 }, | 318 }, |
| 323 | 319 |
| 324 /** @private */ | 320 /** @private */ |
| 325 historyViewChanged_: function() { | 321 historyViewChanged_: function() { |
| 326 // This allows the synced-device-manager to render so that it can be set as | 322 // This allows the synced-device-manager to render so that it can be set as |
| 327 // the scroll target. | 323 // the scroll target. |
| 328 requestAnimationFrame(function() { | 324 requestAnimationFrame(function() { |
| 329 // <iron-pages> can occasionally end up with no item selected during | 325 md_history.ensureLazyLoaded().then(function() { |
| 330 // tests. | 326 // <iron-pages> can occasionally end up with no item selected during |
| 331 if (!this.$.content.selectedItem) | 327 // tests. |
| 332 return; | 328 if (!this.$.content.selectedItem) |
| 333 this.scrollTarget = | 329 return; |
| 334 this.$.content.selectedItem.getContentScrollTarget(); | 330 this.scrollTarget = |
| 335 this._scrollHandler(); | 331 this.$.content.selectedItem.getContentScrollTarget(); |
| 332 this._scrollHandler(); |
| 333 }.bind(this)); |
| 336 }.bind(this)); | 334 }.bind(this)); |
| 337 this.recordHistoryPageView_(); | 335 this.recordHistoryPageView_(); |
| 338 }, | 336 }, |
| 339 | 337 |
| 340 /** | 338 /** |
| 341 * This computed binding is needed to make the iron-pages selector update when | 339 * This computed binding is needed to make the iron-pages selector update when |
| 342 * the synced-device-manager is instantiated for the first time. Otherwise the | 340 * the synced-device-manager is instantiated for the first time. Otherwise the |
| 343 * fallback selection will continue to be used after the corresponding item is | 341 * fallback selection will continue to be used after the corresponding item is |
| 344 * added as a child of iron-pages. | 342 * added as a child of iron-pages. |
| 345 * @param {string} selectedPage | 343 * @param {string} selectedPage |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 break; | 376 break; |
| 379 } | 377 } |
| 380 break; | 378 break; |
| 381 } | 379 } |
| 382 | 380 |
| 383 md_history.BrowserService.getInstance().recordHistogram( | 381 md_history.BrowserService.getInstance().recordHistogram( |
| 384 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END | 382 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END |
| 385 ); | 383 ); |
| 386 }, | 384 }, |
| 387 }); | 385 }); |
| OLD | NEW |