Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1879)

Unified Diff: content/browser/web_contents/render_view_host_manager.cc

Issue 46403006: Prevent a browser crash if dialogs are shown when navigating away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix typo Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/render_view_host_manager.cc
diff --git a/content/browser/web_contents/render_view_host_manager.cc b/content/browser/web_contents/render_view_host_manager.cc
index 392b869af64a18ee574fea79df204ddd3b55d8d5..1dee37f1162d841eadb66c6e1e42ad9bcd561aea 100644
--- a/content/browser/web_contents/render_view_host_manager.cc
+++ b/content/browser/web_contents/render_view_host_manager.cc
@@ -425,6 +425,11 @@ void RenderViewHostManager::SwapOutOldPage() {
CHECK(cross_navigation_pending_ || pending_nav_params_.get());
// First close any modal dialogs that would prevent us from swapping out.
+ // TODO(creis): This is not a guarantee. The renderer could immediately
+ // create another dialog in a loop, potentially causing a renderer crash when
+ // we tell it to swap out with a nested message loop and PageGroupLoadDeferrer
+ // on the stack. We should prevent the renderer from showing more dialogs
+ // until the SwapOut. See http://crbug.com/312490.
delegate_->CancelModalDialogsForRenderManager();
// Tell the old renderer it is being swapped out. This will fire the unload
@@ -755,6 +760,14 @@ void RenderViewHostManager::CommitPending() {
// this triggers won't be able to figure out what's going on.
bool will_focus_location_bar = delegate_->FocusLocationBarByDefault();
+ // We currently can't guarantee that the renderer isn't showing a new modal
+ // dialog, even though we canceled them in SwapOutOldPage. (It may have
+ // created another in the meantime.) Make sure we run and reset the callback
+ // now before we delete its RVH below.
+ // TODO(creis): Remove this if we can guarantee that no new dialogs will be
+ // shown after SwapOutOldPage. See http://crbug.com/312490.
+ delegate_->CancelModalDialogsForRenderManager();
+
// Next commit the Web UI, if any. Either replace |web_ui_| with
// |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or
// leave |web_ui_| as is if reusing it.
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698