| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/renderer/validation_message_agent.h" | 5 #include "chrome/renderer/validation_message_agent.h" | 
| 6 | 6 | 
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" | 
| 8 #include "chrome/common/validation_message_messages.h" | 8 #include "chrome/common/validation_message_messages.h" | 
| 9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" | 
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 
| 11 | 11 | 
| 12 ValidationMessageAgent::ValidationMessageAgent(content::RenderView* render_view) | 12 ValidationMessageAgent::ValidationMessageAgent(content::RenderView* render_view) | 
| 13     : content::RenderViewObserver(render_view) | 13     : content::RenderViewObserver(render_view) | 
| 14 { | 14 { | 
| 15   render_view->GetWebView()->setValidationMessageClient(this); | 15   render_view->GetWebView()->setValidationMessageClient(this); | 
| 16 } | 16 } | 
| 17 | 17 | 
| 18 ValidationMessageAgent::~ValidationMessageAgent() {} | 18 ValidationMessageAgent::~ValidationMessageAgent() {} | 
| 19 | 19 | 
| 20 void ValidationMessageAgent::showValidationMessage( | 20 void ValidationMessageAgent::showValidationMessage( | 
| 21     const WebKit::WebRect& anchor_in_screen, | 21     const WebKit::WebRect& anchor_in_root_view, | 
| 22     const WebKit::WebString& main_text, | 22     const WebKit::WebString& main_text, | 
| 23     const WebKit::WebString& sub_text, | 23     const WebKit::WebString& sub_text, | 
| 24     WebKit::WebTextDirection hint) { | 24     WebKit::WebTextDirection hint) { | 
| 25   string16 wrapped_main_text = main_text; | 25   string16 wrapped_main_text = main_text; | 
| 26   string16 wrapped_sub_text = sub_text; | 26   string16 wrapped_sub_text = sub_text; | 
| 27   if (hint == WebKit::WebTextDirectionLeftToRight) { | 27   if (hint == WebKit::WebTextDirectionLeftToRight) { | 
| 28     wrapped_main_text | 28     wrapped_main_text | 
| 29         = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text); | 29         = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text); | 
| 30     if (!wrapped_sub_text.empty()) { | 30     if (!wrapped_sub_text.empty()) { | 
| 31       wrapped_sub_text | 31       wrapped_sub_text | 
| 32           = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text); | 32           = base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text); | 
| 33     } | 33     } | 
| 34   } else if (hint == WebKit::WebTextDirectionRightToLeft | 34   } else if (hint == WebKit::WebTextDirectionRightToLeft | 
| 35              && !base::i18n::IsRTL()) { | 35              && !base::i18n::IsRTL()) { | 
| 36     base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text); | 36     base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text); | 
| 37     if (!wrapped_sub_text.empty()) { | 37     if (!wrapped_sub_text.empty()) { | 
| 38       base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text); | 38       base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text); | 
| 39     } | 39     } | 
| 40   } | 40   } | 
| 41 | 41 | 
| 42   Send(new ValidationMessageMsg_ShowValidationMessage( | 42   Send(new ValidationMessageMsg_ShowValidationMessage( | 
| 43       routing_id(), anchor_in_screen, wrapped_main_text, wrapped_sub_text)); | 43       routing_id(), anchor_in_root_view, wrapped_main_text, wrapped_sub_text)); | 
| 44 } | 44 } | 
| 45 | 45 | 
| 46 void ValidationMessageAgent::hideValidationMessage() { | 46 void ValidationMessageAgent::hideValidationMessage() { | 
| 47   Send(new ValidationMessageMsg_HideValidationMessage()); | 47   Send(new ValidationMessageMsg_HideValidationMessage()); | 
| 48 } | 48 } | 
| 49 | 49 | 
|  | 50 void ValidationMessageAgent::moveValidationMessage( | 
|  | 51       const WebKit::WebRect& anchor_in_root_view) { | 
|  | 52   Send(new ValidationMessageMsg_MoveValidationMessage( | 
|  | 53       routing_id(), anchor_in_root_view)); | 
|  | 54 } | 
|  | 55 | 
| OLD | NEW | 
|---|