Observers
Historically, each successful operation is notified through the nsINavBookmarksObserver interface. To listen to such notifications you must register using nsINavBookmarksService addObserver and removeObserver methods. Note that bookmark addition or order changes won’t notify bookmark-moved for items that have their indexes changed. Similarly, lastModified changes not done explicitly (like changing another property) won’t fire an onItemChanged notification for the lastModified property.
However, right now we are in the process of implementing a Places Observers system to change the nsINavBookmarksObserver interface.
Generally - the Observer pattern follows a subscription model. A subscriber (commonly referred to as the observer) subscribes to an event or an action handled by a publisher (commonly referred to as the subject) is notified when the event or action occurs.
Each successful operation is noticed by observer for these events and passed to a subscriber.
PlacesObservers.webidl a Global Singleton which provides utilities to observe or notify all events. PlacesEvent.webidl states all types of possible events and describes their features. In our case, events are:
“page-visited”-data: PlacesVisitFired whenever a page is visited
“bookmark-added”-data: PlacesBookmarkAdditionFired whenever a bookmark (or a bookmark folder/separator) is created.
“bookmark-removed”-data: PlacesBookmarkRemovedFired whenever a bookmark (or a bookmark folder/separator) is removed.
“bookmark-moved”-data: PlacesBookmarkMovedFired whenever a bookmark (or a bookmark folder/separator) is moved.
“bookmark-guid-changed”-data: PlacesBookmarkGuidFired whenever a bookmark guid changes.
“bookmark-keyword-changed”-data: PlacesBookmarkKeywordFired whenever a bookmark keyword changes.
“bookmark-tags-changed”-data: PlacesBookmarkTagsFired whenever tags of bookmark changes.
“bookmark-time-changed”-data: PlacesBookmarkTimeFired whenever dateAdded or lastModified of a bookmark is explicitly changed through the Bookmarks API. This notification doesn’t fire when a bookmark is created, or when a property of a bookmark (e.g. title) is changed, even if lastModified will be updated as a consequence of that change.
“bookmark-title-changed”-data: PlacesBookmarkTitleFired whenever a bookmark title changes.
“bookmark-url-changed”-data: PlacesBookmarkUrlFired whenever a bookmark url changes.
“favicon-changed”-data: PlacesFaviconFired whenever a favicon changes.
“page-title-changed”-data: PlacesVisitTitleFired whenever a page title changes.
“history-cleared”-data: PlacesHistoryClearedFired whenever history is cleared.
“page-rank-changed”-data: PlacesRankingFired whenever pages ranking is changed.
“page-removed”-data: PlacesVisitRemovedFired whenever a page or its visits are removed. This may be invoked when a page is removed from the store because it has no more visits, nor bookmarks. It may also be invoked when all or some of the page visits are removed, but the page itself is not removed from the store, because it may be bookmarked.
“purge-caches”-data: PlacesPurgeCachesFired whenever changes happened that could not be observed through other notifications, for example a database fixup. When received, observers, especially data views, should drop any caches and reload from scratch.