| 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 189 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 | 297 // the new one will only fire if it has a shorter delay than the time |
| 295 // left on the existing timeouts. | 298 // left on the existing timeouts. |
| 296 void StartHangMonitorTimeout(base::TimeDelta delay); | 299 void StartHangMonitorTimeout(base::TimeDelta delay); |
| 297 | 300 |
| 298 // Stops all existing hang monitor timeouts and assumes the renderer is | 301 // Stops all existing hang monitor timeouts and assumes the renderer is |
| 299 // responsive. | 302 // responsive. |
| 300 void StopHangMonitorTimeout(); | 303 void StopHangMonitorTimeout(); |
| 301 | 304 |
| 302 // Forwards the given message to the renderer. These are called by the view | 305 // Forwards the given message to the renderer. These are called by the view |
| 303 // when it has received a message. | 306 // when it has received a message. |
| 304 void ForwardGestureEvent(const blink::WebGestureEvent& gesture_event); | |
| 305 void ForwardGestureEventWithLatencyInfo( | 307 void ForwardGestureEventWithLatencyInfo( |
| 306 const blink::WebGestureEvent& gesture_event, | 308 const blink::WebGestureEvent& gesture_event, |
| 307 const ui::LatencyInfo& ui_latency); | 309 const ui::LatencyInfo& ui_latency); |
| 308 void ForwardTouchEventWithLatencyInfo( | 310 void ForwardTouchEventWithLatencyInfo( |
| 309 const blink::WebTouchEvent& touch_event, | 311 const blink::WebTouchEvent& touch_event, |
| 310 const ui::LatencyInfo& ui_latency); | 312 const ui::LatencyInfo& ui_latency); |
| 311 void ForwardMouseEventWithLatencyInfo( | 313 void ForwardMouseEventWithLatencyInfo( |
| 312 const blink::WebMouseEvent& mouse_event, | 314 const blink::WebMouseEvent& mouse_event, |
| 313 const ui::LatencyInfo& ui_latency); | 315 const ui::LatencyInfo& ui_latency); |
| 314 void ForwardWheelEventWithLatencyInfo( | 316 void ForwardWheelEventWithLatencyInfo( |
| 315 const blink::WebMouseWheelEvent& wheel_event, | 317 const blink::WebMouseWheelEvent& wheel_event, |
| 316 const ui::LatencyInfo& ui_latency); | 318 const ui::LatencyInfo& ui_latency); |
| 317 | 319 |
| 320 // TouchEmulatorClient overrides. |
| 321 virtual void ForwardGestureEvent( |
| 322 const blink::WebGestureEvent& gesture_event) OVERRIDE; |
| 323 virtual void ForwardTouchEvent( |
| 324 const blink::WebTouchEvent& touch_event) OVERRIDE; |
| 325 virtual void SetCursor(const WebCursor& cursor) OVERRIDE; |
| 326 |
| 318 // Queues a synthetic gesture for testing purposes. Invokes the on_complete | 327 // Queues a synthetic gesture for testing purposes. Invokes the on_complete |
| 319 // callback when the gesture is finished running. | 328 // callback when the gesture is finished running. |
| 320 void QueueSyntheticGesture( | 329 void QueueSyntheticGesture( |
| 321 scoped_ptr<SyntheticGesture> synthetic_gesture, | 330 scoped_ptr<SyntheticGesture> synthetic_gesture, |
| 322 const base::Callback<void(SyntheticGesture::Result)>& on_complete); | 331 const base::Callback<void(SyntheticGesture::Result)>& on_complete); |
| 323 | 332 |
| 324 void CancelUpdateTextDirection(); | 333 void CancelUpdateTextDirection(); |
| 325 | 334 |
| 326 // Called when a mouse click/gesture tap activates the renderer. | 335 // Called when a mouse click/gesture tap activates the renderer. |
| 327 virtual void OnPointerEventActivate(); | 336 virtual void OnPointerEventActivate(); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 bool OnSwapCompositorFrame(const IPC::Message& message); | 673 bool OnSwapCompositorFrame(const IPC::Message& message); |
| 665 void OnOverscrolled(gfx::Vector2dF accumulated_overscroll, | 674 void OnOverscrolled(gfx::Vector2dF accumulated_overscroll, |
| 666 gfx::Vector2dF current_fling_velocity); | 675 gfx::Vector2dF current_fling_velocity); |
| 667 void OnFlingingStopped(); | 676 void OnFlingingStopped(); |
| 668 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 677 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
| 669 void OnUpdateIsDelayed(); | 678 void OnUpdateIsDelayed(); |
| 670 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); | 679 void OnQueueSyntheticGesture(const SyntheticGesturePacket& gesture_packet); |
| 671 virtual void OnFocus(); | 680 virtual void OnFocus(); |
| 672 virtual void OnBlur(); | 681 virtual void OnBlur(); |
| 673 void OnSetCursor(const WebCursor& cursor); | 682 void OnSetCursor(const WebCursor& cursor); |
| 683 void OnSetTouchEventEmulationEnabled(bool enabled, bool allow_pinch); |
| 674 void OnTextInputTypeChanged(ui::TextInputType type, | 684 void OnTextInputTypeChanged(ui::TextInputType type, |
| 675 ui::TextInputMode input_mode, | 685 ui::TextInputMode input_mode, |
| 676 bool can_compose_inline); | 686 bool can_compose_inline); |
| 677 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | 687 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) |
| 678 void OnImeCompositionRangeChanged( | 688 void OnImeCompositionRangeChanged( |
| 679 const gfx::Range& range, | 689 const gfx::Range& range, |
| 680 const std::vector<gfx::Rect>& character_bounds); | 690 const std::vector<gfx::Rect>& character_bounds); |
| 681 #endif | 691 #endif |
| 682 void OnImeCancelComposition(); | 692 void OnImeCancelComposition(); |
| 683 void OnDidActivateAcceleratedCompositing(bool activated); | 693 void OnDidActivateAcceleratedCompositing(bool activated); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 | 922 |
| 913 // Keeps track of whether the webpage has any touch event handler. If it does, | 923 // Keeps track of whether the webpage has any touch event handler. If it does, |
| 914 // then touch events are sent to the renderer. Otherwise, the touch events are | 924 // then touch events are sent to the renderer. Otherwise, the touch events are |
| 915 // not sent to the renderer. | 925 // not sent to the renderer. |
| 916 bool has_touch_handler_; | 926 bool has_touch_handler_; |
| 917 | 927 |
| 918 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; | 928 base::WeakPtrFactory<RenderWidgetHostImpl> weak_factory_; |
| 919 | 929 |
| 920 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; | 930 scoped_ptr<SyntheticGestureController> synthetic_gesture_controller_; |
| 921 | 931 |
| 932 scoped_ptr<TouchEmulator> touch_emulator_; |
| 933 |
| 922 // Receives and handles all input events. | 934 // Receives and handles all input events. |
| 923 scoped_ptr<InputRouter> input_router_; | 935 scoped_ptr<InputRouter> input_router_; |
| 924 | 936 |
| 925 scoped_ptr<OverscrollController> overscroll_controller_; | 937 scoped_ptr<OverscrollController> overscroll_controller_; |
| 926 | 938 |
| 927 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; | 939 scoped_ptr<TimeoutMonitor> hang_monitor_timeout_; |
| 928 | 940 |
| 929 #if defined(OS_WIN) | 941 #if defined(OS_WIN) |
| 930 std::list<HWND> dummy_windows_for_activation_; | 942 std::list<HWND> dummy_windows_for_activation_; |
| 931 #endif | 943 #endif |
| 932 | 944 |
| 933 // List of callbacks for pending snapshot requests to the renderer. | 945 // List of callbacks for pending snapshot requests to the renderer. |
| 934 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; | 946 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; |
| 935 | 947 |
| 936 int64 last_input_number_; | 948 int64 last_input_number_; |
| 937 | 949 |
| 938 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 950 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
| 939 }; | 951 }; |
| 940 | 952 |
| 941 } // namespace content | 953 } // namespace content |
| 942 | 954 |
| 943 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 955 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
| OLD | NEW |