Hi, ive been trying to implement my own ContentListener in the winEmbed sample embedding application.  I would like to intercept the request when a user clicks on a link and supply my own local markup instead.  I have extended the WebBrowserChrome class implementing a contentlistener and i have registered it with the browser object, i have not implemented any of the nsIURIContentListener functions yet as i am just testing to see how things work.  My problem is that when i run the application now and i click on any link it tries to open it in a new window and then fails with an xpconnect issue.  I have attached some code below detailing what i have done, i have left out the code that is already existent in the winEmbed application, and i would like to know if i have implemented anything wrong that is causing this behaviour.  I assume that leaving the nsIURIContentListener methods returning NS_ERROR_NOT_IMPLEMENTED would mean that the default contentlistener would handle the link click? Thanks.

/**WebBrowserChrome.h*/
#include "nsIURIContentListener.h"
...
class WebBrowserChrome   : public nsIURIContentListener
...
public:
    NS_DECL_NSIURICONTENTLISTENER
protected:
    PRBool         mIsURIContentListener;



/*WebBrowserChrome.cpp*/
#include "nsIURIContentListener.h"
...
(void)mWebBrowser->SetParentURIContentListener(NS_STATIC_CAST(nsIURIContentListener *, this));
...
NS_INTERFACE_MAP_BEGIN(WebBrowserChrome)
   NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
NS_INTERFACE_MAP_END
...
//http://lxr.mozilla.org/seamonkey/source/uriloader/base/nsIURIContentListener.idl
//*****************************************************************************
// GeckoContainer::nsIURIContentListener
//*****************************************************************************  

/* boolean onStartURIOpen (in nsIURI aURI); */
NS_IMETHODIMP WebBrowserChrome::OnStartURIOpen(nsIURI *aURI, PRBool *_retval)
{
    /*nsCAutoString uriString;
    aURI->GetAsciiSpec(uriString);//parse the URI to a string
    printf("%s \n",uriString.get());//print out the string
    fflush(stdout);//flush the output stream here*/
   
    printf("OnStartURIOpen");
    return NS_ERROR_NOT_IMPLEMENTED;
}

/* boolean doContent (in string aContentType, in boolean aIsContentPreferred, in nsIRequest aRequest, out nsIStreamListener aContentHandler); */
NS_IMETHODIMP WebBrowserChrome::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest, nsIStreamListener **aContentHandler, PRBool *_retval)
{
     printf("DoContent");
    return NS_ERROR_NOT_IMPLEMENTED;
}

/* boolean isPreferred (in string aContentType, out string aDesiredContentType); */
NS_IMETHODIMP WebBrowserChrome::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval)
{
    printf("IsPreferred");
    return NS_ERROR_NOT_IMPLEMENTED;
}

/* boolean canHandleContent (in string aContentType, in boolean aIsContentPreferred, out string aDesiredContentType); */
NS_IMETHODIMP WebBrowserChrome::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
{
    printf("CanHandleContent");
    return NS_ERROR_NOT_IMPLEMENTED;
}

/* attribute nsISupports loadCookie; */
NS_IMETHODIMP WebBrowserChrome::GetLoadCookie(nsISupports * *aLoadCookie)
{
    return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SetLoadCookie(nsISupports * aLoadCookie)
{
    return NS_ERROR_NOT_IMPLEMENTED;
}

/* attribute nsIURIContentListener parentContentListener; */
NS_IMETHODIMP WebBrowserChrome::GetParentContentListener(nsIURIContentListener * *aParentContentListener)
{
    return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP WebBrowserChrome::SetParentContentListener(nsIURIContentListener * aParentContentListener)
{
    return NS_ERROR_NOT_IMPLEMENTED;
}
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to