Merge pull request #4314 from deepak1556/download_cancel_patch
fix crash when default download is canceled
This commit is contained in:
commit
f624800881
6 changed files with 97 additions and 26 deletions
|
@ -306,12 +306,14 @@ 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",
|
||||
DownloadItem::Create(isolate(), item),
|
||||
download_item_handle,
|
||||
api::WebContents::CreateFrom(isolate(), web_contents));
|
||||
if (prevent_default) {
|
||||
item->Cancel(true);
|
||||
download_item_handle->Destroy(item);
|
||||
item->Remove();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue