Move form validation message bubble into content/, wire up to Android WebView.

At the moment, when form validation inside Blink fails (e.g. entering an invalid email address in an <input type=email />) we call out to chrome/ to show some UI to the user to indicate the error and give the opportunity to correct it.

This change moves the IPC to content/ (via RenderViewHost) and plumbs the validation handlers through WebContents and WebContentsDelegate. This gives content embedders the opportunity to receive the Blink callback.

There should be no behavior change; the implementation for showing the bubble on desktop platforms remains in the chrome/ layer. On Android it is moved into the WebContentsDelegateAndroid component such that Android WebView can share the code.

BUG=293608
[email protected], [email protected], [email protected], [email protected], [email protected]

Review URL: https://codereview.chromium.org/23609053

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240420 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index d9ac631..2236fa1 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -550,6 +550,12 @@
     IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification)
     IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint,
                         OnFirstVisuallyNonEmptyPaint)
+    IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage,
+                        OnShowValidationMessage)
+    IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage,
+                        OnHideValidationMessage)
+    IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage,
+                        OnMoveValidationMessage)
     IPC_MESSAGE_UNHANDLED(handled = false)
   IPC_END_MESSAGE_MAP_EX()
   render_view_message_source_ = NULL;
@@ -1601,6 +1607,26 @@
   return &frame_tree_;
 }
 
+void WebContentsImpl::OnShowValidationMessage(
+    const gfx::Rect& anchor_in_root_view,
+    const string16& main_text,
+    const string16& sub_text) {
+  if (delegate_)
+    delegate_->ShowValidationMessage(
+        this, anchor_in_root_view, main_text, sub_text);
+}
+
+void WebContentsImpl::OnHideValidationMessage() {
+  if (delegate_)
+    delegate_->HideValidationMessage(this);
+}
+
+void WebContentsImpl::OnMoveValidationMessage(
+    const gfx::Rect& anchor_in_root_view) {
+  if (delegate_)
+    delegate_->MoveValidationMessage(this, anchor_in_root_view);
+}
+
 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) {
   if (browser_plugin_embedder_)
     browser_plugin_embedder_->DidSendScreenRects();