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

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: Test found real subtle bug (display flex overriding [hidden] attribute) 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 59
60 /** @private */
60 hasSeenForeignData_: Boolean, 61 hasSeenForeignData_: Boolean,
62
63 /**
64 * The session ID referring to the currently active action menu.
65 * @private {?string}
66 */
67 actionMenuModel_: String,
61 }, 68 },
62 69
63 listeners: { 70 listeners: {
64 'toggle-menu': 'onToggleMenu_', 71 'open-menu': 'onOpenMenu_',
65 'scroll': 'onListScroll_',
66 'update-focus-grid': 'updateFocusGrid_', 72 'update-focus-grid': 'updateFocusGrid_',
67 }, 73 },
68 74
69 /** @type {?cr.ui.FocusGrid} */ 75 /** @type {?cr.ui.FocusGrid} */
70 focusGrid_: null, 76 focusGrid_: null,
71 77
72 /** @override */ 78 /** @override */
73 attached: function() { 79 attached: function() {
74 this.focusGrid_ = new cr.ui.FocusGrid(); 80 this.focusGrid_ = new cr.ui.FocusGrid();
75 81
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 timestamp: session.timestamp, 134 timestamp: session.timestamp,
129 tabs: tabs, 135 tabs: tabs,
130 tag: session.tag, 136 tag: session.tag,
131 }; 137 };
132 }, 138 },
133 139
134 /** @private */ 140 /** @private */
135 onSignInTap_: function() { chrome.send('startSignInFlow'); }, 141 onSignInTap_: function() { chrome.send('startSignInFlow'); },
136 142
137 /** @private */ 143 /** @private */
138 onListScroll_: function() { 144 onOpenMenu_: function(e) {
139 var menu = this.$.menu.getIfExists(); 145 var menu = /** @type {CrActionMenuElement} */ this.$.menu.get();
140 if (menu) 146 this.actionMenuModel_ = e.detail.tag;
141 menu.closeMenu(); 147 menu.showAt(e.detail.target);
148 md_history.BrowserService.getInstance().recordHistogram(
149 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU,
150 SyncedTabsHistogram.LIMIT);
142 }, 151 },
143 152
144 /** @private */ 153 /** @private */
145 onToggleMenu_: function(e) {
146 var menu = /** @type {CrSharedMenuElement} */ this.$.menu.get();
147 menu.toggleMenu(e.detail.target, e.detail.tag);
148 if (menu.menuOpen) {
149 md_history.BrowserService.getInstance().recordHistogram(
150 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU,
151 SyncedTabsHistogram.LIMIT);
152 }
153 },
154
155 /** @private */
156 onOpenAllTap_: function() { 154 onOpenAllTap_: function() {
157 var menu = assert(this.$.menu.getIfExists()); 155 var menu = assert(this.$.menu.getIfExists());
158 var browserService = md_history.BrowserService.getInstance(); 156 var browserService = md_history.BrowserService.getInstance();
159 browserService.recordHistogram( 157 browserService.recordHistogram(
160 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL, 158 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL,
161 SyncedTabsHistogram.LIMIT); 159 SyncedTabsHistogram.LIMIT);
162 browserService.openForeignSessionAllTabs(menu.itemData); 160 browserService.openForeignSessionAllTabs(assert(this.actionMenuModel_));
163 menu.closeMenu(); 161 this.actionMenuModel_ = null;
162 menu.close();
164 }, 163 },
165 164
166 /** @private */ 165 /** @private */
167 updateFocusGrid_: function() { 166 updateFocusGrid_: function() {
168 if (!this.focusGrid_) 167 if (!this.focusGrid_)
169 return; 168 return;
170 169
171 this.focusGrid_.destroy(); 170 this.focusGrid_.destroy();
172 171
173 this.debounce('updateFocusGrid', function() { 172 this.debounce('updateFocusGrid', function() {
174 Polymer.dom(this.root) 173 Polymer.dom(this.root)
175 .querySelectorAll('history-synced-device-card') 174 .querySelectorAll('history-synced-device-card')
176 .reduce( 175 .reduce(
177 function(prev, cur) { 176 function(prev, cur) {
178 return prev.concat(cur.createFocusRows()); 177 return prev.concat(cur.createFocusRows());
179 }, 178 },
180 []) 179 [])
181 .forEach(function(row) { this.focusGrid_.addRow(row); }.bind(this)); 180 .forEach(function(row) { this.focusGrid_.addRow(row); }.bind(this));
182 this.focusGrid_.ensureRowActive(); 181 this.focusGrid_.ensureRowActive();
183 }); 182 });
184 }, 183 },
185 184
186 /** @private */ 185 /** @private */
187 onDeleteSessionTap_: function() { 186 onDeleteSessionTap_: function() {
188 var menu = assert(this.$.menu.getIfExists()); 187 var menu = assert(this.$.menu.getIfExists());
189 var browserService = md_history.BrowserService.getInstance(); 188 var browserService = md_history.BrowserService.getInstance();
190 browserService.recordHistogram( 189 browserService.recordHistogram(
191 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW, 190 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW,
192 SyncedTabsHistogram.LIMIT); 191 SyncedTabsHistogram.LIMIT);
193 browserService.deleteForeignSession(menu.itemData); 192 browserService.deleteForeignSession(assert(this.actionMenuModel_));
194 menu.closeMenu(); 193 this.actionMenuModel_ = null;
194 menu.close();
195 }, 195 },
196 196
197 /** @private */ 197 /** @private */
198 clearDisplayedSyncedDevices_: function() { this.syncedDevices_ = []; }, 198 clearDisplayedSyncedDevices_: function() { this.syncedDevices_ = []; },
199 199
200 /** 200 /**
201 * Decide whether or not should display no synced tabs message. 201 * Decide whether or not should display no synced tabs message.
202 * @param {boolean} signInState 202 * @param {boolean} signInState
203 * @param {number} syncedDevicesLength 203 * @param {number} syncedDevicesLength
204 * @param {boolean} guestSession 204 * @param {boolean} guestSession
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // User signed in, show the loading message when querying for synced 288 // User signed in, show the loading message when querying for synced
289 // devices. 289 // devices.
290 this.fetchingSyncedTabs_ = true; 290 this.fetchingSyncedTabs_ = true;
291 }, 291 },
292 292
293 searchTermChanged: function(searchTerm) { 293 searchTermChanged: function(searchTerm) {
294 this.clearDisplayedSyncedDevices_(); 294 this.clearDisplayedSyncedDevices_();
295 this.updateSyncedDevices(this.sessionList); 295 this.updateSyncedDevices(this.sessionList);
296 } 296 }
297 }); 297 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698