diff options
Diffstat (limited to 'chrome/common/extensions/docs/static/event_pages.html')
-rw-r--r-- | chrome/common/extensions/docs/static/event_pages.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/chrome/common/extensions/docs/static/event_pages.html b/chrome/common/extensions/docs/static/event_pages.html new file mode 100644 index 0000000..b980809 --- /dev/null +++ b/chrome/common/extensions/docs/static/event_pages.html @@ -0,0 +1,78 @@ +<div id="pageData-name" class="pageData">Event Pages</div> +<div id="pageData-showTOC" class="pageData">true</div> + +<p class="warning"> + <!-- Standard content lead-in for APIs that are not yet available on + the stable channel. --> + <em>Warning:</em> This API is still under development. It is only + available for Chrome users on the + <span> + <strong>dev</strong> + <a href="http://www.chromium.org/getting-involved/dev-channel">early + release channel</a>.</span> +</p> + +<p> +Event pages are very similar to +<a href="background_pages.html">background pages</a>, +with one important difference: +event pages are loaded only when they are needed. +When the event page is not actively doing something, +it is unloaded, freeing memory and other system resources. +</p> + +<h2 id="manifest">Manifest</h2> + +<p> +Register your event page in the +<a href="manifest.html">extension manifest</a>: +</p> + +<pre>{ + "name": "My extension", + ... + <b>"background": { + "scripts": ["eventPage.js"], + "persistent": false + }</b>, + ... +}</pre> + +<p> +Notice that without the "persistent" key, you have +a regular background page. Persistence is what differentiates +an event page from a background page. +</p> + +<h2 id="lifetime">Lifetime</h2> + +<p> +The event page is loaded when it is "needed", and unloaded +when it goes idle again. Here are some examples of things +that will cause the event page to load: +</p> +<ul> +<li>The extension is first installed. +<li>The event page listens for an event and the event is dispatched. +<li>A content script or other extension +<a href="messaging.html">sends a message.</a> +<li>Another view in the extension (for example, a popup) calls +<code><a href="runtime.html#method-getBackgroundPage">chrome.runtime.getBackgroundPage()</a></code>. +</ul> + +<p> +Once it has been loaded, the event page will stay running +as long as it is active (for example, calling an extension +API or issuing a network request). Additionally, the +event page will not unload until all visible views (for example, +popup windows) are closed. +</p> + +<p> +Once the event page has been idle a short time +(a few seconds), the +<code><a href="runtime.html#event-onSuspend">chrome.runtime.onSuspend</a></code> +event is dispatched. The event page has a few more seconds to handle this +event before it is forcibly unloaded. Note that once the event is dispatched, +new activity will not keep the event page open. +</p> |