OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <queue> | 11 #include <queue> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback.h" | 16 #include "base/callback.h" |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
21 #include "base/process/kill.h" | 21 #include "base/process/kill.h" |
22 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "base/timer/timer.h" | 24 #include "base/timer/timer.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "content/browser/renderer_host/input/input_ack_handler.h" | 26 #include "content/browser/renderer_host/input/input_ack_handler.h" |
27 #include "content/browser/renderer_host/input/input_router_client.h" | 27 #include "content/browser/renderer_host/input/input_router_client.h" |
28 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 28 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
29 #include "content/browser/renderer_host/input/touch_emulator_client.h" | |
30 #include "content/common/input/synthetic_gesture_packet.h" | 29 #include "content/common/input/synthetic_gesture_packet.h" |
31 #include "content/common/view_message_enums.h" | 30 #include "content/common/view_message_enums.h" |
32 #include "content/port/browser/event_with_latency_info.h" | 31 #include "content/port/browser/event_with_latency_info.h" |
33 #include "content/port/common/input_event_ack_state.h" | 32 #include "content/port/common/input_event_ack_state.h" |
34 #include "content/public/browser/render_widget_host.h" | 33 #include "content/public/browser/render_widget_host.h" |
35 #include "content/public/common/page_zoom.h" | 34 #include "content/public/common/page_zoom.h" |
36 #include "ipc/ipc_listener.h" | 35 #include "ipc/ipc_listener.h" |
37 #include "ui/base/ime/text_input_mode.h" | 36 #include "ui/base/ime/text_input_mode.h" |
38 #include "ui/base/ime/text_input_type.h" | 37 #include "ui/base/ime/text_input_type.h" |
39 #include "ui/events/latency_info.h" | 38 #include "ui/events/latency_info.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 77 |
79 namespace content { | 78 namespace content { |
80 class BackingStore; | 79 class BackingStore; |
81 class InputRouter; | 80 class InputRouter; |
82 class MockRenderWidgetHost; | 81 class MockRenderWidgetHost; |
83 class OverscrollController; | 82 class OverscrollController; |
84 class RenderWidgetHostDelegate; | 83 class RenderWidgetHostDelegate; |
85 class RenderWidgetHostViewPort; | 84 class RenderWidgetHostViewPort; |
86 class SyntheticGestureController; | 85 class SyntheticGestureController; |
87 class TimeoutMonitor; | 86 class TimeoutMonitor; |
88 class TouchEmulator; | |
89 class WebCursor; | 87 class WebCursor; |
90 struct EditCommand; | 88 struct EditCommand; |
91 | 89 |
92 // This implements the RenderWidgetHost interface that is exposed to | 90 // This implements the RenderWidgetHost interface that is exposed to |
93 // embedders of content, and adds things only visible to content. | 91 // embedders of content, and adds things only visible to content. |
94 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, | 92 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, |
95 public InputRouterClient, | 93 public InputRouterClient, |
96 public InputAckHandler, | 94 public InputAckHandler, |
97 public TouchEmulatorClient, | |
98 public IPC::Listener { | 95 public IPC::Listener { |
99 public: | 96 public: |
100 // routing_id can be MSG_ROUTING_NONE, in which case the next available | 97 // routing_id can be MSG_ROUTING_NONE, in which case the next available |
101 // routing id is taken from the RenderProcessHost. | 98 // routing id is taken from the RenderProcessHost. |
102 // If this object outlives |delegate|, DetachDelegate() must be called when | 99 // If this object outlives |delegate|, DetachDelegate() must be called when |
103 // |delegate| goes away. | 100 // |delegate| goes away. |
104 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 101 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
105 RenderProcessHost* process, | 102 RenderProcessHost* process, |
106 int routing_id, | 103 int routing_id, |
107 bool hidden); | 104 bool hidden); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // the new one will only fire if it has a shorter delay than the time | 291 // the new one will only fire if it has a shorter delay than the time |
295 // left on the existing timeouts. | 292 // left on the existing timeouts. |
296 void StartHangMonitorTimeout(base::TimeDelta delay); | 293 void StartHangMonitorTimeout(base::TimeDelta delay); |
297 | 294 |
298 // Stops all existing hang monitor timeouts and assumes the renderer is | 295 // Stops all existing hang monitor timeouts and assumes the renderer is |
299 // responsive. | 296 // responsive. |
300 void StopHangMonitorTimeout(); | 297 void StopHangMonitorTimeout(); |
301 | 298 |
302 // Forwards the given message to the renderer. These are called by the view | 299 // Forwards the given message to the renderer. These are called by the view |
303 // when it has received a message. | 300 // when it has received a message. |
| 301 void ForwardGestureEvent(const blink::WebGestureEvent& gesture_event); |
304 void ForwardGestureEventWithLatencyInfo( | 302 void ForwardGestureEventWithLatencyInfo( |
305 const blink::WebGestureEvent& gesture_event, | 303 const blink::WebGestureEvent& gesture_event, |
306 const ui::LatencyInfo& ui_latency); | 304 const ui::LatencyInfo& ui_latency); |
307 void ForwardTouchEventWithLatencyInfo( | 305 void ForwardTouchEventWithLatencyInfo( |
308 const blink::WebTouchEvent& touch_event, | 306 const blink::WebTouchEvent& touch_event, |
309 const ui::LatencyInfo& ui_latency); | 307 const ui::LatencyInfo& ui_latency); |
310 void ForwardMouseEventWithLatencyInfo( | 308 void ForwardMouseEventWithLatencyInfo( |
311 const blink::WebMouseEvent& mouse_event, | 309 const blink::WebMouseEvent& mouse_event, |
312 const ui::LatencyInfo& ui_latency); | 310 const ui::LatencyInfo& ui_latency); |
313 void ForwardWheelEventWithLatencyInfo( | 311 void ForwardWheelEventWithLatencyInfo( |
314 const blink::WebMouseWheelEvent& wheel_event, | 312 const blink::WebMouseWheelEvent& wheel_event, |
315 const ui::LatencyInfo& ui_latency); | 313 const ui::LatencyInfo& ui_latency); |
316 | 314 |
317 // TouchEmulatorClient overrides. | |
318 virtual void ForwardGestureEvent( | |
319 const blink::WebGestureEvent& gesture_event) OVERRIDE; | |
320 virtual void ForwardTouchEvent( | |
321 const blink::WebTouchEvent& touch_event) OVERRIDE; | |
322 virtual void SetCursor(const WebCursor& cursor) OVERRIDE; | |
323 | |
324 // Queues a synthetic gesture for testing purposes. Invokes the on_complete | 315 // Queues a synthetic gesture for testing purposes. Invokes the on_complete |
325 // callback when the gesture is finished running. | 316 // callback when the gesture is finished running. |
326 void QueueSyntheticGesture( | 317 void QueueSyntheticGesture( |
327 scoped_ptr<SyntheticGesture> synthetic_gesture, | 318 scoped_ptr<SyntheticGesture> synthetic_gesture, |
328 const base::Callback<void(SyntheticGesture::Result)>& on_complete); | 319 const base::Callback<void(SyntheticGesture::Result)>& on_complete); |
329 | 320 |
330 void CancelUpdateTextDirection(); | 321 void CancelUpdateTextDirection(); |
331 | 322 |
332 // Called when a mouse click/gesture tap activates the renderer. | 323 // Called when a mouse click/gesture tap activates the renderer. |
333 virtual void OnPointerEventActivate(); | 324 virtual void OnPointerEventActivate(); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 bool OnSwapCompositorFrame(const IPC::Message& message); | 651 bool OnSwapCompositorFrame(const IPC::Message& message); |
661 void OnOverscrolled(gfx::Vector2dF accumulated_overscroll, | 652 void OnOverscrolled(gfx::Vector2dF accumulated_overscroll, |
662 gfx::Vector2dF current_fling_velocity); | 653 gfx::Vector2dF current_fling_velocity); |
663 void OnFlingingStopped(); | 654 void OnFlingingStopped(); |
664 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 655 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
665 void OnUpdateIsDelayed(); | 656 void OnUpdateIsDelayed(); |
666 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); | 657 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); |
667 virtual void OnFocus(); | 658 virtual void OnFocus(); |
668 virtual void OnBlur(); | 659 virtual void OnBlur(); |
669 void OnSetCursor(const WebCursor& cursor); | 660 void OnSetCursor(const WebCursor& cursor); |
670 void OnSetTouchEventEmulationEnabled(bool enabled, bool allow_pinch); | |
671 void OnTextInputTypeChanged(ui::TextInputType type, | 661 void OnTextInputTypeChanged(ui::TextInputType type, |
672 ui::TextInputMode input_mode, | 662 ui::TextInputMode input_mode, |
673 bool can_compose_inline); | 663 bool can_compose_inline); |
674 #if defined(OS_MACOSX) || defined(USE_AURA) | 664 #if defined(OS_MACOSX) || defined(USE_AURA) |
675 void OnImeCompositionRangeChanged( | 665 void OnImeCompositionRangeChanged( |
676 const gfx::Range& range, | 666 const gfx::Range& range, |
677 const std::vector<gfx::Rect>& character_bounds); | 667 const std::vector<gfx::Rect>& character_bounds); |
678 #endif | 668 #endif |
679 void OnImeCancelComposition(); | 669 void OnImeCancelComposition(); |
680 void OnDidActivateAcceleratedCompositing(bool activated); | 670 void OnDidActivateAcceleratedCompositing(bool activated); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 | 896 |
907 // Keeps track of whether the webpage has any touch event handler. If it does, | 897 // Keeps track of whether the webpage has any touch event handler. If it does, |
908 // then touch events are sent to the renderer. Otherwise, the touch events are | 898 // then touch events are sent to the renderer. Otherwise, the touch events are |
909 // not sent to the renderer. | 899 // not sent to the renderer. |
910 bool has_touch_handler_; | 900 bool has_touch_handler_; |
911 | 901 |
912 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 902 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
913 | 903 |
914 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; | 904 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; |
915 | 905 |
916 scoped_ptr<TouchEmulator> touch_emulator_; | |
917 | |
918 // Receives and handles all input events. | 906 // Receives and handles all input events. |
919 scoped_ptr<InputRouter> input_router_; | 907 scoped_ptr<InputRouter> input_router_; |
920 | 908 |
921 scoped_ptr<OverscrollController> overscroll_controller_; | 909 scoped_ptr<OverscrollController> overscroll_controller_; |
922 | 910 |
923 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; | 911 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; |
924 | 912 |
925 #if defined(OS_WIN) | 913 #if defined(OS_WIN) |
926 std::list<HWND> dummy_windows_for_activation_; | 914 std::list<HWND> dummy_windows_for_activation_; |
927 #endif | 915 #endif |
928 | 916 |
929 // List of callbacks for pending snapshot requests to the renderer. | 917 // List of callbacks for pending snapshot requests to the renderer. |
930 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; | 918 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; |
931 | 919 |
932 int64 last_input_number_; | 920 int64 last_input_number_; |
933 | 921 |
934 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 922 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
935 }; | 923 }; |
936 | 924 |
937 } // namespace content | 925 } // namespace content |
938 | 926 |
939 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 927 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
OLD | NEW |