Introduce DomAutomationControllerHost Mojo interface

This CL introduces a new DOMAutomationControllerHost interface
and converts FrameHostMsg_DomOperationResponse to the interface.

The existing legacy IPC implementation has received the message
both in WebContentsImpl and InterstitialPageImpl. To convert to
Mojo, RenderFrameHostImpl implements DomOperationResponse, then
calls the message handler using RenderProcessHostDelegate.

Lastly, this CL removes "On" prefix in OnDomOperationResponse
functions to be aligned with the message of DOMAutomationControllerHost
interface.

Bug: 1047354
Change-Id: I6a847a4a6b2e68c0bf6fe8f6c7d923c9c8201ca5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2109448
Commit-Queue: Gyuyoung Kim <[email protected]>
Reviewed-by: Matt Falkenhagen <[email protected]>
Reviewed-by: Ɓukasz Anforowicz <[email protected]>
Reviewed-by: Dave Tapuska <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Cr-Commit-Position: refs/heads/master@{#766804}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index a271b0f..e05ddd9 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -926,8 +926,6 @@
 
   bool handled = true;
   IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContentsImpl, message, render_frame_host)
-    IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse,
-                        OnDomOperationResponse)
     IPC_MESSAGE_HANDLER(FrameHostMsg_DidRunInsecureContent,
                         OnDidRunInsecureContent)
     IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisplayContentWithCertificateErrors,
@@ -4962,16 +4960,6 @@
   delegate_->UnregisterProtocolHandler(this, protocol, url, user_gesture);
 }
 
-void WebContentsImpl::OnDomOperationResponse(RenderFrameHostImpl* source,
-                                             const std::string& json_string) {
-  // TODO(nick, lukasza): The notification below should probably be updated to
-  // include |source|.
-  std::string json = json_string;
-  NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE,
-                                         Source<WebContents>(this),
-                                         Details<std::string>(&json));
-}
-
 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url,
                                          bool blocked_by_policy) {
   // TODO(nick): Should we consider |source| here? Should we call FilterURL on
@@ -4982,6 +4970,17 @@
     observer.AppCacheAccessed(manifest_url, blocked_by_policy);
 }
 
+void WebContentsImpl::DomOperationResponse(const std::string& json_string) {
+  // TODO(lukasza): The notification below should probably indicate which
+  // RenderFrameHostImpl the message is coming from. This can enable tests to
+  // talk to 2 frames at the same time, without being confused which frame a
+  // given response comes from.  See also a corresponding TODO in the
+  // ExecuteScriptHelper in //content/public/test/browser_test_utils.cc
+  NotificationService::current()->Notify(
+      NOTIFICATION_DOM_OPERATION_RESPONSE, Source<WebContents>(this),
+      Details<const std::string>(&json_string));
+}
+
 void WebContentsImpl::OnServiceWorkerAccessed(
     RenderFrameHost* render_frame_host,
     const GURL& scope,