Hi,
I am trying to implement the nsIURIContentListener interface and get it
registered so I can closely monitor URI changes before the location is
changed. I have added this interface to my "Chrome" class and basically
stubbed out all the methods. I then registered the interface using
SetParentURIContentListener. After that I put breakpoints on all the
methods included in nsIURIContentListener but none of them seem to be
called, even when the user clicks on a URL.
I am using Mozilla checked out of CVS about a week ago, since I had
problems getting older release versions building with my compiler (VC++
2005 express).
My main initialization looks like this (error checking removed to be
concise):
NS_InitEmbedding(nsnull, nsnull);
nsCOMPtr<nsIComponentRegistrar> registrar;
nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
if (NS_FAILED(rv)) return false;
rv = registrar->AutoRegister(nsnull);
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
mBaseWindow = do_QueryInterface(mWebBrowser, &rv);
chrome = new TestChrome();
chrome->AddRef();
mWebBrowser->SetContainerWindow(NS_STATIC_CAST(nsIWebBrowserChrome*,
chrome));
mWebBrowser->SetParentURIContentListener(NS_STATIC_CAST(nsIURIContentListener
*, chrome));
nsCOMPtr<nsIWebBrowserSetup>setup(do_QueryInterface(mWebBrowser));
if (setup)
{
setup->SetProperty(nsIWebBrowserSetup::SETUP_IS_CHROME_WRAPPER,
PR_TRUE);
}
nsWeakPtr
weakling(dont_AddRef(NS_GetWeakReference(NS_STATIC_CAST(nsIWebProgressListener*,
chrome))));
mWebBrowser->AddWebBrowserListener(weakling,
NS_GET_IID(nsIWebProgressListener));
Then my "TestChrome" class is defined to be:
class TestChrome : public nsIInterfaceRequestor,
public nsIWebBrowserChrome,
public nsIWebBrowserChromeFocus,
public nsIEmbeddingSiteWindow2,
public nsIWebProgressListener,
public nsIContextMenuListener2,
public nsITooltipListener,
public nsIURIContentListener,
public nsSupportsWeakReference
{
public:
TestChrome() {};
NS_DECL_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
NS_DECL_NSIEMBEDDINGSITEWINDOW
NS_DECL_NSIEMBEDDINGSITEWINDOW2
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSICONTEXTMENULISTENER2
NS_DECL_NSITOOLTIPLISTENER
NS_DECL_NSIURICONTENTLISTENER
protected:
nsCOMPtr<nsIWebBrowser> mWebBrowser;
};
And the nsIURIContentListener methods are stubbed out like this (however
none of them ever get called so it shouldnt make any difference):
NS_IMETHODIMP TestChrome::OnStartURIOpen(nsIURI *aURI, PRBool *_retval){
*_retval = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP TestChrome::DoContent(const char *aContentType, PRBool
aIsContentPreferred, nsIRequest *aRequest, nsIStreamListener
**aContentHandler, PRBool *_retval){
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP TestChrome::IsPreferred(const char *aContentType, char
**aDesiredContentType, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP TestChrome::CanHandleContent(const char *aContentType,
PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP TestChrome::GetLoadCookie(nsISupports * *aLoadCookie){
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP TestChrome::SetLoadCookie(nsISupports *aLoadCookie){
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP TestChrome::GetParentContentListener(nsIURIContentListener
* *aParentContentListener){
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP TestChrome::SetParentContentListener(nsIURIContentListener
*aParentContentListener){
return NS_ERROR_NOT_IMPLEMENTED;
}
Any ideas?
Craig.
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding