Hi... I'm trying to intercept Torrent file clicks in a Firefox
extension..
I've got the following code in my extension, which works (it gives me
the alert box when I click a torrent file mimetyped-link) but every
other link I click on in Firefox just opens up a new tab with the
address
resource://gre/res/%5Bxpconnect%20wrapped%20nsIURI%5D
and firefox reports
Firefox can't find the file at /res/[xpconnect wrapped nsIURI].

Does anyone know what this might be?
Does anyone you know what might fix this?
Can anyone see anything wrong with the following code?

Thanks a lot,
Tom.

//implementation of nsIURIContentListener
var myListener =
{
    QueryInterface: function(iid)
    {
        if (iid.equals(Components.interfaces.nsIURIContentListener) ||
            iid.equals(Components.interfaces.nsISupportsWeakReference)
||
            iid.equals(Components.interfaces.nsISupports))
            return this;
        throw Components.results.NS_NOINTERFACE;
    },
    onStartURIOpen: function(uri)
    {
        return false;
    },
    doContent: function(contentType, isContentPreferred, request,
contentHandler)
    {
        return false;
    },
    isPreferred: function(contentType, desiredContentType)
    {
        if (contentType == "application/x-bittorrent")
        {
            alert( "got bittorrent" );
            return true;
        }
    else return false;
    },
    canHandleContent: function(contentType, isContentPreferred,
desiredContentType)
    {
        return false;
    },
    GetWeakReference: function()
    {
        return this;
   }
}

// Set up the content listener
var wnd =
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                        .getInterface(Components.interfaces.nsIWebNavigation)
                        .QueryInterface(Components.interfaces.nsIDocShell)
                        
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                  .getInterface(Components.interfaces.nsIURIContentListener);
wnd.parentContentListener = myListener;

_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to