Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/resources/md_history/synced_device_manager.js

Issue 2251323002: MD History: Synced Tabs fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@history_css_shuffle
Patch Set: Review comment, revulcanize Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 * separatorIndexes: !Array<number>, 9 * separatorIndexes: !Array<number>,
9 * timestamp: number, 10 * timestamp: number,
10 * tabs: !Array<!ForeignSessionTab>, 11 * tabs: !Array<!ForeignSessionTab>,
11 * tag: string}} 12 * tag: string}}
12 */ 13 */
13 var ForeignDeviceInternal; 14 var ForeignDeviceInternal;
14 15
15 Polymer({ 16 Polymer({
16 is: 'history-synced-device-manager', 17 is: 'history-synced-device-manager',
17 18
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 53
53 /** @private */ 54 /** @private */
54 fetchingSyncedTabs_: { 55 fetchingSyncedTabs_: {
55 type: Boolean, 56 type: Boolean,
56 value: false, 57 value: false,
57 } 58 }
58 }, 59 },
59 60
60 listeners: { 61 listeners: {
61 'toggle-menu': 'onToggleMenu_', 62 'toggle-menu': 'onToggleMenu_',
63 'scroll': 'onListScroll_'
62 }, 64 },
63 65
64 /** @override */ 66 /** @override */
65 attached: function() { 67 attached: function() {
66 // Update the sign in state. 68 // Update the sign in state.
67 chrome.send('otherDevicesInitialized'); 69 chrome.send('otherDevicesInitialized');
68 }, 70 },
69 71
70 /** 72 /**
71 * @param {!ForeignSession} session 73 * @param {!ForeignSession} session
(...skipping 26 matching lines...) Expand all
98 windowAdded = true; 100 windowAdded = true;
99 } 101 }
100 } 102 }
101 } 103 }
102 if (windowAdded && i != session.windows.length - 1) 104 if (windowAdded && i != session.windows.length - 1)
103 separatorIndexes.push(tabs.length - 1); 105 separatorIndexes.push(tabs.length - 1);
104 } 106 }
105 return { 107 return {
106 device: session.name, 108 device: session.name,
107 lastUpdateTime: '– ' + session.modifiedTime, 109 lastUpdateTime: '– ' + session.modifiedTime,
110 opened: true,
108 separatorIndexes: separatorIndexes, 111 separatorIndexes: separatorIndexes,
109 timestamp: session.timestamp, 112 timestamp: session.timestamp,
110 tabs: tabs, 113 tabs: tabs,
111 tag: session.tag, 114 tag: session.tag,
112 }; 115 };
113 }, 116 },
114 117
115 onSignInTap_: function() { 118 onSignInTap_: function() {
116 chrome.send('startSignInFlow'); 119 chrome.send('startSignInFlow');
117 }, 120 },
118 121
122 onListScroll_: function() {
123 var menu = this.$.menu.getIfExists();
124 if (menu)
125 menu.closeMenu();
126 },
127
119 onToggleMenu_: function(e) { 128 onToggleMenu_: function(e) {
120 this.$.menu.get().then(function(menu) { 129 this.$.menu.get().then(function(menu) {
121 menu.toggleMenu(e.detail.target, e.detail.tag); 130 menu.toggleMenu(e.detail.target, e.detail.tag);
122 }); 131 });
123 }, 132 },
124 133
125 onOpenAllTap_: function() { 134 onOpenAllTap_: function() {
126 var menu = assert(this.$.menu.getIfExists()); 135 var menu = assert(this.$.menu.getIfExists());
127 md_history.BrowserService.getInstance().openForeignSessionAllTabs( 136 md_history.BrowserService.getInstance().openForeignSessionAllTabs(
128 menu.itemData); 137 menu.itemData);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); 211 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length);
203 for (var i = 0; i < updateCount; i++) { 212 for (var i = 0; i < updateCount; i++) {
204 var oldDevice = this.syncedDevices_[i]; 213 var oldDevice = this.syncedDevices_[i];
205 if (oldDevice.tag != sessionList[i].tag || 214 if (oldDevice.tag != sessionList[i].tag ||
206 oldDevice.timestamp != sessionList[i].timestamp) { 215 oldDevice.timestamp != sessionList[i].timestamp) {
207 this.splice( 216 this.splice(
208 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); 217 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i]));
209 } 218 }
210 } 219 }
211 220
212 // Then, append any new devices. 221 if (sessionList.length >= this.syncedDevices_.length) {
213 for (var i = updateCount; i < sessionList.length; i++) { 222 // The list grew; append new items.
214 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); 223 for (var i = updateCount; i < sessionList.length; i++) {
224 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i]));
225 }
226 } else {
227 // The list shrank; remove deleted items.
228 this.splice(
229 'syncedDevices_', updateCount,
230 this.syncedDevices_.length - updateCount);
215 } 231 }
216 }, 232 },
217 233
218 /** 234 /**
219 * End fetching synced tabs when sync is disabled. 235 * End fetching synced tabs when sync is disabled.
220 */ 236 */
221 tabSyncDisabled: function() { 237 tabSyncDisabled: function() {
222 this.fetchingSyncedTabs_ = false; 238 this.fetchingSyncedTabs_ = false;
223 this.clearDisplayedSyncedDevices_(); 239 this.clearDisplayedSyncedDevices_();
224 }, 240 },
(...skipping 20 matching lines...) Expand all
245 // User signed in, show the loading message when querying for synced 261 // User signed in, show the loading message when querying for synced
246 // devices. 262 // devices.
247 this.fetchingSyncedTabs_ = true; 263 this.fetchingSyncedTabs_ = true;
248 }, 264 },
249 265
250 searchTermChanged: function(searchTerm) { 266 searchTermChanged: function(searchTerm) {
251 this.clearDisplayedSyncedDevices_(); 267 this.clearDisplayedSyncedDevices_();
252 this.updateSyncedDevices(this.sessionList); 268 this.updateSyncedDevices(this.sessionList);
253 } 269 }
254 }); 270 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698