Rely on OnDownloadDestroyed to destroy downloadItem

This commit is contained in:
Cheng Zhao 2016-02-02 18:49:43 +08:00
parent f624800881
commit f1f91828ba
3 changed files with 4 additions and 18 deletions

View file

@ -306,14 +306,12 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
auto web_contents = item->GetWebContents();
if (SavePageHandler::IsSavePageTypes(item->GetMimeType()))
return;
auto download_item_handle = DownloadItem::Create(isolate(), item);
bool prevent_default = Emit(
"will-download",
download_item_handle,
DownloadItem::Create(isolate(), item),
api::WebContents::CreateFrom(isolate(), web_contents));
if (prevent_default) {
item->Cancel(true);
download_item_handle->Destroy(item);
item->Remove();
}
}