Hello,
In my XPCOM extension I implemented the nsIObserver interface and registered to 'domwindowopened' service and then when a window is opened, I remember its DOMWindow pointer:


NS_IMETHODIMP
MyComponent::Observe(
        nsISupports *aSubject,
        const char *aTopic,
        const PRUnichar *aData
        )
{
        nsresult rv;
        if (aTopic && strcmp(aTopic, "domwindowopened") == 0) {
                nsCOMPtr<nsIDOMWindow> pDOMWindow = nsnull;
                pDOMWindow      = do_QueryInterface(aSubject, &rv);
                RememberThisDOMWindow(pDOMWindow);
        }
        ....
}


Now, implementing the nsIWebProgressListener interface, I can gain access to the top nsIDOMWindow of the page eg.:



NS_IMETHODIMP
MyComponent::OnStateChange(
nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
PRUint32 aStateFlags,
nsresult aStatus
)
{



nsCOMPtr<nsIDOMWindow> pDOMWindow = nsnull; nsCOMPtr<nsIDOMWindow> pTopDOMWindow = nsnull; aWebProgress->GetDOMWindow(getter_AddRefs(pDOMWindow)); pDOMWindow->GetTop(getter_AddRefs(pTopDOMWindow)); ..... }

Assuming that I have only ONE window opened.

My question is: why the top DOMWindow here, and none of those obtained within OnStateChange by calling:

        aWebProgress->GetDOMWindow(getter_AddRefs(pDOMWindow));

is the same as that I've remembered befored? Where did I go wrong?

I am opearating on DOMWindows within OnStateChange but I need to know which window was closed by the user.


Thanks alot in advance for any help.

VONUYX



_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to