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" | |
29 #include "content/common/input/synthetic_gesture_packet.h" | 30 #include "content/common/input/synthetic_gesture_packet.h" |
30 #include "content/common/view_message_enums.h" | 31 #include "content/common/view_message_enums.h" |
31 #include "content/port/browser/event_with_latency_info.h" | 32 #include "content/port/browser/event_with_latency_info.h" |
32 #include "content/port/common/input_event_ack_state.h" | 33 #include "content/port/common/input_event_ack_state.h" |
33 #include "content/public/browser/render_widget_host.h" | 34 #include "content/public/browser/render_widget_host.h" |
34 #include "content/public/common/page_zoom.h" | 35 #include "content/public/common/page_zoom.h" |
35 #include "ipc/ipc_listener.h" | 36 #include "ipc/ipc_listener.h" |
36 #include "ui/base/ime/text_input_mode.h" | 37 #include "ui/base/ime/text_input_mode.h" |
37 #include "ui/base/ime/text_input_type.h" | 38 #include "ui/base/ime/text_input_type.h" |
38 #include "ui/events/latency_info.h" | 39 #include "ui/events/latency_info.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 | 78 |
78 namespace content { | 79 namespace content { |
79 class BackingStore; | 80 class BackingStore; |
80 class InputRouter; | 81 class InputRouter; |
81 class MockRenderWidgetHost; | 82 class MockRenderWidgetHost; |
82 class OverscrollController; | 83 class OverscrollController; |
83 class RenderWidgetHostDelegate; | 84 class RenderWidgetHostDelegate; |
84 class RenderWidgetHostViewPort; | 85 class RenderWidgetHostViewPort; |
85 class SyntheticGestureController; | 86 class SyntheticGestureController; |
86 class TimeoutMonitor; | 87 class TimeoutMonitor; |
88 class TouchEmulator; | |
87 class WebCursor; | 89 class WebCursor; |
88 struct EditCommand; | 90 struct EditCommand; |
89 | 91 |
90 // This implements the RenderWidgetHost interface that is exposed to | 92 // This implements the RenderWidgetHost interface that is exposed to |
91 // embedders of content, and adds things only visible to content. | 93 // embedders of content, and adds things only visible to content. |
92 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, | 94 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, |
93 public InputRouterClient, | 95 public InputRouterClient, |
94 public InputAckHandler, | 96 public InputAckHandler, |
97 public TouchEmulatorClient, | |
95 public IPC::Listener { | 98 public IPC::Listener { |
96 public: | 99 public: |
97 // routing_id can be MSG_ROUTING_NONE, in which case the next available | 100 // routing_id can be MSG_ROUTING_NONE, in which case the next available |
98 // routing id is taken from the RenderProcessHost. | 101 // routing id is taken from the RenderProcessHost. |
99 // If this object outlives |delegate|, DetachDelegate() must be called when | 102 // If this object outlives |delegate|, DetachDelegate() must be called when |
100 // |delegate| goes away. | 103 // |delegate| goes away. |
101 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 104 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
102 RenderProcessHost* process, | 105 RenderProcessHost* process, |
103 int routing_id, | 106 int routing_id, |
104 bool hidden); | 107 bool hidden); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 // the new one will only fire if it has a shorter delay than the time | 294 // the new one will only fire if it has a shorter delay than the time |
292 // left on the existing timeouts. | 295 // left on the existing timeouts. |
293 void StartHangMonitorTimeout(base::TimeDelta delay); | 296 void StartHangMonitorTimeout(base::TimeDelta delay); |
294 | 297 |
295 // Stops all existing hang monitor timeouts and assumes the renderer is | 298 // Stops all existing hang monitor timeouts and assumes the renderer is |
296 // responsive. | 299 // responsive. |
297 void StopHangMonitorTimeout(); | 300 void StopHangMonitorTimeout(); |
298 | 301 |
299 // Forwards the given message to the renderer. These are called by the view | 302 // Forwards the given message to the renderer. These are called by the view |
300 // when it has received a message. | 303 // when it has received a message. |
301 void ForwardGestureEvent(const blink::WebGestureEvent& gesture_event); | 304 // Some of these methods are TouchEmulatorClient overrides. |
305 virtual void ForwardGestureEvent( | |
jdduke (slow)
2014/04/07 18:12:37
It's OK to re-order the TouchEmulatorClient specif
dgozman
2014/04/08 16:56:49
Done.
| |
306 const blink::WebGestureEvent& gesture_event) OVERRIDE; | |
302 void ForwardGestureEventWithLatencyInfo( | 307 void ForwardGestureEventWithLatencyInfo( |
303 const blink::WebGestureEvent& gesture_event, | 308 const blink::WebGestureEvent& gesture_event, |
304 const ui::LatencyInfo& ui_latency); | 309 const ui::LatencyInfo& ui_latency); |
305 void ForwardTouchEventWithLatencyInfo( | 310 virtual void ForwardTouchEventWithLatencyInfo( |
306 const blink::WebTouchEvent& touch_event, | 311 const blink::WebTouchEvent& touch_event, |
307 const ui::LatencyInfo& ui_latency); | 312 const ui::LatencyInfo& ui_latency) OVERRIDE; |
308 void ForwardMouseEventWithLatencyInfo( | 313 void ForwardMouseEventWithLatencyInfo( |
309 const blink::WebMouseEvent& mouse_event, | 314 const blink::WebMouseEvent& mouse_event, |
310 const ui::LatencyInfo& ui_latency); | 315 const ui::LatencyInfo& ui_latency); |
311 void ForwardWheelEventWithLatencyInfo( | 316 void ForwardWheelEventWithLatencyInfo( |
312 const blink::WebMouseWheelEvent& wheel_event, | 317 const blink::WebMouseWheelEvent& wheel_event, |
313 const ui::LatencyInfo& ui_latency); | 318 const ui::LatencyInfo& ui_latency); |
314 | 319 |
320 // Sets cursor to the view. TouchEmulatorClient override. | |
321 virtual void SetCursor(const WebCursor& cursor) OVERRIDE; | |
322 | |
315 // Queues a synthetic gesture for testing purposes. Invokes the on_complete | 323 // Queues a synthetic gesture for testing purposes. Invokes the on_complete |
316 // callback when the gesture is finished running. | 324 // callback when the gesture is finished running. |
317 void QueueSyntheticGesture( | 325 void QueueSyntheticGesture( |
318 scoped_ptr<SyntheticGesture> synthetic_gesture, | 326 scoped_ptr<SyntheticGesture> synthetic_gesture, |
319 const base::Callback<void(SyntheticGesture::Result)>& on_complete); | 327 const base::Callback<void(SyntheticGesture::Result)>& on_complete); |
320 | 328 |
321 void CancelUpdateTextDirection(); | 329 void CancelUpdateTextDirection(); |
322 | 330 |
323 // Called when a mouse click/gesture tap activates the renderer. | 331 // Called when a mouse click/gesture tap activates the renderer. |
324 virtual void OnPointerEventActivate(); | 332 virtual void OnPointerEventActivate(); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 bool OnSwapCompositorFrame(const IPC::Message& message); | 669 bool OnSwapCompositorFrame(const IPC::Message& message); |
662 void OnOverscrolled(gfx::Vector2dF accumulated_overscroll, | 670 void OnOverscrolled(gfx::Vector2dF accumulated_overscroll, |
663 gfx::Vector2dF current_fling_velocity); | 671 gfx::Vector2dF current_fling_velocity); |
664 void OnFlingingStopped(); | 672 void OnFlingingStopped(); |
665 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 673 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
666 void OnUpdateIsDelayed(); | 674 void OnUpdateIsDelayed(); |
667 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); | 675 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); |
668 virtual void OnFocus(); | 676 virtual void OnFocus(); |
669 virtual void OnBlur(); | 677 virtual void OnBlur(); |
670 void OnSetCursor(const WebCursor& cursor); | 678 void OnSetCursor(const WebCursor& cursor); |
679 void OnSetTouchEventEmulationEnabled(bool enabled); | |
671 void OnTextInputTypeChanged(ui::TextInputType type, | 680 void OnTextInputTypeChanged(ui::TextInputType type, |
672 ui::TextInputMode input_mode, | 681 ui::TextInputMode input_mode, |
673 bool can_compose_inline); | 682 bool can_compose_inline); |
674 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | 683 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) |
675 void OnImeCompositionRangeChanged( | 684 void OnImeCompositionRangeChanged( |
676 const gfx::Range& range, | 685 const gfx::Range& range, |
677 const std::vector<gfx::Rect>& character_bounds); | 686 const std::vector<gfx::Rect>& character_bounds); |
678 #endif | 687 #endif |
679 void OnImeCancelComposition(); | 688 void OnImeCancelComposition(); |
680 void OnDidActivateAcceleratedCompositing(bool activated); | 689 void OnDidActivateAcceleratedCompositing(bool activated); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 | 918 |
910 // Keeps track of whether the webpage has any touch event handler. If it does, | 919 // Keeps track of whether the webpage has any touch event handler. If it does, |
911 // then touch events are sent to the renderer. Otherwise, the touch events are | 920 // then touch events are sent to the renderer. Otherwise, the touch events are |
912 // not sent to the renderer. | 921 // not sent to the renderer. |
913 bool has_touch_handler_; | 922 bool has_touch_handler_; |
914 | 923 |
915 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 924 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
916 | 925 |
917 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; | 926 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; |
918 | 927 |
928 scoped_ptr<TouchEmulator> touch_emulator_; | |
929 | |
919 // Receives and handles all input events. | 930 // Receives and handles all input events. |
920 scoped_ptr<InputRouter> input_router_; | 931 scoped_ptr<InputRouter> input_router_; |
921 | 932 |
922 scoped_ptr<OverscrollController> overscroll_controller_; | 933 scoped_ptr<OverscrollController> overscroll_controller_; |
923 | 934 |
924 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; | 935 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; |
925 | 936 |
926 #if defined(OS_WIN) | 937 #if defined(OS_WIN) |
927 std::list<HWND> dummy_windows_for_activation_; | 938 std::list<HWND> dummy_windows_for_activation_; |
928 #endif | 939 #endif |
929 | 940 |
930 // List of callbacks for pending snapshot requests to the renderer. | 941 // List of callbacks for pending snapshot requests to the renderer. |
931 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; | 942 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; |
932 | 943 |
933 int64 last_input_number_; | 944 int64 last_input_number_; |
934 | 945 |
935 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 946 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
936 }; | 947 }; |
937 | 948 |
938 } // namespace content | 949 } // namespace content |
939 | 950 |
940 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 951 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
OLD | NEW |