Chrome是什么?
chrome.manifest是唯一定义这些元素如何集成的文件。作为特例,XULRunner应用程序还会读取其他的chrome/chrome.manifest配置文件。
Chrome提供者
为一个指定窗口类型(如浏览器窗口)提供chrome被称作chrome提供者。不同的提供者共通为一个完整的chrome集合提供一个特定的窗口,这其中包括了工具栏按钮上的图片、文本描述文件、窗口内容和外观本身。
有三种基本类型的chrome提供者。
Content
The main source file for a window description comes from the content provider, and it can be any file type viewable from within Mozilla. It will typically be a XUL file, since XUL is designed for describing the contents of windows and dialogs. The JavaScript files that define the user interface are also contained within the content packages, as well as most XBL binding files.
Locale
Localizable applications keep all their localized information in locale providers. This allows translators to plug in a different chrome package to translate an application without altering the rest of the source code. The two main types of localizable files are DTD files and Java-style properties files.
Skin
Note: Scripts (including those found in XBL) loaded from skin packages will not execute.
Chrome的注册
这种纯文本的chrome清单机制基于一个简单的按行格式。每行内容被独立解析,如果该行内容可解析则chrome注册机制执行相应的操作。否则chrome注册机制忽略该行内容,并会在运行时错误控制台上打印警告消息。
Manifest指令
注释
使用#作为注释符
content
语法:
content packagename uri/to/files/ [flags]
以上指令会注册一个可以引用的路径为:chrome://packagename/content/。指令中既可以使用相对路径URI,也可以使用绝对路径URI。注意:必须用/结束URI定义。
locale
语法:
locale packagename localename uri/to/files/ [flags]
以上指令会注册一个本地化语言包引用路径为:chrome://packagename/locale/。应用程序会根据用户的语言环境选择最适合的语言包。
skin
语法:
skin packagename skinname uri/to/files/ [flags]
以上指令会注册一个皮肤包的引用路径为:chrome://packagename/skin/。其中的skinname指向一个本地已安装的皮肤名。当为一个皮肤包注册了不止一个皮肤名时,chrome注册机制会根据用户首选项选择一个最适合的皮肤。
overlay
语法:
overlay chrome://URI-to-be-overlaid chrome://overlay-URI [flags]
style
语法:
style chrome://URI-to-style chrome://stylesheet-URI [flags]
override
语法:
override chrome://package/type/original-uri.whatever new-resolved-URI [flags]
注意:override指令是非递归指令。
resource
Firefox 3新引入的指令
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:
当使用JavaScript代码模块功能时,可以通过resource伪协议来让扩展和应用程序通过使用Components.utils.import访问JavaScript模块。
语法:
resource aliasname uri/to/files/ [flags]
以上指令会创建一个resource://
Note that there are no security restrictions preventing web content from including content at resource: URIs, so take care with what you make visible there.
注意:对于resource指令,Firefox不提供同源性安全策略保护。因此需要谨慎使用resource指令开放js代码模块中的导出符号。
语法:
以上指令标明该Manifest指令适用的目标应用程序。可以通过该指令实现对不同的目标应用程序执行特定应用程序的Manifest指令。
语法:
以上指令详细定义了该Manifest指令适用的目标应用程序版本。可以通过该指令实现对不同的目标应用程序版本执行特定应用程序的Manifest指令。
Firefox3中的新增Manifest标记
Firefox3中的新增Manifest标记
Firefox3中的新增Manifest标记,用处类似appversion
仅用于content注册标记。
The Chrome List extension shows all registered chrome. This is very helpful when trying to write a chrome.manifest file as you can inspect where the files are being mapped from (jar files, local directory, etc.)</div>
Manifest标记
application
application=app-ID
如:
overlay chrome://browser/content/browser.xul chrome://myaddon/content/ffOverlay.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://messenger/content/mailWindowOverlay.xul chrome://myaddon/content/tbOverlay.xul application={3550f703-e582-4d05-9a08-453d09bdfdc6}
overlay chrome://songbird/content/xul/layoutBaseOverlay.xul chrome://myaddon/content/sbOverlay.xul application=songbird@songbirdnest.com
appversion
appversion=version
appversion<version
appversion<=version
appversion>version
appversion>=version
contentaccessible
实例:
content packagename chrome/path/ contentaccessible=yes
该标记仅对content指令有效。用于显式的指明该chrome内容可以被外部非信任源的标签和脚本代码访问。
os
Extensions (or themes) may offer different features depending on the operating system on which Firefox is running. The value is compared to the value of OS_TARGET for the platform.
实例:
os=WINNT
os=Darwin
osversion
platform
实例:
content global-platform jar:toolkit.jar!/toolkit/content/global-platform/ platform
如上实例,一旦使用该Manifest标记,global-platform目录下必须有根据不同平台名(如win,mac,unix)命名的子目录,并将相应平台适用的content资源存放在相应的子目录中。任何子目录之外的资源将被忽略。
xpcnativewrappers
调试chrome.manifest