Commit a8a66ac3 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Fix obscure JS dialog crash

Fixed: 1142806
Change-Id: I633364889de7b1dc3b30847840ead8dadd0afcb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503778Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821443}
parent 431f0b31
...@@ -57,7 +57,7 @@ void JavaScriptTabModalDialogManagerDelegateDesktop::SetTabNeedsAttention( ...@@ -57,7 +57,7 @@ void JavaScriptTabModalDialogManagerDelegateDesktop::SetTabNeedsAttention(
Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
if (!browser) { if (!browser) {
// It's possible that the WebContents is no longer in the tab strip. If so, // It's possible that the WebContents is no longer in the tab strip. If so,
// just give up. https://crbug.com/786178#c7. // just give up. https://crbug.com/786178
return; return;
} }
...@@ -69,7 +69,13 @@ void JavaScriptTabModalDialogManagerDelegateDesktop::SetTabNeedsAttention( ...@@ -69,7 +69,13 @@ void JavaScriptTabModalDialogManagerDelegateDesktop::SetTabNeedsAttention(
bool JavaScriptTabModalDialogManagerDelegateDesktop::IsWebContentsForemost() { bool JavaScriptTabModalDialogManagerDelegateDesktop::IsWebContentsForemost() {
Browser* browser = BrowserList::GetInstance()->GetLastActive(); Browser* browser = BrowserList::GetInstance()->GetLastActive();
DCHECK(browser); if (!browser) {
// It's rare, but there are crashes from where sites are trying to show
// dialogs in the split second of time between when their Browser is gone
// and they're gone. In that case, bail. https://crbug.com/1142806
return false;
}
return browser->tab_strip_model()->GetActiveWebContents() == web_contents_; return browser->tab_strip_model()->GetActiveWebContents() == web_contents_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment