| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('ntp4', function() { | 9 cr.define('ntp4', function() { |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 var a = this.ownerDocument.createElement('a'); | 82 var a = this.ownerDocument.createElement('a'); |
| 83 a.className = 'recent-menu-item'; | 83 a.className = 'recent-menu-item'; |
| 84 if (isWindow) { | 84 if (isWindow) { |
| 85 a.href = ''; | 85 a.href = ''; |
| 86 a.classList.add('recent-window'); | 86 a.classList.add('recent-window'); |
| 87 a.textContent = formatTabsText(data.tabs.length); | 87 a.textContent = formatTabsText(data.tabs.length); |
| 88 } else { | 88 } else { |
| 89 a.href = data.url; | 89 a.href = data.url; |
| 90 a.style.backgroundImage = 'url(chrome://favicon/' + data.url + ')'; | 90 a.style.backgroundImage = 'url(chrome://favicon/' + data.url + ')'; |
| 91 a.textContent = data.title; | 91 a.textContent = data.title; |
| 92 // TODO(estade): add app ping url. | |
| 93 } | 92 } |
| 94 | 93 |
| 95 function onActivate(e) { | 94 function onClick(e) { |
| 96 chrome.send('recordAppLaunchByURL', | 95 chrome.send('recordAppLaunchByURL', |
| 97 [encodeURIComponent(data.url), | 96 [encodeURIComponent(data.url), |
| 98 ntp4.APP_LAUNCH.NTP_RECENTLY_CLOSED]); | 97 ntp4.APP_LAUNCH.NTP_RECENTLY_CLOSED]); |
| 99 // TODO(estade): don't convert to string. | 98 var index = Array.prototype.indexOf.call(a.parentNode.children, a); |
| 100 chrome.send('reopenTab', [String(data.sessionId)]); | 99 chrome.send('reopenTab', [data.sessionId, index, |
| 100 e.button, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey]); |
| 101 // We are likely deleted by this point! | 101 // We are likely deleted by this point! |
| 102 | 102 |
| 103 e.preventDefault(); | 103 e.preventDefault(); |
| 104 } | 104 } |
| 105 a.addEventListener('activate', onActivate); | 105 a.addEventListener('click', onClick); |
| 106 | 106 |
| 107 this.menu.appendChild(a); | 107 this.menu.appendChild(a); |
| 108 cr.ui.decorate(a, MenuItem); | 108 cr.ui.decorate(a, MenuItem); |
| 109 }, | 109 }, |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 return { | 112 return { |
| 113 RecentMenuButton: RecentMenuButton, | 113 RecentMenuButton: RecentMenuButton, |
| 114 }; | 114 }; |
| 115 }); | 115 }); |
| OLD | NEW |