Merge pull request #4314 from deepak1556/download_cancel_patch

fix crash when default download is canceled
This commit is contained in:
Cheng Zhao 2016-02-02 18:40:44 +08:00
commit f624800881
6 changed files with 97 additions and 26 deletions

View file

@ -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();
}
}