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

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

Issue 2204833003: MD History: Add menu to cards on Synced Tabs page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@history_improve_collapse_button
Patch Set: 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 * separatorIndexes: !Array<number>, 8 * separatorIndexes: !Array<number>,
9 * timestamp: number, 9 * timestamp: number,
10 * tabs: !Array<!ForeignSessionTab>, 10 * tabs: !Array<!ForeignSessionTab>,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 value: loadTimeData.getBoolean('isGuestSession'), 50 value: loadTimeData.getBoolean('isGuestSession'),
51 }, 51 },
52 52
53 /** @private */ 53 /** @private */
54 fetchingSyncedTabs_: { 54 fetchingSyncedTabs_: {
55 type: Boolean, 55 type: Boolean,
56 value: false, 56 value: false,
57 } 57 }
58 }, 58 },
59 59
60 listeners: {
61 'toggle-menu': 'onToggleMenu_',
62 },
63
60 /** @override */ 64 /** @override */
61 attached: function() { 65 attached: function() {
62 // Update the sign in state. 66 // Update the sign in state.
63 chrome.send('otherDevicesInitialized'); 67 chrome.send('otherDevicesInitialized');
64 }, 68 },
65 69
66 /** 70 /**
67 * @param {!ForeignSession} session 71 * @param {!ForeignSession} session
68 * @return {!ForeignDeviceInternal} 72 * @return {!ForeignDeviceInternal}
69 */ 73 */
70 createInternalDevice_: function(session) { 74 createInternalDevice_: function(session) {
71 var tabs = []; 75 var tabs = [];
72 var separatorIndexes = []; 76 var separatorIndexes = [];
73 for (var i = 0; i < session.windows.length; i++) { 77 for (var i = 0; i < session.windows.length; i++) {
74 var windowId = session.windows[i].sessionId; 78 var windowId = session.windows[i].sessionId;
75 var newTabs = session.windows[i].tabs; 79 var newTabs = session.windows[i].tabs;
76 if (newTabs.length == 0) 80 if (newTabs.length == 0)
77 continue; 81 continue;
78 82
79 newTabs.forEach(function(tab) { 83 newTabs.forEach(function(tab) {
80 tab.windowId = windowId; 84 tab.windowId = windowId;
81 }); 85 });
82 86
83 if (!this.searchTerm) { 87 if (!this.searchTerm) {
84 // Add all the tabs if there is no search term. 88 // Add all the tabs if there is no search term.
85 tabs = tabs.concat(newTabs); 89 tabs = tabs.concat(newTabs);
86 separatorIndexes.push(tabs.length - 1); 90 if (i != session.windows.length - 1)
91 separatorIndexes.push(tabs.length - 1);
87 } else { 92 } else {
88 var searchText = this.searchTerm.toLowerCase(); 93 var searchText = this.searchTerm.toLowerCase();
89 var windowAdded = false; 94 var windowAdded = false;
90 for (var j = 0; j < newTabs.length; j++) { 95 for (var j = 0; j < newTabs.length; j++) {
91 var tab = newTabs[j]; 96 var tab = newTabs[j];
92 if (tab.title.toLowerCase().indexOf(searchText) != -1) { 97 if (tab.title.toLowerCase().indexOf(searchText) != -1) {
93 tabs.push(tab); 98 tabs.push(tab);
94 windowAdded = true; 99 windowAdded = true;
95 } 100 }
96 } 101 }
97 if (windowAdded) 102 if (windowAdded && i != session.windows.length - 1)
98 separatorIndexes.push(tabs.length - 1); 103 separatorIndexes.push(tabs.length - 1);
calamity 2016/08/04 07:30:05 Move this outside the if-else and move windowAdded
tsergeant 2016/08/05 02:40:02 Done.
99 } 104 }
100 105
101 } 106 }
102 return { 107 return {
103 device: session.name, 108 device: session.name,
104 lastUpdateTime: '– ' + session.modifiedTime, 109 lastUpdateTime: '– ' + session.modifiedTime,
105 separatorIndexes: separatorIndexes, 110 separatorIndexes: separatorIndexes,
106 timestamp: session.timestamp, 111 timestamp: session.timestamp,
107 tabs: tabs, 112 tabs: tabs,
108 tag: session.tag, 113 tag: session.tag,
109 }; 114 };
110 }, 115 },
111 116
112
113 onSignInTap_: function() { 117 onSignInTap_: function() {
114 chrome.send('SyncSetupShowSetupUI'); 118 chrome.send('SyncSetupShowSetupUI');
115 chrome.send('SyncSetupStartSignIn', [false]); 119 chrome.send('SyncSetupStartSignIn', [false]);
116 }, 120 },
117 121
122 onToggleMenu_: function(e) {
123 this.$.menu.toggleMenu(e.detail.target, e.detail.tag);
124 },
125
126 onOpenAllTap_: function() {
127 md_history.BrowserService.getInstance().openForeignSessionAllTabs(
128 this.$.menu.itemData);
129 this.$.menu.closeMenu();
130 },
131
132 onDeleteSessionTap_: function() {
133 md_history.BrowserService.getInstance().deleteForeignSession(
134 this.$.menu.itemData);
135 this.$.menu.closeMenu();
136 },
137
118 /** @private */ 138 /** @private */
119 clearDisplayedSyncedDevices_: function() { 139 clearDisplayedSyncedDevices_: function() {
120 this.syncedDevices_ = []; 140 this.syncedDevices_ = [];
121 }, 141 },
122 142
123 /** 143 /**
124 * Decide whether or not should display no synced tabs message. 144 * Decide whether or not should display no synced tabs message.
125 * @param {boolean} signInState 145 * @param {boolean} signInState
126 * @param {number} syncedDevicesLength 146 * @param {number} syncedDevicesLength
127 * @param {boolean} guestSession 147 * @param {boolean} guestSession
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // User signed in, show the loading message when querying for synced 230 // User signed in, show the loading message when querying for synced
211 // devices. 231 // devices.
212 this.fetchingSyncedTabs_ = true; 232 this.fetchingSyncedTabs_ = true;
213 }, 233 },
214 234
215 searchTermChanged: function(searchTerm) { 235 searchTermChanged: function(searchTerm) {
216 this.clearDisplayedSyncedDevices_(); 236 this.clearDisplayedSyncedDevices_();
217 this.updateSyncedDevices(this.sessionList); 237 this.updateSyncedDevices(this.sessionList);
218 } 238 }
219 }); 239 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698