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

Unified Diff: chrome/renderer/validation_message_agent.cc

Issue 13160004: Re-implement form validation message UI with native widgets. (Common and Mac) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | « chrome/renderer/validation_message_agent.h ('k') | ipc/ipc_message_start.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/validation_message_agent.cc
diff --git a/chrome/renderer/validation_message_agent.cc b/chrome/renderer/validation_message_agent.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8be1280b7fa145a1c0b88b998431905b5d202af8
--- /dev/null
+++ b/chrome/renderer/validation_message_agent.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/validation_message_agent.h"
+
+#include "base/i18n/rtl.h"
+#include "chrome/common/validation_message_messages.h"
+#include "content/public/renderer/render_view.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+
+ValidationMessageAgent::ValidationMessageAgent(content::RenderView* render_view)
+ : content::RenderViewObserver(render_view)
+{
+#if defined(OS_MACOSX)
+ // TODO(tkent): enable this for other platforms.
+ // crbug.com/235717, crbug.com/235719, crbug.com/235721.
+ render_view->GetWebView()->setValidationMessageClient(this);
+#endif
+}
+
+ValidationMessageAgent::~ValidationMessageAgent() {}
+
+void ValidationMessageAgent::showValidationMessage(
+ const WebKit::WebRect& anchor_in_screen,
+ const WebKit::WebString& main_text,
+ const WebKit::WebString& sub_text,
+ WebKit::WebTextDirection hint) {
+ string16 wrapped_main_text = main_text;
+ string16 wrapped_sub_text = sub_text;
+ if (hint == WebKit::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 == WebKit::WebTextDirectionRightToLeft
+ && !base::i18n::IsRTL()) {
+ base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text);
+ if (!wrapped_sub_text.empty()) {
+ base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text);
+ }
+ }
+
+ Send(new ValidationMessageMsg_ShowValidationMessage(
+ routing_id(), anchor_in_screen, wrapped_main_text, wrapped_sub_text));
+}
+
+void ValidationMessageAgent::hideValidationMessage() {
+ Send(new ValidationMessageMsg_HideValidationMessage());
+}
+
« no previous file with comments | « chrome/renderer/validation_message_agent.h ('k') | ipc/ipc_message_start.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698