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

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

Issue 606061: Adds an example extension to demonstrate the processes experimental API.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/docs/examples/api/processes/show_tabs/manifest.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/examples/api/processes/show_tabs/popup.html
===================================================================
--- chrome/common/extensions/docs/examples/api/processes/show_tabs/popup.html (revision 0)
+++ chrome/common/extensions/docs/examples/api/processes/show_tabs/popup.html (revision 0)
@@ -0,0 +1,91 @@
+<html>
+<head>
+<script>
+ // Show a list of all tabs in the same process as this one.
+ function init() {
+ chrome.windows.getCurrent(function(currentWindow) {
+ chrome.tabs.getSelected(currentWindow.id, function(selectedTab) {
+ chrome.experimental.processes.getProcessForTab(selectedTab.id,
+ function(process) {
+ var outputDiv = document.getElementById("tab-list");
+ var titleDiv = document.getElementById("title");
+ titleDiv.innerHTML = "<b>Tabs in Process " + process.id + ":</b>";
+ displayTabInfo(currentWindow.id, selectedTab, outputDiv);
+ displaySameProcessTabs(selectedTab, process.id, outputDiv);
+ }
+ );
+
+ });
+ });
+ }
+
+ function displaySameProcessTabs(selectedTab, processId, outputDiv) {
+ // Loop over all windows and their tabs
+ var tabs = [];
+ chrome.windows.getAll({ populate: true }, function(windowList) {
+ for (var i = 0; i < windowList.length; i++) {
+ for (var j = 0; j < windowList[i].tabs.length; j++) {
+ var tab = windowList[i].tabs[j];
+ if (tab.id != selectedTab.id) {
+ tabs.push(tab);
+ }
+ }
+ }
+
+ // Display tab in list if it is in the same process
+ tabs.forEach(function(tab) {
+ chrome.experimental.processes.getProcessForTab(tab.id,
+ function(process) {
+ if (process.id == processId) {
+ displayTabInfo(tab.windowId, tab, outputDiv);
+ }
+ }
+ );
+ });
+ });
+ }
+
+ // Print a link to a given tab
+ function displayTabInfo(windowId, tab, outputDiv) {
+ if (tab.favIconUrl != undefined) {
+ outputDiv.innerHTML += "<img src='" + tab.favIconUrl + "'>\n";
+ }
+ outputDiv.innerHTML +=
+ "<b><a href='#' onclick='showTab(window, " + windowId + ", " + tab.id +
+ ")'>" + tab.title + "</a></b><br>\n" +
+ "<i>" + tab.url + "</i><br>\n";
+ }
+
+ // Bring the selected tab to the front
+ function showTab(origWindow, windowId, tabId) {
+ // TODO: Bring the window to the front. (See http://crbug.com/31434)
+ chrome.tabs.update(tabId, { selected: true });
+ origWindow.close();
+ }
+</script>
+<style>
+body {
+ overflow: hidden;
+ margin: 0px;
+ padding: 0px;
+ background: white;
+}
+
+div:first-child {
+ margin-top: 0px;
+}
+
+div {
+ padding: 1px 3px;
+ font-family: sans-serif;
+ font-size: 10pt;
+ width: 400px;
+ margin-top: 1px;
+}
+</style>
+</head>
+<body onload="init()" style="width: 400px">
+<div id="title"></div>
+<div id="tab-list"></div>
+</body>
+</html>
Property changes on: chrome\common\extensions\docs\examples\api\processes\show_tabs\popup.html
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/common/extensions/docs/examples/api/processes/show_tabs/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698