OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind_helpers.h" | 5 #include "base/bind_helpers.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
10 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 10 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 gesture_recognizer_->AddGestureEventHelper(this); | 56 gesture_recognizer_->AddGestureEventHelper(this); |
57 #endif // defined(USE_AURA) | 57 #endif // defined(USE_AURA) |
58 } | 58 } |
59 | 59 |
60 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() { | 60 RenderWidgetHostViewGuest::~RenderWidgetHostViewGuest() { |
61 #if defined(USE_AURA) | 61 #if defined(USE_AURA) |
62 gesture_recognizer_->RemoveGestureEventHelper(this); | 62 gesture_recognizer_->RemoveGestureEventHelper(this); |
63 #endif // defined(USE_AURA) | 63 #endif // defined(USE_AURA) |
64 } | 64 } |
65 | 65 |
| 66 bool RenderWidgetHostViewGuest::OnMessageReceivedFromEmbedder( |
| 67 const IPC::Message& message, |
| 68 WebContents* embedder_web_contents) { |
| 69 bool handled = true; |
| 70 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(RenderWidgetHostViewGuest, message, |
| 71 embedder_web_contents) |
| 72 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_HandleInputEvent, |
| 73 OnHandleInputEvent) |
| 74 IPC_MESSAGE_UNHANDLED(handled = false) |
| 75 IPC_END_MESSAGE_MAP() |
| 76 return handled; |
| 77 } |
| 78 |
66 void RenderWidgetHostViewGuest::WasShown() { | 79 void RenderWidgetHostViewGuest::WasShown() { |
67 // If the WebContents associated with us showed an interstitial page in the | 80 // If the WebContents associated with us showed an interstitial page in the |
68 // beginning, the teardown path might call WasShown() while |host_| is in | 81 // beginning, the teardown path might call WasShown() while |host_| is in |
69 // the process of destruction. Avoid calling WasShown below in this case. | 82 // the process of destruction. Avoid calling WasShown below in this case. |
70 // TODO(lazyboy): We shouldn't be showing interstitial pages in guests in the | 83 // TODO(lazyboy): We shouldn't be showing interstitial pages in guests in the |
71 // first place: http://crbug.com/273089. | 84 // first place: http://crbug.com/273089. |
72 // | 85 // |
73 // |guest_| is NULL during test. | 86 // |guest_| is NULL during test. |
74 if ((guest_ && guest_->is_in_destruction()) || !host_->is_hidden()) | 87 if ((guest_ && guest_->is_in_destruction()) || !host_->is_hidden()) |
75 return; | 88 return; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 SkColorType RenderWidgetHostViewGuest::PreferredReadbackFormat() { | 536 SkColorType RenderWidgetHostViewGuest::PreferredReadbackFormat() { |
524 return kN32_SkColorType; | 537 return kN32_SkColorType; |
525 } | 538 } |
526 | 539 |
527 RenderWidgetHostViewBase* | 540 RenderWidgetHostViewBase* |
528 RenderWidgetHostViewGuest::GetGuestRenderWidgetHostView() const { | 541 RenderWidgetHostViewGuest::GetGuestRenderWidgetHostView() const { |
529 return static_cast<RenderWidgetHostViewBase*>( | 542 return static_cast<RenderWidgetHostViewBase*>( |
530 guest_->GetEmbedderRenderWidgetHostView()); | 543 guest_->GetEmbedderRenderWidgetHostView()); |
531 } | 544 } |
532 | 545 |
| 546 void RenderWidgetHostViewGuest::OnHandleInputEvent( |
| 547 WebContents* embedder_web_contents, |
| 548 int browser_plugin_instance_id, |
| 549 const gfx::Rect& guest_window_rect, |
| 550 const blink::WebInputEvent* event) { |
| 551 if (blink::WebInputEvent::isMouseEventType(event->type)) { |
| 552 host_->ForwardMouseEvent( |
| 553 *static_cast<const blink::WebMouseEvent*>(event)); |
| 554 return; |
| 555 } |
| 556 |
| 557 if (event->type == blink::WebInputEvent::MouseWheel) { |
| 558 host_->ForwardWheelEvent( |
| 559 *static_cast<const blink::WebMouseWheelEvent*>(event)); |
| 560 return; |
| 561 } |
| 562 |
| 563 if (blink::WebInputEvent::isKeyboardEventType(event->type)) { |
| 564 RenderViewHostImpl* embedder_rvh = static_cast<RenderViewHostImpl*>( |
| 565 embedder_web_contents->GetRenderViewHost()); |
| 566 if (!embedder_rvh->GetLastKeyboardEvent()) |
| 567 return; |
| 568 NativeWebKeyboardEvent keyboard_event( |
| 569 *embedder_rvh->GetLastKeyboardEvent()); |
| 570 host_->ForwardKeyboardEvent(keyboard_event); |
| 571 return; |
| 572 } |
| 573 |
| 574 if (blink::WebInputEvent::isTouchEventType(event->type)) { |
| 575 host_->ForwardTouchEventWithLatencyInfo( |
| 576 *static_cast<const blink::WebTouchEvent*>(event), |
| 577 ui::LatencyInfo()); |
| 578 return; |
| 579 } |
| 580 |
| 581 if (blink::WebInputEvent::isGestureEventType(event->type)) { |
| 582 host_->ForwardGestureEvent( |
| 583 *static_cast<const blink::WebGestureEvent*>(event)); |
| 584 return; |
| 585 } |
| 586 } |
| 587 |
533 } // namespace content | 588 } // namespace content |
OLD | NEW |