summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-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/android/validation_message_bubble_android.cc79
-rw-r--r--chrome/browser/ui/android/validation_message_bubble_android.h41
-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
8 files changed, 45 insertions, 255 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/android/validation_message_bubble_android.cc b/chrome/browser/ui/android/validation_message_bubble_android.cc
deleted file mode 100644
index 9b1af80..0000000
--- a/chrome/browser/ui/android/validation_message_bubble_android.cc
+++ /dev/null
@@ -1,79 +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/ui/android/validation_message_bubble_android.h"
-
-#include "base/android/jni_string.h"
-#include "content/public/browser/android/content_view_core.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/web_contents.h"
-#include "jni/ValidationMessageBubble_jni.h"
-#include "ui/gfx/rect.h"
-
-using base::android::ConvertUTF16ToJavaString;
-using content::ContentViewCore;
-using content::RenderWidgetHost;
-
-namespace {
-
-inline ContentViewCore* GetContentViewCoreFrom(RenderWidgetHost* widget_host) {
- return ContentViewCore::FromWebContents(
- content::WebContents::FromRenderViewHost(
- content::RenderViewHost::From(widget_host)));
-}
-
-}
-
-ValidationMessageBubbleAndroid::ValidationMessageBubbleAndroid(
- RenderWidgetHost* widget_host,
- const gfx::Rect& anchor_in_root_view,
- const base::string16& main_text,
- const base::string16& sub_text) {
- JNIEnv* env = base::android::AttachCurrentThread();
- java_validation_message_bubble_.Reset(
- Java_ValidationMessageBubble_createAndShow(
- env,
- GetContentViewCoreFrom(widget_host)->GetJavaObject().obj(),
- anchor_in_root_view.x(),
- anchor_in_root_view.y(),
- anchor_in_root_view.width(),
- anchor_in_root_view.height(),
- ConvertUTF16ToJavaString(env, main_text).obj(),
- ConvertUTF16ToJavaString(env, sub_text).obj()));
-}
-
-ValidationMessageBubbleAndroid::~ValidationMessageBubbleAndroid() {
- Java_ValidationMessageBubble_close(base::android::AttachCurrentThread(),
- java_validation_message_bubble_.obj());
-}
-
-void ValidationMessageBubbleAndroid::SetPositionRelativeToAnchor(
- RenderWidgetHost* widget_host, const gfx::Rect& anchor_in_root_view) {
- Java_ValidationMessageBubble_setPositionRelativeToAnchor(
- base::android::AttachCurrentThread(),
- java_validation_message_bubble_.obj(),
- GetContentViewCoreFrom(widget_host)->GetJavaObject().obj(),
- anchor_in_root_view.x(),
- anchor_in_root_view.y(),
- anchor_in_root_view.width(),
- anchor_in_root_view.height());
-}
-
-// static
-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
diff --git a/chrome/browser/ui/android/validation_message_bubble_android.h b/chrome/browser/ui/android/validation_message_bubble_android.h
deleted file mode 100644
index 6997483..0000000
--- a/chrome/browser/ui/android/validation_message_bubble_android.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 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_UI_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
-#define CHROME_BROWSER_UI_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 content {
-class RenderWidgetHost;
-}
-
-namespace gfx {
-class Rect;
-}
-
-// An implementation of ValidationMessageBubble for Android. This class is a
-// bridge to a Java implementation.
-class ValidationMessageBubbleAndroid : public chrome::ValidationMessageBubble {
- public:
- ValidationMessageBubbleAndroid(content::RenderWidgetHost* widget_host,
- const gfx::Rect& anchor_in_screen,
- const base::string16& main_text,
- const base::string16& sub_text);
- virtual ~ValidationMessageBubbleAndroid();
- virtual void SetPositionRelativeToAnchor(
- content::RenderWidgetHost* widget_host,
- const gfx::Rect& anchor_in_screen) OVERRIDE;
-
- static bool Register(JNIEnv* env);
-
- private:
- base::android::ScopedJavaGlobalRef<jobject> java_validation_message_bubble_;
-};
-
-#endif // CHROME_BROWSER_UI_ANDROID_VALIDATION_MESSAGE_BUBBLE_ANDROID_H_
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_