Observer Notifications

  • Revision slug: Observer_Notifications
  • Revision title: Observer Notifications
  • Revision id: 53263
  • Created:
  • Creator: Johnjbarton
  • Is current revision? No
  • Comment 30 words added, 24 words removed

Revision Content

Observer topics

The following are topics that you can observe during the course of an application. Unless otherwise noted you register for the topics using the {{ interface("nsIObserverService") }}.

Application startup

These are the topics that you can observe on startup, in order of appearance.

If your component requires access to the user profile, or any services which require access to the profile (preferences, bookmarks, and so on) then a common pattern is to register with the {{ interface("nsICategoryManager") }} for the app-startup topic which can be done in the component's registration code, and then in that notification register with the observer service for the profile-after-change notification. See Receiving startup notifications for more information about how this works.

{{ Fx_minversion_note("3.5", "Starting in Firefox 3.5 components can simply register for the profile-after-change notification in " .. interface("nsICategoryManager") .. ".") }}

Topic Description
xpcom-startup

{{ Note("An extension can no longer be registered to receive this notification in Firefox 4 and later. See XPCOM changes in Gecko 2.0 for details.") }}

Called when xpcom is initialized. Many things are not available for use at this point. To receive this notification you have to register with {{ interface("nsICategoryManager") }}. The registered component is always retrieved as a singleton (That is getService() will be used to instantiate it).

app-startup

{{ Note("An extension can no longer be registered to receive this notification in Firefox 4 and later. See XPCOM changes in Gecko 2.0 for details.") }}

General event for application startup. To receive this notification you have to register with {{ interface("nsICategoryManager") }}. Prepend "service," to the contract ID in the category registration to be invoked via getService() instead of createInstance().

profile-do-change This is fired after the profile has been selected. You will not be able to access user preferences, bookmarks, or anything that uses the profile folder until this event occurs. This occurs after any profile migration.
profile-after-change

This is fired after all the observers for profile-do-change have been notified.

{{ fx_minversion_note("3.5", "You can register with " .. interface("nsICategoryManager") .. " to receive this notification. Prior to Firefox 3.5, this was available to observers observing the app-startup/xpcom-startup notification.") }}

final-ui-startup

Triggered just before the first window for the application is displayed.

{{ Note("You must register with " .. interface("nsICategoryManager") .. " to receive this notification.") }}

sessionstore-windows-restored {{ Fx_minversion_inline("3") }}

Sent by the session restore process to indicate that all initial browser windows have opened. Note that while the window are open and the chrome loaded the tabs in the windows may still be being restored after this notification.

{{ Note("This notification is specific to Firefox and SeaMonkey 2.0 applications") }}

Application shutdown

These are the topics that you can observe on shutdown, in order of appearance.

Topic Description
quit-application-requested Something has requested that the application be shutdown. You can cancel the shutdown from here by setting aSubject.data to true (aSubject is the first parameter to your observer, the data value is an {{ interface("nsISupportsPRBool") }}).
quit-application-granted All observers have agreed to the shutdown.
quit-application The application is about to quit. This can be in response to a normal shutdown, or a restart. {{ Note("The data value for this notification is either 'shutdown' or 'restart'.") }}
profile-change-net-teardown The network connection is going offline at this point. {{ Note("The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.") }}
profile-change-teardown Part of the shutdown, profile data is still available at this point. {{ Note("The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.") }}
profile-before-change Called just before the profile is lost. {{ Note("The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.") }}
xpcom-will-shutdown {{ fx_minversion_inline("3.6") }} Called just before xpcom-shutdown. Observer must not spin event loop.
xpcom-shutdown This is the end. Many things will not be available here.

Browser

These topics indicate interesting things that happen that the browser alerts you to.

Topic Description
browser:purge-session-history Sent when the sanitizer runs to purge all history and other information.
browser-lastwindow-close-requested Sent when the browser wishes to close the last open browser window. When this is sent, it is possible that other windows may still be open, such as the download manager or preferences. The data value is an {{ interface("nsISupportsPRBool") }}. Recipients may set this to true to abort the close. {{ fx_minversion_inline("3.6") }}
browser-lastwindow-close-granted Sent when all interested parties have responded to the browser-lastwindow-close-requested notification and none of them requested that the close be aborted. After this is sent and handled, the browser window will close. {{ fx_minversion_inline("3.6") }}

Documents

These topics indicate notifications you can monitor related to DOM documents.

Topic Subject Data Description
chrome-document-global-created {{ gecko_minversion_inline("1.9.2.6") }} {{ interface("nsIDOMWindow") }} null Sent immediately after a chrome document window has been set up, but before any script code has been executed. This lets extensions inject API into chrome windows as needed. |data| is intentionally left blank.
content-document-global-created {{ gecko_minversion_inline("1.9.2.6") }} {{ interface("nsIDOMWindow") }} origin Sent immediately after a web content document window has been set up, but before any script code has been executed. This lets extensions inject API into content windows as needed. |data| is a string form of the origin (for use in security checks), eg "http://developer.mozilla.org".
user-interaction-active {{ interface("nsIDOMWindow") }} null

Sent once every 5000ms while this chrome document sees some kind of user activity (for example, keyboard or mouse events), and at the exact moment of the state transition from idle to active.

This topic has existed at least since Firefox 3.0, and still exists in Firefox 4.0b8.

user-interaction-inactive {{ interface("nsIDOMWindow") }} null

Sent after every 5000ms where this chrome document has seen no user activity (for example, keyboard or mouse events). (The counting starts at the time of the last "user-interaction-active" message.)

This topic has existed at least since Firefox 3.0, and still exists in Firefox 4.0b8.

Windows

These topics indicate points of interest during the lifetime of a window.

Topic Data Description
dom-window-destroyed {{ gecko_minversion_inline("1.9") }}   Called just before a DOM window is destroyed.
inner-window-destroyed {{ gecko_minversion_inline("2.0") }}  null Called when an inner window is removed from the backward/forward cache. See Working With BFCache for information about the bfcache, and Inner and outer windows for details about how the window hierarchy works. Extensions that cache information about windows may wish to observe this so they can release information when the window is destroyed.  The window id can be obtained from subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data
outer-window-destroyed {{ gecko_minversion_inline("2.0") }} null Called when an outer window is removed from the backward/forward cache. See Working With BFCache for information about the bfcache, and Inner and outer windows for details about how the window hierarchy works. Extensions that cache information about windows may wish to observe this so they can release information when the window is destroyed.  The window id can be obtained from subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data
toplevel-window-ready   Called just after a new top level window has been opened and is ready, but has not yet loaded a document.
xul-window-destroyed   Called just before a XUL window is destroyed.
xul-window-registered   Called just after a top level XUL window is registered with the window mediator service.
xul-window-visible   Called just after a XUL window is made visible.

IO Notifications

These topics can be used to watch the IO service for useful information.

Topic Description
offline-requested Called to query whether the application can go offline. The attempt to go offline can be canceled.

{{ Note("If your code chooses to cancel the attempt to go offline, it must notify the user.") }}

network:offline-about-to-go-offline Called just before all network IO is taken offline.
network:offline-status-changed Called when the offline state has changed. {{ Note("The data value for this notification 'offline' or 'online' to indicate the new state.") }}

HTTP requests

These are the topics that you can observe during a HTTP request (see Setting HTTP request headers and Creating Sandboxed HTTP Connections). Both are passed an {{ Interface("nsIHttpChannel") }} as the subject parameter.

Topic Description
http-on-modify-request Called as a http request is made. The channel is available to allow you to modify headers and such. See this code snippet to learn how to get the tab that issued the request.
http-on-examine-response Called after a response has been received from the webserver. Headers are available on the channel.
http-on-examine-cached-response {{ Fx_minversion_inline("3") }} Called instead of http-on-examine-response when a response will be read completely from the cache. Headers are available on the channel.

Cookies

These topics indicate whenever a cookie has been changed (added, changed, cleared, or deleted) or its setting rejected by the browser. See {{ Interface("nsICookieService") }} for details.

Topic Description
cookie-changed Called upon a cookie change (added, changed, cleared, or deleted)
cookie-rejected Called when the setting of a cookie was rejected by the browser (per the user's preferences)

Download Manager

These topics indicate that events related to the Download Manager have occurred.

Topic Description
download-manager-ui-done Called when the list of downloads in the Download Manager windows finishes updating.  This can happen multiple times, such as when the window first opens, when multiple items are removed, and when entering private browsing mode.
download-manager-remove-download {{ Fx_minversion_inline("3") }} Called when a download of the list is removed or all the list is cleared. The subject will be the download id wrapped in {{ interface("nsISupportsPRUint32") }}, for one download removed, or null for multi download remove, for example when the download list is cleared.

Extension Manager

{{ gecko_callout_heading("2.0") }}

These notifications are no longer available starting with Gecko 2.0, instead use AddonManager.addAddonListener() to receive similar events.

This topic indicates when the extension manager performs some action. Note that any action will be taken the next time the application starts. See {{ Interface("nsIExtensionManager") }} for details.

Topic Data Description
em-action-requested item-installed A new extension has been installed.
em-action-requested item-upgraded A different version of an existing extension has been installed.
em-action-requested item-uninstalled An addon has been marked to be uninstalled.
em-action-requested item-enabled An addon has been enabled.
em-action-requested item-disabled An addon has been disabled.
em-action-requested item-cancel-action A previous action has been cancelled.

Idle Service

This topic indicates when actions related to the Idle Service, provided by the {{ interface("nsIIdleService") }} interface. Unlike the user-interaction-active and user-interaction-inactive topics listed above, the Idle Service monitors user activity in general, whether related to the Mozilla application or not (acting somewhat like the user activity/inactivity events a screen saver would be interested in).

Topic Data Description
idle The length of time the user has been idle, in milliseconds. Sent when the user becomes idle.
idle-daily The length of time the user has been idle, in milliseconds. Sent once a day while the user is idle. {{ gecko_minversion_inline("1.9.2") }}
back The length of time the user has been idle, in milliseconds. Sent when the user returns from being idle.

Computer sleep and wake

This topic indicates when actions related to the computer going to sleep or waking up occur.

Topic Data Description
sleep_notification null Sent when the computer is going to sleep.
wake_notification null Sent when the computer is waking up.

Login Manager

This topic indicates when actions related to the Login Manager occur.

Topic Data Description
passwordmgr-found-form noAutofillForms A login is available for this form, but autofill of forms is disabled, so the form was not automatically filled out.  {{ fx_minversion_inline("3") }}
passwordmgr-found-form autocompleteOff A login is available for this form, but autocomplete is disabled.{{ fx_minversion_inline("3") }}
passwordmgr-storage-changed addLogin A login has been added to the Login Manager's database. The notification's subject is the login that was added to the database. {{ fx_minversion_inline("3") }}
passwordmgr-storage-changed removeLogin A login was removed from the Login Manager's database. The notification's subject is the login that was removed from the database. {{ fx_minversion_inline("3") }}
passwordmgr-storage-changed modifyLogin A login in the Login Manager's database was modified. The notification's subject is an array whose first entry is the old login and whose second entry is the new one. {{ fx_minversion_inline("3") }}
passwordmgr-storage-changed removeAllLogins All logins have been removed from the Login Manager's database. {{ fx_minversion_inline("3") }}
passwordmgr-storage-changed hostSavingEnabled Host saving has been enabled. {{ fx_minversion_inline("3") }}
passwordmgr-storage-changed hostSavingDisabled Host saving has been disabled. {{ fx_minversion_inline("3") }}

Places

This topic indicates when actions related to Places (the history and bookmarks database) occur.

Topic Data Description
places-autocomplete-feedback-updated   Sent when Places updates the location bar's autocompletion display.
places-connection-closed   Sent after Places has closed its database connection. Once this has been sent, no Places features will work. {{ gecko_minversion_inline("2.0") }}
places-connection-closing  

Sent as the last notification before the Places service closes its database connection. {{ gecko_minversion_inline("2.0") }}

Warning: This is for internal use only.
places-database-locked   The Places database is currently locked by a third-party process and cannot be opened.
places-favicons-expired   Sent when all favicons have been expired. {{ gecko_minversion_inline("1.9.2") }}
places-init-complete   The Places database has been successfully initialized. You should wait until this notification occurs before querying the places database.
places-maintenance-finished   Sent when maintenance of the Places database is complete; this is done periodically in the background to keep the Places database tidy.
places-shutdown   Sent when Places shuts down. If you are referencing instances of {{ interface("mozIStorageStatement") }} referencing Places databases when this notification occurs, you should call their {{ ifmethod("mozIStorageStatement", "finalize") }} method {{ gecko_minversion_inline("2.0") }}
places-sync-finished   Sent when the Places database has been successfully flushed to disk.
places-will-close-connection  

Sent when the Places service is about to close its database connection. Only necessary cleanup tasks should run at this point, and nothing should be added to the database. In addition, after this has been sent, no Places APIs should be called. {{ gecko_minversion_inline("2.0") }}

Warning: This is for internal use only.

Session Store

These topics are used when actions related to Session Store occur.

Topic Data Description
sessionstore-state-read   Sent immediately after session store data is read and before it's used. {{ fx_minversion_inline("3") }}
sessionstore-state-write   Sent immediately before the session store data is written to disk. {{ fx_minversion_inline("3") }}

Private browsing

These topics indicate when actions related to private browsing occur.

Topic Data Description
private-browsing enter Sent when private browsing mode is activated. {{ fx_minversion_inline("3.5") }}
private-browsing exit Sent when private browsing mode is deactivated. {{ fx_minversion_inline("3.5") }}

Bookmarks

These topics indicate when actions related to bookmarks occur.

Topic Data Description
bookmarks-restore-begin json Sent just before bookmarks are restored from JSON. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-begin html Sent just before bookmarks are restored from HTML. If bookmarks will be restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-begin html-initial Sent just before bookmarks are restored from HTML on initial import. If bookmarks are restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-success json Sent just after bookmarks are restored from JSON. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-success html Sent just after bookmarks are restored from HTML. If bookmarks were restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-success html-initial Sent just after bookmarks are restored from HTML on initial import. If bookmarks were restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-failed json Sent when bookmarks could not be sucessfully restored from JSON. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-failed html Sent when bookmarks could not be successfully restored from HTML. If bookmarks were to have been restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}
bookmarks-restore-failed html-initial Sent when bookmarks could not be successfully restored from HTML on intial import. If bookmarks were to have been restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}

Themes

These topics indicate when actions related to themes occur.

Topic Data Description
lightweight-theme-preview-requested {{ fx_minversion_inline("3.6") }} json Sent when the user requests to preview a lightweight theme, but before existing windows are styled with the new theme.
lightweight-theme-change-requested {{ fx_minversion_inline("3.6") }} json Sent to indicate that the user has chosen a new theme in the add-ons manager, but before the change takes effect.
lightweight-theme-changed {{ fx_minversion_inline("3.6") }} - Sent after the current theme is changed.
lightweight-theme-styling-update {{ fx_minversion_inline("3.6") }} json Sent when the current theme being used is changed; this is sent even when the user is previewing a theme, not just when the theme is actually selected.
lightweight-theme-list-changed {{ fx_minversion_inline("3.6") }} - The list of available lightweight themes has changed.

{{ languages( { "ja": "ja/Observer_Notifications" } ) }}

Revision Source

<h2 name="Observer_topics">Observer topics</h2>
<p>The following are topics that you can observe during the course of an application. Unless otherwise noted you register for the topics using the {{ interface("nsIObserverService") }}.</p>
<h3 name="Application_startup">Application startup</h3>
<p>These are the topics that you can observe on startup, in order of appearance.</p>
<p>If your component requires access to the user profile, or any services which require access to the profile (preferences, bookmarks, and so on) then a common pattern is to register with the {{ interface("nsICategoryManager") }} for the app-startup topic which can be done in the component's registration code, and then in that notification register with the observer service for the profile-after-change notification. See <a href="/en/XPCOM/Receiving_startup_notifications" title="en/XPCOM/Receiving startup notifications">Receiving startup notifications</a> for more information about how this works.</p>
<p>{{ Fx_minversion_note("3.5", "Starting in Firefox 3.5 components can simply register for the profile-after-change notification in " .. interface("nsICategoryManager") .. ".") }}</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Description</th> </tr> <tr> <td>xpcom-startup</td> <td> <p>{{ Note("An extension can no longer be registered to receive this notification in Firefox 4 and later. See <a href='\"en/XPCOM/XPCOM_changes_in_Gecko_2.0#Category_registration\"'>XPCOM changes in Gecko 2.0</a> for details.") }}</p> <p>Called when xpcom is initialized. Many things are not available for use at this point. To receive this notification you have to register with {{ interface("nsICategoryManager") }}. The registered component is always retrieved as a singleton (That is getService() will be used to instantiate it).</p> </td> </tr> <tr> <td>app-startup</td> <td> <p>{{ Note("An extension can no longer be registered to receive this notification in Firefox 4 and later. See <a href='\"en/XPCOM/XPCOM_changes_in_Gecko_2.0#Category_registration\"'>XPCOM changes in Gecko 2.0</a> for details.") }}</p> <p>General event for application startup. To receive this notification you have to register with {{ interface("nsICategoryManager") }}. Prepend "service," to the contract ID in the category registration to be invoked via getService() instead of createInstance().</p> </td> </tr> <tr> <td>profile-do-change</td> <td>This is fired after the profile has been selected. You will not be able to access user preferences, bookmarks, or anything that uses the profile folder until this event occurs. This occurs after any profile migration.</td> </tr> <tr> <td>profile-after-change</td> <td> <p>This is fired after all the observers for profile-do-change have been notified.</p> <p>{{ fx_minversion_note("3.5", "You can register with " .. interface("nsICategoryManager") .. " to receive this notification. Prior to Firefox 3.5, this was available to observers observing the app-startup/xpcom-startup notification.") }}</p> </td> </tr> <tr> <td>final-ui-startup</td> <td> <p>Triggered just before the first window for the application is displayed.</p> <p>{{ Note("You must register with " .. interface("nsICategoryManager") .. " to receive this notification.") }}</p> </td> </tr> <tr> <td>sessionstore-windows-restored {{ Fx_minversion_inline("3") }}</td> <td> <p>Sent by the session restore process to indicate that all initial browser windows have opened. Note that while the window are open and the chrome loaded the tabs in the windows may still be being restored after this notification.</p> <p>{{ Note("This notification is specific to Firefox and SeaMonkey 2.0 applications") }}</p> </td> </tr> </tbody>
</table>
<h3 name="Application_shutdown">Application shutdown</h3>
<p>These are the topics that you can observe on shutdown, in order of appearance.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Description</th> </tr> <tr> <td>quit-application-requested</td> <td>Something has requested that the application be shutdown. You can cancel the shutdown from here by setting <code>aSubject.data</code> to <code>true</code> (<code>aSubject</code> is the first parameter to your observer, the data value is an {{ interface("nsISupportsPRBool") }}).</td> </tr> <tr> <td>quit-application-granted</td> <td>All observers have agreed to the shutdown.</td> </tr> <tr> <td>quit-application</td> <td>The application is about to quit. This can be in response to a normal shutdown, or a restart. {{ Note("The data value for this notification is either 'shutdown' or 'restart'.") }}</td> </tr> <tr> <td>profile-change-net-teardown</td> <td>The network connection is going offline at this point. {{ Note("The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.") }}</td> </tr> <tr> <td>profile-change-teardown</td> <td>Part of the shutdown, profile data is still available at this point. {{ Note("The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.") }}</td> </tr> <tr> <td>profile-before-change</td> <td>Called just before the profile is lost. {{ Note("The data value for this notification is either 'shutdown-persist' or 'shutdown-cleanse'.") }}</td> </tr> <tr> <td>xpcom-will-shutdown {{ fx_minversion_inline("3.6") }}</td> <td>Called just before xpcom-shutdown. Observer must not spin event loop.</td> </tr> <tr> <td>xpcom-shutdown</td> <td>This is the end. Many things will not be available here.</td> </tr> </tbody>
</table>
<h3 name="Browser">Browser</h3>
<p>These topics indicate interesting things that happen that the browser alerts you to.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Description</th> </tr> <tr> <td>browser:purge-session-history</td> <td>Sent when the sanitizer runs to purge all history and other information.</td> </tr> <tr> <td>browser-lastwindow-close-requested</td> <td>Sent when the browser wishes to close the last open browser window. When this is sent, it is possible that other windows may still be open, such as the download manager or preferences. The data value is an {{ interface("nsISupportsPRBool") }}. Recipients may set this to <code>true</code> to abort the close. {{ fx_minversion_inline("3.6") }}</td> </tr> <tr> <td>browser-lastwindow-close-granted</td> <td>Sent when all interested parties have responded to the browser-lastwindow-close-requested notification and none of them requested that the close be aborted. After this is sent and handled, the browser window will close. {{ fx_minversion_inline("3.6") }}</td> </tr> </tbody>
</table>
<h3 name="Documents">Documents</h3>
<p>These topics indicate notifications you can monitor related to DOM documents.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Subject</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>chrome-document-global-created {{ gecko_minversion_inline("1.9.2.6") }}</td> <td>{{ interface("nsIDOMWindow") }}</td> <td>null</td> <td>Sent immediately after a chrome document window has been set up, but before any script code has been executed. This lets extensions inject API into chrome windows as needed. |data| is intentionally left blank.</td> </tr> <tr> <td>content-document-global-created {{ gecko_minversion_inline("1.9.2.6") }}</td> <td>{{ interface("nsIDOMWindow") }}</td> <td>origin</td> <td>Sent immediately after a web content document window has been set up, but before any script code has been executed. This lets extensions inject API into content windows as needed. |data| is a string form of the origin (for use in security checks), eg "<a class=" external" href="http://developer.mozilla.org" rel="freelink">http://developer.mozilla.org</a>".</td> </tr> <tr> <td>user-interaction-active</td> <td>{{ interface("nsIDOMWindow") }}</td> <td>null</td> <td> <p>Sent once every 5000ms while this chrome document sees some kind of user activity (for example, keyboard or mouse events), <em>and</em> at the exact moment of the state transition from idle to active.</p> <p>This topic has existed at least since Firefox 3.0, and still exists in Firefox 4.0b8.</p> </td> </tr> <tr> <td>user-interaction-inactive</td> <td>{{ interface("nsIDOMWindow") }}</td> <td>null</td> <td> <p>Sent after every 5000ms where this chrome document has seen no user activity (for example, keyboard or mouse events). (The counting starts at the time of the last "user-interaction-active" message.)</p> <p>This topic has existed at least since Firefox 3.0, and still exists in Firefox 4.0b8.</p> </td> </tr> </tbody>
</table>
<h3 name="Windows">Windows</h3>
<p>These topics indicate points of interest during the lifetime of a window.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>dom-window-destroyed {{ gecko_minversion_inline("1.9") }}</td> <td> </td> <td>Called just before a DOM window is destroyed.</td> </tr> <tr> <td>inner-window-destroyed {{ gecko_minversion_inline("2.0") }}</td> <td> null</td> <td>Called when an inner window is removed from the backward/forward cache. See <a href="/En/Working_with_BFCache" title="En/Working with BFCache">Working With BFCache</a> for information about the bfcache, and <a href="/en/Inner_and_outer_windows" title="en/Inner and outer windows">Inner and outer windows</a> for details about how the window hierarchy works. Extensions that cache information about windows may wish to observe this so they can release information when the window is destroyed.  The <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534149" title="https://bugzilla.mozilla.org/show_bug.cgi?id=534149">window id</a> can be obtained from subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data</td> </tr> <tr> <td>outer-window-destroyed {{ gecko_minversion_inline("2.0") }}</td> <td>null </td> <td>Called when an outer window is removed from the backward/forward cache. See <a href="/En/Working_with_BFCache" title="En/Working with BFCache">Working With BFCache</a> for information about the bfcache, and <a href="/en/Inner_and_outer_windows" title="en/Inner and outer windows">Inner and outer windows</a> for details about how the window hierarchy works. Extensions that cache information about windows may wish to observe this so they can release information when the window is destroyed.  The<a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=534149" title="https://bugzilla.mozilla.org/show_bug.cgi?id=534149"> window id</a> can be obtained from subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data</td> </tr> <tr> <td>toplevel-window-ready</td> <td> </td> <td>Called just after a new top level window has been opened and is ready, but has not yet loaded a document.</td> </tr> <tr> <td>xul-window-destroyed</td> <td> </td> <td>Called just before a XUL window is destroyed.</td> </tr> <tr> <td>xul-window-registered</td> <td> </td> <td>Called just after a top level XUL window is registered with the window mediator service.</td> </tr> <tr> <td>xul-window-visible</td> <td> </td> <td>Called just after a XUL window is made visible.</td> </tr> </tbody>
</table>
<h3 name="IO_Notifications">IO Notifications</h3>
<p>These topics can be used to watch the IO service for useful information.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Description</th> </tr> <tr> <td>offline-requested</td> <td>Called to query whether the application can go offline. The attempt to go offline can be canceled. <p>{{ Note("If your code chooses to cancel the attempt to go offline, it <b>must</b> notify the user.") }}</p> </td> </tr> <tr> <td>network:offline-about-to-go-offline</td> <td>Called just before all network IO is taken offline.</td> </tr> <tr> <td>network:offline-status-changed</td> <td>Called when the offline state has changed. {{ Note("The data value for this notification 'offline' or 'online' to indicate the new state.") }}</td> </tr> </tbody>
</table>
<h3 name="HTTP_requests">HTTP requests</h3>
<p>These are the topics that you can observe during a HTTP request (see <a href="/en/Setting_HTTP_request_headers" title="en/Setting_HTTP_request_headers">Setting HTTP request headers</a> and <a href="/en/Creating_Sandboxed_HTTP_Connections#HTTP_notifications" title="en/Creating_Sandboxed_HTTP_Connections#HTTP_notifications"> Creating Sandboxed HTTP Connections</a>). Both are passed an {{ Interface("nsIHttpChannel") }} as the subject parameter.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Description</th> </tr> <tr> <td>http-on-modify-request</td> <td>Called as a http request is made. The channel is available to allow you to modify headers and such. See <a class="internal" href="/en/Code_snippets/Tabbed_browser#Getting_the_tab_that_fires_the_http-on-modify-request_notification" title="en/Code snippets/Tabbed browser#Getting the tab that fires the http-on-modify-request notification">this code snippet</a> to learn how to get the tab that issued the request.</td> </tr> <tr> <td>http-on-examine-response</td> <td>Called after a response has been received from the webserver. Headers are available on the channel.</td> </tr> <tr> <td>http-on-examine-cached-response {{ Fx_minversion_inline("3") }}</td> <td>Called instead of http-on-examine-response when a response will be read completely from the cache. Headers are available on the channel.</td> </tr> </tbody>
</table>
<h3 name="Cookies">Cookies</h3>
<p>These topics indicate whenever a cookie has been changed (added, changed, cleared, or deleted) or its setting rejected by the browser. See {{ Interface("nsICookieService") }} for details.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Description</th> </tr> <tr> <td>cookie-changed</td> <td>Called upon a cookie change (added, changed, cleared, or deleted)</td> </tr> <tr> <td>cookie-rejected</td> <td>Called when the setting of a cookie was rejected by the browser (per the user's preferences)</td> </tr> </tbody>
</table>
<h3 name="Download_Manager">Download Manager</h3>
<p>These topics indicate that events related to the Download Manager have occurred.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Description</th> </tr> <tr> <td>download-manager-ui-done</td> <td>Called when the list of downloads in the Download Manager windows finishes updating.  This can happen multiple times, such as when the window first opens, when multiple items are removed, and when entering private browsing mode.</td> </tr> <tr> <td>download-manager-remove-download {{ Fx_minversion_inline("3") }}</td> <td>Called when a download of the list is removed or all the list is cleared. The subject will be the download id wrapped in {{ interface("nsISupportsPRUint32") }}, for one download removed, or null for multi download remove, for example when the download list is cleared.</td> </tr> </tbody>
</table>
<h3 name="Extension_Manager">Extension Manager</h3>
<div class="geckoVersionNote">
<p>{{ gecko_callout_heading("2.0") }}</p>
<p>These notifications are no longer available starting with Gecko 2.0, instead use <code><a href="/en/Addons/Add-on_Manager/AddonManager#addAddonListener()" title="https://developer.mozilla.org/en/Addons/Add-on_Manager/AddonManager#addAddonListener()">AddonManager.addAddonListener()</a></code> to receive similar events.</p>
</div>
<p>This topic indicates when the extension manager performs some action. Note that any action will be taken the next time the application starts. See {{ Interface("nsIExtensionManager") }} for details.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>em-action-requested</td> <td>item-installed</td> <td>A new extension has been installed.</td> </tr> <tr> <td>em-action-requested</td> <td>item-upgraded</td> <td>A different version of an existing extension has been installed.</td> </tr> <tr> <td>em-action-requested</td> <td>item-uninstalled</td> <td>An addon has been marked to be uninstalled.</td> </tr> <tr> <td>em-action-requested</td> <td>item-enabled</td> <td>An addon has been enabled.</td> </tr> <tr> <td>em-action-requested</td> <td>item-disabled</td> <td>An addon has been disabled.</td> </tr> <tr> <td>em-action-requested</td> <td>item-cancel-action</td> <td>A previous action has been cancelled.</td> </tr> </tbody>
</table>
<h3 name="Idle_Service">Idle Service</h3>
<p>This topic indicates when actions related to the Idle Service, provided by the {{ interface("nsIIdleService") }} interface. Unlike the user-interaction-active and user-interaction-inactive topics listed above, the Idle Service monitors user activity in general, whether related to the Mozilla application or not (acting somewhat like the user activity/inactivity events a screen saver would be interested in).</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>idle</td> <td>The length of time the user has been idle, in milliseconds.</td> <td>Sent when the user becomes idle.</td> </tr> <tr> <td>idle-daily</td> <td>The length of time the user has been idle, in milliseconds.</td> <td>Sent once a day while the user is idle. {{ gecko_minversion_inline("1.9.2") }}</td> </tr> <tr> <td>back</td> <td>The length of time the user has been idle, in milliseconds.</td> <td>Sent when the user returns from being idle.</td> </tr> </tbody>
</table>
<h3 name="Computer_sleep_and_wake">Computer sleep and wake</h3>
<p>This topic indicates when actions related to the computer going to sleep or waking up occur.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>sleep_notification</td> <td>null</td> <td>Sent when the computer is going to sleep.</td> </tr> <tr> <td>wake_notification</td> <td>null</td> <td>Sent when the computer is waking up.</td> </tr> </tbody>
</table>
<h3 name="Login_Manage">Login Manager</h3>
<p>This topic indicates when actions related to the Login Manager occur.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>passwordmgr-found-form</td> <td>noAutofillForms</td> <td>A login is available for this form, but autofill of forms is disabled, so the form was not automatically filled out.  {{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>passwordmgr-found-form</td> <td>autocompleteOff</td> <td>A login is available for this form, but autocomplete is disabled.{{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>passwordmgr-storage-changed</td> <td>addLogin</td> <td>A login has been added to the Login Manager's database. The notification's subject is the login that was added to the database. {{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>passwordmgr-storage-changed</td> <td>removeLogin</td> <td>A login was removed from the Login Manager's database. The notification's subject is the login that was removed from the database. {{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>passwordmgr-storage-changed</td> <td>modifyLogin</td> <td>A login in the Login Manager's database was modified. The notification's subject is an array whose first entry is the old login and whose second entry is the new one. {{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>passwordmgr-storage-changed</td> <td>removeAllLogins</td> <td>All logins have been removed from the Login Manager's database. {{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>passwordmgr-storage-changed</td> <td>hostSavingEnabled</td> <td>Host saving has been enabled. {{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>passwordmgr-storage-changed</td> <td>hostSavingDisabled</td> <td>Host saving has been disabled. {{ fx_minversion_inline("3") }}</td> </tr> </tbody>
</table>
<h3 name="Places">Places</h3>
<p>This topic indicates when actions related to Places (the history and bookmarks database) occur.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>places-autocomplete-feedback-updated</td> <td> </td> <td>Sent when Places updates the location bar's autocompletion display.</td> </tr> <tr> <td>places-connection-closed</td> <td> </td> <td>Sent after Places has closed its database connection. Once this has been sent, no Places features will work. {{ gecko_minversion_inline("2.0") }}</td> </tr> <tr> <td>places-connection-closing</td> <td> </td> <td> <p>Sent as the last notification before the Places service closes its database connection. {{ gecko_minversion_inline("2.0") }}</p> <div class="warning"><strong>Warning:</strong> This is for internal use only.</div> </td> </tr> <tr> <td>places-database-locked</td> <td> </td> <td>The Places database is currently locked by a third-party process and cannot be opened.</td> </tr> <tr> <td>places-favicons-expired</td> <td> </td> <td>Sent when all favicons have been expired. {{ gecko_minversion_inline("1.9.2") }}</td> </tr> <tr> <td>places-init-complete</td> <td> </td> <td>The Places database has been successfully initialized. You should wait until this notification occurs before querying the places database.</td> </tr> <tr> <td>places-maintenance-finished</td> <td> </td> <td>Sent when maintenance of the Places database is complete; this is done periodically in the background to keep the Places database tidy.</td> </tr> <tr> <td>places-shutdown</td> <td> </td> <td>Sent when Places shuts down. If you are referencing instances of {{ interface("mozIStorageStatement") }} referencing Places databases when this notification occurs, you should call their {{ ifmethod("mozIStorageStatement", "finalize") }} method {{ gecko_minversion_inline("2.0") }}</td> </tr> <tr> <td>places-sync-finished</td> <td> </td> <td>Sent when the Places database has been successfully flushed to disk.</td> </tr> <tr> <td>places-will-close-connection</td> <td> </td> <td> <p>Sent when the Places service is about to close its database connection. Only necessary cleanup tasks should run at this point, and nothing should be added to the database. In addition, after this has been sent, no Places APIs should be called. {{ gecko_minversion_inline("2.0") }}</p> <div class="warning"><strong>Warning:</strong> This is for internal use only.</div> </td> </tr> </tbody>
</table>
<h3 name="Session_Store">Session Store</h3>
<p>These topics are used when actions related to Session Store occur.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>sessionstore-state-read</td> <td> </td> <td>Sent immediately after session store data is read and before it's used. {{ fx_minversion_inline("3") }}</td> </tr> <tr> <td>sessionstore-state-write</td> <td> </td> <td>Sent immediately before the session store data is written to disk. {{ fx_minversion_inline("3") }}</td> </tr> </tbody>
</table>
<h3 name="Private_browsing">Private browsing</h3>
<p>These topics indicate when actions related to private browsing occur.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>private-browsing</td> <td>enter</td> <td>Sent when private browsing mode is activated. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>private-browsing</td> <td>exit</td> <td>Sent when private browsing mode is deactivated. {{ fx_minversion_inline("3.5") }}</td> </tr> </tbody>
</table>
<h3 name="Bookmarks">Bookmarks</h3>
<p>These topics indicate when actions related to bookmarks occur.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>bookmarks-restore-begin</td> <td>json</td> <td>Sent just before bookmarks are restored from JSON. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-begin</td> <td>html</td> <td>Sent just before bookmarks are restored from HTML. If bookmarks will be restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-begin</td> <td>html-initial</td> <td>Sent just before bookmarks are restored from HTML on initial import. If bookmarks are restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-success</td> <td>json</td> <td>Sent just after bookmarks are restored from JSON. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-success</td> <td>html</td> <td>Sent just after bookmarks are restored from HTML. If bookmarks were restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-success</td> <td>html-initial</td> <td>Sent just after bookmarks are restored from HTML on initial import. If bookmarks were restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-failed</td> <td>json</td> <td>Sent when bookmarks could not be sucessfully restored from JSON. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-failed</td> <td>html</td> <td>Sent when bookmarks could not be successfully restored from HTML. If bookmarks were to have been restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}</td> </tr> <tr> <td>bookmarks-restore-failed</td> <td>html-initial</td> <td>Sent when bookmarks could not be successfully restored from HTML on intial import. If bookmarks were to have been restored into a specific folder, observers will be passed an {{ Interface("nsISupportsPRInt64") }} through their subject parameters indicating the ID of the folder. The subject is null otherwise. {{ fx_minversion_inline("3.5") }}</td> </tr> </tbody>
</table>
<h3 name="Themes">Themes</h3>
<p>These topics indicate when actions related to themes occur.</p>
<table class="standard-table"> <tbody> <tr> <th>Topic</th> <th>Data</th> <th>Description</th> </tr> <tr> <td>lightweight-theme-preview-requested {{ fx_minversion_inline("3.6") }}</td> <td>json</td> <td>Sent when the user requests to preview a lightweight theme, but before existing windows are styled with the new theme.</td> </tr> <tr> <td>lightweight-theme-change-requested {{ fx_minversion_inline("3.6") }}</td> <td>json</td> <td>Sent to indicate that the user has chosen a new theme in the add-ons manager, but before the change takes effect.</td> </tr> <tr> <td>lightweight-theme-changed {{ fx_minversion_inline("3.6") }}</td> <td>-</td> <td>Sent after the current theme is changed.</td> </tr> <tr> <td>lightweight-theme-styling-update {{ fx_minversion_inline("3.6") }}</td> <td>json</td> <td>Sent when the current theme being used is changed; this is sent even when the user is previewing a theme, not just when the theme is actually selected.</td> </tr> <tr> <td>lightweight-theme-list-changed {{ fx_minversion_inline("3.6") }}</td> <td>-</td> <td>The list of available lightweight themes has changed.</td> </tr> </tbody>
</table>
<p>{{ languages( { "ja": "ja/Observer_Notifications" } ) }}</p>
Revert to this revision