--- a/toolkit/modules/NewTabUtils.jsm
+++ b/toolkit/modules/NewTabUtils.jsm
@@ -923,92 +923,16 @@ var ActivityStreamProvider = {
} catch (e) {
link.eTLD = "";
}
return link;
});
},
/*
- * 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.
*
* @param {Object} aOptions
* options.ignoreBlocked: Do not filter out blocked links .
*
* @returns {Promise} Returns a promise with the array of links as payload.
*/
getTopFrecentSites: Task.async(function*(aOptions = {}) {
@@ -1167,17 +1091,17 @@ var ActivityStreamLinks = {
* @param {Object} aLink
* The link which contains a URL to add to the block list
*/
blockURL(aLink) {
BlockedLinks.block(aLink);
},
onLinkBlocked(aLink) {
- Services.obs.notifyObservers(null, "newtab-linkChanged", {url: aLink.url, blocked: true})
+ Services.obs.notifyObservers(null, "newtab-linkBlocked", aLink.url);
},
/**
* Adds a bookmark
*
* @param {String} aUrl
* The url to bookmark
*
@@ -1838,17 +1762,16 @@ this.NewTabUtils = {
// Strip off common subdomains of the same site (e.g., www, load balancer)
return host.replace(/^(m|mobile|www\d*)\./, "");
},
init: function NewTabUtils_init() {
if (this.initWithoutProviders()) {
PlacesProvider.init();
- ActivityStreamProvider.init();
Links.addProvider(PlacesProvider);
BlockedLinks.addObserver(Links);
BlockedLinks.addObserver(ActivityStreamLinks);
}
},
initWithoutProviders: function NewTabUtils_initWithoutProviders() {
if (!this._initialized) {