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

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

Issue 2255033002: [MD History] Copy stats from the old history page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sidebar_stats
Patch Set: add_stats 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 * opened: boolean,
9 * separatorIndexes: !Array<number>, 9 * separatorIndexes: !Array<number>,
10 * timestamp: number, 10 * timestamp: number,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 /** @private */ 48 /** @private */
49 guestSession_: { 49 guestSession_: {
50 type: Boolean, 50 type: Boolean,
51 value: loadTimeData.getBoolean('isGuestSession'), 51 value: loadTimeData.getBoolean('isGuestSession'),
52 }, 52 },
53 53
54 /** @private */ 54 /** @private */
55 fetchingSyncedTabs_: { 55 fetchingSyncedTabs_: {
56 type: Boolean, 56 type: Boolean,
57 value: false, 57 value: false,
58 } 58 },
59
60 hasSeenForeignData_: Boolean,
59 }, 61 },
60 62
61 listeners: { 63 listeners: {
62 'toggle-menu': 'onToggleMenu_', 64 'toggle-menu': 'onToggleMenu_',
63 'scroll': 'onListScroll_' 65 'scroll': 'onListScroll_'
64 }, 66 },
65 67
66 /** @override */ 68 /** @override */
67 attached: function() { 69 attached: function() {
68 // Update the sign in state. 70 // Update the sign in state.
69 chrome.send('otherDevicesInitialized'); 71 chrome.send('otherDevicesInitialized');
72 md_history.BrowserService.getInstance().recordHistogram(
73 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.INITIALIZED,
74 SyncedTabsHistogram.LIMIT);
70 }, 75 },
71 76
72 /** 77 /**
73 * @param {!ForeignSession} session 78 * @param {!ForeignSession} session
74 * @return {!ForeignDeviceInternal} 79 * @return {!ForeignDeviceInternal}
75 */ 80 */
76 createInternalDevice_: function(session) { 81 createInternalDevice_: function(session) {
77 var tabs = []; 82 var tabs = [];
78 var separatorIndexes = []; 83 var separatorIndexes = [];
79 for (var i = 0; i < session.windows.length; i++) { 84 for (var i = 0; i < session.windows.length; i++) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 126
122 onListScroll_: function() { 127 onListScroll_: function() {
123 var menu = this.$.menu.getIfExists(); 128 var menu = this.$.menu.getIfExists();
124 if (menu) 129 if (menu)
125 menu.closeMenu(); 130 menu.closeMenu();
126 }, 131 },
127 132
128 onToggleMenu_: function(e) { 133 onToggleMenu_: function(e) {
129 this.$.menu.get().then(function(menu) { 134 this.$.menu.get().then(function(menu) {
130 menu.toggleMenu(e.detail.target, e.detail.tag); 135 menu.toggleMenu(e.detail.target, e.detail.tag);
136 if (menu.menuOpen) {
137 md_history.BrowserService.getInstance().recordHistogram(
138 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU,
139 SyncedTabsHistogram.LIMIT);
140 }
131 }); 141 });
132 }, 142 },
133 143
134 onOpenAllTap_: function() { 144 onOpenAllTap_: function() {
135 var menu = assert(this.$.menu.getIfExists()); 145 var menu = assert(this.$.menu.getIfExists());
136 md_history.BrowserService.getInstance().openForeignSessionAllTabs( 146 var browserService = md_history.BrowserService.getInstance();
147 browserService.recordHistogram(
148 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL,
149 SyncedTabsHistogram.LIMIT);
150 browserService.openForeignSessionAllTabs(
137 menu.itemData); 151 menu.itemData);
138 menu.closeMenu(); 152 menu.closeMenu();
139 }, 153 },
140 154
141 onDeleteSessionTap_: function() { 155 onDeleteSessionTap_: function() {
142 var menu = assert(this.$.menu.getIfExists()); 156 var menu = assert(this.$.menu.getIfExists());
143 md_history.BrowserService.getInstance().deleteForeignSession( 157 var browserService = md_history.BrowserService.getInstance();
144 menu.itemData); 158 browserService.recordHistogram(
159 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW,
160 SyncedTabsHistogram.LIMIT);
161 browserService.deleteForeignSession(menu.itemData);
145 menu.closeMenu(); 162 menu.closeMenu();
146 }, 163 },
147 164
148 /** @private */ 165 /** @private */
149 clearDisplayedSyncedDevices_: function() { 166 clearDisplayedSyncedDevices_: function() {
150 this.syncedDevices_ = []; 167 this.syncedDevices_ = [];
151 }, 168 },
152 169
153 /** 170 /**
154 * Decide whether or not should display no synced tabs message. 171 * Decide whether or not should display no synced tabs message.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 * about updating individual tabs rather than replacing whole sessions, but 217 * about updating individual tabs rather than replacing whole sessions, but
201 * this approach seems to have acceptable performance. 218 * this approach seems to have acceptable performance.
202 * @param {?Array<!ForeignSession>} sessionList 219 * @param {?Array<!ForeignSession>} sessionList
203 */ 220 */
204 updateSyncedDevices: function(sessionList) { 221 updateSyncedDevices: function(sessionList) {
205 this.fetchingSyncedTabs_ = false; 222 this.fetchingSyncedTabs_ = false;
206 223
207 if (!sessionList) 224 if (!sessionList)
208 return; 225 return;
209 226
227 if (sessionList.length > 0 && !this.hasSeenForeignData_) {
228 this.hasSeenForeignData_ = true;
229 md_history.BrowserService.getInstance().recordHistogram(
230 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA,
231 SyncedTabsHistogram.LIMIT);
232 }
233
210 // First, update any existing devices that have changed. 234 // First, update any existing devices that have changed.
211 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); 235 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length);
212 for (var i = 0; i < updateCount; i++) { 236 for (var i = 0; i < updateCount; i++) {
213 var oldDevice = this.syncedDevices_[i]; 237 var oldDevice = this.syncedDevices_[i];
214 if (oldDevice.tag != sessionList[i].tag || 238 if (oldDevice.tag != sessionList[i].tag ||
215 oldDevice.timestamp != sessionList[i].timestamp) { 239 oldDevice.timestamp != sessionList[i].timestamp) {
216 this.splice( 240 this.splice(
217 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); 241 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i]));
218 } 242 }
219 } 243 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // User signed in, show the loading message when querying for synced 279 // User signed in, show the loading message when querying for synced
256 // devices. 280 // devices.
257 this.fetchingSyncedTabs_ = true; 281 this.fetchingSyncedTabs_ = true;
258 }, 282 },
259 283
260 searchTermChanged: function(searchTerm) { 284 searchTermChanged: function(searchTerm) {
261 this.clearDisplayedSyncedDevices_(); 285 this.clearDisplayedSyncedDevices_();
262 this.updateSyncedDevices(this.sessionList); 286 this.updateSyncedDevices(this.sessionList);
263 } 287 }
264 }); 288 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698