How to get a window id when extension is running in application mode?

2,789 views
Skip to first unread message

Chrome786

unread,
Mar 23, 2011, 5:32:19 PM3/23/11
to Chromium-extensions
I am trying to get the window id when an application loads my extension.
 
Here is what I am doing...
 
- Launch chrome, it loads my extension correctly.
- Navigate to google.com.
- goto Settings->Tools and click on "Create applications shortcuts.." option.
- It will create an application shortcut on desktop
- (Close all browser instances) When you lauch that application using that shortcut, it loads background page for my extension but "currentWindow is undefined" for application shortcuts..
 
Here is my code in background.html.
 
chrome.windows.getCurrent(function(currentWindow) {
                    alert("Init: currentWindow.id: " + currentWindow.id);
                    alert(currentWindow.type);
                });
 
NOTE: In chrome browser it works fine.
 
Is there any way to get the window id? when my extension is running in application mode?
 
Thanks!

Adam

unread,
Mar 24, 2011, 1:00:36 PM3/24/11
to Chromium-extensions
Have you tried getting the current tab?

In the API docs, it does note that windows may not exist. You can
check for the existence of at least one window via:

chrome.windows.WINDOW_ID_NONE

-Adam

PhistucK

unread,
Mar 24, 2011, 1:18:01 PM3/24/11
to Adam, Chromium-extensions
But that may mean that no window (including application windows) is focused (meaning, the browser is not focused).

PhistucK



--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


Chrome786

unread,
Mar 24, 2011, 5:29:09 PM3/24/11
to PhistucK, Adam, Chromium-extensions
Adam,
Tab is undefined here too.
 
 chrome.tabs.getCurrent(function(TAB)
                {
                    // TAB is undefined here too.
                });

Phistuck,
Window is focused but may not be created at that time?
 
Thanks!

PhistucK

unread,
Mar 24, 2011, 5:31:51 PM3/24/11
to Chrome786, Adam, Chromium-extensions
Not sure what you are referring to. I replied Adam.

PhistucK
Reply all
Reply to author
Forward
0 new messages