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_router_client.h" | 27 #include "content/browser/renderer_host/input/input_router_client.h" |
27 #include "content/browser/renderer_host/synthetic_gesture_controller.h" | 28 #include "content/browser/renderer_host/synthetic_gesture_controller.h" |
28 #include "content/common/browser_rendering_stats.h" | 29 #include "content/common/browser_rendering_stats.h" |
29 #include "content/common/view_message_enums.h" | 30 #include "content/common/view_message_enums.h" |
30 #include "content/port/browser/event_with_latency_info.h" | 31 #include "content/port/browser/event_with_latency_info.h" |
31 #include "content/port/common/input_event_ack_state.h" | 32 #include "content/port/common/input_event_ack_state.h" |
32 #include "content/public/browser/render_widget_host.h" | 33 #include "content/public/browser/render_widget_host.h" |
33 #include "content/public/common/page_zoom.h" | 34 #include "content/public/common/page_zoom.h" |
34 #include "ipc/ipc_listener.h" | 35 #include "ipc/ipc_listener.h" |
35 #include "ui/base/ime/text_input_mode.h" | 36 #include "ui/base/ime/text_input_mode.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 class OverscrollController; | 82 class OverscrollController; |
82 class RenderWidgetHostDelegate; | 83 class RenderWidgetHostDelegate; |
83 class RenderWidgetHostViewPort; | 84 class RenderWidgetHostViewPort; |
84 class SyntheticGestureController; | 85 class SyntheticGestureController; |
85 struct EditCommand; | 86 struct EditCommand; |
86 | 87 |
87 // This implements the RenderWidgetHost interface that is exposed to | 88 // This implements the RenderWidgetHost interface that is exposed to |
88 // embedders of content, and adds things only visible to content. | 89 // embedders of content, and adds things only visible to content. |
89 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, | 90 class CONTENT_EXPORT RenderWidgetHostImpl : virtual public RenderWidgetHost, |
90 public InputRouterClient, | 91 public InputRouterClient, |
| 92 public InputAckHandler, |
91 public IPC::Listener { | 93 public IPC::Listener { |
92 public: | 94 public: |
93 // routing_id can be MSG_ROUTING_NONE, in which case the next available | 95 // routing_id can be MSG_ROUTING_NONE, in which case the next available |
94 // routing id is taken from the RenderProcessHost. | 96 // routing id is taken from the RenderProcessHost. |
95 // If this object outlives |delegate|, DetachDelegate() must be called when | 97 // If this object outlives |delegate|, DetachDelegate() must be called when |
96 // |delegate| goes away. | 98 // |delegate| goes away. |
97 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 99 RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
98 RenderProcessHost* process, | 100 RenderProcessHost* process, |
99 int routing_id, | 101 int routing_id, |
100 bool hidden); | 102 bool hidden); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 | 517 |
516 base::TimeDelta GetSyntheticGestureMessageInterval() const; | 518 base::TimeDelta GetSyntheticGestureMessageInterval() const; |
517 | 519 |
518 // Sets whether the overscroll controller should be enabled for this page. | 520 // Sets whether the overscroll controller should be enabled for this page. |
519 void SetOverscrollControllerEnabled(bool enabled); | 521 void SetOverscrollControllerEnabled(bool enabled); |
520 | 522 |
521 // Suppreses future char events until a keydown. See | 523 // Suppreses future char events until a keydown. See |
522 // suppress_next_char_events_. | 524 // suppress_next_char_events_. |
523 void SuppressNextCharEvents(); | 525 void SuppressNextCharEvents(); |
524 | 526 |
| 527 // Called by RenderWidgetHostView in response to OnSetNeedsFlushInput. |
| 528 void FlushInput(); |
| 529 |
525 // Indicates whether the renderer drives the RenderWidgetHosts's size or the | 530 // Indicates whether the renderer drives the RenderWidgetHosts's size or the |
526 // other way around. | 531 // other way around. |
527 bool should_auto_resize() { return should_auto_resize_; } | 532 bool should_auto_resize() { return should_auto_resize_; } |
528 | 533 |
529 void ComputeTouchLatency(const ui::LatencyInfo& latency_info); | 534 void ComputeTouchLatency(const ui::LatencyInfo& latency_info); |
530 void FrameSwapped(const ui::LatencyInfo& latency_info); | 535 void FrameSwapped(const ui::LatencyInfo& latency_info); |
531 void DidReceiveRendererFrame(); | 536 void DidReceiveRendererFrame(); |
532 | 537 |
533 // Returns the ID that uniquely describes this component to the latency | 538 // Returns the ID that uniquely describes this component to the latency |
534 // subsystem. | 539 // subsystem. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 virtual bool OnSendTouchEvent( | 737 virtual bool OnSendTouchEvent( |
733 const TouchEventWithLatencyInfo& touch_event) OVERRIDE; | 738 const TouchEventWithLatencyInfo& touch_event) OVERRIDE; |
734 virtual bool OnSendGestureEvent( | 739 virtual bool OnSendGestureEvent( |
735 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE; | 740 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE; |
736 virtual bool OnSendMouseEventImmediately( | 741 virtual bool OnSendMouseEventImmediately( |
737 const MouseEventWithLatencyInfo& mouse_event) OVERRIDE; | 742 const MouseEventWithLatencyInfo& mouse_event) OVERRIDE; |
738 virtual bool OnSendTouchEventImmediately( | 743 virtual bool OnSendTouchEventImmediately( |
739 const TouchEventWithLatencyInfo& touch_event) OVERRIDE; | 744 const TouchEventWithLatencyInfo& touch_event) OVERRIDE; |
740 virtual bool OnSendGestureEventImmediately( | 745 virtual bool OnSendGestureEventImmediately( |
741 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE; | 746 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE; |
| 747 virtual void SetNeedsFlush() OVERRIDE; |
| 748 virtual void DidFlush() OVERRIDE; |
| 749 |
| 750 // InputAckHandler |
742 virtual void OnKeyboardEventAck(const NativeWebKeyboardEvent& event, | 751 virtual void OnKeyboardEventAck(const NativeWebKeyboardEvent& event, |
743 InputEventAckState ack_result) OVERRIDE; | 752 InputEventAckState ack_result) OVERRIDE; |
744 virtual void OnWheelEventAck(const WebKit::WebMouseWheelEvent& event, | 753 virtual void OnWheelEventAck(const WebKit::WebMouseWheelEvent& event, |
745 InputEventAckState ack_result) OVERRIDE; | 754 InputEventAckState ack_result) OVERRIDE; |
746 virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event, | 755 virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event, |
747 InputEventAckState ack_result) OVERRIDE; | 756 InputEventAckState ack_result) OVERRIDE; |
748 virtual void OnGestureEventAck(const WebKit::WebGestureEvent& event, | 757 virtual void OnGestureEventAck(const WebKit::WebGestureEvent& event, |
749 InputEventAckState ack_result) OVERRIDE; | 758 InputEventAckState ack_result) OVERRIDE; |
750 virtual void OnUnexpectedEventAck(bool bad_message) OVERRIDE; | 759 virtual void OnUnexpectedEventAck(bool bad_message) OVERRIDE; |
751 | 760 |
752 void SimulateTouchGestureWithMouse(const WebKit::WebMouseEvent& mouse_event); | 761 void SimulateTouchGestureWithMouse(const WebKit::WebMouseEvent& mouse_event); |
753 | 762 |
754 // Called when there is a new auto resize (using a post to avoid a stack | 763 // Called when there is a new auto resize (using a post to avoid a stack |
755 // which may get in recursive loops). | 764 // which may get in recursive loops). |
756 void DelayedAutoResized(); | 765 void DelayedAutoResized(); |
757 | 766 |
| 767 // Creates the proper InputRouter, either Buffered or Immediate. |
| 768 scoped_ptr<InputRouter> CreateInputRouter(); |
758 | 769 |
759 // Our delegate, which wants to know mainly about keyboard events. | 770 // Our delegate, which wants to know mainly about keyboard events. |
760 // It will remain non-NULL until DetachDelegate() is called. | 771 // It will remain non-NULL until DetachDelegate() is called. |
761 RenderWidgetHostDelegate* delegate_; | 772 RenderWidgetHostDelegate* delegate_; |
762 | 773 |
763 // Created during construction but initialized during Init*(). Therefore, it | 774 // Created during construction but initialized during Init*(). Therefore, it |
764 // is guaranteed never to be NULL, but its channel may be NULL if the | 775 // is guaranteed never to be NULL, but its channel may be NULL if the |
765 // renderer crashed, so you must always check that. | 776 // renderer crashed, so you must always check that. |
766 RenderProcessHost* process_; | 777 RenderProcessHost* process_; |
767 | 778 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 int64 last_input_number_; | 940 int64 last_input_number_; |
930 | 941 |
931 BrowserRenderingStats rendering_stats_; | 942 BrowserRenderingStats rendering_stats_; |
932 | 943 |
933 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); | 944 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); |
934 }; | 945 }; |
935 | 946 |
936 } // namespace content | 947 } // namespace content |
937 | 948 |
938 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ | 949 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ |
OLD | NEW |