Wednesday, December 13, 2006

What is Chrome URL ?

You can get XUL files like regular HTTP URL or like HTML files.
URL types can automatically handle mulitple themes and locales.
The basic syntax of a chrome URL is as follows:

chrome:////

The text is the package name, such as messenger or editor. The is either 'content', 'skin' or 'locale' depending on which part you want. 'file.xul' is simply the filename.

Example: chrome://messenger/content/messenger.xul

When you select a chrome URL, Mozilla looks down its list of installed packages and tries to locate the JAR file or directory that matches the package name and part.

The mapping between chrome URLs and JAR files are specified in the manifest files stored in the chrome directory.

If you were to move the file messenger.jar somewhere else and update the manifest file accordingly, Thunderbird will still work since it doesn't rely on its specific installed location. By using chrome URLs we can leave details like this to Mozilla. Similarly, if the user changes their theme, the 'skin' part of the chrome URL translates to a different set of files, yet the XUL and scripts don't need to change.

Here are some more examples. Note how none of the URLs specify which theme or locale is used and none specify a specific directory.

chrome://messenger/content/messenger.xul
chrome://messenger/content/attach.js
chrome://messenger/skin/icons/folder-inbox.png
chrome://messenger/locale/messenger.dtd

No comments: