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

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

Issue 2578013002: [MD History] clang-format all javascript. (Closed)
Patch Set: rebase Created 3 years, 12 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
« no previous file with comments | « chrome/browser/resources/md_history/synced_device_card.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * opened: boolean,
9 * separatorIndexes: !Array<number>, 9 * separatorIndexes: !Array<number>,
10 * timestamp: number, 10 * timestamp: number,
11 * tabs: !Array<!ForeignSessionTab>, 11 * tabs: !Array<!ForeignSessionTab>,
12 * tag: string}} 12 * tag: string}}
13 */ 13 */
14 var ForeignDeviceInternal; 14 var ForeignDeviceInternal;
15 15
16 Polymer({ 16 Polymer({
17 is: 'history-synced-device-manager', 17 is: 'history-synced-device-manager',
18 18
19 properties: { 19 properties: {
20 /** 20 /**
21 * @type {?Array<!ForeignSession>} 21 * @type {?Array<!ForeignSession>}
22 */ 22 */
23 sessionList: {type: Array, observer: 'updateSyncedDevices'}, 23 sessionList: {
24 type: Array,
25 observer: 'updateSyncedDevices',
26 },
24 27
25 searchTerm: {type: String, observer: 'searchTermChanged'}, 28 searchTerm: {
29 type: String,
30 observer: 'searchTermChanged',
31 },
26 32
27 /** 33 /**
28 * An array of synced devices with synced tab data. 34 * An array of synced devices with synced tab data.
29 * @type {!Array<!ForeignDeviceInternal>} 35 * @type {!Array<!ForeignDeviceInternal>}
30 */ 36 */
31 syncedDevices_: {type: Array, value: function() { return []; }}, 37 syncedDevices_: {
38 type: Array,
39 value: function() { return []; },
40 },
32 41
33 /** @private */ 42 /** @private */
34 signInState: { 43 signInState: {
35 type: Boolean, 44 type: Boolean,
36 observer: 'signInStateChanged_', 45 observer: 'signInStateChanged_',
37 }, 46 },
38 47
39 /** @private */ 48 /** @private */
40 guestSession_: { 49 guestSession_: {
41 type: Boolean, 50 type: Boolean,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 */ 93 */
85 createInternalDevice_: function(session) { 94 createInternalDevice_: function(session) {
86 var tabs = []; 95 var tabs = [];
87 var separatorIndexes = []; 96 var separatorIndexes = [];
88 for (var i = 0; i < session.windows.length; i++) { 97 for (var i = 0; i < session.windows.length; i++) {
89 var windowId = session.windows[i].sessionId; 98 var windowId = session.windows[i].sessionId;
90 var newTabs = session.windows[i].tabs; 99 var newTabs = session.windows[i].tabs;
91 if (newTabs.length == 0) 100 if (newTabs.length == 0)
92 continue; 101 continue;
93 102
94 newTabs.forEach(function(tab) { 103 newTabs.forEach(function(tab) { tab.windowId = windowId; });
95 tab.windowId = windowId;
96 });
97 104
98 var windowAdded = false; 105 var windowAdded = false;
99 if (!this.searchTerm) { 106 if (!this.searchTerm) {
100 // Add all the tabs if there is no search term. 107 // Add all the tabs if there is no search term.
101 tabs = tabs.concat(newTabs); 108 tabs = tabs.concat(newTabs);
102 windowAdded = true; 109 windowAdded = true;
103 } else { 110 } else {
104 var searchText = this.searchTerm.toLowerCase(); 111 var searchText = this.searchTerm.toLowerCase();
105 for (var j = 0; j < newTabs.length; j++) { 112 for (var j = 0; j < newTabs.length; j++) {
106 var tab = newTabs[j]; 113 var tab = newTabs[j];
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 152 }
146 }, 153 },
147 154
148 /** @private */ 155 /** @private */
149 onOpenAllTap_: function() { 156 onOpenAllTap_: function() {
150 var menu = assert(this.$.menu.getIfExists()); 157 var menu = assert(this.$.menu.getIfExists());
151 var browserService = md_history.BrowserService.getInstance(); 158 var browserService = md_history.BrowserService.getInstance();
152 browserService.recordHistogram( 159 browserService.recordHistogram(
153 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL, 160 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL,
154 SyncedTabsHistogram.LIMIT); 161 SyncedTabsHistogram.LIMIT);
155 browserService.openForeignSessionAllTabs( 162 browserService.openForeignSessionAllTabs(menu.itemData);
156 menu.itemData);
157 menu.closeMenu(); 163 menu.closeMenu();
158 }, 164 },
159 165
160 /** @private */ 166 /** @private */
161 updateFocusGrid_: function() { 167 updateFocusGrid_: function() {
162 if (!this.focusGrid_) 168 if (!this.focusGrid_)
163 return; 169 return;
164 170
165 this.focusGrid_.destroy(); 171 this.focusGrid_.destroy();
166 172
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 */ 251 */
246 updateSyncedDevices: function(sessionList) { 252 updateSyncedDevices: function(sessionList) {
247 this.fetchingSyncedTabs_ = false; 253 this.fetchingSyncedTabs_ = false;
248 254
249 if (!sessionList) 255 if (!sessionList)
250 return; 256 return;
251 257
252 if (sessionList.length > 0 && !this.hasSeenForeignData_) { 258 if (sessionList.length > 0 && !this.hasSeenForeignData_) {
253 this.hasSeenForeignData_ = true; 259 this.hasSeenForeignData_ = true;
254 md_history.BrowserService.getInstance().recordHistogram( 260 md_history.BrowserService.getInstance().recordHistogram(
255 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA, 261 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA,
256 SyncedTabsHistogram.LIMIT); 262 SyncedTabsHistogram.LIMIT);
257 } 263 }
258 264
259 var devices = []; 265 var devices = [];
260 sessionList.forEach(function(session) { 266 sessionList.forEach(function(session) {
261 var device = this.createInternalDevice_(session); 267 var device = this.createInternalDevice_(session);
262 if (device.tabs.length != 0) 268 if (device.tabs.length != 0)
263 devices.push(device); 269 devices.push(device);
264 }.bind(this)); 270 }.bind(this));
265 271
266 this.syncedDevices_ = devices; 272 this.syncedDevices_ = devices;
(...skipping 15 matching lines...) Expand all
282 // User signed in, show the loading message when querying for synced 288 // User signed in, show the loading message when querying for synced
283 // devices. 289 // devices.
284 this.fetchingSyncedTabs_ = true; 290 this.fetchingSyncedTabs_ = true;
285 }, 291 },
286 292
287 searchTermChanged: function(searchTerm) { 293 searchTermChanged: function(searchTerm) {
288 this.clearDisplayedSyncedDevices_(); 294 this.clearDisplayedSyncedDevices_();
289 this.updateSyncedDevices(this.sessionList); 295 this.updateSyncedDevices(this.sessionList);
290 } 296 }
291 }); 297 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/synced_device_card.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698