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

Side by Side Diff: chrome/common/extensions/docs/examples/api/windows/merge_windows/background.html

Issue 8318001: Adding `content_security_policy` to a few sample extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Docs. Zips. Created 9 years, 1 month 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 <!doctype html>
1 <html> 2 <html>
2 <head> 3 <head>
3 <script> 4 <title>Background Page</title>
4 var targetWindow = null; 5 <script src="background.js"></script>
5 var tabCount = 0;
6
7 function start(tab) {
8 chrome.windows.getCurrent(getWindows);
9 }
10
11 function getWindows(win) {
12 targetWindow = win;
13 chrome.tabs.getAllInWindow(targetWindow.id, getTabs);
14 }
15
16 function getTabs(tabs) {
17 tabCount = tabs.length;
18 // We require all the tab information to be populated.
19 chrome.windows.getAll({"populate" : true}, moveTabs);
20 }
21
22 function moveTabs(windows) {
23 var numWindows = windows.length;
24 var tabPosition = tabCount;
25
26 for (var i = 0; i < numWindows; i++) {
27 var win = windows[i];
28
29 if (targetWindow.id != win.id) {
30 var numTabs = win.tabs.length;
31
32 for (var j = 0; j < numTabs; j++) {
33 var tab = win.tabs[j];
34
35 // Move the tab into the window that triggered the browser action.
36 chrome.tabs.move(tab.id,
37 {"windowId": targetWindow.id, "index": tabPosition});
38
39 tabPosition++;
40 }
41 }
42 }
43 }
44
45 // Set up a click handler so that we can merge all the windows.
46 chrome.browserAction.onClicked.addListener(start);
47 </script>
48 </head> 6 </head>
49 </html> 7 <body>
8 </body>
9 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698