2006-07-28
| Table of Contents: |
| Rate This Article: | Add This Article To: |
( Page 4 of 4 )
Defining a Manifest
Most Visual Studio applications today use a manifest to hold application settings. A Firefox manifest serves essentially the same purpose.
However, the settings in this case describe what to load. You must tell Firefox how to load the extension you're creating, or the elements won't get loaded.
The manifest for this sample is relatively simple. However, manifests can define a considerable number of elements. You can see everything a manifest can do here.
In this case, you'll create a simple text file named chrome.manifest and place it in the menuEntry folder, as shown in Figure 1. Listing 3 shows the two entries you need to make in this case. Note that the second and third line appear on a single line in the manifest; I split them for this article.
Listing 3: Defining a Manifest
content menuentry content/ overlay chrome://browser/content/browser.xul chrome://menuentry/content/overlay.xul
The first line tells Firefox what your extension offers as content. In this case, you're offering an extension named menuentry and its content appears in the content folder. Be sure to include the trailing slash, or Firefox won't find the content.
The second line describes how to add the content to the browser. In this case, the extension adds an overlay to the browser.xul file found at the chrome://browser/content/browser.xul URI. Try the URI out in Firefox. The actual overlay appears at chrome://menuentry/content/overlay.xul.
Packaging Your Application
To make it easy to distribute your application, you need to package it. Fortunately, this task is extremely easy. All you need to do is place all of the files (make sure you include folder information) in a ZIP file. Here's the important part: rename the file with an XPI (pronounced zippy) extension.
Application Testing
You'll want to install your new extension to test it. I've seen a number of techniques for accomplishing this task, but here's the easiest method: navigate to the folder that contains the XPI file with your application, and click on the XPI file. Firefox will display a Software Installation dialog box, like the one shown in Figure 4. Click Install Now, and Firefox takes care of all of the details for you.
Now, here's where your first problem can occur. If you see an error message saying that Firefox can't find the installation script, it usually means that the install.rdf file is buried in a folder in the XPI file. Make sure that you create the XPI file with the install.rdf and chrome.manifest files in the root folder.
After you install the extension, you need to close Firefox and restart it. At this point, you'll see the new menu entry, as shown in Figure 5. Clicking it will display a message box.
Once you finish testing your application, you uninstall it as you would any other Firefox extension, by choosing Tools | Extensions. You'll need to close and reopen Firefox to get rid of the old installation. (The Extensions dialog box tells you about this requirement.)
Visual Studio can provide the organization you need to create a great Firefox extension. In addition, the various editors help you create files faster and with fewer errors. If you create enough extensions, you might want to build your own template to make the process easier.
John Mueller is a freelance author and technical editor. He has writing in his blood, having produced 69 books and over 300 articles to date. The topics range from networking to artificial intelligence and from database management to heads down programming. His most recent book is Web Development with Microsoft Visual Studio 2005 (Sybex, ISBN: 078214439X). His technical editing skills have helped over 48 authors refine the content of their manuscripts. You can reach John on the Internet at JMueller@mwt.net and his Web site.
![]() |
|


