From 0c020ed6f31f7350f0e57a467e840b671a0dd0b4 Mon Sep 17 00:00:00 2001 From: k88hudson Date: Wed, 3 May 2017 14:32:47 -0400 Subject: [PATCH] Bug 1361797 - Migrate History/Bookmark observers to system add-on r=ursula MozReview-Commit-ID: 2qK24pez8MZ --HG-- extra : rebase_source : eb3e8a7e0b8cf4990bb655e49c6a33021cb095dc --- toolkit/modules/NewTabUtils.jsm | 79 +-------------------------------- 1 file changed, 1 insertion(+), 78 deletions(-) diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm index 98173a0f8042..427b73771e9e 100644 --- a/toolkit/modules/NewTabUtils.jsm +++ b/toolkit/modules/NewTabUtils.jsm @@ -927,82 +927,6 @@ var ActivityStreamProvider = { }); }, - /* - * Initializes Activity Stream provider - adds a history observer and a - * bookmarks observer. - */ - init() { - PlacesUtils.history.addObserver(this.historyObserver, true); - PlacesUtils.bookmarks.addObserver(this.bookmarksObsever, true); - }, - - /** - * A set of functions called by @mozilla.org/browser/nav-historyservice - * All history events are emitted from this object. - */ - historyObserver: { - onDeleteURI(uri) { - Services.obs.notifyObservers(null, "newtab-deleteURI", {url: uri.spec}); - }, - - onClearHistory() { - Services.obs.notifyObservers(null, "newtab-clearHistory"); - }, - - onFrecencyChanged(uri, newFrecency, guid, hidden, lastVisitDate) { - if (!hidden && lastVisitDate) { - Services.obs.notifyObservers(null, "newtab-linkChanged", { - url: uri.spec, - frecency: newFrecency, - lastVisitDate, - type: "history" - }); - } - }, - - onManyFrecenciesChanged() { - Services.obs.notifyObservers(null, "newtab-manyLinksChanged"); - }, - - onTitleChanged(uri, newTitle) { - Services.obs.notifyObservers(null, "newtab-linkChanged", {url: uri.spec, title: newTitle}); - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver, - Ci.nsISupportsWeakReference]) - }, - - /** - * A set of functions called by @mozilla.org/browser/nav-bookmarks-service - * All bookmark events are emitted from this object. - */ - bookmarksObsever: { - onItemAdded(id, folderId, index, type, uri, title, dateAdded, guid) { - if (type === PlacesUtils.bookmarks.TYPE_BOOKMARK) { - ActivityStreamProvider.getBookmark(guid).then(bookmark => { - Services.obs.notifyObservers(null, "newtab-bookmarkAdded", bookmark); - }).catch(Cu.reportError); - } - }, - - onItemRemoved(id, folderId, index, type, uri) { - if (type === PlacesUtils.bookmarks.TYPE_BOOKMARK) { - Services.obs.notifyObservers(null, "newtab-bookmarkRemoved", {bookmarkId: id, url: uri.spec}); - } - }, - - onItemChanged(id, property, isAnnotation, value, lastModified, type, parent, guid) { - if (type === PlacesUtils.bookmarks.TYPE_BOOKMARK) { - ActivityStreamProvider.getBookmark(guid).then(bookmark => { - Services.obs.notifyObservers(null, "newtab-bookmarkChanged", bookmark); - }).catch(Cu.reportError); - } - }, - - QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarkObserver, - Ci.nsISupportsWeakReference]) - }, - /* * Gets the top frecent sites for Activity Stream. * @@ -1172,7 +1096,7 @@ var ActivityStreamLinks = { }, onLinkBlocked(aLink) { - Services.obs.notifyObservers(null, "newtab-linkChanged", {url: aLink.url, blocked: true}) + Services.obs.notifyObservers(null, "newtab-linkBlocked", aLink.url); }, /** @@ -1843,7 +1767,6 @@ this.NewTabUtils = { init: function NewTabUtils_init() { if (this.initWithoutProviders()) { PlacesProvider.init(); - ActivityStreamProvider.init(); Links.addProvider(PlacesProvider); BlockedLinks.addObserver(Links); BlockedLinks.addObserver(ActivityStreamLinks);