| 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 /** | 5 /** |
| 6 * @typedef {{device: string, | 6 * @typedef {{device: string, |
| 7 * lastUpdateTime: string, | 7 * lastUpdateTime: string, |
| 8 * opened: boolean, | 8 * opened: boolean, |
| 9 * separatorIndexes: !Array<number>, | 9 * separatorIndexes: !Array<number>, |
| 10 * timestamp: number, | 10 * timestamp: number, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * @type {?Array<!ForeignSession>} | 21 * @type {?Array<!ForeignSession>} |
| 22 */ | 22 */ |
| 23 sessionList: {type: Array, observer: 'updateSyncedDevices'}, | 23 sessionList: {type: Array, observer: 'updateSyncedDevices'}, |
| 24 | 24 |
| 25 searchTerm: {type: String, observer: 'searchTermChanged'}, | 25 searchTerm: {type: String, observer: 'searchTermChanged'}, |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * An array of synced devices with synced tab data. | 28 * An array of synced devices with synced tab data. |
| 29 * @type {!Array<!ForeignDeviceInternal>} | 29 * @type {!Array<!ForeignDeviceInternal>} |
| 30 */ | 30 */ |
| 31 syncedDevices_: {type: Array, value: function() { return []; }}, | 31 syncedDevices_: {type: Array, value: () => []}, |
| 32 | 32 |
| 33 /** @private */ | 33 /** @private */ |
| 34 signInState: { | 34 signInState: { |
| 35 type: Boolean, | 35 type: Boolean, |
| 36 observer: 'signInStateChanged_', | 36 observer: 'signInStateChanged_', |
| 37 }, | 37 }, |
| 38 | 38 |
| 39 /** @private */ | 39 /** @private */ |
| 40 guestSession_: { | 40 guestSession_: { |
| 41 type: Boolean, | 41 type: Boolean, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 /** @private */ | 160 /** @private */ |
| 161 updateFocusGrid_: function() { | 161 updateFocusGrid_: function() { |
| 162 if (!this.focusGrid_) | 162 if (!this.focusGrid_) |
| 163 return; | 163 return; |
| 164 | 164 |
| 165 this.focusGrid_.destroy(); | 165 this.focusGrid_.destroy(); |
| 166 | 166 |
| 167 this.debounce('updateFocusGrid', function() { | 167 this.debounce('updateFocusGrid', function() { |
| 168 Polymer.dom(this.root) | 168 Polymer.dom(this.root) |
| 169 .querySelectorAll('history-synced-device-card') | 169 .querySelectorAll('history-synced-device-card') |
| 170 .reduce( | 170 .reduce((prev, cur) => prev.concat(cur.createFocusRows()), []) |
| 171 function(prev, cur) { | 171 .forEach(row => this.focusGrid_.addRow(row)); |
| 172 return prev.concat(cur.createFocusRows()); | |
| 173 }, | |
| 174 []) | |
| 175 .forEach(function(row) { this.focusGrid_.addRow(row); }.bind(this)); | |
| 176 this.focusGrid_.ensureRowActive(); | 172 this.focusGrid_.ensureRowActive(); |
| 177 }); | 173 }); |
| 178 }, | 174 }, |
| 179 | 175 |
| 180 /** @private */ | 176 /** @private */ |
| 181 onDeleteSessionTap_: function() { | 177 onDeleteSessionTap_: function() { |
| 182 var menu = assert(this.$.menu.getIfExists()); | 178 var menu = assert(this.$.menu.getIfExists()); |
| 183 var browserService = md_history.BrowserService.getInstance(); | 179 var browserService = md_history.BrowserService.getInstance(); |
| 184 browserService.recordHistogram( | 180 browserService.recordHistogram( |
| 185 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW, | 181 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return; | 246 return; |
| 251 | 247 |
| 252 if (sessionList.length > 0 && !this.hasSeenForeignData_) { | 248 if (sessionList.length > 0 && !this.hasSeenForeignData_) { |
| 253 this.hasSeenForeignData_ = true; | 249 this.hasSeenForeignData_ = true; |
| 254 md_history.BrowserService.getInstance().recordHistogram( | 250 md_history.BrowserService.getInstance().recordHistogram( |
| 255 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA, | 251 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA, |
| 256 SyncedTabsHistogram.LIMIT); | 252 SyncedTabsHistogram.LIMIT); |
| 257 } | 253 } |
| 258 | 254 |
| 259 var devices = []; | 255 var devices = []; |
| 260 sessionList.forEach(function(session) { | 256 sessionList.forEach(session => { |
| 261 var device = this.createInternalDevice_(session); | 257 var device = this.createInternalDevice_(session); |
| 262 if (device.tabs.length != 0) | 258 if (device.tabs.length != 0) |
| 263 devices.push(device); | 259 devices.push(device); |
| 264 }.bind(this)); | 260 }); |
| 265 | 261 |
| 266 this.syncedDevices_ = devices; | 262 this.syncedDevices_ = devices; |
| 267 }, | 263 }, |
| 268 | 264 |
| 269 /** | 265 /** |
| 270 * Get called when user's sign in state changes, this will affect UI of synced | 266 * Get called when user's sign in state changes, this will affect UI of synced |
| 271 * tabs page. Sign in promo gets displayed when user is signed out, and | 267 * tabs page. Sign in promo gets displayed when user is signed out, and |
| 272 * different messages are shown when there are no synced tabs. | 268 * different messages are shown when there are no synced tabs. |
| 273 */ | 269 */ |
| 274 signInStateChanged_: function() { | 270 signInStateChanged_: function() { |
| 275 this.fire('history-view-changed'); | 271 this.fire('history-view-changed'); |
| 276 | 272 |
| 277 // User signed out, clear synced device list and show the sign in promo. | 273 // User signed out, clear synced device list and show the sign in promo. |
| 278 if (!this.signInState) { | 274 if (!this.signInState) { |
| 279 this.clearDisplayedSyncedDevices_(); | 275 this.clearDisplayedSyncedDevices_(); |
| 280 return; | 276 return; |
| 281 } | 277 } |
| 282 // User signed in, show the loading message when querying for synced | 278 // User signed in, show the loading message when querying for synced |
| 283 // devices. | 279 // devices. |
| 284 this.fetchingSyncedTabs_ = true; | 280 this.fetchingSyncedTabs_ = true; |
| 285 }, | 281 }, |
| 286 | 282 |
| 287 searchTermChanged: function(searchTerm) { | 283 searchTermChanged: function(searchTerm) { |
| 288 this.clearDisplayedSyncedDevices_(); | 284 this.clearDisplayedSyncedDevices_(); |
| 289 this.updateSyncedDevices(this.sessionList); | 285 this.updateSyncedDevices(this.sessionList); |
| 290 } | 286 } |
| 291 }); | 287 }); |
| OLD | NEW |