Firefox plug-in development (4) -- An Example of xulrunner

Source: Internet
Author: User

In the previous section, an extension is written, and a button is added to the ff3 toolbar. Next, I want to add a function on this basis. click the button to read the content of a file on the local disk and display it. How can this problem be solved? Is JavaScript used? Because my ultimate goal is to download files from the server and transmit local files to the server, there are many restrictions on accessing local files using JavaScript, and complex functions cannot be completed. So it is best to call the dll I have compiled. How can this problem be solved? Find it on the Mozilla website.

On the Mozilla website, you can write component to complete some custom operations. First install the gecko SDK (now called xulrunner SDK). There are two versions in Windows: 1.8 For ff1.5/2.0 and 1.9 for ff3.0, since ff3.0 is installed on my machine, download 1.9 first. If it is compatible with ff1.5/2.0, let's talk about it later.

Download xulrunner SDK 1.9, decompress it to the local directory, configure path in the environment variable to the bin directory of xulrunner-SDK, so that you can run xulrunner.exe directly under command prompt. OK. The environment configuration is complete. Let's write a small example below. Mozilla provides a very short example program, here: https://developer.mozilla.org/en/Getting_started_with_XULRunner

This article explains how to write a helloworld program step by step. However, after completing this example, I have several questions:
1. In the extension we wrote in the previous section, the chrome. manifest file is stored in the root directory (similar to the chrome directory). Why is it stored in the chrome directory? Can I keep it the same as extension? I tried it and modified chrome. in manifest, content points to the directory, and then runs it. Nothing happens. The dialog box popped up during normal operation is not displayed. It seems that the parsing is still incorrect. Is it true that xulrunner must require chrome. what about manifest in the chrome directory?
2. Is the ID of the app section in application. ini associated with the extension ID (usually a guid?
3. After xulrunner.exe is called, two directories will be generated: extensions and updates. What are the two directories used?

In addition, it is worth noting that when xulrunnerto execute application.ini, you cannot drop .exe, that is, you cannot write/> xulrunner application. INI, which must be/> xulrunner.exe application. INI. Otherwise, the error message "couldn't parse" will pop up. I am not sure what the cause is.

In addition, here is a tutorial on xulrunner that explains some conceptual things: http://blogs.acceleration.net/ryan/archive/2005/05/06/1073.aspx

After writing this example, it seems that the direction is not quite right. xulrunner seems to be mainly engaged in the interface. How to make components? How do I access local disk files and even the system registry? On the Mozilla developer page, you can see another plug-in: XPCOM. The first section of the Introduction text is as follows:

XPCOM is a cross platform component object model, similar to Microsoft COM. it has multiple language bindings, lew.the XPCOM components be used and implemented in Javascript, Java, and python in addition to C ++. interfaces in XPCOM are defined in a dialect of IDL called xpidl.

XPCOM itself provides a set of core components and classes, e.g. file and memory management, threads, basic data structures (strings, arrays, variants), etc. the majority of XPCOM components is not part of this core set and is provided by other parts of the Platform (e.g. gecko or necko) or by an application or even by an extension.

In general, XPCOM is similar to Microsoft's COM component concept. It can define some interfaces and can be used in JS, Java, Python, and C ++. Haha, it seems that this is what I want. OK. Now let's take a look at this stuff. In the next section, we strive to complete the functions I mentioned at the beginning.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.