session: dont attach download dialog to deleted webContents window

This commit is contained in:
deepak1556 2016-04-27 20:00:31 +05:30
parent 0fa92923da
commit 46208b5b3e
2 changed files with 4 additions and 2 deletions

View file

@ -315,7 +315,7 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
bool prevent_default = Emit(
"will-download",
DownloadItem::Create(isolate(), item),
api::WebContents::CreateFrom(isolate(), web_contents));
web_contents);
if (prevent_default) {
item->Cancel(true);
item->Remove();

View file

@ -70,7 +70,9 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
return;
NativeWindow* window = nullptr;
auto relay = NativeWindowRelay::FromWebContents(item->GetWebContents());
content::WebContents* web_contents = item->GetWebContents();
auto relay = web_contents ? NativeWindowRelay::FromWebContents(web_contents)
: nullptr;
if (relay)
window = relay->window.get();