On 20/01/2005, at 9:47 AM, Christian Biesinger wrote:
On Thu, Jan 20, 2005 at 12:25:53AM +1100, Andre Pang wrote:What I'm having trouble with is 'associating' the .foo extension
(really, an application/x-foo MIME type) with the chrome://fooviewer/
application. e.g. if a user types in 'http://www.example.com/data.foo'
into their browser, I'd like the chrome to appear in the browser window
and act as a content handler/viewer for that particular MIME type.
Hm, not sure how you can do exactly that. For the extension -> type mapping, you can add an entry in the "ext-to-type-mapping" category, where the key is the extension, and the value is the mime type.
Where do I find this ext-to-type-mapping category, sorry?
A content handler (nsIContentHandler) mainly allows you to open a window
or something... it doesn't really let you get the data.
Maybe you can use nsIURIContentListener, and somehow get docshell to load your data, maybe via loadStream...
OK, I don't really mind how it gets done (whether by nsIContentHandler, nsIURIContentListener, etc), as long as I can do it :). One interesting thing is that I actually did get this working using a nsIProtocolHandler -- I registered my own protocol scheme named x-foo:. Unfortunately I really need to get the chrome loading working via an extension/MIME type, not a protocol, but maybe the protocol handler example may give some insight to how to implement it for a content handler/listener? I've pasted the core code of it here to see if one can gleam any ideas:
Protocol.prototype =
{
... newChannel: function (aURI)
{
// Strip away x-foo: from URI
var location = aURI.spec.substring(aURI.spec.indexOf(":") + 1,
aURI.spec.length);return ios.newChannel("chrome://fooview/content/fooview.xul?" + location,
null, null);
}
}
That works absolutely perfectly. Now, if only I could get that working for a extension/content-type handler!
-- % Andre Pang : trust.in.love.to.save <http://www.algorithm.com.au/> _______________________________________________ Mozilla-netlib mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-netlib
