All of the material I have found explains in detail how to create a
custom component, and how to use that component from code; however, I
have been unable to find any documentation concerning registering a
component to handle an existing FireFox event.
If anyone could send me an example of hooking a custom component (or
even just code) into a FireFox event I would really appreciate it. Or
if anyone could point me to a resource that would explain how to
accomplish it, that would be a huge help.
Thanks,
Andrew
Well, there's 'http-on-modify-request' notification you could use, but
apparently before Firefox 3 you can't cancel the request from the
notification (https://bugzilla.mozilla.org/show_bug.cgi?id=350790).
Information and example on examining/canceling the request from a
http-on-modify-request observer:
http://developer.mozilla.org/en/docs/Setting_HTTP_request_headers
http://mxr-test.landfill.bugzilla.org/mxr-test/seamonkey/source/netwerk/test/unit/test_httpcancel.js
There's some partial workaround for Fx2 mentioned in 350790, but I
don't know what it is.
> I have been unable to find any documentation concerning registering a
> component to handle an existing FireFox event.
>
You haven't asked this, but anyway...
Handlers for different notifications are not all registered in the
same way. You can figure out the way to register the handler you need
by looking at the interfaces, documentation, and source code of the
subsystem you're working with. Common ways handlers are registered
are:
* nsIObserverService notification handlers
* http://developer.mozilla.org/en/docs/nsIObserverService
* http://kb.mozillazine.org/Using_observers
* http://xulplanet.com/tutorials/mozsdk/observerserv.php
* nsICategoryManager.addCategoryEntry (a more or less complete list of
categories you can register for is lacking; some common usages include
global startup/shutdown handlers, content policy implementations,
command line handlers, etc)
* http://developer.mozilla.org/en/docs/nsICategoryManager:addCategoryEntry
* You can try searching in LXR.m.o and compreg.dat for used categories.
* DOM event listeners (when you need to handle events dispatched to a
particular element in the window)
* http://www.xulplanet.com/tutorials/xultu/events.html
* http://www.xulplanet.com/references/elemref/ref_EventHandlers.html
* W3C DOM Events specification
* we don't have a good reference on MDC yet
* Handlers specific to a particular situation, usually implement a
custom interface, for example (
* nsIWebProgressListener (registered using tabbrowser's addProgressListener)
* nsIObserver for pref changes (registered using nsIPrefBranch2)
* many many more custom handlers
Nickolay