Convert FrameHostMsg_RunJavaScriptDialog to mojo.
Define synchronous APIs on mojo to handle the appropriate
dialog messaging. Move this solely into blink, the API is still
exposed on the ChromeClient to still support PopupOpeningObservers.
Introduce LocalFrameHostInterceptor on the content/public/test side to
help support stubbing out the LocalFrameHostInterface.
Move handling of Javascript dialogs in test_runner to the browser side.
Some code already existed, the logging is just moved from the renderer
to browser side.
BUG=1039695
Change-Id: I2596c4a9ad35027e3ffde1c29b1525114c2cdfbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994604
Commit-Queue: Dave Tapuska <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: danakj <[email protected]>
Cr-Commit-Position: refs/heads/master@{#734552}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 72d82a7..fc79d5bcf 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -5469,11 +5469,12 @@
}
} // namespace
-void WebContentsImpl::RunJavaScriptDialog(RenderFrameHost* render_frame_host,
- const base::string16& message,
- const base::string16& default_prompt,
- JavaScriptDialogType dialog_type,
- IPC::Message* reply_msg) {
+void WebContentsImpl::RunJavaScriptDialog(
+ RenderFrameHost* render_frame_host,
+ const base::string16& message,
+ const base::string16& default_prompt,
+ JavaScriptDialogType dialog_type,
+ JavaScriptDialogCallback response_callback) {
// Ensure that if showing a dialog is the first thing that a page does, that
// the contents of the previous page aren't shown behind it. This is required
// because showing a dialog freezes the renderer, so no frames will be coming
@@ -5488,10 +5489,10 @@
// http://crbug.com/728276
ForSecurityDropFullscreen();
- auto callback =
- base::BindOnce(&WebContentsImpl::OnDialogClosed, base::Unretained(this),
- render_frame_host->GetProcess()->GetID(),
- render_frame_host->GetRoutingID(), reply_msg);
+ auto callback = base::BindOnce(
+ &WebContentsImpl::OnDialogClosed, base::Unretained(this),
+ render_frame_host->GetProcess()->GetID(),
+ render_frame_host->GetRoutingID(), std::move(response_callback));
std::vector<protocol::PageHandler*> page_handlers =
protocol::PageHandler::EnabledForWebContents(this);
@@ -5549,7 +5550,7 @@
void WebContentsImpl::RunBeforeUnloadConfirm(
RenderFrameHost* render_frame_host,
bool is_reload,
- IPC::Message* reply_msg) {
+ JavaScriptDialogCallback response_callback) {
// Ensure that if showing a dialog is the first thing that a page does, that
// the contents of the previous page aren't shown behind it. This is required
// because showing a dialog freezes the renderer, so no frames will be coming
@@ -5569,10 +5570,10 @@
if (delegate_)
delegate_->WillRunBeforeUnloadConfirm();
- auto callback =
- base::BindOnce(&WebContentsImpl::OnDialogClosed, base::Unretained(this),
- render_frame_host->GetProcess()->GetID(),
- render_frame_host->GetRoutingID(), reply_msg);
+ auto callback = base::BindOnce(
+ &WebContentsImpl::OnDialogClosed, base::Unretained(this),
+ render_frame_host->GetProcess()->GetID(),
+ render_frame_host->GetRoutingID(), std::move(response_callback));
std::vector<protocol::PageHandler*> page_handlers =
protocol::PageHandler::EnabledForWebContents(this);
@@ -6686,7 +6687,7 @@
void WebContentsImpl::OnDialogClosed(int render_process_id,
int render_frame_id,
- IPC::Message* reply_msg,
+ JavaScriptDialogCallback response_callback,
bool dialog_was_suppressed,
bool success,
const base::string16& user_input) {
@@ -6711,18 +6712,12 @@
observer.BeforeUnloadDialogCancelled();
}
- if (rfh) {
- rfh->JavaScriptDialogClosed(reply_msg, success, user_input);
+ std::move(response_callback).Run(success, user_input);
- std::vector<protocol::PageHandler*> page_handlers =
- protocol::PageHandler::EnabledForWebContents(this);
- for (auto* handler : page_handlers)
- handler->DidCloseJavaScriptDialog(success, user_input);
-
- } else {
- // Don't leak the sync IPC reply if the RFH or process is gone.
- delete reply_msg;
- }
+ std::vector<protocol::PageHandler*> page_handlers =
+ protocol::PageHandler::EnabledForWebContents(this);
+ for (auto* handler : page_handlers)
+ handler->DidCloseJavaScriptDialog(success, user_input);
is_showing_javascript_dialog_ = false;
is_showing_before_unload_dialog_ = false;