зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
ee1dca0813
Коммит
3bd7c7fccf
|
@ -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",
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче