• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

7. Hack the Chrome Ugly > 82. Add a New XPCOM Component

Add a New XPCOM Component

Extend Firefox’s component library with a new object that’s usable in the chrome.

Firefox comes preinstalled with over a thousand XPCOM objects (classes and interfaces). Most of these objects provide fundamental services, such as access to files, networks, and data. Nearly all of these objects are written in C++ and are provided in compiled libraries. This hack shows how to add new components written in JavaScript. Typically, new objects provide application-level abstractions on top of the existing libraries, but in theory, they can do anything.

We’ll use as an example the creation of a simple persistence class—one that dumps a simple string of information to a disk-based file. We’ll put all the required logic into a single script named nsStringSave.js, which we’ll put in the components directory in the install area. We’ll use limited error checking, which could easily be done more robustly.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint