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

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

Issue 2583353003: MD History: Replace last usage of cr-shared-menu with cr-action-menu. (Closed)
Patch Set: Fix more Created 4 years 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 30 matching lines...) Expand all
41 type: Boolean, 41 type: Boolean,
42 value: loadTimeData.getBoolean('isGuestSession'), 42 value: loadTimeData.getBoolean('isGuestSession'),
43 }, 43 },
44 44
45 /** @private */ 45 /** @private */
46 fetchingSyncedTabs_: { 46 fetchingSyncedTabs_: {
47 type: Boolean, 47 type: Boolean,
48 value: false, 48 value: false,
49 }, 49 },
50 50
51 /** @private */
51 hasSeenForeignData_: Boolean, 52 hasSeenForeignData_: Boolean,
53
54 /**
55 * The session ID referring to the currently active action menu.
56 * @private {?string}
57 */
58 actionMenuModel_: String,
52 }, 59 },
53 60
54 listeners: { 61 listeners: {
55 'toggle-menu': 'onToggleMenu_', 62 'open-menu': 'onOpenMenu_',
56 'scroll': 'onListScroll_',
57 'update-focus-grid': 'updateFocusGrid_', 63 'update-focus-grid': 'updateFocusGrid_',
58 }, 64 },
59 65
60 /** @type {?cr.ui.FocusGrid} */ 66 /** @type {?cr.ui.FocusGrid} */
61 focusGrid_: null, 67 focusGrid_: null,
62 68
63 /** @override */ 69 /** @override */
64 attached: function() { 70 attached: function() {
65 this.focusGrid_ = new cr.ui.FocusGrid(); 71 this.focusGrid_ = new cr.ui.FocusGrid();
66 72
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 timestamp: session.timestamp, 127 timestamp: session.timestamp,
122 tabs: tabs, 128 tabs: tabs,
123 tag: session.tag, 129 tag: session.tag,
124 }; 130 };
125 }, 131 },
126 132
127 /** @private */ 133 /** @private */
128 onSignInTap_: function() { chrome.send('startSignInFlow'); }, 134 onSignInTap_: function() { chrome.send('startSignInFlow'); },
129 135
130 /** @private */ 136 /** @private */
131 onListScroll_: function() { 137 onOpenMenu_: function(e) {
132 var menu = this.$.menu.getIfExists(); 138 var menu = /** @type {CrSharedMenuElement} */ this.$.menu.get();
tsergeant 2016/12/21 00:39:36 CrActionMenuElement, now (it's weird that closure
dpapad 2016/12/21 01:04:48 Done, and yes, something is fishy. Closure should
133 if (menu) 139 this.actionMenuModel_ = e.detail.tag;
134 menu.closeMenu(); 140 menu.showAt(e.detail.target);
141 md_history.BrowserService.getInstance().recordHistogram(
142 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU,
143 SyncedTabsHistogram.LIMIT);
135 }, 144 },
136 145
137 /** @private */ 146 /** @private */
138 onToggleMenu_: function(e) {
139 var menu = /** @type {CrSharedMenuElement} */ this.$.menu.get();
140 menu.toggleMenu(e.detail.target, e.detail.tag);
141 if (menu.menuOpen) {
142 md_history.BrowserService.getInstance().recordHistogram(
143 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU,
144 SyncedTabsHistogram.LIMIT);
145 }
146 },
147
148 /** @private */
149 onOpenAllTap_: function() { 147 onOpenAllTap_: function() {
150 var menu = assert(this.$.menu.getIfExists()); 148 var menu = assert(this.$.menu.getIfExists());
151 var browserService = md_history.BrowserService.getInstance(); 149 var browserService = md_history.BrowserService.getInstance();
152 browserService.recordHistogram( 150 browserService.recordHistogram(
153 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL, 151 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL,
154 SyncedTabsHistogram.LIMIT); 152 SyncedTabsHistogram.LIMIT);
155 browserService.openForeignSessionAllTabs( 153 browserService.openForeignSessionAllTabs(assert(this.actionMenuModel_));
156 menu.itemData); 154 this.actionMenuModel_ = null;
157 menu.closeMenu(); 155 menu.close();
158 }, 156 },
159 157
160 /** @private */ 158 /** @private */
161 updateFocusGrid_: function() { 159 updateFocusGrid_: function() {
162 if (!this.focusGrid_) 160 if (!this.focusGrid_)
163 return; 161 return;
164 162
165 this.focusGrid_.destroy(); 163 this.focusGrid_.destroy();
166 164
167 this.debounce('updateFocusGrid', function() { 165 this.debounce('updateFocusGrid', function() {
168 Polymer.dom(this.root) 166 Polymer.dom(this.root)
169 .querySelectorAll('history-synced-device-card') 167 .querySelectorAll('history-synced-device-card')
170 .reduce( 168 .reduce(
171 function(prev, cur) { 169 function(prev, cur) {
172 return prev.concat(cur.createFocusRows()); 170 return prev.concat(cur.createFocusRows());
173 }, 171 },
174 []) 172 [])
175 .forEach(function(row) { this.focusGrid_.addRow(row); }.bind(this)); 173 .forEach(function(row) { this.focusGrid_.addRow(row); }.bind(this));
176 this.focusGrid_.ensureRowActive(); 174 this.focusGrid_.ensureRowActive();
177 }); 175 });
178 }, 176 },
179 177
180 /** @private */ 178 /** @private */
181 onDeleteSessionTap_: function() { 179 onDeleteSessionTap_: function() {
182 var menu = assert(this.$.menu.getIfExists()); 180 var menu = assert(this.$.menu.getIfExists());
183 var browserService = md_history.BrowserService.getInstance(); 181 var browserService = md_history.BrowserService.getInstance();
184 browserService.recordHistogram( 182 browserService.recordHistogram(
185 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW, 183 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW,
186 SyncedTabsHistogram.LIMIT); 184 SyncedTabsHistogram.LIMIT);
187 browserService.deleteForeignSession(menu.itemData); 185 browserService.deleteForeignSession(assert(this.actionMenuModel_));
188 menu.closeMenu(); 186 this.actionMenuModel_ = null;
187 menu.close();
189 }, 188 },
190 189
191 /** @private */ 190 /** @private */
192 clearDisplayedSyncedDevices_: function() { this.syncedDevices_ = []; }, 191 clearDisplayedSyncedDevices_: function() { this.syncedDevices_ = []; },
193 192
194 /** 193 /**
195 * Decide whether or not should display no synced tabs message. 194 * Decide whether or not should display no synced tabs message.
196 * @param {boolean} signInState 195 * @param {boolean} signInState
197 * @param {number} syncedDevicesLength 196 * @param {number} syncedDevicesLength
198 * @param {boolean} guestSession 197 * @param {boolean} guestSession
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // User signed in, show the loading message when querying for synced 281 // User signed in, show the loading message when querying for synced
283 // devices. 282 // devices.
284 this.fetchingSyncedTabs_ = true; 283 this.fetchingSyncedTabs_ = true;
285 }, 284 },
286 285
287 searchTermChanged: function(searchTerm) { 286 searchTermChanged: function(searchTerm) {
288 this.clearDisplayedSyncedDevices_(); 287 this.clearDisplayedSyncedDevices_();
289 this.updateSyncedDevices(this.sessionList); 288 this.updateSyncedDevices(this.sessionList);
290 } 289 }
291 }); 290 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698