зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1361797 - Migrate History/Bookmark observers to system add-on r=ursula
MozReview-Commit-ID: 2qK24pez8MZ --HG-- extra : rebase_source : eb3e8a7e0b8cf4990bb655e49c6a33021cb095dc
This commit is contained in:
Родитель
0d3abd6562
Коммит
0c020ed6f3
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче