summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/android/chrome_jni_registrar.cc3
-rw-r--r--chrome/browser/chrome_content_browser_client.cc2
-rw-r--r--chrome/browser/ui/browser.cc33
-rw-r--r--chrome/browser/ui/browser.h12
-rw-r--r--chrome/browser/validation_message_message_filter.cc84
-rw-r--r--chrome/browser/validation_message_message_filter.h46
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/chrome_browser_ui.gypi2
-rw-r--r--chrome/chrome_common.gypi1
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/common/common_message_generator.h1
-rw-r--r--chrome/common/validation_message_messages.h22
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc2
-rw-r--r--chrome/renderer/validation_message_agent.cc55
-rw-r--r--chrome/renderer/validation_message_agent.h36
-rw-r--r--components/web_contents_delegate_android.gypi3
-rw-r--r--components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ValidationMessageBubble.java (renamed from chrome/android/java/src/org/chromium/chrome/browser/ValidationMessageBubble.java)4
-rw-r--r--components/web_contents_delegate_android/component_jni_registrar.cc2
-rw-r--r--components/web_contents_delegate_android/validation_message_bubble_android.cc (renamed from chrome/browser/ui/android/validation_message_bubble_android.cc)17
-rw-r--r--components/web_contents_delegate_android/validation_message_bubble_android.h (renamed from chrome/browser/ui/android/validation_message_bubble_android.h)19
-rw-r--r--components/web_contents_delegate_android/web_contents_delegate_android.cc33
-rw-r--r--components/web_contents_delegate_android/web_contents_delegate_android.h13
-rw-r--r--content/browser/web_contents/web_contents_impl.cc26
-rw-r--r--content/browser/web_contents/web_contents_impl.h6
-rw-r--r--content/common/view_messages.h16
-rw-r--r--content/public/android/java/res/drawable-hdpi/bubble.9.png (renamed from chrome/android/java/res/drawable-hdpi/bubble.9.png)bin884 -> 884 bytes
-rw-r--r--content/public/android/java/res/drawable-hdpi/bubble_arrow_up.png (renamed from chrome/android/java/res/drawable-hdpi/bubble_arrow_up.png)bin396 -> 396 bytes
-rw-r--r--content/public/android/java/res/drawable-hdpi/pageinfo_warning_major.png (renamed from chrome/android/java/res/drawable-hdpi/pageinfo_warning_major.png)bin1518 -> 1518 bytes
-rw-r--r--content/public/android/java/res/drawable-xhdpi/bubble.9.png (renamed from chrome/android/java/res/drawable-xhdpi/bubble.9.png)bin1174 -> 1174 bytes
-rw-r--r--content/public/android/java/res/drawable-xhdpi/bubble_arrow_up.png (renamed from chrome/android/java/res/drawable-xhdpi/bubble_arrow_up.png)bin459 -> 459 bytes
-rw-r--r--content/public/android/java/res/drawable-xhdpi/pageinfo_warning_major.png (renamed from chrome/android/java/res/drawable-xhdpi/pageinfo_warning_major.png)bin1991 -> 1991 bytes
-rw-r--r--content/public/android/java/res/drawable/bubble.9.png (renamed from chrome/android/java/res/drawable/bubble.9.png)bin482 -> 482 bytes
-rw-r--r--content/public/android/java/res/drawable/bubble_arrow_up.png (renamed from chrome/android/java/res/drawable/bubble_arrow_up.png)bin172 -> 172 bytes
-rw-r--r--content/public/android/java/res/drawable/pageinfo_warning_major.png (renamed from chrome/android/java/res/drawable/pageinfo_warning_major.png)bin1009 -> 1009 bytes
-rw-r--r--content/public/android/java/res/layout/validation_message_bubble.xml (renamed from chrome/android/java/res/layout/validation_message_bubble.xml)0
-rw-r--r--content/public/android/java/resource_map/org/chromium/content/R.java14
-rw-r--r--content/public/browser/web_contents_delegate.h16
-rw-r--r--content/renderer/render_view_impl.cc36
-rw-r--r--content/renderer/render_view_impl.h8
39 files changed, 234 insertions, 283 deletions
diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc
index 81bce27..f958b67 100644
--- a/chrome/browser/android/chrome_jni_registrar.cc
+++ b/chrome/browser/android/chrome_jni_registrar.cc
@@ -52,7 +52,6 @@
#include "chrome/browser/ui/android/javascript_app_modal_dialog_android.h"
#include "chrome/browser/ui/android/navigation_popup.h"
#include "chrome/browser/ui/android/ssl_client_certificate_request.h"
-#include "chrome/browser/ui/android/validation_message_bubble_android.h"
#include "chrome/browser/ui/android/website_settings_popup_android.h"
#include "components/autofill/core/browser/android/component_jni_registrar.h"
#include "components/navigation_interception/component_jni_registrar.h"
@@ -137,8 +136,6 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
{ "TtsPlatformImpl", TtsPlatformImplAndroid::Register },
{ "UmaBridge", RegisterUmaBridge },
{ "UrlUtilities", RegisterUrlUtilities },
- { "ValidationMessageBubbleAndroid",
- ValidationMessageBubbleAndroid::Register },
{ "WebsiteSettingsPopupAndroid",
WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid },
#if defined(ENABLE_PRINTING) && !defined(ENABLE_FULL_PRINTING)
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index c62c86f..981532a 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -84,7 +84,6 @@
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
-#include "chrome/browser/validation_message_message_filter.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -920,7 +919,6 @@ void ChromeContentBrowserClient::RenderProcessHostCreated(
host->AddFilter(new ChromeNetBenchmarkingMessageFilter(
id, profile, context));
host->AddFilter(new prerender::PrerenderMessageFilter(id, profile));
- host->AddFilter(new ValidationMessageMessageFilter(id));
host->AddFilter(new TtsMessageFilter(id, profile));
#if defined(ENABLE_WEBRTC)
WebRtcLoggingHandlerHost* webrtc_logging_handler_host =
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index e56a0b6..5c1dc65 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -134,6 +134,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/toolbar_model_impl.h"
#include "chrome/browser/ui/unload_controller.h"
+#include "chrome/browser/ui/validation_message_bubble.h"
#include "chrome/browser/ui/web_applications/web_app_ui.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
@@ -163,6 +164,7 @@
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
@@ -212,6 +214,7 @@ using content::NavigationEntry;
using content::OpenURLParams;
using content::PluginService;
using content::Referrer;
+using content::RenderWidgetHostView;
using content::SiteInstance;
using content::UserMetricsAction;
using content::WebContents;
@@ -1232,6 +1235,36 @@ void Browser::OverscrollUpdate(int delta_y) {
window_->OverscrollUpdate(delta_y);
}
+void Browser::ShowValidationMessage(content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view,
+ const string16& main_text,
+ const string16& sub_text) {
+ RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
+ if (rwhv) {
+ validation_message_bubble_ =
+ chrome::ValidationMessageBubble::CreateAndShow(
+ rwhv->GetRenderWidgetHost(),
+ anchor_in_root_view,
+ main_text,
+ sub_text);
+ }
+}
+
+void Browser::HideValidationMessage(content::WebContents* web_contents) {
+ validation_message_bubble_.reset();
+}
+
+void Browser::MoveValidationMessage(content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view) {
+ if (!validation_message_bubble_)
+ return;
+ RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
+ if (rwhv) {
+ validation_message_bubble_->SetPositionRelativeToAnchor(
+ rwhv->GetRenderWidgetHost(), anchor_in_root_view);
+ }
+}
+
bool Browser::IsMouseLocked() const {
return fullscreen_controller_->IsMouseLocked();
}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index f5e25ea..ecbc17f 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -66,6 +66,7 @@ namespace chrome {
class BrowserCommandController;
class FastUnloadController;
class UnloadController;
+class ValidationMessageBubble;
}
namespace content {
@@ -466,6 +467,15 @@ class Browser : public TabStripModelObserver,
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) OVERRIDE;
virtual void OverscrollUpdate(int delta_y) OVERRIDE;
+ virtual void ShowValidationMessage(content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view,
+ const string16& main_text,
+ const string16& sub_text) OVERRIDE;
+ virtual void HideValidationMessage(
+ content::WebContents* web_contents) OVERRIDE;
+ virtual void MoveValidationMessage(
+ content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view) OVERRIDE;
bool is_type_tabbed() const { return type_ == TYPE_TABBED; }
bool is_type_popup() const { return type_ == TYPE_POPUP; }
@@ -943,6 +953,8 @@ class Browser : public TabStripModelObserver,
scoped_ptr<BrowserLanguageStateObserver> language_state_observer_;
+ scoped_ptr<chrome::ValidationMessageBubble> validation_message_bubble_;
+
DISALLOW_COPY_AND_ASSIGN(Browser);
};
diff --git a/chrome/browser/validation_message_message_filter.cc b/chrome/browser/validation_message_message_filter.cc
deleted file mode 100644
index 49f21b8..0000000
--- a/chrome/browser/validation_message_message_filter.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// 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/browser/validation_message_message_filter.h"
-
-#include "base/bind.h"
-#include "chrome/browser/ui/validation_message_bubble.h"
-#include "chrome/common/validation_message_messages.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/render_widget_host.h"
-
-using content::BrowserThread;
-using content::RenderProcessHost;
-using content::RenderWidgetHost;
-
-namespace {
-
-void DeleteBubbleOnUIThread(chrome::ValidationMessageBubble* bubble) {
- delete bubble;
-}
-
-}
-
-ValidationMessageMessageFilter::ValidationMessageMessageFilter(int renderer_id)
- : renderer_id_(renderer_id) {
-}
-
-ValidationMessageMessageFilter::~ValidationMessageMessageFilter() {
- if (!validation_message_bubble_)
- return;
- // ValidationMessageBubble desructor might call UI-related API.
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&DeleteBubbleOnUIThread,
- validation_message_bubble_.release()));
-}
-
-bool ValidationMessageMessageFilter::OnMessageReceived(
- const IPC::Message& message, bool* message_was_ok) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_EX(
- ValidationMessageMessageFilter, message, *message_was_ok)
- IPC_MESSAGE_HANDLER(ValidationMessageMsg_ShowValidationMessage,
- OnShowValidationMessage)
- IPC_MESSAGE_HANDLER(ValidationMessageMsg_HideValidationMessage,
- OnHideValidationMessage)
- IPC_MESSAGE_HANDLER(ValidationMessageMsg_MoveValidationMessage,
- OnMoveValidationMessage)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void ValidationMessageMessageFilter::OverrideThreadForMessage(
- const IPC::Message& message, BrowserThread::ID* thread) {
- if (message.type() == ValidationMessageMsg_ShowValidationMessage::ID
- || message.type() == ValidationMessageMsg_HideValidationMessage::ID
- || message.type() == ValidationMessageMsg_MoveValidationMessage::ID)
- *thread = BrowserThread::UI;
-}
-
-void ValidationMessageMessageFilter::OnShowValidationMessage(
- int route_id, const gfx::Rect& anchor_in_root_view,
- const base::string16& main_text, const base::string16& sub_text) {
- RenderWidgetHost* widget_host =
- RenderWidgetHost::FromID(renderer_id_, route_id);
- validation_message_bubble_ = chrome::ValidationMessageBubble::CreateAndShow(
- widget_host, anchor_in_root_view, main_text, sub_text);
-}
-
-void ValidationMessageMessageFilter::OnHideValidationMessage() {
- validation_message_bubble_.reset();
-}
-
-void ValidationMessageMessageFilter::OnMoveValidationMessage(
- int route_id, const gfx::Rect& anchor_in_root_view) {
- if (!validation_message_bubble_)
- return;
- RenderWidgetHost* widget_host =
- RenderWidgetHost::FromID(renderer_id_, route_id);
- validation_message_bubble_->SetPositionRelativeToAnchor(
- widget_host, anchor_in_root_view);
-}
-
diff --git a/chrome/browser/validation_message_message_filter.h b/chrome/browser/validation_message_message_filter.h
deleted file mode 100644
index f7c30ba..0000000
--- a/chrome/browser/validation_message_message_filter.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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.
-
-#ifndef CHROME_BROWSER_VALIDATION_MESSAGE_MESSAGE_FILTER_H_
-#define CHROME_BROWSER_VALIDATION_MESSAGE_MESSAGE_FILTER_H_
-
-#include "content/public/browser/browser_message_filter.h"
-
-namespace chrome {
-class ValidationMessageBubble;
-}
-
-namespace gfx {
-class Rect;
-}
-
-// A message filter implementation that receives validation message requests
-// from ValidationMessageAgent.
-class ValidationMessageMessageFilter : public content::BrowserMessageFilter {
- public:
- explicit ValidationMessageMessageFilter(int renderer_id);
-
- // content::BrowserMessageFilter implementation.
- virtual bool OnMessageReceived(const IPC::Message& message,
- bool* message_was_ok) OVERRIDE;
- virtual void OverrideThreadForMessage(
- const IPC::Message& message, content::BrowserThread::ID* thread) OVERRIDE;
-
- private:
- virtual ~ValidationMessageMessageFilter();
- void OnShowValidationMessage(int route_id,
- const gfx::Rect& anchor_in_root_view,
- const base::string16& main_text,
- const base::string16& sub_text);
- void OnHideValidationMessage();
- void OnMoveValidationMessage(int route_id,
- const gfx::Rect& anchor_in_root_view);
-
- scoped_ptr<chrome::ValidationMessageBubble> validation_message_bubble_;
- int renderer_id_;
-
- DISALLOW_COPY_AND_ASSIGN(ValidationMessageMessageFilter);
-};
-
-#endif // CHROME_BROWSER_VALIDATION_MESSAGE_MESSAGE_FILTER_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 584aaf5..0c80b47 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2541,8 +2541,6 @@
'browser/user_data_dir_extractor.h',
'browser/user_data_dir_extractor_win.cc',
'browser/user_data_dir_extractor_win.h',
- 'browser/validation_message_message_filter.cc',
- 'browser/validation_message_message_filter.h',
'browser/value_store/leveldb_value_store.cc',
'browser/value_store/leveldb_value_store.h',
'browser/value_store/testing_value_store.cc',
@@ -3597,7 +3595,6 @@
'android/java/src/org/chromium/chrome/browser/UmaBridge.java',
'android/java/src/org/chromium/chrome/browser/UmaUtils.java',
'android/java/src/org/chromium/chrome/browser/UrlUtilities.java',
- 'android/java/src/org/chromium/chrome/browser/ValidationMessageBubble.java',
'android/java/src/org/chromium/chrome/browser/WebsiteSettingsPopup.java',
'android/java/src/org/chromium/chrome/browser/infobar/AutoLoginDelegate.java',
'android/java/src/org/chromium/chrome/browser/infobar/ConfirmInfoBarDelegate.java',
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 553309e..5fc645e 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -119,8 +119,6 @@
'browser/ui/android/tab_model/tab_model_list.cc',
'browser/ui/android/tab_model/tab_model_list.h',
'browser/ui/android/tab_restore_service_delegate_android.cc',
- 'browser/ui/android/validation_message_bubble_android.h',
- 'browser/ui/android/validation_message_bubble_android.cc',
'browser/ui/android/website_settings_popup_android.cc',
'browser/ui/android/website_settings_popup_android.h',
'browser/ui/android/window_android_helper.cc',
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index c694059..d0a9c46 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -378,7 +378,6 @@
'common/tts_utterance_request.h',
'common/url_constants.cc',
'common/url_constants.h',
- 'common/validation_message_messages.h',
'common/web_application_info.cc',
'common/web_application_info.h',
'common/worker_thread_ticker.cc',
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 5262c0e..4a778cb 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -343,8 +343,6 @@
'renderer/tts_dispatcher.h',
'renderer/translate/translate_helper.cc',
'renderer/translate/translate_helper.h',
- 'renderer/validation_message_agent.cc',
- 'renderer/validation_message_agent.h',
'renderer/web_apps.cc',
'renderer/web_apps.h',
'renderer/webview_color_overlay.cc',
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index e619a99..f65b8e2 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -14,7 +14,6 @@
#include "chrome/common/service_messages.h"
#include "chrome/common/spellcheck_messages.h"
#include "chrome/common/tts_messages.h"
-#include "chrome/common/validation_message_messages.h"
#if defined(ENABLE_MDNS)
#include "chrome/common/local_discovery/local_discovery_messages.h"
diff --git a/chrome/common/validation_message_messages.h b/chrome/common/validation_message_messages.h
deleted file mode 100644
index 26540b1..0000000
--- a/chrome/common/validation_message_messages.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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 "base/strings/string16.h"
-#include "ipc/ipc_message_macros.h"
-#include "ui/gfx/rect.h"
-
-#define IPC_MESSAGE_START ValidationMessageMsgStart
-
-IPC_MESSAGE_CONTROL4(ValidationMessageMsg_ShowValidationMessage,
- int /* route id */,
- gfx::Rect /* anchor rectangle in root view coordinate */,
- base::string16 /* validation message */,
- base::string16 /* supplemental text */)
-
-IPC_MESSAGE_CONTROL0(ValidationMessageMsg_HideValidationMessage)
-
-IPC_MESSAGE_CONTROL2(ValidationMessageMsg_MoveValidationMessage,
- int /* route id */,
- gfx::Rect /* anchor rectangle in root view coordinate */)
-
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 5c02f3a..1ef8502 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -62,7 +62,6 @@
#include "chrome/renderer/searchbox/searchbox.h"
#include "chrome/renderer/searchbox/searchbox_extension.h"
#include "chrome/renderer/tts_dispatcher.h"
-#include "chrome/renderer/validation_message_agent.h"
#include "chrome/renderer/worker_permission_client_proxy.h"
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
@@ -383,7 +382,6 @@ void ChromeContentRendererClient::RenderViewCreated(
PasswordAutofillAgent* password_autofill_agent =
new PasswordAutofillAgent(render_view);
new AutofillAgent(render_view, password_autofill_agent);
- new ValidationMessageAgent(render_view);
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (autofill::password_generation::IsPasswordGenerationEnabled())
diff --git a/chrome/renderer/validation_message_agent.cc b/chrome/renderer/validation_message_agent.cc
deleted file mode 100644
index b9c1b50..0000000
--- a/chrome/renderer/validation_message_agent.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-// 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/public/web/WebView.h"
-
-ValidationMessageAgent::ValidationMessageAgent(content::RenderView* render_view)
- : content::RenderViewObserver(render_view)
-{
- render_view->GetWebView()->setValidationMessageClient(this);
-}
-
-ValidationMessageAgent::~ValidationMessageAgent() {}
-
-void ValidationMessageAgent::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 ValidationMessageMsg_ShowValidationMessage(
- routing_id(), anchor_in_root_view, wrapped_main_text, wrapped_sub_text));
-}
-
-void ValidationMessageAgent::hideValidationMessage() {
- Send(new ValidationMessageMsg_HideValidationMessage());
-}
-
-void ValidationMessageAgent::moveValidationMessage(
- const blink::WebRect& anchor_in_root_view) {
- Send(new ValidationMessageMsg_MoveValidationMessage(
- routing_id(), anchor_in_root_view));
-}
-
diff --git a/chrome/renderer/validation_message_agent.h b/chrome/renderer/validation_message_agent.h
deleted file mode 100644
index 8e82ead..0000000
--- a/chrome/renderer/validation_message_agent.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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.
-
-#ifndef CHROME_RENDERER_VALIDATION_MESSAGE_AGENT_H_
-#define CHROME_RENDERER_VALIDATION_MESSAGE_AGENT_H_
-
-#include "content/public/renderer/render_view_observer.h"
-#include "third_party/WebKit/public/web/WebValidationMessageClient.h"
-
-namespace content {
-class RenderView;
-}
-
-// An impelemntation of blink::WebValidationMessageClient. This dispatches
-// messages to the browser processes.
-class ValidationMessageAgent : public content::RenderViewObserver,
- public blink::WebValidationMessageClient {
- public:
- explicit ValidationMessageAgent(content::RenderView* render_view);
- virtual ~ValidationMessageAgent();
-
- private:
- // WebValidationMessageClient functions:
- 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);
-
- DISALLOW_COPY_AND_ASSIGN(ValidationMessageAgent);
-};
-
-#endif // CHROME_RENDERER_VALIDATION_MESSAGE_AGENT_H_
diff --git a/components/web_contents_delegate_android.gypi b/components/web_contents_delegate_android.gypi
index ae24826..80e601f 100644
--- a/components/web_contents_delegate_android.gypi
+++ b/components/web_contents_delegate_android.gypi
@@ -31,6 +31,8 @@
'web_contents_delegate_android/color_chooser_android.h',
'web_contents_delegate_android/component_jni_registrar.cc',
'web_contents_delegate_android/component_jni_registrar.h',
+ 'web_contents_delegate_android/validation_message_bubble_android.cc',
+ 'web_contents_delegate_android/validation_message_bubble_android.h',
'web_contents_delegate_android/web_contents_delegate_android.cc',
'web_contents_delegate_android/web_contents_delegate_android.h',
],
@@ -52,6 +54,7 @@
'type': 'none',
'sources': [
'web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ColorChooserAndroid.java',
+ 'web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ValidationMessageBubble.java',
'web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/WebContentsDelegateAndroid.java',
],
'variables': {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ValidationMessageBubble.java b/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ValidationMessageBubble.java
index 1ec80e9..035f4f9 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ValidationMessageBubble.java
+++ b/components/web_contents_delegate_android/android/java/src/org/chromium/components/web_contents_delegate_android/ValidationMessageBubble.java
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.chromium.chrome.browser;
+package org.chromium.components.web_contents_delegate_android;
import android.graphics.Point;
import android.graphics.RectF;
@@ -16,7 +16,7 @@ import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CalledByNative;
-import org.chromium.chrome.R;
+import org.chromium.content.R;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.RenderCoordinates;
diff --git a/components/web_contents_delegate_android/component_jni_registrar.cc b/components/web_contents_delegate_android/component_jni_registrar.cc
index b5c5e15..3d1bc60 100644
--- a/components/web_contents_delegate_android/component_jni_registrar.cc
+++ b/components/web_contents_delegate_android/component_jni_registrar.cc
@@ -7,12 +7,14 @@
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "components/web_contents_delegate_android/color_chooser_android.h"
+#include "components/web_contents_delegate_android/validation_message_bubble_android.h"
#include "components/web_contents_delegate_android/web_contents_delegate_android.h"
namespace web_contents_delegate_android {
static base::android::RegistrationMethod kComponentRegisteredMethods[] = {
{ "ColorChooserAndroid", RegisterColorChooserAndroid },
+ { "ValidationMessageBubble", ValidationMessageBubbleAndroid::Register },
{ "WebContentsDelegateAndroid", RegisterWebContentsDelegateAndroid },
};
diff --git a/chrome/browser/ui/android/validation_message_bubble_android.cc b/components/web_contents_delegate_android/validation_message_bubble_android.cc
index 9b1af80..8ea3af0 100644
--- a/chrome/browser/ui/android/validation_message_bubble_android.cc
+++ b/components/web_contents_delegate_android/validation_message_bubble_android.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/android/validation_message_bubble_android.h"
+#include "components/web_contents_delegate_android/validation_message_bubble_android.h"
#include "base/android/jni_string.h"
#include "content/public/browser/android/content_view_core.h"
@@ -25,6 +25,8 @@ inline ContentViewCore* GetContentViewCoreFrom(RenderWidgetHost* widget_host) {
}
+namespace web_contents_delegate_android {
+
ValidationMessageBubbleAndroid::ValidationMessageBubbleAndroid(
RenderWidgetHost* widget_host,
const gfx::Rect& anchor_in_root_view,
@@ -65,15 +67,4 @@ bool ValidationMessageBubbleAndroid::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
-namespace chrome {
-
-scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow(
- RenderWidgetHost* widget_host,
- const gfx::Rect& anchor_in_root_view,
- const base::string16& main_text,
- const base::string16& sub_text) {
- return scoped_ptr<ValidationMessageBubble>(new ValidationMessageBubbleAndroid(
- widget_host, anchor_in_root_view, main_text, sub_text)).Pass();
-}
-
-} // namespace chrome
+} // namespace web_contents_delegate_android
diff --git a/chrome/browser/ui/android/validation_message_bubble_android.h b/components/web_contents_delegate_android/validation_message_bubble_android.h
index 6997483..d5ec77f 100644
--- a/chrome/browser/ui/android/validation_message_bubble_android.h
+++ b/components/web_contents_delegate_android/validation_message_bubble_android.h
@@ -2,26 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_UI_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
-#define CHROME_BROWSER_UI_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
+#ifndef COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
+#define COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
#include <jni.h>
#include "base/android/scoped_java_ref.h"
#include "base/strings/string16.h"
-#include "chrome/browser/ui/validation_message_bubble.h"
+
+namespace gfx {
+class Rect;
+}
namespace content {
class RenderWidgetHost;
}
-namespace gfx {
-class Rect;
-}
+namespace web_contents_delegate_android {
// An implementation of ValidationMessageBubble for Android. This class is a
// bridge to a Java implementation.
-class ValidationMessageBubbleAndroid : public chrome::ValidationMessageBubble {
+class ValidationMessageBubbleAndroid {
public:
ValidationMessageBubbleAndroid(content::RenderWidgetHost* widget_host,
const gfx::Rect& anchor_in_screen,
@@ -38,4 +39,6 @@ class ValidationMessageBubbleAndroid : public chrome::ValidationMessageBubble {
base::android::ScopedJavaGlobalRef<jobject> java_validation_message_bubble_;
};
-#endif // CHROME_BROWSER_UI_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
+} // namespace web_contents_delegate_android
+
+#endif // COMPONENTS_WEB_CONTENTS_DELEGATE_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
diff --git a/components/web_contents_delegate_android/web_contents_delegate_android.cc b/components/web_contents_delegate_android/web_contents_delegate_android.cc
index 1474e60..e1c91fd 100644
--- a/components/web_contents_delegate_android/web_contents_delegate_android.cc
+++ b/components/web_contents_delegate_android/web_contents_delegate_android.cc
@@ -10,6 +10,7 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "components/web_contents_delegate_android/color_chooser_android.h"
+#include "components/web_contents_delegate_android/validation_message_bubble_android.h"
#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/color_chooser.h"
#include "content/public/browser/invalidate_type.h"
@@ -29,6 +30,7 @@ using base::android::ConvertUTF8ToJavaString;
using base::android::ConvertUTF16ToJavaString;
using base::android::ScopedJavaLocalRef;
using content::ColorChooser;
+using content::RenderWidgetHostView;
using content::WebContents;
using content::WebContentsDelegate;
@@ -311,6 +313,37 @@ bool WebContentsDelegateAndroid::IsFullscreenForTabOrPending(
env, obj.obj());
}
+void WebContentsDelegateAndroid::ShowValidationMessage(
+ WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view,
+ const string16& main_text,
+ const string16& sub_text) {
+ RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
+ if (rwhv) {
+ validation_message_bubble_.reset(
+ new ValidationMessageBubbleAndroid(rwhv->GetRenderWidgetHost(),
+ anchor_in_root_view,
+ main_text,
+ sub_text));
+ }
+}
+
+void WebContentsDelegateAndroid::HideValidationMessage(
+ WebContents* web_contents) {
+ validation_message_bubble_.reset();
+}
+
+void WebContentsDelegateAndroid::MoveValidationMessage(
+ WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view) {
+ if (!validation_message_bubble_)
+ return;
+ RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
+ if (rwhv) {
+ validation_message_bubble_->SetPositionRelativeToAnchor(
+ rwhv->GetRenderWidgetHost(), anchor_in_root_view);
+ }
+}
// ----------------------------------------------------------------------------
// Native JNI methods
// ----------------------------------------------------------------------------
diff --git a/components/web_contents_delegate_android/web_contents_delegate_android.h b/components/web_contents_delegate_android/web_contents_delegate_android.h
index 565a1e0..c9ef1af 100644
--- a/components/web_contents_delegate_android/web_contents_delegate_android.h
+++ b/components/web_contents_delegate_android/web_contents_delegate_android.h
@@ -22,6 +22,8 @@ struct OpenURLParams;
namespace web_contents_delegate_android {
+class ValidationMessageBubbleAndroid;
+
enum WebContentsDelegateLogLevel {
// Equivalent of WebCore::WebConsoleMessage::LevelDebug.
WEB_CONTENTS_DELEGATE_LOG_LEVEL_DEBUG = 0,
@@ -86,6 +88,15 @@ class WebContentsDelegateAndroid : public content::WebContentsDelegate {
bool enter_fullscreen) OVERRIDE;
virtual bool IsFullscreenForTabOrPending(
const content::WebContents* web_contents) const OVERRIDE;
+ virtual void ShowValidationMessage(content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view,
+ const string16& main_text,
+ const string16& sub_text) OVERRIDE;
+ virtual void HideValidationMessage(
+ content::WebContents* web_contents) OVERRIDE;
+ virtual void MoveValidationMessage(
+ content::WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view) OVERRIDE;
protected:
base::android::ScopedJavaLocalRef<jobject> GetJavaDelegate(JNIEnv* env) const;
@@ -95,6 +106,8 @@ class WebContentsDelegateAndroid : public content::WebContentsDelegate {
// strong reference to that object as long as they want to receive callbacks
// on it. Using a weak ref here allows it to be correctly GCed.
JavaObjectWeakGlobalRef weak_java_delegate_;
+
+ scoped_ptr<ValidationMessageBubbleAndroid> validation_message_bubble_;
};
bool RegisterWebContentsDelegateAndroid(JNIEnv* env);
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index d9ac631..2236fa1 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -550,6 +550,12 @@ bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstVisuallyNonEmptyPaint,
OnFirstVisuallyNonEmptyPaint)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShowValidationMessage,
+ OnShowValidationMessage)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_HideValidationMessage,
+ OnHideValidationMessage)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_MoveValidationMessage,
+ OnMoveValidationMessage)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX()
render_view_message_source_ = NULL;
@@ -1601,6 +1607,26 @@ FrameTree* WebContentsImpl::GetFrameTree() {
return &frame_tree_;
}
+void WebContentsImpl::OnShowValidationMessage(
+ const gfx::Rect& anchor_in_root_view,
+ const string16& main_text,
+ const string16& sub_text) {
+ if (delegate_)
+ delegate_->ShowValidationMessage(
+ this, anchor_in_root_view, main_text, sub_text);
+}
+
+void WebContentsImpl::OnHideValidationMessage() {
+ if (delegate_)
+ delegate_->HideValidationMessage(this);
+}
+
+void WebContentsImpl::OnMoveValidationMessage(
+ const gfx::Rect& anchor_in_root_view) {
+ if (delegate_)
+ delegate_->MoveValidationMessage(this, anchor_in_root_view);
+}
+
void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) {
if (browser_plugin_embedder_)
browser_plugin_embedder_->DidSendScreenRects();
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index e790f15..0db67f2 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -698,6 +698,12 @@ class CONTENT_EXPORT WebContentsImpl
bool has_video,
bool has_audio,
bool is_playing);
+ void OnShowValidationMessage(const gfx::Rect& anchor_in_root_view,
+ const string16& main_text,
+ const string16& sub_text);
+ void OnHideValidationMessage();
+ void OnMoveValidationMessage(const gfx::Rect& anchor_in_root_view);
+
// Called by derived classes to indicate that we're no longer waiting for a
// response. This won't actually update the throbber, but it will get picked
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 1c5a8a9..a3fdaae 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -2237,6 +2237,22 @@ IPC_MESSAGE_CONTROL0(ViewHostMsg_CancelVibration)
IPC_MESSAGE_ROUTED1(ViewHostMsg_FocusedNodeTouched,
bool /* editable */)
+// Message sent from the renderer to the browser when an HTML form has failed
+// validation constraints.
+IPC_MESSAGE_ROUTED3(ViewHostMsg_ShowValidationMessage,
+ gfx::Rect /* anchor rectangle in root view coordinate */,
+ base::string16 /* validation message */,
+ base::string16 /* supplemental text */)
+
+// Message sent from the renderer to the browser when a HTML form validation
+// message should be hidden from view.
+IPC_MESSAGE_ROUTED0(ViewHostMsg_HideValidationMessage)
+
+// Message sent from the renderer to the browser when the suggested co-ordinates
+// of the anchor for a HTML form validation message have changed.
+IPC_MESSAGE_ROUTED1(ViewHostMsg_MoveValidationMessage,
+ gfx::Rect /* anchor rectangle in root view coordinate */)
+
#if defined(OS_ANDROID)
// Response to ViewMsg_FindMatchRects.
//
diff --git a/chrome/android/java/res/drawable-hdpi/bubble.9.png b/content/public/android/java/res/drawable-hdpi/bubble.9.png
index 905730f..905730f 100644
--- a/chrome/android/java/res/drawable-hdpi/bubble.9.png
+++ b/content/public/android/java/res/drawable-hdpi/bubble.9.png
Binary files differ
diff --git a/chrome/android/java/res/drawable-hdpi/bubble_arrow_up.png b/content/public/android/java/res/drawable-hdpi/bubble_arrow_up.png
index 9f941a4..9f941a4 100644
--- a/chrome/android/java/res/drawable-hdpi/bubble_arrow_up.png
+++ b/content/public/android/java/res/drawable-hdpi/bubble_arrow_up.png
Binary files differ
diff --git a/chrome/android/java/res/drawable-hdpi/pageinfo_warning_major.png b/content/public/android/java/res/drawable-hdpi/pageinfo_warning_major.png
index 081668f..081668f 100644
--- a/chrome/android/java/res/drawable-hdpi/pageinfo_warning_major.png
+++ b/content/public/android/java/res/drawable-hdpi/pageinfo_warning_major.png
Binary files differ
diff --git a/chrome/android/java/res/drawable-xhdpi/bubble.9.png b/content/public/android/java/res/drawable-xhdpi/bubble.9.png
index c5d2e8f..c5d2e8f 100644
--- a/chrome/android/java/res/drawable-xhdpi/bubble.9.png
+++ b/content/public/android/java/res/drawable-xhdpi/bubble.9.png
Binary files differ
diff --git a/chrome/android/java/res/drawable-xhdpi/bubble_arrow_up.png b/content/public/android/java/res/drawable-xhdpi/bubble_arrow_up.png
index 0ec744c..0ec744c 100644
--- a/chrome/android/java/res/drawable-xhdpi/bubble_arrow_up.png
+++ b/content/public/android/java/res/drawable-xhdpi/bubble_arrow_up.png
Binary files differ
diff --git a/chrome/android/java/res/drawable-xhdpi/pageinfo_warning_major.png b/content/public/android/java/res/drawable-xhdpi/pageinfo_warning_major.png
index 9b9e312..9b9e312 100644
--- a/chrome/android/java/res/drawable-xhdpi/pageinfo_warning_major.png
+++ b/content/public/android/java/res/drawable-xhdpi/pageinfo_warning_major.png
Binary files differ
diff --git a/chrome/android/java/res/drawable/bubble.9.png b/content/public/android/java/res/drawable/bubble.9.png
index f3089cc..f3089cc 100644
--- a/chrome/android/java/res/drawable/bubble.9.png
+++ b/content/public/android/java/res/drawable/bubble.9.png
Binary files differ
diff --git a/chrome/android/java/res/drawable/bubble_arrow_up.png b/content/public/android/java/res/drawable/bubble_arrow_up.png
index 75d8e79..75d8e79 100644
--- a/chrome/android/java/res/drawable/bubble_arrow_up.png
+++ b/content/public/android/java/res/drawable/bubble_arrow_up.png
Binary files differ
diff --git a/chrome/android/java/res/drawable/pageinfo_warning_major.png b/content/public/android/java/res/drawable/pageinfo_warning_major.png
index 82c9635..82c9635 100644
--- a/chrome/android/java/res/drawable/pageinfo_warning_major.png
+++ b/content/public/android/java/res/drawable/pageinfo_warning_major.png
Binary files differ
diff --git a/chrome/android/java/res/layout/validation_message_bubble.xml b/content/public/android/java/res/layout/validation_message_bubble.xml
index 4e44be7..4e44be7 100644
--- a/chrome/android/java/res/layout/validation_message_bubble.xml
+++ b/content/public/android/java/res/layout/validation_message_bubble.xml
diff --git a/content/public/android/java/resource_map/org/chromium/content/R.java b/content/public/android/java/resource_map/org/chromium/content/R.java
index ac39779..fec2cea 100644
--- a/content/public/android/java/resource_map/org/chromium/content/R.java
+++ b/content/public/android/java/resource_map/org/chromium/content/R.java
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 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.
@@ -16,22 +16,28 @@ package org.chromium.content;
* com.android.internal.R.
*/
public final class R {
+ /** Attributes */
public static final class attr {
public static int select_dialog_multichoice;
public static int select_dialog_singlechoice;
}
+ /** Dimensions */
public static final class dimen {
public static int link_preview_overlay_radius;
}
+ /** Drawables */
public static final class drawable {
public static int ondemand_overlay;
}
+ /** id */
public static final class id {
public static int ampm;
+ public static int arrow_image;
public static int date_picker;
public static int date_time_suggestion_value;
public static int date_time_suggestion_label;
public static int hour;
+ public static int main_text;
public static int milli;
public static int minute;
public static int pickers;
@@ -45,18 +51,23 @@ public final class R {
public static int select_action_menu_paste;
public static int select_action_menu_share;
public static int select_action_menu_web_search;
+ public static int sub_text;
public static int time_picker;
public static int year;
}
+ /** layouts */
public static final class layout {
public static int date_time_picker_dialog;
public static int date_time_suggestion;
public static int two_field_date_picker;
public static int multi_field_time_picker_dialog;
+ public static int validation_message_bubble;
}
+ /** menus */
public static final class menu {
public static int select_action_menu;
}
+ /** strings */
public static final class string {
public static int accessibility_content_view;
public static int accessibility_date_picker_month;
@@ -89,6 +100,7 @@ public final class R {
public static int time_picker_dialog_title;
public static int week_picker_dialog_title;
}
+ /** styles */
public static final class style {
public static int SelectPopupDialog;
}
diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h
index 81faa6b..7f37194 100644
--- a/content/public/browser/web_contents_delegate.h
+++ b/content/public/browser/web_contents_delegate.h
@@ -451,6 +451,22 @@ class CONTENT_EXPORT WebContentsDelegate {
virtual gfx::Size GetSizeForNewRenderView(
const WebContents* web_contents) const;
+ // Notification that validation of a form displayed by the |web_contents|
+ // has failed. There can only be one message per |web_contents| at a time.
+ virtual void ShowValidationMessage(WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view,
+ const string16& main_text,
+ const string16& sub_text) {}
+
+ // Notification that the delegate should hide any showing form validation
+ // message.
+ virtual void HideValidationMessage(WebContents* web_contents) {}
+
+ // Notification that the form element that triggered the validation failure
+ // has moved.
+ virtual void MoveValidationMessage(WebContents* web_contents,
+ const gfx::Rect& anchor_in_root_view) {}
+
protected:
virtual ~WebContentsDelegate();
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);