all tabs in all windows

190 views
Skip to first unread message

ast

unread,
Feb 1, 2012, 6:40:56 AM2/1/12
to Chromium-extensions
Hi,

I try to get all tabs in all windows and discovered that operation
like this:

var someVar = false;
chrome.windows.getAll(undefined, function (windows) {
for (var w = 0, window; window = windows[w]; w++) {
console.log(window);
chrome.tabs.getAllInWindow(window.id, function
(tabs) {
for (var i = 0, tab; tab = tabs[i]; i++) {
// console.log("tab.url", tab.url);
if (tab.url && isOkUrl(tab.url)) {
someVar = true;
...
}});
if (someVar) { // someVar == false


is executing asynchronously

Is there any callback, which is executed after all windows and tabs
check?

John J Barton

unread,
Feb 2, 2012, 6:52:06 PM2/2/12
to ast, Chromium-extensions

Yes, this one:

function antonCallback(someVar) {
// do something with someVar
}

If you replace
someVar = true;
with
antonCallback(true);
You will find someVar is true.

jjb

ozze...@yahoo.com

unread,
Feb 5, 2012, 3:50:19 PM2/5/12
to Chromium-extensions


On Feb 3, 7:52 am, John J Barton <johnjbar...@johnjbarton.com> wrote:

ozze...@yahoo.com

unread,
Feb 5, 2012, 3:50:10 PM2/5/12
to Chromium-extensions
Reply all
Reply to author
Forward
0 new messages