From 0e7fe5cab991f8751ecaa6cd43ff7e51d9647dde Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Tue, 24 Feb 2009 19:02:43 +0000 Subject: Implement ResourceMessageFilter::OnGetWindowRect and OnGetRootWindowRect on linux. This fixes a problem typing in the username when authenticating to gmail. The error message was: FATAL:browser/renderer_host/render_view_host.cc(658)] Check failed: false. Can't send sync messages to UI thread without pumping messages in the renderer or else deadlocks can occur if the pagehas windowed plugins! (message type 8219) Review URL: http://codereview.chromium.org/28026 Patch from Craig Schlenter . git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10275 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/renderer_host/render_view_host.cc | 2 +- .../renderer_host/resource_message_filter.cc | 39 ++++++++++++++++++++-- .../renderer_host/resource_message_filter.h | 2 +- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 723e91e9..8770bcf 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -656,7 +656,7 @@ bool RenderViewHost::CanTerminate() const { void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { if (msg.is_sync() && !msg.is_caller_pumping_messages()) { NOTREACHED() << "Can't send sync messages to UI thread without pumping " - "messages in the renderer or else deadlocks can occur if the page" + "messages in the renderer or else deadlocks can occur if the page " "has windowed plugins! (message type " << msg.type() << ")"; IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); reply->set_reply_error(); diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 9cd52ef..e19c00b 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -4,6 +4,10 @@ #include "chrome/browser/renderer_host/resource_message_filter.h" +#if defined(OS_LINUX) +#include +#endif + #include "base/clipboard.h" #include "base/gfx/native_widget_types.h" #include "base/histogram.h" @@ -206,7 +210,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { OnClipboardReadAsciiText) IPC_MESSAGE_HANDLER(ViewHostMsg_ClipboardReadHTML, OnClipboardReadHTML) -#if defined(OS_WIN) +#if defined(OS_WIN)|| defined(OS_LINUX) IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnGetWindowRect) IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnGetRootWindowRect) #endif @@ -556,7 +560,38 @@ void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id, *rect = window_rect; } -#endif // OS_WIN +#elif defined(OS_LINUX) + +// Returns the rectangle of the WebWidget in screen coordinates. +void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id, + gfx::Rect* rect) { + // Ideally this would be gtk_widget_get_window but that's only + // from gtk 2.14 onwards. :( + GdkWindow* window = gfx::NativeViewFromId(window_id)->window; + DCHECK(window); + gint x, y, width, height; + // This is the "position of a window in root window coordinates". + gdk_window_get_origin(window, &x, &y); + gdk_window_get_size(window, &width, &height); + *rect = gfx::Rect(x, y, width, height); +} + +// Returns the rectangle of the window in which this WebWidget is embedded. +void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id, + gfx::Rect* rect) { + // Windows uses GetAncestor(window, GA_ROOT) here which probably means + // we want the top level window. + GdkWindow* window = + gdk_window_get_toplevel(gfx::NativeViewFromId(window_id)->window); + DCHECK(window); + gint x, y, width, height; + // This is the "position of a window in root window coordinates". + gdk_window_get_origin(window, &x, &y); + gdk_window_get_size(window, &width, &height); + *rect = gfx::Rect(x, y, width, height); +} + +#endif // OS_LINUX void ResourceMessageFilter::OnGetMimeTypeFromExtension( const FilePath::StringType& ext, std::string* mime_type) { diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index ef389a8..4121a50 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -153,7 +153,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, void OnClipboardReadText(std::wstring* result); void OnClipboardReadAsciiText(std::string* result); void OnClipboardReadHTML(std::wstring* markup, GURL* src_url); -#if defined(OS_WIN) +#if defined(OS_WIN)|| defined(OS_LINUX) void OnGetWindowRect(gfx::NativeViewId window, gfx::Rect *rect); void OnGetRootWindowRect(gfx::NativeViewId window, gfx::Rect *rect); #endif -- cgit v1.1