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

Commit

Permalink
release new_contents in all cases so we can continue to manage its li…
Browse files Browse the repository at this point in the history
…fetime without any other changes for now

fixes brave/browser-laptop#14893
auditors @darkdh
  • Loading branch information
bridiver authored and darkdh committed Aug 3, 2018
1 parent 3fd75f7 commit f58697f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -767,19 +767,21 @@ void WebContents::WebContentsCreated(

void WebContents::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
std::unique_ptr<content::WebContents> new_contents_unique,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
// continue to manage the lifetime of the webcontents without uniqueptr for now
auto new_contents = new_contents_unique.release();
if (brave::api::Extension::IsBackgroundPageWebContents(source)) {
user_gesture = true;
}

bool active = disposition != WindowOpenDisposition::NEW_BACKGROUND_TAB;

::Browser* browser = nullptr;
auto tab_helper = extensions::TabHelper::FromWebContents(new_contents.get());
auto tab_helper = extensions::TabHelper::FromWebContents(new_contents);
if (tab_helper) {
tab_helper->SetActive(active);

Expand Down Expand Up @@ -814,7 +816,7 @@ void WebContents::AddNewContents(
"add-new-contents",
event,
source,
new_contents.get(),
new_contents,
disposition,
initial_rect,
user_gesture);
Expand All @@ -828,14 +830,13 @@ void WebContents::AddNewContents(
}

if (blocked) {
auto guest = brave::TabViewGuest::FromWebContents(new_contents.get());
auto guest = brave::TabViewGuest::FromWebContents(new_contents);
if (guest) {
guest->Destroy(true);
} else {
new_contents.reset();
delete new_contents;
}
} else {
new_contents.release();
if (browser) {
tab_helper->SetBrowser(browser);
}
Expand Down

0 comments on commit f58697f

Please sign in to comment.