Accessing a Firefox tab item in nsIWebProgressListener :: OnStateChange using C ++

I am developing an extension for Firefox versions 3.0-3.5 using VS2008.

I want to set the attribute to the tab after completing the request to load the document in this tab window.

So, in the OnStateChange method, I check the loading of the document. I used STATE_STOP and STATE_IS_DOCUMENT for this.

I want to determine which tab window was associated with a particular document request.

I have a valid DOM document pointer obtained from nsIWebProgress * aWebProgress, which is the first input of the OnStateChange parameter.

if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_DOCUMENT)) { nsCOMPtr<nsIDOMWindow> domwin; nsCOMPtr<nsIDOMDocument> domDoc; aWebProgress->GetDOMWindow(getter_AddRefs(domwin)); domwin->GetDocument(getter_AddRefs(domDoc)); } 

I tried to get the nsIDOMDocumentXBL pointer using the QIing pointer nsIDOMDocument (domDoc in my example), but it is not with error code 0x80004002 (2147500034) ieNS_ERROR_NO_INTERFACE.

How to get a tab element corresponding to a document download request.

Can anyone help me?

Thanks, Advance, Waibhav D. Gade.

+4
source share
1 answer

IF I understand the question correctly and you want for the content window you need https://developer.mozilla.org/en/Working_with_windows_in_chrome_code#Accessing_the_elements_of_the_top-level_document_from_a_child_window to get the chrome window, then run the implementation of gBrowserDocument.

You would save a lot of time if you stopped writing C ++ and switched to JS for such things.

+1
source

Source: https://habr.com/ru/post/1304550/


All Articles