Chromium Code Reviews| 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: [Polymer.IronScrollTargetBehavior], | 25 behaviors: [ |
| 26 Polymer.IronScrollTargetBehavior, | |
| 27 WebUIListenerBehavior, | |
| 28 ], | |
| 26 | 29 |
| 27 properties: { | 30 properties: { |
| 28 // Used to display notices for profile sign-in status. | 31 // Used to display notices for profile sign-in status. |
| 29 showSidebarFooter: Boolean, | 32 showSidebarFooter: Boolean, |
| 30 | 33 |
| 31 hasSyncedResults: Boolean, | 34 hasSyncedResults: Boolean, |
| 32 | 35 |
| 33 // The id of the currently selected page. | 36 // The id of the currently selected page. |
| 34 selectedPage_: {type: String, observer: 'selectedPageChanged_'}, | 37 selectedPage_: {type: String, observer: 'selectedPageChanged_'}, |
| 35 | 38 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 sessionList: null, | 70 sessionList: null, |
| 68 }; | 71 }; |
| 69 } | 72 } |
| 70 }, | 73 }, |
| 71 | 74 |
| 72 // True if the window is narrow enough for the page to have a drawer. | 75 // True if the window is narrow enough for the page to have a drawer. |
| 73 hasDrawer_: Boolean, | 76 hasDrawer_: Boolean, |
| 74 | 77 |
| 75 isUserSignedIn_: { | 78 isUserSignedIn_: { |
| 76 type: Boolean, | 79 type: Boolean, |
| 77 // Updated on synced-device-manager attach by chrome.sending | 80 // Updated on synced-device-manager. |
| 78 // 'otherDevicesInitialized'. | |
| 79 value: loadTimeData.getBoolean('isUserSignedIn'), | 81 value: loadTimeData.getBoolean('isUserSignedIn'), |
| 80 }, | 82 }, |
| 81 | 83 |
| 82 toolbarShadow_: { | 84 toolbarShadow_: { |
| 83 type: Boolean, | 85 type: Boolean, |
| 84 reflectToAttribute: true, | 86 reflectToAttribute: true, |
| 85 notify: true, | 87 notify: true, |
| 86 } | 88 } |
| 87 }, | 89 }, |
| 88 | 90 |
| 89 // TODO(calamity): Replace these event listeners with data bound properties. | 91 // TODO(calamity): Replace these event listeners with data bound properties. |
| 90 listeners: { | 92 listeners: { |
| 91 'cr-menu-tap': 'onMenuTap_', | 93 'cr-menu-tap': 'onMenuTap_', |
| 92 'history-checkbox-select': 'checkboxSelected', | 94 'history-checkbox-select': 'checkboxSelected', |
| 93 'unselect-all': 'unselectAll', | 95 'unselect-all': 'unselectAll', |
| 94 'delete-selected': 'deleteSelected', | 96 'delete-selected': 'deleteSelected', |
| 95 'history-close-drawer': 'closeDrawer_', | 97 'history-close-drawer': 'closeDrawer_', |
| 96 'history-view-changed': 'historyViewChanged_', | 98 'history-view-changed': 'historyViewChanged_', |
| 97 }, | 99 }, |
| 98 | 100 |
| 99 /** @override */ | 101 /** @override */ |
| 100 ready: function() { | 102 ready: function() { |
| 101 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 103 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 102 | 104 |
| 103 cr.ui.decorate('command', cr.ui.Command); | 105 cr.ui.decorate('command', cr.ui.Command); |
| 104 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 106 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
| 105 document.addEventListener('command', this.onCommand_.bind(this)); | 107 document.addEventListener('command', this.onCommand_.bind(this)); |
| 106 }, | 108 }, |
| 107 | 109 |
| 110 /** @override */ | |
| 111 attached: function() { | |
| 112 this.addWebUIListener('sign-in-state-updated', | |
| 113 this.updateSignInState.bind(this)); | |
|
Dan Beam
2016/09/28 03:56:49
this part is perfect :)
| |
| 114 }, | |
| 115 | |
| 108 onFirstRender: function() { | 116 onFirstRender: function() { |
| 109 setTimeout(function() { | 117 setTimeout(function() { |
| 110 chrome.send( | 118 chrome.send( |
| 111 'metricsHandler:recordTime', | 119 'metricsHandler:recordTime', |
| 112 ['History.ResultsRenderedTime', window.performance.now()]); | 120 ['History.ResultsRenderedTime', window.performance.now()]); |
| 113 }); | 121 }); |
| 114 | 122 |
| 115 // Focus the search field on load. Done here to ensure the history page | 123 // Focus the search field on load. Done here to ensure the history page |
| 116 // is rendered before we try to take focus. | 124 // is rendered before we try to take focus. |
| 117 if (!this.hasDrawer_) { | 125 if (!this.hasDrawer_) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 break; | 347 break; |
| 340 } | 348 } |
| 341 break; | 349 break; |
| 342 } | 350 } |
| 343 | 351 |
| 344 md_history.BrowserService.getInstance().recordHistogram( | 352 md_history.BrowserService.getInstance().recordHistogram( |
| 345 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END | 353 'History.HistoryPageView', histogramValue, HistoryPageViewHistogram.END |
| 346 ); | 354 ); |
| 347 }, | 355 }, |
| 348 }); | 356 }); |
| OLD | NEW |