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

Unified Diff: content/renderer/render_view_impl.cc

Issue 50223002: Prevent modal dialogs when preparing to swap out. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index bdf12203e22c16e28dc1878efab03144d7541b5a..c8e0efd60888f1b576e700888021abab3afcbc2d 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -832,6 +832,7 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
navigation_gesture_(NavigationGestureUnknown),
opened_by_user_gesture_(true),
opener_suppressed_(false),
+ suppress_dialogs_until_swap_out_(false),
page_id_(-1),
last_page_id_sent_to_browser_(-1),
next_page_id_(params->next_page_id),
@@ -1423,6 +1424,8 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
OnEnumerateDirectoryResponse)
IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse)
IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose)
+ IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut,
+ OnSuppressDialogsUntilSwapOut)
IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut)
IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged)
@@ -2271,6 +2274,11 @@ bool RenderViewImpl::RunJavaScriptMessage(JavaScriptMessageType type,
const string16& default_value,
const GURL& frame_url,
string16* result) {
+ // Don't allow further dialogs if we are waiting to swap out, since the
+ // PageGroupLoadDeferrer in our stack prevents it.
+ if (suppress_dialogs_until_swap_out_)
+ return false;
+
bool success = false;
string16 result_temp;
if (!result)
@@ -2706,6 +2714,11 @@ bool RenderViewImpl::runModalBeforeUnloadDialog(
if (is_swapped_out_)
return true;
+ // Don't allow further dialogs if we are waiting to swap out, since the
+ // PageGroupLoadDeferrer in our stack prevents it.
+ if (suppress_dialogs_until_swap_out_)
+ return false;
+
bool success = false;
// This is an ignored return value, but is included so we can accept the same
// response as RunJavaScriptMessage.
@@ -2991,8 +3004,15 @@ void RenderViewImpl::show(WebNavigationPolicy policy) {
}
void RenderViewImpl::runModal() {
+ // TODO(creis): runModalDialog looks deprecated. Is this code dead?
Charlie Reis 2013/10/29 02:59:56 Darin, can we still get here? I didn't see any ca
Charlie Reis 2013/10/30 16:09:52 Ah, I had the name wrong. showModalDialog still e
+ NOTREACHED();
DCHECK(did_show_) << "should already have shown the view";
+ // Don't allow further dialogs if we are waiting to swap out, since the
+ // PageGroupLoadDeferrer in our stack prevents it.
+ if (suppress_dialogs_until_swap_out_)
+ return;
+
// We must keep WebKit's shared timer running in this case in order to allow
// showModalDialog to function properly.
//
@@ -5377,6 +5397,11 @@ void RenderViewImpl::OnShouldClose() {
before_unload_end_time));
}
+void RenderViewImpl::OnSuppressDialogsUntilSwapOut() {
+ // Don't show any more dialogs until we finish OnSwapOut.
+ suppress_dialogs_until_swap_out_ = true;
+}
+
void RenderViewImpl::OnSwapOut() {
// Only run unload if we're not swapped out yet, but send the ack either way.
if (!is_swapped_out_) {
@@ -5410,6 +5435,9 @@ void RenderViewImpl::OnSwapOut() {
webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false);
}
+ // It is now safe to show modal dialogs again.
+ suppress_dialogs_until_swap_out_ = false;
+
Send(new ViewHostMsg_SwapOut_ACK(routing_id_));
}
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698