OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * @fileoverview The recently closed menu: button, model data, and menu. | 6 * @fileoverview The recently closed menu: button, model data, and menu. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('ntp', function() { | 9 cr.define('ntp', function() { |
10 'use strict'; | 10 'use strict'; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 a.href = ''; | 83 a.href = ''; |
84 a.classList.add('recent-window'); | 84 a.classList.add('recent-window'); |
85 a.textContent = formatTabsText(data.tabs.length); | 85 a.textContent = formatTabsText(data.tabs.length); |
86 a.title = data.tabs.map(function(tab) { return tab.title; }).join('\n'); | 86 a.title = data.tabs.map(function(tab) { return tab.title; }).join('\n'); |
87 } else { | 87 } else { |
88 a.href = data.url; | 88 a.href = data.url; |
89 a.style.backgroundImage = 'url(chrome://favicon/' + data.url + ')'; | 89 a.style.backgroundImage = 'url(chrome://favicon/' + data.url + ')'; |
90 a.textContent = data.title; | 90 a.textContent = data.title; |
91 } | 91 } |
92 | 92 |
93 function onClick(e) { | 93 function onActivated(e) { |
94 ntp.logTimeToClick('RecentlyClosed'); | 94 ntp.logTimeToClick('RecentlyClosed'); |
95 chrome.send('recordAppLaunchByURL', | 95 chrome.send('recordAppLaunchByURL', |
96 [encodeURIComponent(data.url), | 96 [encodeURIComponent(data.url), |
97 ntp.APP_LAUNCH.NTP_RECENTLY_CLOSED]); | 97 ntp.APP_LAUNCH.NTP_RECENTLY_CLOSED]); |
98 var index = Array.prototype.indexOf.call(a.parentNode.children, a); | 98 var index = Array.prototype.indexOf.call(a.parentNode.children, a); |
99 chrome.send('reopenTab', [data.sessionId, index, | 99 var orig = e.originalEvent; |
Dan Beam
2012/09/21 03:44:50
nit: IMO
var params = [data.sessionId,
aboxhall
2012/09/21 06:46:00
Done.
aboxhall
2012/09/21 06:46:00
Done.
| |
100 e.button, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]); | 100 if (orig.type == 'click') { |
101 chrome.send('reopenTab', [data.sessionId, index, | |
102 orig.button, orig.altKey, orig.ctrlKey, orig.metaKey, | |
103 orig.shiftKey]); | |
104 } else { | |
105 chrome.send('reopenTab', [data.sessionId, index, | |
106 0, orig.altKey, orig.ctrlKey, orig.metaKey, orig.shiftKey]); | |
107 } | |
101 // We are likely deleted by this point! | 108 // We are likely deleted by this point! |
102 | 109 e.stopPropagation(); |
103 e.preventDefault(); | 110 e.preventDefault(); |
104 } | 111 } |
105 a.addEventListener('click', onClick); | 112 a.addEventListener('activate', onActivated); |
Dan Beam
2012/09/21 03:44:50
I really wish this was [cr:ui:]menu:activate or so
aboxhall
2012/09/21 06:46:00
Should I try to fix that in this CL?
Dan Beam
2012/09/21 10:23:48
Any CL ever would surpass the current plans :P
aboxhall
2012/09/24 00:48:52
I found 45 occurrences of 'activate' under chrome/
| |
106 | 113 |
107 this.menu.appendChild(a); | 114 this.menu.appendChild(a); |
108 cr.ui.decorate(a, MenuItem); | 115 cr.ui.decorate(a, MenuItem); |
109 }, | 116 }, |
110 }; | 117 }; |
111 | 118 |
112 return { | 119 return { |
113 RecentMenuButton: RecentMenuButton, | 120 RecentMenuButton: RecentMenuButton, |
114 }; | 121 }; |
115 }); | 122 }); |
OLD | NEW |