Bug 1245599 - Implement chrome.downloads.onCreated r=kmag
MozReview-Commit-ID: 53yhKZYHDrD
This commit is contained in:
@@ -141,7 +141,8 @@ const DownloadMap = {
|
||||
let self = this;
|
||||
return list.addView({
|
||||
onDownloadAdded(download) {
|
||||
self.newFromDownload(download, null);
|
||||
const item = self.newFromDownload(download, null);
|
||||
self.emit("create", item);
|
||||
},
|
||||
|
||||
onDownloadRemoved(download) {
|
||||
@@ -478,7 +479,20 @@ extensions.registerSchemaAPI("downloads", "downloads", (extension, context) => {
|
||||
};
|
||||
}).api(),
|
||||
|
||||
onCreated: ignoreEvent(context, "downloads.onCreated"),
|
||||
onCreated: new SingletonEventManager(context, "downloads.onCreated", fire => {
|
||||
const handler = (what, item) => {
|
||||
runSafeSync(context, fire, item.serialize());
|
||||
};
|
||||
let registerPromise = DownloadMap.getDownloadList().then(() => {
|
||||
DownloadMap.on("create", handler);
|
||||
});
|
||||
return () => {
|
||||
registerPromise.then(() => {
|
||||
DownloadMap.off("create", handler);
|
||||
});
|
||||
};
|
||||
}).api(),
|
||||
|
||||
onErased: ignoreEvent(context, "downloads.onErased"),
|
||||
onDeterminingFilename: ignoreEvent(context, "downloads.onDeterminingFilename"),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user