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

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

Issue 256233002: Ensure that modal dialogs from subframes can be cleaned up correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak. Created 6 years, 8 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/browser/web_contents/web_contents_impl.h ('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/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index bddc8de7b9cea9a3582fc124fc4cb921a73d0f2d..fd5f957087fba1d6200649027e6773af80937b48 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3080,7 +3080,8 @@ void WebContentsImpl::RunJavaScriptMessage(
default_prompt,
base::Bind(&WebContentsImpl::OnDialogClosed,
base::Unretained(this),
- rfh,
+ rfh->GetProcess()->GetID(),
+ rfh->GetRoutingID(),
reply_msg,
false),
&suppress_this_message);
@@ -3089,7 +3090,8 @@ void WebContentsImpl::RunJavaScriptMessage(
if (suppress_this_message) {
// If we are suppressing messages, just reply as if the user immediately
// pressed "Cancel", passing true to |dialog_was_suppressed|.
- OnDialogClosed(rfh, reply_msg, true, false, base::string16());
+ OnDialogClosed(rfh->GetProcess()->GetID(), rfh->GetRoutingID(), reply_msg,
+ true, false, base::string16());
}
// OnDialogClosed (two lines up) may have caused deletion of this object (see
@@ -3122,7 +3124,8 @@ void WebContentsImpl::RunBeforeUnloadConfirm(
dialog_manager_->RunBeforeUnloadDialog(
this, message, is_reload,
base::Bind(&WebContentsImpl::OnDialogClosed, base::Unretained(this),
- rfh, reply_msg, false));
+ rfh->GetProcess()->GetID(), rfh->GetRoutingID(), reply_msg,
+ false));
}
WebContents* WebContentsImpl::GetAsWebContents() {
@@ -3796,17 +3799,21 @@ bool WebContentsImpl::CreateRenderViewForInitialEmptyDocument() {
}
#endif
-void WebContentsImpl::OnDialogClosed(RenderFrameHost* rfh,
+void WebContentsImpl::OnDialogClosed(int render_process_id,
+ int render_frame_id,
IPC::Message* reply_msg,
bool dialog_was_suppressed,
bool success,
const base::string16& user_input) {
+ RenderFrameHostImpl* rfh = RenderFrameHostImpl::FromID(render_process_id,
+ render_frame_id);
last_dialog_suppressed_ = dialog_was_suppressed;
if (is_showing_before_unload_dialog_ && !success) {
// If a beforeunload dialog is canceled, we need to stop the throbber from
// spinning, since we forced it to start spinning in Navigate.
- DidStopLoading(rfh);
+ if (rfh)
+ DidStopLoading(rfh);
controller_.DiscardNonCommittedEntries();
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
@@ -3814,8 +3821,13 @@ void WebContentsImpl::OnDialogClosed(RenderFrameHost* rfh,
}
is_showing_before_unload_dialog_ = false;
- static_cast<RenderFrameHostImpl*>(rfh)->JavaScriptDialogClosed(
- reply_msg, success, user_input, dialog_was_suppressed);
+ if (rfh) {
+ rfh->JavaScriptDialogClosed(reply_msg, success, user_input,
+ dialog_was_suppressed);
+ } else {
+ // Don't leak the sync IPC reply if the RFH or process is gone.
+ delete reply_msg;
+ }
}
void WebContentsImpl::SetEncoding(const std::string& encoding) {
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698