Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

可安装bundle的目录结构

XULRunner应用扩展主题都共享相同的目录结构,并且这样的目录结构某些时候还可以用于像可安装应用扩展那样的独立XULRunner应用。

一个bundle的基本目录结构

一个bundle可能包含以下任何种类的文件:

bundle内容相对于root的路径 说明

版本信息

/install.rdf 扩展或主题的安装清单文件  
/application.ini 应用启动清单文件  
/bootstrap.js The bootstrap script for extensions not requiring a restart (those with <em:bootstrap>true</em:bootstrap> in their install.rdf). Note that other files and directories (e.g. chrome.manifest, components, defaults) in bootstrapped extensions are not processed by a supporting application. (>=2.0)
/chrome.manifest Chrome注册清单文件 (>=1.8)
/components/* XPCOM 组件 (*.js, *.dll)和 *.xpt 接口文件 (>=1.7)
/defaults/preferences/*.js 默认配置文件 (>=1.7)
/plugins/* NPAPI 插件 (>=1.8)
/chrome/icons/default/* 窗口图标 (>=1.8)
/options.xul 用于显示在Add-ons管理器中的扩展配置选项画面 (>=7.0)
... 附加资源 (如 chrome:// 或 resource:// 提供可在chrome.manifest文件中被注册的附加资源)  
Application-specific
/searchplugins/*.src Sherlock search plugins Firefox 1.5 and greater.
/searchplugins/*.xml MozSearch and OpenSearch plugins Firefox 2 and greater
/dictionaries/*.{aff|dic} Myspell dictionaries Firefox 2 and greater

当然一个扩展并不需要(通常是不需要)所有的这些目录。主题由于安全原因被限制了功能,并且通常仅能提供一个chrome.manifest文件用于注册主题和JAR文件。

平台特定文件

Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) 移除了对平台特定文件子目录的支持,接下来讨论。取而代之的是你需要使用清单标识(如OSABI标识)在你的chrome.manifest文件中以指定组件应该被加载到哪种平台上。

例如:

binary-component components/windows/mycomponent.dll ABI=WINNT_x86-msvc
binary-component components/mac/mycomponent.dylib ABI=Darwin_x86-gcc3
binary-component components/mac/mycomponent64.dylib ABI=Darwin_x86_64-gcc3
binary-component components/linux/mycomponent.so ABI=Linux_x86-gcc3

这也意味着你可以不再将平台特定配置文件包含进你的bundle。

平台特定子目录:Gecko 1.9.2x及其更早版本

Gecko 2.0 note
(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)

对于平台特定子目录的支持已经在Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)中被移除. 参见 Platform-specific files 以学习如何使用平台特定文件。

在某些情况下一个扩展或应用可能希望包含针对不同平台的组件或插件,或者主题的作者可能想要包含多平台特定的JAR文件。为了实现第一种情况,扩展或应用需要为平台特定文件(starting with Toolkit/Gecko 1.8, Firefox/Thunderbird 1.5)指定特定的子目录。平台字符串标识被定义于工具构建处理、操作系统唯一结果结合、处理器架构和编译期间。具体字符串格式如下:

{OS_TARGET}_{TARGET_XPCOM_ABI}

所有加载于主扩展目录中的文件此时都会从子目录中被加载

/platform/{platform string}

如何它存在的话。比如如果一个插件的供应商想让他的插件可以用于装有Linux(of the form: /platform/Linux*/)、Macintosh(of the form: /platform/Darwin*/)或Windows(of the form: /platform/WIN*/)的电脑上,那么他需要提供以下文件:

/platform/Linux_x86-gcc3/plugins/libMyPlugin.so
/platform/WINNT_x86-msvc/plugins/MyPlugin.dll
/platform/Darwin_ppc-gcc3/plugins/libMyPlugin.dylib

因为XPT文件不是平台特定的,因此任何相关的XPT文件都可以放到通用的组件目录中:

/components/MyPlugin.xpt

如果一个扩展含有非二进制的平台特定代码(例如那种从脚本中使用windows注册表的代码),那么它也可以使用系统标识符作为平台子目录名:

/platform/WINNT/components/registerDoctype.js

当平台特定JAR文件被使用时,每个平台目录都应该拥有它自己的chrome.manifest清单文件:

chrome.manifest
chrome/mytheme-base.jar
platform/Darwin/chrome.manifest
platform/Darwin/chrome/mytheme-mac.jar
platform/WINNT/chrome.manifest
platform/WINNT/chrome/mytheme-win.jar

应用或扩展加载器先处理基础目录,然后再是可应用平台目录(先是 /{OS_TARGET}/, 然后是 /{OS_TARGET}_{TARGET_XPCOM_ABI}/)。当默认配置被定义于几个目录中,那么最后一个被加载的配置将覆盖之前的配置。

Official references for toolkit API

文档标签和贡献者

 此页面的贡献者: du.wei
 最后编辑者: du.wei,