Suppression for crbug/241044.
[chromium-blink-merge.git] / chrome / renderer / validation_message_agent.cc
blob24f39854813b2dc63d0dd42549ba952bbc192246
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/renderer/validation_message_agent.h"
7 #include "base/i18n/rtl.h"
8 #include "chrome/common/validation_message_messages.h"
9 #include "content/public/renderer/render_view.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
12 ValidationMessageAgent::ValidationMessageAgent(content::RenderView* render_view)
13 : content::RenderViewObserver(render_view)
15 #if !defined(OS_ANDROID)
16 // TODO(tkent): enable this for Android. crbug.com/235721.
17 render_view->GetWebView()->setValidationMessageClient(this);
18 #endif
21 ValidationMessageAgent::~ValidationMessageAgent() {}
23 void ValidationMessageAgent::showValidationMessage(
24 const WebKit::WebRect& anchor_in_screen,
25 const WebKit::WebString& main_text,
26 const WebKit::WebString& sub_text,
27 WebKit::WebTextDirection hint) {
28 string16 wrapped_main_text = main_text;
29 string16 wrapped_sub_text = sub_text;
30 if (hint == WebKit::WebTextDirectionLeftToRight) {
31 wrapped_main_text
32 = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text);
33 if (!wrapped_sub_text.empty()) {
34 wrapped_sub_text
35 = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text);
37 } else if (hint == WebKit::WebTextDirectionRightToLeft
38 && !base::i18n::IsRTL()) {
39 base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text);
40 if (!wrapped_sub_text.empty()) {
41 base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text);
45 Send(new ValidationMessageMsg_ShowValidationMessage(
46 routing_id(), anchor_in_screen, wrapped_main_text, wrapped_sub_text));
49 void ValidationMessageAgent::hideValidationMessage() {
50 Send(new ValidationMessageMsg_HideValidationMessage());