summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authorbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 21:24:07 +0000
committerbenm@chromium.org <benm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 21:24:07 +0000
commitedc3af84cd907175e0dd24bfc377d20c06fd7d0e (patch)
treea58d91856734a6001965ff8b111fc4a12f2c3b6e /content/renderer
parentc9e487a5cd3be915d23a1861f022223294be3fe9 (diff)
downloadchromium_src-edc3af84cd907175e0dd24bfc377d20c06fd7d0e.zip
chromium_src-edc3af84cd907175e0dd24bfc377d20c06fd7d0e.tar.gz
chromium_src-edc3af84cd907175e0dd24bfc377d20c06fd7d0e.tar.bz2
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 R=jam@chromium.org, joi@chromium.org, joth@chromium.org, nasko@chromium.org, tkent@chromium.org Review URL: https://codereview.chromium.org/23609053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/render_view_impl.cc36
-rw-r--r--content/renderer/render_view_impl.h8
2 files changed, 44 insertions, 0 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 82567ed..e8ba84a 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -15,6 +15,7 @@
#include "base/debug/alias.h"
#include "base/debug/trace_event.h"
#include "base/files/file_path.h"
+#include "base/i18n/rtl.h"
#include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h"
@@ -2621,6 +2622,41 @@ bool RenderViewImpl::runModalBeforeUnloadDialog(
return success;
}
+void RenderViewImpl::showValidationMessage(
+ const blink::WebRect& anchor_in_root_view,
+ const blink::WebString& main_text,
+ const blink::WebString& sub_text,
+ blink::WebTextDirection hint) {
+ base::string16 wrapped_main_text = main_text;
+ base::string16 wrapped_sub_text = sub_text;
+ if (hint == blink::WebTextDirectionLeftToRight) {
+ wrapped_main_text =
+ base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text);
+ if (!wrapped_sub_text.empty()) {
+ wrapped_sub_text =
+ base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text);
+ }
+ } else if (hint == blink::WebTextDirectionRightToLeft
+ && !base::i18n::IsRTL()) {
+ base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text);
+ if (!wrapped_sub_text.empty()) {
+ base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text);
+ }
+ }
+ Send(new ViewHostMsg_ShowValidationMessage(
+ routing_id(), anchor_in_root_view, wrapped_main_text, wrapped_sub_text));
+}
+
+void RenderViewImpl::hideValidationMessage() {
+ Send(new ViewHostMsg_HideValidationMessage(routing_id()));
+}
+
+void RenderViewImpl::moveValidationMessage(
+ const blink::WebRect& anchor_in_root_view) {
+ Send(new ViewHostMsg_MoveValidationMessage(routing_id(),
+ anchor_in_root_view));
+}
+
void RenderViewImpl::showContextMenu(
WebFrame* frame, const WebContextMenuData& data) {
ContextMenuParams params = ContextMenuParamsBuilder::Build(data);
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index db72d1f..047e894 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -440,6 +440,14 @@ class CONTENT_EXPORT RenderViewImpl
virtual bool runModalBeforeUnloadDialog(blink::WebFrame* frame,
bool is_reload,
const blink::WebString& message);
+ virtual void showValidationMessage(const blink::WebRect& anchor_in_root_view,
+ const blink::WebString& main_text,
+ const blink::WebString& sub_text,
+ blink::WebTextDirection hint) OVERRIDE;
+ virtual void hideValidationMessage() OVERRIDE;
+ virtual void moveValidationMessage(
+ const blink::WebRect& anchor_in_root_view) OVERRIDE;
+
// DEPRECATED
virtual bool runModalBeforeUnloadDialog(blink::WebFrame* frame,
const blink::WebString& message);