Chrome registration

  • Revision slug: Chrome_Registration
  • Revision title: Chrome registration
  • Revision id: 13639
  • Created:
  • Creator: Verruckt
  • Is current revision? No
  • Comment /* Skin */

Revision Content

What is Chrome?

Chrome is the set of user interface elements of the application window that are outside of a window's content area. Toolbars, menu bars, progress bars, and window title bars are all examples of elements that are typically part of the chrome.

Chrome Providers

A supplier of chrome for a given window type (e.g., for the browser window) is called a chrome provider. The providers work together to supply a complete set of chrome for a particular window, from the images on the toolbar buttons to the files that describe the text, contents and appearance of the window itself.

There are three basic types of chrome providers:

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 (pele)

A skin provider is responsible for providing a complete set of files that describe the visual appearance of the chrome. Typically a skin provider will provide CSS files and images.

The Chrome Registry

The gecko runtime maintains a service known as the chrome registry that provides mappings from chrome package names to the physical location of chrome packages on disk.

This chrome registry is configurable and persistent, and thus a user can install different chrome providers, and select a preferred skin and locale. This is accomplished through xpinstall and the extension manager.

In order to inform the chrome registry of the available chrome, a text manifest is used: this manifest is "chrome.manifest" in the root of an extension, or theme, and chrome/*.manifest in a XULRunner application.

The plaintext chrome manifests are a simple line-based format. Each line is parsed individually; if the line is parseable the chrome registry takes the action identified by that line; otherwise the chrome registry ignores that line (and prints a warning message in the runtime error console).

locale packagename localename path/to/files
skin packagename skinname path/to/files

Manifest Instructions

Comments

A line is a comment if it begins with the character '#'; any other characters on the line are ignored.

# this line is a comment - you can put whatever you want here

content

A content package is registered with the line

content packagename uri/to/files/ [flags]

This will register a location to use when resolving the URI <tt>chrome://packagename/content/...</tt>. The URI may be absolute or relative to the location of the manifest file. Note, that it must end with an '/'.

locale

A locale package is registered with the line

locale packagename localename uri/to/files/ [flags]

This will register a locale package when resolving the URI chrome://packagename/locale/... . The localename is usually a plain language identifier "en" or a language-country identifier "en-US". If more than one locale is registered for a package, the chrome registry will select the best-fit locale using the user's preferences.

skin

A skin package is registered with the line

skin packagename skinname uri/to/files/ [flags]

This will register a skin package when resolving the URI chrome://packagename/skin/... . The skinname is an opaque string identifying an installed skin. If more than one skin is registered for a package, the chrome registry will select the best-fit skin using the user's preferences.

overlay

XUL overlays are registered with the following syntax:

overlay chrome://URI-to-be-overlaid chrome://overlay-URI [flags]

style

Style overlays (custom CSS which will be applied to a chrome page) are registered with the following syntax:

style chrome://URI-to-style chrome://stylesheet-URI [flags]

override

In some cases an extension or embedder may wish to override a chrome file provided by the application or XULRunner. In order to allow for this, the chrome registration manifest allows for "override" instructions:

override chrome://package/type/original-uri.whatever new-resolved-URI [flags]

Manifest Flags

Manifest lines can have multiple, space-delimited flags added at the end of the registration line. These flags mark special attributes of chrome in that package, or limit the conditions under which the line is used.

application

Extensions may install into multiple applications. There may be chrome registration lines which only apply to one particular application. The flag

application=app-ID

indicates that the instruction should only be applied if the extension is installed into the application identified by app-ID is running. Multiple application flags may be included on a single line, in which case the line is applied if any of the flags match.

appversion

Extensions may install into multiple versions of an application. There may be chrome registration lines which only apply to a particular application version. The flag

appversion=version
appversion<version
appversion<=version
appversion>version
appversion>=version

indicates that the instruction should only be applied if the extension is installed into the application version identified. Multiple appversion flags may be included on a single line, in which case the line is applied if any of the flags match. The version string must conform to the Toolkit version format.

platform (Platform-specific packages)

Some packages are marked with a special flag indicating that they are platform specific. Some parts of content, skin, locales may be different based on the platform being run. These packages contain three different sets of files, for windows/os2, macintosh, and unix-like platforms. For example, the order of the "OK" and "cancel" buttons on a dialog is different, as well as the name of some items.

The "platform" modifier is only parsed for content registration, it is not recognized for locale or skin registration. However it applies to content, locale, and skin parts of the package, when specified.

To indicate that a package is platform-specific, add the "platform" modifier to the "content" line after the path, for example:

content global-platform jar:toolkit.jar!/toolkit/content/global-platform/ platform

Once that is specified in your manifest you then ensure that under the directory global-platform are subdirectories win (Windows/OS2), mac (OS9/OSX), or unix (Everything Else). Anything residing outside of these subdirectories will be ignored.

xpcnativewrappers

Chrome packages can decide whether to use the xpcnativewrappers security mechanism to protect their code against malicious content that they might access. See Safely accessing content DOM from chrome for details.

As of Firefox 1.5 alpha releases (Deer Park alphas), this flag is *off* by default, and must be explicitly enabled by specifying xpcnativewrappers=yes.

As of the first Firefox 1.5 beta release, this flag will be enabled by default, and extensions that need insecure access to the content objects will be required to specify xpcnativewrappers=no.

The xpcnativewrappers flag applies only to content packages: it is not recognized for locale or skin registration.

Example Chrome Manifest

content       necko                   jar:comm.jar!/content/necko/ xpcnativewrappers=yes
locale	       necko       en-US       jar:en-US.jar!/locale/en-US/necko/
content       xbl-marquee             jar:comm.jar!/content/xbl-marquee/
content       pipnss                  jar:pipnss.jar!/content/pipnss/
locale        pipnss      en-US       jar:en-US.jar!/locale/en-US/pipnss/
# Firefox-only
overlay chrome://browser/content/pageInfo.xul           chrome://pippki/content/PageInfoOverlay.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://communicator/content/pref/preftree.xul chrome://pippki/content/PrefOverlay.xul
overlay chrome://navigator/content/pageInfo.xul         chrome://pippki/content/PageInfoOverlay.xul application=seamonkey@applications.mozilla.org
content       pippki                  jar:pippki.jar!/content/pippki/ xpcnativewrappers=yes
locale        pippki      en-US       jar:en-US.jar!/locale/en-US/pippki/
content       global-platform         jar:toolkit.jar!/content/global-platform/ platform
skin          global      classic/1.0 jar:classic.jar!/skin/classic/global/
override chrome://global/content/netError.xhtml jar:embedder.jar!/global/content/netError.xhtml
content       inspector               jar:inspector.jar!/content/inspector/ xpcnativewrappers=no

Old-style contents.rdf manifests

Before the plaintext manifests were introduced (which happened in Firefox 1.5, Toolkit 1.8), RDF manifests named "contents.rdf" were used to register chrome. This format is deprecated; however, the Mozilla Suite (SeaMonkey) does not support the plaintext manifest format yet, so contents.rdf manifests are required for extensions that wish to maintain backwards compatibility with Firefox 1.0 or the suite.

Official References for Toolkit API

{{wiki.template(':en/Toolkit_API/Official_References')}}

{{ wiki.languages( { "fr": "fr/Enregistrement_chrome", "pl": "pl/Rejestracja_Chrome" } ) }}

Revision Source

<p>
</p>
<h3 name="What_is_Chrome.3F"> What is Chrome? </h3>
<p><a href="en/Chrome">Chrome</a> is the set of user interface elements of the application window that are outside of a window's content area. Toolbars, menu bars, progress bars, and window title bars are all examples of elements that are typically part of the chrome.
</p>
<h3 name="Chrome_Providers">Chrome Providers</h3>
<p>A supplier of chrome for a given window type (e.g., for the browser window) is called a chrome provider. The providers work together to supply a complete set of chrome for a particular window, from the images on the toolbar buttons to the files that describe the text, contents and appearance of the window itself.
</p><p>There are three basic types of chrome providers:
</p>
<h4 name="Content"> Content </h4>
<p>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. 
</p>
<h4 name="Locale"> Locale </h4>
<p>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. 
</p>
<h4 name="skin_.28pele.29"> skin (pele) </h4>
<p>A skin provider is responsible for providing a complete set of files that describe the visual appearance of the chrome. Typically a skin provider will provide CSS files and images.
</p>
<h3 name="The_Chrome_Registry"> The Chrome Registry </h3>
<p>The gecko runtime maintains a service known as the chrome registry that provides mappings from chrome package names to the physical location of chrome packages on disk.
</p><p>This chrome registry is configurable and persistent, and thus a user can install different chrome providers, and select a preferred skin and locale. This is accomplished through xpinstall and the extension manager.
</p><p>In order to inform the chrome registry of the available chrome, a text manifest is used: this manifest is "chrome.manifest" in the root of an extension, or theme, and chrome/*.manifest in a XULRunner application.
</p><p>The plaintext chrome manifests are a simple line-based format. Each line is parsed individually; if the line is parseable the chrome registry takes the action identified by that line; otherwise the chrome registry ignores that line (and prints a warning message in the runtime error console).
</p>
<pre class="eval">locale packagename localename path/to/files
skin packagename skinname path/to/files
</pre>
<h3 name="Manifest_Instructions"> Manifest Instructions </h3>
<h4 name="Comments"> Comments </h4>
<p>A line is a comment if it begins with the character '#'; any other characters on the line are ignored.
</p>
<pre class="eval"># this line is a comment - you can put whatever you want here
</pre>
<h4 name="content"> content </h4>
<p>A content package is registered with the line
</p>
<pre class="eval">content <i>packagename</i> <i>uri/to/files/</i> <i>[flags]</i>
</pre>
<p>This will register a location to use when resolving the URI <tt>chrome://<i>packagename</i>/content/...</tt>. The URI may be absolute or relative to the location of the manifest file. Note, that it must end with an '/'.
</p>
<h4 name="locale"> locale </h4>
<p>A locale package is registered with the line
</p>
<pre class="eval">locale <i>packagename</i> <i>localename</i> <i>uri/to/files/</i> <i>[flags]</i>
</pre>
<p>This will register a locale package when resolving the URI chrome://<i>packagename</i>/locale/... . The <i>localename</i> is usually a plain language identifier "en" or a language-country identifier "en-US". If more than one locale is registered for a package, the chrome registry will select the best-fit locale using the user's preferences.
</p>
<h4 name="skin"> skin </h4>
<p>A skin package is registered with the line
</p>
<pre class="eval">skin <i>packagename</i> <i>skinname</i> <i>uri/to/files/</i> <i>[flags]</i>
</pre>
<p>This will register a skin package when resolving the URI chrome://packagename/skin/... . The <i>skinname</i> is an opaque string identifying an installed skin. If more than one skin is registered for a package, the chrome registry will select the best-fit skin using the user's preferences.
</p>
<h4 name="overlay"> overlay </h4>
<p>XUL overlays are registered with the following syntax:
</p>
<pre class="eval">overlay chrome://<i>URI-to-be-overlaid</i> chrome://<i>overlay-URI</i> <i>[flags]</i>
</pre>
<h4 name="style"> style </h4>
<p>Style overlays (custom CSS which will be applied to a chrome page) are registered with the following syntax:
</p>
<pre class="eval">style chrome://<i>URI-to-style</i> chrome://<i>stylesheet-URI</i> <i>[flags]</i>
</pre>
<h4 name="override"> override </h4>
<p>In some cases an extension or embedder may wish to override a chrome file provided by the application or XULRunner. In order to allow for this, the chrome registration manifest allows for "override" instructions:
</p>
<pre class="eval">override chrome://<i>package</i>/<i>type</i>/<i>original-uri.whatever</i> <i>new-resolved-URI</i> <i>[flags]</i>
</pre>
<h3 name="Manifest_Flags"> Manifest Flags </h3>
<p>Manifest lines can have multiple, space-delimited flags added at the end of the registration line. These flags mark special attributes of chrome in that package, or limit the conditions under which the line is used.
</p>
<h4 name="application"> application </h4>
<p>Extensions may install into multiple applications. There may be chrome registration lines which only apply to one particular application. The flag
</p>
<pre class="eval">application=<i>app-ID</i>
</pre>
<p>indicates that the instruction should only be applied if the extension is installed into the application identified by <i>app-ID</i> is running. Multiple application flags may be included on a single line, in which case the line is applied if any of the flags match.
</p>
<h4 name="appversion"> appversion </h4>
<p>Extensions may install into multiple versions of an application. There may be chrome registration lines which only apply to a particular application version. The flag
</p>
<pre class="eval">appversion=<i>version</i>
appversion&lt;<i>version</i>
appversion&lt;=<i>version</i>
appversion&gt;<i>version</i>
appversion&gt;=<i>version</i>
</pre>
<p>indicates that the instruction should only be applied if the extension is installed into the application version identified. Multiple <code>appversion</code> flags may be included on a single line, in which case the line is applied if any of the flags match. The version string must conform to the <a href="en/Toolkit_version_format">Toolkit version format</a>.
</p>
<h4 name="platform_.28Platform-specific_packages.29"> platform (Platform-specific packages) </h4>
<p>Some packages are marked with a special flag indicating that they are platform specific. Some parts of content, skin, locales may be different based on the platform being run. These packages contain three different sets of files, for windows/os2, macintosh, and unix-like platforms. For example, the order of the "OK" and "cancel" buttons on a dialog is different, as well as the name of some items.
</p><p>The "platform" modifier is only parsed for content registration, it is not recognized for locale or skin registration. However it applies to content, locale, and skin parts of the package, when specified.
</p><p>To indicate that a package is platform-specific, add the "platform" modifier to the "content" line after the path, for example:
</p>
<pre class="eval">content global-platform jar:toolkit.jar!/toolkit/content/global-platform/ platform
</pre>
<p>Once that is specified in your manifest you then ensure that under the directory global-platform are subdirectories <code>win</code> (Windows/OS2), <code>mac</code> (OS9/OSX), or <code>unix</code> (Everything Else). Anything residing outside of these subdirectories will be ignored.
</p>
<h4 name="xpcnativewrappers"> xpcnativewrappers </h4>
<p>Chrome packages can decide whether to use the xpcnativewrappers security mechanism to protect their code against malicious content that they might access. See <a href="en/Safely_accessing_content_DOM_from_chrome">Safely accessing content DOM from chrome</a> for details.
</p><p>As of Firefox 1.5 alpha releases (Deer Park alphas), this flag is *off* by default, and must be explicitly enabled by specifying xpcnativewrappers=yes.
</p><p>As of the first Firefox 1.5 beta release, this flag will be enabled by default, and extensions that need insecure access to the content objects will be required to specify xpcnativewrappers=no.
</p><p>The xpcnativewrappers flag applies only to content packages: it is not recognized for locale or skin registration.
</p>
<h3 name="Example_Chrome_Manifest"> Example Chrome Manifest </h3>
<pre class="eval">content       necko                   jar:comm.jar!/content/necko/ xpcnativewrappers=yes
locale	       necko       en-US       jar:en-US.jar!/locale/en-US/necko/
content       xbl-marquee             jar:comm.jar!/content/xbl-marquee/
content       pipnss                  jar:pipnss.jar!/content/pipnss/
locale        pipnss      en-US       jar:en-US.jar!/locale/en-US/pipnss/
# Firefox-only
overlay chrome://browser/content/pageInfo.xul           chrome://pippki/content/PageInfoOverlay.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://communicator/content/pref/preftree.xul chrome://pippki/content/PrefOverlay.xul
overlay chrome://navigator/content/pageInfo.xul         chrome://pippki/content/PageInfoOverlay.xul application=seamonkey@applications.mozilla.org
content       pippki                  jar:pippki.jar!/content/pippki/ xpcnativewrappers=yes
locale        pippki      en-US       jar:en-US.jar!/locale/en-US/pippki/
content       global-platform         jar:toolkit.jar!/content/global-platform/ platform
skin          global      classic/1.0 jar:classic.jar!/skin/classic/global/
override chrome://global/content/netError.xhtml jar:embedder.jar!/global/content/netError.xhtml
content       inspector               jar:inspector.jar!/content/inspector/ xpcnativewrappers=no
</pre>
<h3 name="Old-style_contents.rdf_manifests"> Old-style contents.rdf manifests </h3>
<p>Before the plaintext manifests were introduced (which happened in Firefox 1.5, Toolkit 1.8), RDF manifests named "contents.rdf" were used to register chrome. This format is deprecated; however, the Mozilla Suite (SeaMonkey) does not support the plaintext manifest format yet, so contents.rdf manifests are required for extensions that wish to maintain backwards compatibility with Firefox 1.0 or the suite.
</p>
<h3 name="Official_References_for_Toolkit_API"> Official References for <a href="en/Toolkit_API">Toolkit API</a> </h3>
<p>{{wiki.template(':en/Toolkit_API/Official_References')}}
</p>{{ wiki.languages( { "fr": "fr/Enregistrement_chrome", "pl": "pl/Rejestracja_Chrome" } ) }}
Revert to this revision