Bug 488165 - Correct set the record object type when processing records

Set _recordObj for Bookmarks/History engines and override PlacesItem.decrypt to switch itself to the right type after CryptoWrapper decrypts the payload.
This commit is contained in:
Edward Lee 2009-04-13 14:54:31 -05:00
Родитель ee1dca0813
Коммит 3bd7c7fccf
3 изменённых файлов: 29 добавлений и 0 удалений

Просмотреть файл

@ -77,6 +77,7 @@ BookmarksEngine.prototype = {
name: "bookmarks",
displayName: "Bookmarks",
logName: "Bookmarks",
_recordObj: PlacesItem,
_storeObj: BookmarksStore,
_trackerObj: BookmarksTracker
};

Просмотреть файл

@ -61,6 +61,7 @@ HistoryEngine.prototype = {
name: "history",
displayName: "History",
logName: "History",
_recordObj: HistoryRec,
_storeObj: HistoryStore,
_trackerObj: HistoryTracker,

Просмотреть файл

@ -55,6 +55,33 @@ function PlacesItem(uri) {
this._PlacesItem_init(uri);
}
PlacesItem.prototype = {
decrypt: function PlacesItem_decrypt(onComplete, passphrase) {
CryptoWrapper.prototype.decrypt.call(this, Utils.bind2(this, function(ret) {
// Convert the abstract places item to the actual object type
if (!this.deleted)
this.__proto__ = this.getTypeObject(this.type).prototype;
// Give the original callback the result
onComplete(ret);
}), passphrase);
},
getTypeObject: function PlacesItem_getTypeObject(type) {
switch (type) {
case "bookmark":
return Bookmark;
case "microsummary":
return BookmarkMicsum;
case "folder":
return BookmarkFolder;
case "livemark":
return Livemark;
case "separator":
return BookmarkSeparator;
}
throw "Unknown places item object type";
},
__proto__: CryptoWrapper.prototype,
_logName: "Record.PlacesItem",