summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc21
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h3
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h2
-rw-r--r--chrome/common/render_messages.h1
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/renderer/print_web_view_helper.h5
-rw-r--r--chrome/renderer/render_view.cc10
-rw-r--r--chrome/renderer/render_view.h3
-rw-r--r--chrome/renderer/render_widget.cc33
-rw-r--r--chrome/renderer/render_widget.h17
11 files changed, 61 insertions, 43 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 6481881..cdadd9e 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -135,7 +135,7 @@ IPC_DEFINE_MESSAGE_MAP(RenderWidgetHost)
IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyPluginContainer,
OnMsgDestroyPluginContainer)
#elif defined(OS_MACOSX)
- IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_ShowPopup, OnMsgShowPopup(msg))
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect)
IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnMsgGetRootWindowRect)
@@ -752,6 +752,7 @@ void RenderWidgetHost::OnMsgImeUpdateStatus(int control,
}
#if defined(OS_LINUX)
+
void RenderWidgetHost::OnMsgCreatePluginContainer(
gfx::PluginWindowHandle *container) {
*container = view_->CreatePluginContainer();
@@ -761,18 +762,15 @@ void RenderWidgetHost::OnMsgDestroyPluginContainer(
gfx::PluginWindowHandle container) {
view_->DestroyPluginContainer(container);
}
+
#elif defined(OS_MACOSX)
-void RenderWidgetHost::OnMsgShowPopup(const IPC::Message& message) {
- void* iter = NULL;
- ViewHostMsg_ShowPopup_Params validated_params;
- if (!IPC::ParamTraits<ViewHostMsg_ShowPopup_Params>::Read(&message, &iter,
- &validated_params))
- return;
- view_->ShowPopupWithItems(validated_params.bounds,
- validated_params.item_height,
- validated_params.selected_item,
- validated_params.popup_items);
+void RenderWidgetHost::OnMsgShowPopup(
+ const ViewHostMsg_ShowPopup_Params& params) {
+ view_->ShowPopupWithItems(params.bounds,
+ params.item_height,
+ params.selected_item,
+ params.popup_items);
}
void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view,
@@ -794,6 +792,7 @@ void RenderWidgetHost::OnMsgGetRootWindowRect(gfx::NativeViewId window_id,
*results = view_->GetRootWindowRect();
}
}
+
#endif
void RenderWidgetHost::PaintBackingStoreRect(TransportDIB* bitmap,
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index d2d2826..e133670 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -38,6 +38,7 @@ class TransportDIB;
class WebCursor;
struct ViewHostMsg_PaintRect_Params;
struct ViewHostMsg_ScrollRect_Params;
+struct ViewHostMsg_ShowPopup_Params;
// This class manages the browser side of a browser<->renderer HWND connection.
// The HWND lives in the browser process, and windows events are sent over
@@ -396,7 +397,7 @@ class RenderWidgetHost : public IPC::Channel::Listener {
void OnMsgCreatePluginContainer(gfx::PluginWindowHandle *container);
void OnMsgDestroyPluginContainer(gfx::PluginWindowHandle container);
#elif defined(OS_MACOSX)
- void OnMsgShowPopup(const IPC::Message& message);
+ void OnMsgShowPopup(const ViewHostMsg_ShowPopup_Params& params);
void OnMsgGetScreenInfo(gfx::NativeViewId view,
WebKit::WebScreenInfo* results);
void OnMsgGetWindowRect(gfx::NativeViewId window_id, gfx::Rect* results);
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index fd72167..0837bc7 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -23,6 +23,7 @@ class BackingStore;
class RenderProcessHost;
class RenderWidgetHost;
class WebCursor;
+struct WebMenuItem;
// RenderWidgetHostView is an interface implemented by an object that acts as
// the "View" portion of a RenderWidgetHost. The RenderWidgetHost and its
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 270f00f..6c705db 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -13,8 +13,8 @@
#include "base/time.h"
#include "chrome/browser/cocoa/base_view.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
-
#include "webkit/glue/webcursor.h"
+#include "webkit/glue/webmenuitem.h"
class RenderWidgetHostViewMac;
class RWHVMEditCommandHelper;
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 829a8ed..c887d40 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -34,6 +34,7 @@
#include "webkit/glue/webaccessibility.h"
#include "webkit/glue/webappcachecontext.h"
#include "webkit/glue/webdropdata.h"
+#include "webkit/glue/webmenuitem.h"
#include "webkit/glue/webplugin.h"
#include "webkit/glue/webplugininfo.h"
#include "webkit/glue/webpreferences.h"
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 31670ba..d3046d0 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -655,6 +655,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
int /* route_id */,
gfx::Rect /* initial_pos */)
+ // Message to show a popup menu using native cocoa controls (Mac only).
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowPopup,
+ ViewHostMsg_ShowPopup_Params)
+
// This message is sent after ViewHostMsg_ShowView to cause the RenderView
// to run in a modal fashion until it is closed.
IPC_SYNC_MESSAGE_ROUTED0_0(ViewHostMsg_RunModal)
@@ -1431,10 +1435,6 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_CONTROL1(ViewHostMsg_ExtensionCloseChannel,
int /* port_id */)
- // Message to show a popup menu using native cocoa controls (Mac only).
- IPC_MESSAGE_ROUTED1(ViewHostMsg_ShowPopup,
- ViewHostMsg_ShowPopup_Params)
-
// Sent as a result of a focus change in the renderer (if accessibility is
// enabled), to notify the browser side that its accessibility focus needs to
// change as well. Takes the id of the accessibility object that now has
diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h
index 07a57c3..11e16fd 100644
--- a/chrome/renderer/print_web_view_helper.h
+++ b/chrome/renderer/print_web_view_helper.h
@@ -72,11 +72,6 @@ class PrintWebViewHelper : public WebViewDelegate {
virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebKit::WebRect& clip_rect) {}
virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition) {}
- virtual void ShowAsPopupWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {}
virtual void CloseWidgetSoon(WebWidget* webwidget) {}
virtual void Focus(WebWidget* webwidget) {}
virtual void Blur(WebWidget* webwidget) {}
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d9df8e4..5f82399 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -107,6 +107,7 @@ using WebKit::WebDragData;
using WebKit::WebForm;
using WebKit::WebHistoryItem;
using WebKit::WebNavigationType;
+using WebKit::WebPopupMenuInfo;
using WebKit::WebRect;
using WebKit::WebScriptSource;
using WebKit::WebSize;
@@ -1759,6 +1760,15 @@ WebWidget* RenderView::CreatePopupWidget(WebView* webview,
return widget->webwidget();
}
+WebWidget* RenderView::CreatePopupWidgetWithInfo(WebView* webview,
+ const WebPopupMenuInfo& info) {
+ RenderWidget* widget = RenderWidget::Create(routing_id_,
+ render_thread_,
+ true);
+ widget->ConfigureAsExternalPopupMenu(info);
+ return widget->webwidget();
+}
+
WebPluginDelegate* RenderView::CreatePluginDelegate(
WebView* webview,
const GURL& url,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 24621a4..bf6b6e3 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -233,6 +233,9 @@ class RenderView : public RenderWidget,
bool user_gesture,
const GURL& creator_url);
virtual WebWidget* CreatePopupWidget(WebView* webview, bool activatable);
+ virtual WebWidget* CreatePopupWidgetWithInfo(
+ WebView* webview,
+ const WebKit::WebPopupMenuInfo& info);
virtual WebPluginDelegate* CreatePluginDelegate(
WebView* webview,
const GURL& url,
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index cf2e1da..7ff612f 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -16,6 +16,7 @@
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkShader.h"
#include "webkit/api/public/WebCursorInfo.h"
+#include "webkit/api/public/WebPopupMenuInfo.h"
#include "webkit/api/public/WebRect.h"
#include "webkit/api/public/WebScreenInfo.h"
#include "webkit/api/public/WebSize.h"
@@ -30,6 +31,7 @@
using WebKit::WebCursorInfo;
using WebKit::WebInputEvent;
+using WebKit::WebPopupMenuInfo;
using WebKit::WebRect;
using WebKit::WebScreenInfo;
using WebKit::WebSize;
@@ -86,6 +88,14 @@ RenderWidget* RenderWidget::Create(int32 opener_id,
return widget;
}
+void RenderWidget::ConfigureAsExternalPopupMenu(const WebPopupMenuInfo& info) {
+ popup_params_.reset(new ViewHostMsg_ShowPopup_Params);
+ popup_params_->item_height = info.itemHeight;
+ popup_params_->selected_item = info.selectedIndex;
+ for (size_t i = 0; i < info.items.size(); ++i)
+ popup_params_->popup_items.push_back(WebMenuItem(info.items[i]));
+}
+
void RenderWidget::Init(int32 opener_id) {
DCHECK(!webwidget_);
@@ -589,26 +599,17 @@ void RenderWidget::Show(WebWidget* webwidget,
// NOTE: initial_pos_ may still have its default values at this point, but
// that's okay. It'll be ignored if as_popup is false, or the browser
// process will impose a default position otherwise.
- render_thread_->Send(new ViewHostMsg_ShowWidget(
- opener_id_, routing_id_, initial_pos_));
+ if (popup_params_.get()) {
+ popup_params_->bounds = initial_pos_;
+ Send(new ViewHostMsg_ShowPopup(routing_id_, *popup_params_));
+ popup_params_.reset();
+ } else {
+ Send(new ViewHostMsg_ShowWidget(opener_id_, routing_id_, initial_pos_));
+ }
SetPendingWindowRect(initial_pos_);
}
}
-void RenderWidget::ShowAsPopupWithItems(WebWidget* webwidget,
- const WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items) {
- ViewHostMsg_ShowPopup_Params params;
- params.bounds = bounds;
- params.item_height = item_height;
- params.selected_item = selected_index;
- params.popup_items = items;
-
- Send(new ViewHostMsg_ShowPopup(routing_id_, params));
-}
-
void RenderWidget::Focus(WebWidget* webwidget) {
// Prevent the widget from stealing the focus if it does not have focus
// already. We do this by explicitely setting the focus to false again.
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 3be99d8..f1fa069 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -23,8 +23,13 @@
#include "webkit/glue/webcursor.h"
class RenderThreadBase;
+struct ViewHostMsg_ShowPopup_Params;
struct WebPluginGeometry;
+namespace WebKit {
+struct WebPopupMenuInfo;
+}
+
// RenderWidget provides a communication bridge between a WebWidget and
// a RenderWidgetHost, the latter of which lives in a different process.
class RenderWidget : public IPC::Channel::Listener,
@@ -39,6 +44,10 @@ class RenderWidget : public IPC::Channel::Listener,
RenderThreadBase* render_thread,
bool activatable);
+ // Called after Create to configure a RenderWidget to be rendered by the host
+ // as a popup menu with the given data.
+ void ConfigureAsExternalPopupMenu(const WebKit::WebPopupMenuInfo& info);
+
// The routing ID assigned by the RenderProcess. Will be MSG_ROUTING_NONE if
// not yet assigned a view ID, in which case, the process MUST NOT send
// messages with this ID to the parent.
@@ -63,11 +72,6 @@ class RenderWidget : public IPC::Channel::Listener,
virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy,
const WebKit::WebRect& clip_rect);
virtual void Show(WebWidget* webwidget, WindowOpenDisposition disposition);
- virtual void ShowAsPopupWithItems(WebWidget* webwidget,
- const WebKit::WebRect& bounds,
- int item_height,
- int selected_index,
- const std::vector<WebMenuItem>& items);
virtual void CloseWidgetSoon(WebWidget* webwidget);
virtual void Focus(WebWidget* webwidget);
virtual void Blur(WebWidget* webwidget);
@@ -207,6 +211,7 @@ class RenderWidget : public IPC::Channel::Listener,
// We store the current cursor object so we can avoid spamming SetCursor
// messages.
WebCursor current_cursor_;
+
// The size of the RenderWidget.
gfx::Size size_;
@@ -289,6 +294,8 @@ class RenderWidget : public IPC::Channel::Listener,
int pending_window_rect_count_;
WebKit::WebRect pending_window_rect_;
+ scoped_ptr<ViewHostMsg_ShowPopup_Params> popup_params_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};