Commit 90e100b3 authored by fsamuel's avatar fsamuel Committed by Commit bot

Browser Plugin: Move input to RWHVGuest to support interstitial pages

BUG=273089

Review URL: https://codereview.chromium.org/554733003

Cr-Commit-Position: refs/heads/master@{#294170}
parent 5dc66194
......@@ -128,6 +128,16 @@ WebContentsImpl* BrowserPluginGuest::CreateNewGuestWindow(
bool BrowserPluginGuest::OnMessageReceivedFromEmbedder(
const IPC::Message& message) {
RenderWidgetHostViewGuest* rwhv = static_cast<RenderWidgetHostViewGuest*>(
web_contents()->GetRenderWidgetHostView());
if (rwhv &&
rwhv->OnMessageReceivedFromEmbedder(
message,
static_cast<RenderViewHostImpl*>(
embedder_web_contents()->GetRenderViewHost()))) {
return true;
}
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK,
......@@ -140,8 +150,6 @@ bool BrowserPluginGuest::OnMessageReceivedFromEmbedder(
OnExecuteEditCommand)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ExtendSelectionAndDelete,
OnExtendSelectionAndDelete)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent,
OnHandleInputEvent)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeConfirmComposition,
OnImeConfirmComposition)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ImeSetComposition,
......@@ -631,50 +639,6 @@ void BrowserPluginGuest::OnReclaimCompositorResources(
params.ack);
}
void BrowserPluginGuest::OnHandleInputEvent(
int browser_plugin_instance_id,
const gfx::Rect& guest_window_rect,
const blink::WebInputEvent* event) {
RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
GetWebContents()->GetRenderViewHost());
if (blink::WebInputEvent::isMouseEventType(event->type)) {
guest_rvh->ForwardMouseEvent(
*static_cast<const blink::WebMouseEvent*>(event));
return;
}
if (event->type == blink::WebInputEvent::MouseWheel) {
guest_rvh->ForwardWheelEvent(
*static_cast<const blink::WebMouseWheelEvent*>(event));
return;
}
if (blink::WebInputEvent::isKeyboardEventType(event->type)) {
RenderViewHostImpl* embedder_rvh = static_cast<RenderViewHostImpl*>(
embedder_web_contents_->GetRenderViewHost());
if (!embedder_rvh->GetLastKeyboardEvent())
return;
NativeWebKeyboardEvent keyboard_event(
*embedder_rvh->GetLastKeyboardEvent());
guest_rvh->ForwardKeyboardEvent(keyboard_event);
return;
}
if (blink::WebInputEvent::isTouchEventType(event->type)) {
guest_rvh->ForwardTouchEventWithLatencyInfo(
*static_cast<const blink::WebTouchEvent*>(event),
ui::LatencyInfo());
return;
}
if (blink::WebInputEvent::isGestureEventType(event->type)) {
guest_rvh->ForwardGestureEvent(
*static_cast<const blink::WebGestureEvent*>(event));
return;
}
}
void BrowserPluginGuest::OnLockMouse(bool user_gesture,
bool last_unlocked_by_target,
bool privileged) {
......
......@@ -245,9 +245,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public WebContentsObserver {
int instance_id,
const FrameHostMsg_ReclaimCompositorResources_Params& params);
void OnHandleInputEvent(int instance_id,
const gfx::Rect& guest_window_rect,
const blink::WebInputEvent* event);
void OnLockMouse(bool user_gesture,
bool last_unlocked_by_target,
bool privileged);
......
......@@ -63,6 +63,19 @@ RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() {
#endif // defined(USE_AURA)
}
bool RenderWidgetHostViewGuest::OnMessageReceivedFromEmbedder(
const IPC::Message& message,
RenderWidgetHostImpl* embedder) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(RenderWidgetHostViewGuest, message,
embedder)
IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent,
OnHandleInputEvent)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void RenderWidgetHostViewGuest::WasShown() {
// If the WebContents associated with us showed an interstitial page in the
// beginning, the teardown path might call WasShown() while |host_| is in
......@@ -530,4 +543,44 @@ RenderWidgetHostViewGuest::GetGuestRenderWidgetHostView() const {
guest_->GetEmbedderRenderWidgetHostView());
}
void RenderWidgetHostViewGuest::OnHandleInputEvent(
RenderWidgetHostImpl* embedder,
int browser_plugin_instance_id,
const gfx::Rect& guest_window_rect,
const blink::WebInputEvent* event) {
if (blink::WebInputEvent::isMouseEventType(event->type)) {
host_->ForwardMouseEvent(
*static_cast<const blink::WebMouseEvent*>(event));
return;
}
if (event->type == blink::WebInputEvent::MouseWheel) {
host_->ForwardWheelEvent(
*static_cast<const blink::WebMouseWheelEvent*>(event));
return;
}
if (blink::WebInputEvent::isKeyboardEventType(event->type)) {
if (!embedder->GetLastKeyboardEvent())
return;
NativeWebKeyboardEvent keyboard_event(
*embedder->GetLastKeyboardEvent());
host_->ForwardKeyboardEvent(keyboard_event);
return;
}
if (blink::WebInputEvent::isTouchEventType(event->type)) {
host_->ForwardTouchEventWithLatencyInfo(
*static_cast<const blink::WebTouchEvent*>(event),
ui::LatencyInfo());
return;
}
if (blink::WebInputEvent::isGestureEventType(event->type)) {
host_->ForwardGestureEvent(
*static_cast<const blink::WebGestureEvent*>(event));
return;
}
}
} // namespace content
......@@ -21,9 +21,9 @@
struct ViewHostMsg_TextInputState_Params;
namespace content {
class BrowserPluginGuest;
class RenderWidgetHost;
class RenderWidgetHostImpl;
class BrowserPluginGuest;
struct NativeWebKeyboardEvent;
// See comments in render_widget_host_view.h about this class and its members.
......@@ -46,6 +46,9 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest
RenderWidgetHostViewBase* platform_view);
virtual ~RenderWidgetHostViewGuest();
bool OnMessageReceivedFromEmbedder(const IPC::Message& message,
RenderWidgetHostImpl* embedder);
// RenderWidgetHostView implementation.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
virtual void InitAsChild(gfx::NativeView parent_view) OVERRIDE;
......@@ -163,6 +166,11 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest
RenderWidgetHostViewBase* GetGuestRenderWidgetHostView() const;
void OnHandleInputEvent(RenderWidgetHostImpl* embedder,
int browser_plugin_instance_id,
const gfx::Rect& guest_window_rect,
const blink::WebInputEvent* event);
// BrowserPluginGuest and RenderWidgetHostViewGuest's lifetimes are not tied
// to one another, therefore we access |guest_| through WeakPtr.
base::WeakPtr<BrowserPluginGuest> guest_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment