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

Side by Side Diff: chrome/common/extensions/docs/examples/api/processes/show_tabs/popup.html

Issue 3801008: Expands the chrome.experimental.processes extension API. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months 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 | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script> 3 <script>
4 // Show a list of all tabs in the same process as this one. 4 // Show a list of all tabs in the same process as this one.
5 function init() { 5 function init() {
6 chrome.windows.getCurrent(function(currentWindow) { 6 chrome.windows.getCurrent(function(currentWindow) {
7 chrome.tabs.getSelected(currentWindow.id, function(selectedTab) { 7 chrome.tabs.getSelected(currentWindow.id, function(selectedTab) {
8 chrome.experimental.processes.getProcessForTab(selectedTab.id, 8 chrome.experimental.processes.getProcessIdForTab(selectedTab.id,
9 function(process) { 9 function(pid) {
10 var outputDiv = document.getElementById("tab-list"); 10 var outputDiv = document.getElementById("tab-list");
11 var titleDiv = document.getElementById("title"); 11 var titleDiv = document.getElementById("title");
12 titleDiv.innerHTML = "<b>Tabs in Process " + process.id + ":</b>"; 12 titleDiv.innerHTML = "<b>Tabs in Process " + pid + ":</b>";
13 displayTabInfo(currentWindow.id, selectedTab, outputDiv); 13 displayTabInfo(currentWindow.id, selectedTab, outputDiv);
14 displaySameProcessTabs(selectedTab, process.id, outputDiv); 14 displaySameProcessTabs(selectedTab, pid, outputDiv);
15 } 15 }
16 ); 16 );
17 17
18 }); 18 });
19 }); 19 });
20 } 20 }
21 21
22 function displaySameProcessTabs(selectedTab, processId, outputDiv) { 22 function displaySameProcessTabs(selectedTab, processId, outputDiv) {
23 // Loop over all windows and their tabs 23 // Loop over all windows and their tabs
24 var tabs = []; 24 var tabs = [];
25 chrome.windows.getAll({ populate: true }, function(windowList) { 25 chrome.windows.getAll({ populate: true }, function(windowList) {
26 for (var i = 0; i < windowList.length; i++) { 26 for (var i = 0; i < windowList.length; i++) {
27 for (var j = 0; j < windowList[i].tabs.length; j++) { 27 for (var j = 0; j < windowList[i].tabs.length; j++) {
28 var tab = windowList[i].tabs[j]; 28 var tab = windowList[i].tabs[j];
29 if (tab.id != selectedTab.id) { 29 if (tab.id != selectedTab.id) {
30 tabs.push(tab); 30 tabs.push(tab);
31 } 31 }
32 } 32 }
33 } 33 }
34 34
35 // Display tab in list if it is in the same process 35 // Display tab in list if it is in the same process
36 tabs.forEach(function(tab) { 36 tabs.forEach(function(tab) {
37 chrome.experimental.processes.getProcessForTab(tab.id, 37 chrome.experimental.processes.getProcessIdForTab(tab.id,
38 function(process) { 38 function(pid) {
39 if (process.id == processId) { 39 if (pid == processId) {
40 displayTabInfo(tab.windowId, tab, outputDiv); 40 displayTabInfo(tab.windowId, tab, outputDiv);
41 } 41 }
42 } 42 }
43 ); 43 );
44 }); 44 });
45 }); 45 });
46 } 46 }
47 47
48 // Print a link to a given tab 48 // Print a link to a given tab
49 function displayTabInfo(windowId, tab, outputDiv) { 49 function displayTabInfo(windowId, tab, outputDiv) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 width: 400px; 83 width: 400px;
84 margin-top: 1px; 84 margin-top: 1px;
85 } 85 }
86 </style> 86 </style>
87 </head> 87 </head>
88 <body onload="init()" style="width: 400px"> 88 <body onload="init()" style="width: 400px">
89 <div id="title"></div> 89 <div id="title"></div>
90 <div id="tab-list"></div> 90 <div id="tab-list"></div>
91 </body> 91 </body>
92 </html> 92 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698