Hello,
I am writing an XPCOM extension for Firefox. The component implements the nsIWebProgressListener interface to listen to various events from the browser.
Now what I want to do is to obtain the adress of the webpage that is being displayed in the window when the OnStateChange methods of nsIWebProgressListener reaches the state: STATE_STOP | STATE_IS_DOCUMENT.



As mentioned by someone else, I obtained the nsIWebNavigation interface as following:


----------------------------------------
// Get the service manager
nsCOMPtr<nsIServiceManager> pServman;
NS_GetServiceManager(getter_AddRefs(pServman));


// Get the web browser
nsCOMPtr<nsIWebBrowser> pWebBrowser;
pServman->GetServiceByContractID("@mozilla.org/embedding/browser/nsWebBrowser;1" , NS_GET_IID(nsIWebBrowser), getter_AddRefs(pWebBrowser));



nsCOMPtr<nsIWebNavigation> pWebNav(do_QueryInterface(pWebBrowser, &rv)); ---------------------------------------

It is ok till here. I have some pointer in pWebNav and the status rv is OK. But when I try to get the URI by calling:


nsCOMPtr<nsIURI> pURI; pWebNav->GetCurrentURI(getter_AddRefs(pURI));


this method fails.


Anyone know where I went wrong? Or you may know another way to do it? Any simple sample code may be great.

I would appriciate very much your help

Vonuyx

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

Reply via email to