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

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

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
(Empty)
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
3 // found in the LICENSE file.
4
5 var targetWindow = null;
6 var tabCount = 0;
7
8 function start(tab) {
9 chrome.windows.getCurrent(getWindows);
10 }
11
12 function getWindows(win) {
13 targetWindow = win;
14 chrome.tabs.getAllInWindow(targetWindow.id, getTabs);
15 }
16
17 function getTabs(tabs) {
18 tabCount = tabs.length;
19 // We require all the tab information to be populated.
20 chrome.windows.getAll({"populate" : true}, moveTabs);
21 }
22
23 function moveTabs(windows) {
24 var numWindows = windows.length;
25 var tabPosition = tabCount;
26
27 for (var i = 0; i < numWindows; i++) {
28 var win = windows[i];
29
30 if (targetWindow.id != win.id) {
31 var numTabs = win.tabs.length;
32
33 for (var j = 0; j < numTabs; j++) {
34 var tab = win.tabs[j];
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 tabPosition++;
39 }
40 }
41 }
42 }
43
44 // Set up a click handler so that we can merge all the windows.
45 chrome.browserAction.onClicked.addListener(start);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698