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

Side by Side 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, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/validation_message_agent.h ('k') | ipc/ipc_message_start.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "chrome/renderer/validation_message_agent.h"
6
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"
11
12 ValidationMessageAgent::ValidationMessageAgent(content::RenderView* render_view)
13 : content::RenderViewObserver(render_view)
14 {
15 #if defined(OS_MACOSX)
16 // TODO(tkent): enable this for other platforms.
17 // crbug.com/235717, crbug.com/235719, crbug.com/235721.
18 render_view->GetWebView()->setValidationMessageClient(this);
19 #endif
20 }
21
22 ValidationMessageAgent::~ValidationMessageAgent() {}
23
24 void ValidationMessageAgent::showValidationMessage(
25 const WebKit::WebRect& anchor_in_screen,
26 const WebKit::WebString& main_text,
27 const WebKit::WebString& sub_text,
28 WebKit::WebTextDirection hint) {
29 string16 wrapped_main_text = main_text;
30 string16 wrapped_sub_text = sub_text;
31 if (hint == WebKit::WebTextDirectionLeftToRight) {
32 wrapped_main_text
33 = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text);
34 if (!wrapped_sub_text.empty()) {
35 wrapped_sub_text
36 = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text);
37 }
38 } else if (hint == WebKit::WebTextDirectionRightToLeft
39 && !base::i18n::IsRTL()) {
40 base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text);
41 if (!wrapped_sub_text.empty()) {
42 base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text);
43 }
44 }
45
46 Send(new ValidationMessageMsg_ShowValidationMessage(
47 routing_id(), anchor_in_screen, wrapped_main_text, wrapped_sub_text));
48 }
49
50 void ValidationMessageAgent::hideValidationMessage() {
51 Send(new ValidationMessageMsg_HideValidationMessage());
52 }
53
OLDNEW
« 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