| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script> |
| 4 // Show a list of all tabs in the same process as this one. |
| 5 function init() { |
| 6 chrome.windows.getCurrent(function(currentWindow) { |
| 7 chrome.tabs.getSelected(currentWindow.id, function(selectedTab) { |
| 8 chrome.experimental.processes.getProcessForTab(selectedTab.id, |
| 9 function(process) { |
| 10 var outputDiv = document.getElementById("tab-list"); |
| 11 var titleDiv = document.getElementById("title"); |
| 12 titleDiv.innerHTML = "<b>Tabs in Process " + process.id + ":</b>"; |
| 13 displayTabInfo(currentWindow.id, selectedTab, outputDiv); |
| 14 displaySameProcessTabs(selectedTab, process.id, outputDiv); |
| 15 } |
| 16 ); |
| 17 |
| 18 }); |
| 19 }); |
| 20 } |
| 21 |
| 22 function displaySameProcessTabs(selectedTab, processId, outputDiv) { |
| 23 // Loop over all windows and their tabs |
| 24 var tabs = []; |
| 25 chrome.windows.getAll({ populate: true }, function(windowList) { |
| 26 for (var i = 0; i < windowList.length; i++) { |
| 27 for (var j = 0; j < windowList[i].tabs.length; j++) { |
| 28 var tab = windowList[i].tabs[j]; |
| 29 if (tab.id != selectedTab.id) { |
| 30 tabs.push(tab); |
| 31 } |
| 32 } |
| 33 } |
| 34 |
| 35 // Display tab in list if it is in the same process |
| 36 tabs.forEach(function(tab) { |
| 37 chrome.experimental.processes.getProcessForTab(tab.id, |
| 38 function(process) { |
| 39 if (process.id == processId) { |
| 40 displayTabInfo(tab.windowId, tab, outputDiv); |
| 41 } |
| 42 } |
| 43 ); |
| 44 }); |
| 45 }); |
| 46 } |
| 47 |
| 48 // Print a link to a given tab |
| 49 function displayTabInfo(windowId, tab, outputDiv) { |
| 50 if (tab.favIconUrl != undefined) { |
| 51 outputDiv.innerHTML += "<img src='" + tab.favIconUrl + "'>\n"; |
| 52 } |
| 53 outputDiv.innerHTML += |
| 54 "<b><a href='#' onclick='showTab(window, " + windowId + ", " + tab.id + |
| 55 ")'>" + tab.title + "</a></b><br>\n" + |
| 56 "<i>" + tab.url + "</i><br>\n"; |
| 57 } |
| 58 |
| 59 // Bring the selected tab to the front |
| 60 function showTab(origWindow, windowId, tabId) { |
| 61 // TODO: Bring the window to the front. (See http://crbug.com/31434) |
| 62 chrome.tabs.update(tabId, { selected: true }); |
| 63 origWindow.close(); |
| 64 } |
| 65 </script> |
| 66 <style> |
| 67 body { |
| 68 overflow: hidden; |
| 69 margin: 0px; |
| 70 padding: 0px; |
| 71 background: white; |
| 72 } |
| 73 |
| 74 div:first-child { |
| 75 margin-top: 0px; |
| 76 } |
| 77 |
| 78 div { |
| 79 padding: 1px 3px; |
| 80 font-family: sans-serif; |
| 81 font-size: 10pt; |
| 82 width: 400px; |
| 83 margin-top: 1px; |
| 84 } |
| 85 </style> |
| 86 </head> |
| 87 <body onload="init()" style="width: 400px"> |
| 88 <div id="title"></div> |
| 89 <div id="tab-list"></div> |
| 90 </body> |
| 91 </html> |
| OLD | NEW |