--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -2314,75 +2314,83 @@ XPCOMUtils.defineLazyGetter(this, "gKeyw
let observer = {
QueryInterface: XPCOMUtils.generateQI(Ci.nsINavBookmarkObserver),
onBeginUpdateBatch() {},
onEndUpdateBatch() {},
onItemAdded() {},
onItemVisited() {},
onItemMoved() {},
- onItemRemoved(id, parentId, index, itemType, uri, guid, parentGuid) {
+ onItemRemoved(id, parentId, index, itemType, uri, guid, parentGuid,
+ source) {
if (itemType != PlacesUtils.bookmarks.TYPE_BOOKMARK)
return;
let keywords = keywordsForHref(uri.spec);
// This uri has no keywords associated, so there's nothing to do.
if (keywords.length == 0)
return;
(async function() {
// If the uri is not bookmarked anymore, we can remove this keyword.
let bookmark = await PlacesUtils.bookmarks.fetch({ url: uri });
if (!bookmark) {
for (let keyword of keywords) {
- await PlacesUtils.keywords.remove(keyword);
+ await PlacesUtils.keywords.remove({ keyword, source });
}
}
})().catch(Cu.reportError);
},
onItemChanged(id, prop, isAnno, val, lastMod, itemType, parentId, guid,
- parentGuid, oldVal) {
+ parentGuid, oldVal, source) {
if (gIgnoreKeywordNotifications) {
return;
}
if (prop == "keyword") {
this._onKeywordChanged(guid, val, oldVal);
} else if (prop == "uri") {
- this._onUrlChanged(guid, val, oldVal).catch(Cu.reportError);
+ this._onUrlChanged(guid, val, oldVal, source).catch(Cu.reportError);
}
},
_onKeywordChanged(guid, keyword, href) {
if (keyword.length == 0) {
// We are removing a keyword.
let keywords = keywordsForHref(href)
for (let kw of keywords) {
cache.delete(kw);
}
} else {
// We are adding a new keyword.
cache.set(keyword, { keyword, url: new URL(href) });
}
},
- async _onUrlChanged(guid, url, oldUrl) {
+ async _onUrlChanged(guid, url, oldUrl, source) {
// Check if the old url is associated with keywords.
let entries = [];
await PlacesUtils.keywords.fetch({ url: oldUrl }, e => entries.push(e));
if (entries.length == 0) {
return;
}
// Move the keywords to the new url.
for (let entry of entries) {
- await PlacesUtils.keywords.remove(entry.keyword);
- entry.url = new URL(url);
- await PlacesUtils.keywords.insert(entry);
+ await PlacesUtils.keywords.remove({
+ keyword: entry.keyword,
+ source,
+ });
+ await PlacesUtils.keywords.insert({
+ keyword: entry.keyword,
+ url,
+ postData: entry.postData,
+ source,
+ });
}
},
};
PlacesUtils.bookmarks.addObserver(observer);
PlacesUtils.registerShutdownFunction(() => {
PlacesUtils.bookmarks.removeObserver(observer);
});