Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
Get native window reference manually if it's not found in user data (…
Browse files Browse the repository at this point in the history
…as a result of losing a race condition)

Fixes brave/browser-laptop#14409

Auditors: @bridiver
  • Loading branch information
bsclifton authored and darkdh committed Aug 3, 2018
1 parent ce65cd2 commit a2f7fb4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion atom/browser/atom_download_manager_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <utility>
#include <vector>

#include "atom/browser/extensions/tab_helper.h"
#include "atom/browser/native_window.h"
#include "base/bind.h"
#include "base/files/file_util.h"
Expand All @@ -19,6 +20,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_util.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/safe_browsing/file_type_policies.h"
#include "components/prefs/pref_service.h"
Expand Down Expand Up @@ -63,7 +65,19 @@ NativeWindow* GetNativeWindowFromWebContents(
content::WebContents* web_contents) {
DCHECK(web_contents);
auto relay = NativeWindowRelay::FromWebContents(web_contents);
return relay ? relay->window.get() : nullptr;
if (relay)
return relay->window.get();

auto helper =
extensions::TabHelper::FromWebContents(web_contents);
if (!helper)
return nullptr;

auto browser = helper->browser();
if (!browser)
return nullptr;

return static_cast<NativeWindow*>(browser->window());
}

// Blank newtab on download should be closed after starting download.
Expand Down

0 comments on commit a2f7fb4

Please sign in to comment.