Sunday, March 22, 2009

Ubiquity and Its Configuration Files

Ubiquity is a Firefox extension. To learn more, click here. You can download the latest beta version from here. By clicking on the link, you'll download an .xpi file to your Firefox. The .xpi file (pronounced zippy) is nothing more than a .zip file that has been renamed.

After installtion, a new folder with the following directories:

ubiquity@labs.mozilla.com/
chrome/
chrome/content/
chrome/skin/
defaults/
defaults/preferences/

will be created in C:\Documents and Settings\<user>\Application Data\Mozilla\Firefox\Profiles\eid50wk9.default\extensions folder on Window XP.

Intall Manifest
In the root folder (i.e., ubiquity@labs.mozilla.com/; hereafter will be referred to as "<UB>"), there is an install manifest file named intall.rdf (a plain text file). install.rdf file is used by the Extension Manager when installing an XPI file and when registering an extension at specified location. From it, you can find the following information:

  • version of the extension being installed (i.e., 0.2pre19)
  • versions of Firefox the extension is designed for (i.e., minVersion: 3.0 and maxVersion: 3.2.*)


Chrome Manifest

At the root folder, there is also a chrome manifest file named chrome.manifest. Chrome is the term used to refer to Interface Packages created for Firefox. The Firefox browser contains a component, the Chrome Manager, that handles the installation and loading of the various parts of Firefox. Everything from the guts (global, browser, etc.) to extensions (such as Ubiquity)register themselves with this manager. Chrome manifest file tells Firefox where your chrome files are and what to do with them. The content of chrome.manifest for Ubiquity looks like this:

resource ubiquity ./
content ubiquity chrome/content/
skin ubiquity skin chrome/skin/
overlay chrome://browser/content/browser.xul chrome://ubiquity/content/browser.xul


content

A content package is registered with the line

content packagename uri/to/files/ [flags]

This will register a location to use when resolving the URI chrome://packagename/content/... . The URI may be absolute or relative to the location of the manifest file. Note, that it must end with an '/'. For instance, "chrome://ubiquity/content/editor.html" is mapped to "<UB>/chrome/content/editor.html."

skin
A skin package is registered with the line

skin packagename skinname uri/to/files/ [flags]

This will register a skin package when resolving the URI chrome://packagename/skin/... . The skinname is an opaque string identifying an installed skin. If more than one skin is registered for a package, the chrome registry will select the best-fit skin using the user's preferences. For instance, "chrome://ubiquity/skin/buttons/grad.png" is mapped to "<UB>/chrome/skin/buttons/grad.png."

resource

When using JavaScript code modules it may be necessary to create resource protocol aliases so extensions and applications can load modules using Components.utils.import. Aliases can be created using the resource instruction:

resource aliasname uri/to/files/ [flags]

This will create a mapping for resource://<aliasname>/ URIs to the path given. For instance, "resource://ubiquity/scripts/jquery.js" is mapped to "<UB>/scripts/jquery.js."

overlay

XUL overlays are registered with the following syntax:

overlay chrome://URI-to-be-overlaid chrome://overlay-URI [flags]

Extensions usually modify an application's UI ("chrome") and behavior by providing overlays to already existent windows/documents. Those overlays are a part of the extension's content package (content provider).

References

  1. Chrome Registration
  2. Firefox Extension Development Tutorial :: Configuration Files
  3. Getting started with extension development

No comments: