Visit Mozilla.org

Observer Notifications

From MDC

Contents

[edit] 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 observer service.

[edit] Application startup

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

Topic Description
xpcom-startup Called when xpcom is initialized. Many things are not available for use at this point. You must register in the category manager to see this topic.
app-startup General event for application startup. You must register in the category manager to see this topic.
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.
final-ui-startup Triggered just before the first window for the application is displayed.
sessionstore-windows-restored New in Firefox 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.

[edit] 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.
quit-application-granted All observers have agreed to the shutdown.
quit-application The application is about to quit.
profile-change-net-teardown The network connection is going offline at this point.
profile-change-teardown Part of the shutdown, profile data is still available at this point.
profile-before-change Called just before the profile is lost.
xpcom-shutdown This is the end. Many things will not be available here.

[edit] Windows

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

Topic Description
toplevel-window-readyCalled just after a new top level window has been opened and is ready, but has not yet loaded a document.
xul-window-registeredCalled just after a top level XUL window is registered with the window mediator service.
xul-window-visibleCalled just after a XUL window is made visible.
xul-window-destroyedCalled just before a XUL window is destroyed.
dom-window-destroyedCalled just before a DOM window is destroyed.

[edit] 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 cancelled.

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. The data of the notification will be "offline" or "online" to indicate the new state.

[edit] 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 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.
http-on-examine-response Called after a response has been received from the webserver. Headers are available on the channel.

[edit] Cookies

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

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