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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 | 222 |
| 222 /** | 223 /** |
| 223 * Update sign in state of synced device manager after user logs in or out. | 224 * Update sign in state of synced device manager after user logs in or out. |
| 224 * @param {boolean} isUserSignedIn | 225 * @param {boolean} isUserSignedIn |
| 225 */ | 226 */ |
| 226 updateSignInState: function(isUserSignedIn) { | 227 updateSignInState: function(isUserSignedIn) { |
| 227 var syncedDeviceManagerElem = | 228 var syncedDeviceManagerElem = |
| 228 /** @type {HistorySyncedDeviceManagerElement} */this | 229 /** @type {HistorySyncedDeviceManagerElement} */this |
| 229 .$$('history-synced-device-manager'); | 230 .$$('history-synced-device-manager'); |
| 230 if (syncedDeviceManagerElem) | 231 if (syncedDeviceManagerElem) |
| 231 syncedDeviceManagerElem.updateSignInState(isUserSignedIn); | 232 syncedDeviceManagerElem.signInState = isUserSignedIn; |
| 232 }, | 233 }, |
| 233 | 234 |
| 234 /** | 235 /** |
| 235 * @param {string} selectedPage | 236 * @param {string} selectedPage |
| 236 * @return {boolean} | 237 * @return {boolean} |
| 237 * @private | 238 * @private |
| 238 */ | 239 */ |
| 239 syncedTabsSelected_: function(selectedPage) { | 240 syncedTabsSelected_: function(selectedPage) { |
| 240 return selectedPage == 'syncedTabs'; | 241 return selectedPage == 'syncedTabs'; |
| 241 }, | 242 }, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 259 routeDataChanged_: function(page) { | 260 routeDataChanged_: function(page) { |
| 260 this.selectedPage_ = page; | 261 this.selectedPage_ = page; |
| 261 }, | 262 }, |
| 262 | 263 |
| 263 /** | 264 /** |
| 264 * @param {string} selectedPage | 265 * @param {string} selectedPage |
| 265 * @private | 266 * @private |
| 266 */ | 267 */ |
| 267 selectedPageChanged_: function(selectedPage) { | 268 selectedPageChanged_: function(selectedPage) { |
| 268 this.set('routeData_.page', selectedPage); | 269 this.set('routeData_.page', selectedPage); |
| 270 | |
| 271 // Log the current view on the next animation frame to allow the iron-pages | |
| 272 // to detect that the synced-device-manager has been rendered. | |
| 273 requestAnimationFrame(function() { | |
| 274 this.recordHistoryView_(); | |
| 275 }.bind(this)); | |
| 269 }, | 276 }, |
| 270 | 277 |
| 271 /** | 278 /** |
| 272 * This computed binding is needed to make the iron-pages selector update when | 279 * This computed binding is needed to make the iron-pages selector update when |
| 273 * the synced-device-manager is instantiated for the first time. Otherwise the | 280 * the synced-device-manager is instantiated for the first time. Otherwise the |
| 274 * fallback selection will continue to be used after the corresponding item is | 281 * fallback selection will continue to be used after the corresponding item is |
| 275 * added as a child of iron-pages. | 282 * added as a child of iron-pages. |
| 276 * @param {string} selectedPage | 283 * @param {string} selectedPage |
| 277 * @param {Array} items | 284 * @param {Array} items |
| 278 * @return {string} | 285 * @return {string} |
| 279 * @private | 286 * @private |
| 280 */ | 287 */ |
| 281 getSelectedPage_: function(selectedPage, items) { | 288 getSelectedPage_: function(selectedPage, items) { |
| 282 return selectedPage; | 289 return selectedPage; |
| 283 }, | 290 }, |
| 284 | 291 |
| 285 /** @private */ | 292 /** @private */ |
| 286 closeDrawer_: function() { | 293 closeDrawer_: function() { |
| 287 var drawer = this.$$('#drawer'); | 294 var drawer = this.$$('#drawer'); |
| 288 if (drawer) | 295 if (drawer) |
| 289 drawer.close(); | 296 drawer.close(); |
| 290 }, | 297 }, |
| 298 | |
| 299 /** @private */ | |
| 300 recordHistoryView_: function() { | |
| 301 var histogramValue = HistoryViewHistogram.END; | |
| 302 switch (this.$.content.selectedItem.id) { | |
| 303 case 'history': | |
| 304 switch (this.queryState_.range) { | |
| 305 case HistoryRange.ALL_TIME: | |
| 306 histogramValue = HistoryViewHistogram.HISTORY; | |
| 307 break; | |
| 308 case HistoryRange.WEEK: | |
| 309 histogramValue = HistoryViewHistogram.GROUPED_WEEK; | |
| 310 break; | |
| 311 case HistoryRange.MONTH: | |
| 312 histogramValue = HistoryViewHistogram.GROUPED_MONTH; | |
| 313 break; | |
| 314 } | |
|
tsergeant
2016/08/15 07:05:17
Nit: deindent to line up with switch
calamity
2016/08/17 03:15:28
Done.
| |
| 315 break; | |
| 316 case 'synced-devices': | |
| 317 var syncedDeviceManager = | |
| 318 /** @type {HistorySyncedDeviceManagerElement} */ this.$.content | |
| 319 .selectedItem; | |
| 320 histogramValue = syncedDeviceManager.signInState ? | |
| 321 HistoryViewHistogram.SYNCED_TABS : | |
| 322 HistoryViewHistogram.SIGNIN_PROMO; | |
| 323 break; | |
| 324 } | |
| 325 | |
| 326 md_history.BrowserService.getInstance().recordHistogram([ | |
| 327 'History.HistoryView', histogramValue, HistoryViewHistogram.END | |
| 328 ]); | |
| 329 }, | |
| 291 }); | 330 }); |
| OLD | NEW |