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 Polymer({ | 5 Polymer({ |
| 6 is: 'history-app', | 6 is: 'history-app', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 showSidebarFooter: Boolean, | 9 showSidebarFooter: Boolean, |
| 10 | 10 |
| 11 // The id of the currently selected page. | 11 // The id of the currently selected page. |
| 12 selectedPage_: {type: String, value: 'history', observer: 'unselectAll'}, | 12 selectedPage_: {type: String, observer: 'unselectAll'}, |
| 13 | 13 |
| 14 // Whether domain-grouped history is enabled. | 14 // Whether domain-grouped history is enabled. |
| 15 grouped_: {type: Boolean, reflectToAttribute: true}, | 15 grouped_: {type: Boolean, reflectToAttribute: true}, |
| 16 | 16 |
| 17 /** @type {!QueryState} */ | 17 /** @type {!QueryState} */ |
| 18 queryState_: { | 18 queryState_: { |
| 19 type: Object, | 19 type: Object, |
| 20 value: function() { | 20 value: function() { |
| 21 return { | 21 return { |
| 22 // Whether the most recent query was incremental. | 22 // Whether the most recent query was incremental. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 ], | 69 ], |
| 70 | 70 |
| 71 // TODO(calamity): Replace these event listeners with data bound properties. | 71 // TODO(calamity): Replace these event listeners with data bound properties. |
| 72 listeners: { | 72 listeners: { |
| 73 'cr-menu-tap': 'onMenuTap_', | 73 'cr-menu-tap': 'onMenuTap_', |
| 74 'history-checkbox-select': 'checkboxSelected', | 74 'history-checkbox-select': 'checkboxSelected', |
| 75 'unselect-all': 'unselectAll', | 75 'unselect-all': 'unselectAll', |
| 76 'delete-selected': 'deleteSelected', | 76 'delete-selected': 'deleteSelected', |
| 77 'search-domain': 'searchDomain_', | 77 'search-domain': 'searchDomain_', |
| 78 'history-close-drawer': 'closeDrawer_', | 78 'history-close-drawer': 'closeDrawer_', |
| 79 'history-view-changed': 'recordHistoryView_', | |
| 79 }, | 80 }, |
| 80 | 81 |
| 81 /** @override */ | 82 /** @override */ |
| 82 ready: function() { | 83 ready: function() { |
| 83 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 84 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 84 | 85 |
| 85 cr.ui.decorate('command', cr.ui.Command); | 86 cr.ui.decorate('command', cr.ui.Command); |
| 86 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 87 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
| 87 document.addEventListener('command', this.onCommand_.bind(this)); | 88 document.addEventListener('command', this.onCommand_.bind(this)); |
| 88 | 89 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 223 |
| 223 /** | 224 /** |
| 224 * Update sign in state of synced device manager after user logs in or out. | 225 * Update sign in state of synced device manager after user logs in or out. |
| 225 * @param {boolean} isUserSignedIn | 226 * @param {boolean} isUserSignedIn |
| 226 */ | 227 */ |
| 227 updateSignInState: function(isUserSignedIn) { | 228 updateSignInState: function(isUserSignedIn) { |
| 228 var syncedDeviceManagerElem = | 229 var syncedDeviceManagerElem = |
| 229 /** @type {HistorySyncedDeviceManagerElement} */this | 230 /** @type {HistorySyncedDeviceManagerElement} */this |
| 230 .$$('history-synced-device-manager'); | 231 .$$('history-synced-device-manager'); |
| 231 if (syncedDeviceManagerElem) | 232 if (syncedDeviceManagerElem) |
| 232 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); | 233 syncedDeviceManagerElem.signInState = isUserSignedIn; |
| 233 }, | 234 }, |
| 234 | 235 |
| 235 /** | 236 /** |
| 236 * @param {string} selectedPage | 237 * @param {string} selectedPage |
| 237 * @return {boolean} | 238 * @return {boolean} |
| 238 * @private | 239 * @private |
| 239 */ | 240 */ |
| 240 syncedTabsSelected_: function(selectedPage) { | 241 syncedTabsSelected_: function(selectedPage) { |
| 241 return selectedPage == 'syncedTabs'; | 242 return selectedPage == 'syncedTabs'; |
| 242 }, | 243 }, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 260 routeDataChanged_: function(page) { | 261 routeDataChanged_: function(page) { |
| 261 this.selectedPage_ = page; | 262 this.selectedPage_ = page; |
| 262 }, | 263 }, |
| 263 | 264 |
| 264 /** | 265 /** |
| 265 * @param {string} selectedPage | 266 * @param {string} selectedPage |
| 266 * @private | 267 * @private |
| 267 */ | 268 */ |
| 268 selectedPageChanged_: function(selectedPage) { | 269 selectedPageChanged_: function(selectedPage) { |
| 269 this.set('routeData_.page', selectedPage); | 270 this.set('routeData_.page', selectedPage); |
| 271 | |
| 272 // Log the current view on the next animation frame to allow the iron-pages | |
| 273 // to detect that the synced-device-manager has been rendered. | |
| 274 requestAnimationFrame(function() { | |
| 275 this.recordHistoryView_(); | |
| 276 }.bind(this)); | |
| 270 }, | 277 }, |
| 271 | 278 |
| 272 /** | 279 /** |
| 273 * This computed binding is needed to make the iron-pages selector update when | 280 * This computed binding is needed to make the iron-pages selector update when |
| 274 * the synced-device-manager is instantiated for the first time. Otherwise the | 281 * the synced-device-manager is instantiated for the first time. Otherwise the |
| 275 * fallback selection will continue to be used after the corresponding item is | 282 * fallback selection will continue to be used after the corresponding item is |
| 276 * added as a child of iron-pages. | 283 * added as a child of iron-pages. |
| 277 * @param {string} selectedPage | 284 * @param {string} selectedPage |
| 278 * @param {Array} items | 285 * @param {Array} items |
| 279 * @return {string} | 286 * @return {string} |
| 280 * @private | 287 * @private |
| 281 */ | 288 */ |
| 282 getSelectedPage_: function(selectedPage, items) { | 289 getSelectedPage_: function(selectedPage, items) { |
| 283 return selectedPage; | 290 return selectedPage; |
| 284 }, | 291 }, |
| 285 | 292 |
| 286 /** @private */ | 293 /** @private */ |
| 287 closeDrawer_: function() { | 294 closeDrawer_: function() { |
| 288 var drawer = this.$$('#drawer'); | 295 var drawer = this.$$('#drawer'); |
| 289 if (drawer) | 296 if (drawer) |
| 290 drawer.close(); | 297 drawer.close(); |
| 291 }, | 298 }, |
| 299 | |
| 300 /** @private */ | |
| 301 recordHistoryView_: function() { | |
| 302 var histogramValue = HistoryViewHistogram.END; | |
| 303 switch (this.$.content.selectedItem.id) { | |
|
tsergeant
2016/08/17 06:03:09
Why not just use this.selectedPage here? Then ther
calamity
2016/08/18 03:11:15
Done. Normalizing sounds... annoying and subtle. I
| |
| 304 case 'history': | |
| 305 switch (this.queryState_.range) { | |
| 306 case HistoryRange.ALL_TIME: | |
| 307 histogramValue = HistoryViewHistogram.HISTORY; | |
| 308 break; | |
| 309 case HistoryRange.WEEK: | |
| 310 histogramValue = HistoryViewHistogram.GROUPED_WEEK; | |
| 311 break; | |
| 312 case HistoryRange.MONTH: | |
| 313 histogramValue = HistoryViewHistogram.GROUPED_MONTH; | |
| 314 break; | |
| 315 } | |
| 316 break; | |
| 317 case 'synced-devices': | |
| 318 var syncedDeviceManager = | |
| 319 /** @type {HistorySyncedDeviceManagerElement} */ this.$.content | |
| 320 .selectedItem; | |
| 321 histogramValue = syncedDeviceManager.signInState ? | |
| 322 HistoryViewHistogram.SYNCED_TABS : | |
| 323 HistoryViewHistogram.SIGNIN_PROMO; | |
| 324 break; | |
| 325 } | |
| 326 | |
| 327 md_history.BrowserService.getInstance().recordHistogram( | |
| 328 'History.HistoryView', histogramValue, HistoryViewHistogram.END | |
| 329 ); | |
| 330 }, | |
| 292 }); | 331 }); |
| OLD | NEW |