| 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 * separatorIndexes: !Array<number>, | 8 * separatorIndexes: !Array<number>, |
| 9 * timestamp: number, | 9 * timestamp: number, |
| 10 * tabs: !Array<!ForeignSessionTab>, | 10 * tabs: !Array<!ForeignSessionTab>, |
| 11 * tag: string}} | 11 * tag: string}} |
| 12 */ | 12 */ |
| 13 var ForeignDeviceInternal; | 13 var ForeignDeviceInternal; |
| 14 | 14 |
| 15 Polymer({ | 15 Polymer({ |
| 16 is: 'history-synced-device-manager', | 16 is: 'history-synced-device-manager', |
| 17 | 17 |
| 18 properties: { | 18 properties: { |
| 19 /** | 19 /** |
| 20 * @type {?Array<!ForeignSession>} | 20 * @type {?Array<!ForeignSession>} |
| 21 */ | 21 */ |
| 22 sessionList: { | 22 sessionList: { |
| 23 type: Array, | 23 type: Array, |
| 24 observer: 'updateSyncedDevices' | 24 observer: 'updateSyncedDevices' |
| 25 }, | 25 }, |
| 26 | 26 |
| 27 searchedTerm: { | 27 searchTerm: { |
| 28 type: String, | 28 type: String, |
| 29 observer: 'searchTermChanged' | 29 observer: 'searchTermChanged' |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * An array of synced devices with synced tab data. | 33 * An array of synced devices with synced tab data. |
| 34 * @type {!Array<!ForeignDeviceInternal>} | 34 * @type {!Array<!ForeignDeviceInternal>} |
| 35 */ | 35 */ |
| 36 syncedDevices_: { | 36 syncedDevices_: { |
| 37 type: Array, | 37 type: Array, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 57 */ | 57 */ |
| 58 createInternalDevice_: function(session) { | 58 createInternalDevice_: function(session) { |
| 59 var tabs = []; | 59 var tabs = []; |
| 60 var separatorIndexes = []; | 60 var separatorIndexes = []; |
| 61 for (var i = 0; i < session.windows.length; i++) { | 61 for (var i = 0; i < session.windows.length; i++) { |
| 62 var newTabs = session.windows[i].tabs; | 62 var newTabs = session.windows[i].tabs; |
| 63 if (newTabs.length == 0) | 63 if (newTabs.length == 0) |
| 64 continue; | 64 continue; |
| 65 | 65 |
| 66 | 66 |
| 67 if (!this.searchedTerm) { | 67 if (!this.searchTerm) { |
| 68 // Add all the tabs if there is no search term. | 68 // Add all the tabs if there is no search term. |
| 69 tabs = tabs.concat(newTabs); | 69 tabs = tabs.concat(newTabs); |
| 70 separatorIndexes.push(tabs.length - 1); | 70 separatorIndexes.push(tabs.length - 1); |
| 71 } else { | 71 } else { |
| 72 var searchText = this.searchedTerm.toLowerCase(); | 72 var searchText = this.searchTerm.toLowerCase(); |
| 73 var windowAdded = false; | 73 var windowAdded = false; |
| 74 for (var j = 0; j < newTabs.length; j++) { | 74 for (var j = 0; j < newTabs.length; j++) { |
| 75 var tab = newTabs[j]; | 75 var tab = newTabs[j]; |
| 76 if (tab.title.toLowerCase().indexOf(searchText) != -1) { | 76 if (tab.title.toLowerCase().indexOf(searchText) != -1) { |
| 77 tabs.push(tab); | 77 tabs.push(tab); |
| 78 windowAdded = true; | 78 windowAdded = true; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 if (windowAdded) | 81 if (windowAdded) |
| 82 separatorIndexes.push(tabs.length - 1); | 82 separatorIndexes.push(tabs.length - 1); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // User signed out, clear synced device list and show the sign in promo. | 173 // User signed out, clear synced device list and show the sign in promo. |
| 174 if (!isUserSignedIn) { | 174 if (!isUserSignedIn) { |
| 175 this.clearDisplayedSyncedDevices_(); | 175 this.clearDisplayedSyncedDevices_(); |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 // User signed in, show the loading message when querying for synced | 178 // User signed in, show the loading message when querying for synced |
| 179 // devices. | 179 // devices. |
| 180 this.fetchingSyncedTabs_ = true; | 180 this.fetchingSyncedTabs_ = true; |
| 181 }, | 181 }, |
| 182 | 182 |
| 183 searchTermChanged: function(searchedTerm) { | 183 searchTermChanged: function(searchTerm) { |
| 184 this.clearDisplayedSyncedDevices_(); | 184 this.clearDisplayedSyncedDevices_(); |
| 185 this.updateSyncedDevices(this.sessionList); | 185 this.updateSyncedDevices(this.sessionList); |
| 186 } | 186 } |
| 187 }); | 187 }); |
| OLD | NEW |