| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_INPUT_IMMEDIATE_INPUT_ROUTER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_IMMEDIATE_INPUT_ROUTER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_IMMEDIATE_INPUT_ROUTER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_IMMEDIATE_INPUT_ROUTER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "content/browser/renderer_host/input/gesture_event_filter.h" | 13 #include "content/browser/renderer_host/input/fling/flinger.h" |
| 14 #include "content/browser/renderer_host/input/gesture_event_filter_client.h" |
| 14 #include "content/browser/renderer_host/input/input_router.h" | 15 #include "content/browser/renderer_host/input/input_router.h" |
| 15 #include "content/browser/renderer_host/input/touch_event_queue.h" | 16 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 16 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" | |
| 17 #include "content/public/browser/native_web_keyboard_event.h" | 17 #include "content/public/browser/native_web_keyboard_event.h" |
| 18 | 18 |
| 19 namespace IPC { | 19 namespace IPC { |
| 20 class Sender; | 20 class Sender; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 struct LatencyInfo; | 24 struct LatencyInfo; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 class BaseGestureEventFilter; |
| 29 class InputAckHandler; | 29 class InputAckHandler; |
| 30 class InputRouterClient; | 30 class InputRouterClient; |
| 31 class OverscrollController; | 31 class OverscrollController; |
| 32 class RenderWidgetHostImpl; | 32 class RenderWidgetHostImpl; |
| 33 | 33 |
| 34 // A default implementation for browser input event routing. Input commands are | 34 // A default implementation for browser input event routing. Input commands are |
| 35 // forwarded to the renderer immediately upon receipt. | 35 // forwarded to the renderer immediately upon receipt. |
| 36 class CONTENT_EXPORT ImmediateInputRouter | 36 class CONTENT_EXPORT ImmediateInputRouter |
| 37 : public NON_EXPORTED_BASE(InputRouter), | 37 : public NON_EXPORTED_BASE(InputRouter), |
| 38 public NON_EXPORTED_BASE(GestureEventFilterClient), | 38 public NON_EXPORTED_BASE(GestureEventFilterClient), |
| 39 public NON_EXPORTED_BASE(TouchEventQueueClient), | 39 public NON_EXPORTED_BASE(TouchEventQueueClient), |
| 40 public NON_EXPORTED_BASE(TouchpadTapSuppressionControllerClient) { | 40 public NON_EXPORTED_BASE(FlingHelper) { |
| 41 public: | 41 public: |
| 42 ImmediateInputRouter(IPC::Sender* sender, | 42 ImmediateInputRouter(IPC::Sender* sender, |
| 43 InputRouterClient* client, | 43 InputRouterClient* client, |
| 44 InputAckHandler* ack_handler, | 44 InputAckHandler* ack_handler, |
| 45 int routing_id); | 45 int routing_id); |
| 46 virtual ~ImmediateInputRouter(); | 46 virtual ~ImmediateInputRouter(); |
| 47 | 47 |
| 48 // InputRouter | 48 // InputRouter |
| 49 virtual void Flush() OVERRIDE; | 49 virtual void Flush() OVERRIDE; |
| 50 virtual bool SendInput(scoped_ptr<IPC::Message> message) OVERRIDE; | 50 virtual bool SendInput(scoped_ptr<IPC::Message> message) OVERRIDE; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 virtual const NativeWebKeyboardEvent* GetLastKeyboardEvent() const OVERRIDE; | 63 virtual const NativeWebKeyboardEvent* GetLastKeyboardEvent() const OVERRIDE; |
| 64 virtual bool ShouldForwardTouchEvent() const OVERRIDE; | 64 virtual bool ShouldForwardTouchEvent() const OVERRIDE; |
| 65 | 65 |
| 66 // IPC::Listener | 66 // IPC::Listener |
| 67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 friend class ImmediateInputRouterTest; | 70 friend class ImmediateInputRouterTest; |
| 71 friend class MockRenderWidgetHost; | 71 friend class MockRenderWidgetHost; |
| 72 | 72 |
| 73 // TouchpadTapSuppressionControllerClient | |
| 74 virtual void SendMouseEventImmediately( | 73 virtual void SendMouseEventImmediately( |
| 75 const MouseEventWithLatencyInfo& mouse_event) OVERRIDE; | 74 const MouseEventWithLatencyInfo& mouse_event) OVERRIDE; |
| 76 | 75 |
| 77 // TouchEventQueueClient | 76 // TouchEventQueueClient |
| 78 virtual void SendTouchEventImmediately( | 77 virtual void SendTouchEventImmediately( |
| 79 const TouchEventWithLatencyInfo& touch_event) OVERRIDE; | 78 const TouchEventWithLatencyInfo& touch_event) OVERRIDE; |
| 80 virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event, | 79 virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event, |
| 81 InputEventAckState ack_result) OVERRIDE; | 80 InputEventAckState ack_result) OVERRIDE; |
| 82 | 81 |
| 83 // GetureEventFilterClient | 82 // GetureEventFilterClient |
| 84 virtual void SendGestureEventImmediately( | 83 virtual void SendGestureEventImmediately( |
| 85 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE; | 84 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE; |
| 86 virtual void OnGestureEventAck(const GestureEventWithLatencyInfo& event, | 85 virtual void OnGestureEventAck(const GestureEventWithLatencyInfo& event, |
| 87 InputEventAckState ack_result) OVERRIDE; | 86 InputEventAckState ack_result) OVERRIDE; |
| 88 | 87 |
| 88 // FlingHelper |
| 89 virtual void SendEventForFling(const WebKit::WebInputEvent& event) OVERRIDE; |
| 90 virtual void FlingFinished( |
| 91 WebKit::WebGestureEvent::SourceDevice source) OVERRIDE; |
| 92 |
| 89 bool SendMoveCaret(scoped_ptr<IPC::Message> message); | 93 bool SendMoveCaret(scoped_ptr<IPC::Message> message); |
| 90 bool SendSelectRange(scoped_ptr<IPC::Message> message); | 94 bool SendSelectRange(scoped_ptr<IPC::Message> message); |
| 91 bool Send(IPC::Message* message); | 95 bool Send(IPC::Message* message); |
| 92 | 96 |
| 93 // Transmits the given input event an as an IPC::Message. This is an internal | 97 // Transmits the given input event an as an IPC::Message. This is an internal |
| 94 // helper for |FilterAndSendInputEvent()| and should not be used otherwise. | 98 // helper for |FilterAndSendInputEvent()| and should not be used otherwise. |
| 95 void SendWebInputEvent(const WebKit::WebInputEvent& input_event, | 99 void SendWebInputEvent(const WebKit::WebInputEvent& input_event, |
| 96 const ui::LatencyInfo& latency_info, | 100 const ui::LatencyInfo& latency_info, |
| 97 bool is_keyboard_shortcut); | 101 bool is_keyboard_shortcut); |
| 98 | 102 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 167 |
| 164 void HandleGestureScroll(const GestureEventWithLatencyInfo& gesture_event); | 168 void HandleGestureScroll(const GestureEventWithLatencyInfo& gesture_event); |
| 165 | 169 |
| 166 void SimulateTouchGestureWithMouse( | 170 void SimulateTouchGestureWithMouse( |
| 167 const MouseEventWithLatencyInfo& mouse_event); | 171 const MouseEventWithLatencyInfo& mouse_event); |
| 168 | 172 |
| 169 bool IsInOverscrollGesture() const; | 173 bool IsInOverscrollGesture() const; |
| 170 | 174 |
| 171 int routing_id() const { return routing_id_; } | 175 int routing_id() const { return routing_id_; } |
| 172 | 176 |
| 173 | |
| 174 IPC::Sender* sender_; | 177 IPC::Sender* sender_; |
| 175 InputRouterClient* client_; | 178 InputRouterClient* client_; |
| 176 InputAckHandler* ack_handler_; | 179 InputAckHandler* ack_handler_; |
| 177 int routing_id_; | 180 int routing_id_; |
| 178 | 181 |
| 179 // (Similar to |mouse_move_pending_|.) True while waiting for SelectRange_ACK. | 182 // (Similar to |mouse_move_pending_|.) True while waiting for SelectRange_ACK. |
| 180 bool select_range_pending_; | 183 bool select_range_pending_; |
| 181 | 184 |
| 182 // (Similar to |next_mouse_move_|.) The next SelectRange to send, if any. | 185 // (Similar to |next_mouse_move_|.) The next SelectRange to send, if any. |
| 183 scoped_ptr<IPC::Message> next_selection_range_; | 186 scoped_ptr<IPC::Message> next_selection_range_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // Keeps track of whether the webpage has any touch event handler. If it does, | 229 // Keeps track of whether the webpage has any touch event handler. If it does, |
| 227 // then touch events are sent to the renderer. Otherwise, the touch events are | 230 // then touch events are sent to the renderer. Otherwise, the touch events are |
| 228 // not sent to the renderer. | 231 // not sent to the renderer. |
| 229 bool has_touch_handler_; | 232 bool has_touch_handler_; |
| 230 | 233 |
| 231 // The source of the ack within the scope of |ProcessInputEventAck()|. | 234 // The source of the ack within the scope of |ProcessInputEventAck()|. |
| 232 // Defaults to ACK_SOURCE_NONE. | 235 // Defaults to ACK_SOURCE_NONE. |
| 233 AckSource current_ack_source_; | 236 AckSource current_ack_source_; |
| 234 | 237 |
| 235 scoped_ptr<TouchEventQueue> touch_event_queue_; | 238 scoped_ptr<TouchEventQueue> touch_event_queue_; |
| 236 scoped_ptr<GestureEventFilter> gesture_event_filter_; | 239 scoped_ptr<Flinger> flinger_; |
| 240 |
| 241 scoped_ptr<BaseGestureEventFilter> event_filter_; |
| 242 |
| 243 enum InputMessageSource { |
| 244 MESSAGE_SOURCE_FLING, |
| 245 MESSAGE_SOURCE_REGULAR, |
| 246 }; |
| 247 |
| 248 std::queue<InputMessageSource> in_process_messages_sources_; |
| 237 | 249 |
| 238 DISALLOW_COPY_AND_ASSIGN(ImmediateInputRouter); | 250 DISALLOW_COPY_AND_ASSIGN(ImmediateInputRouter); |
| 239 }; | 251 }; |
| 240 | 252 |
| 241 } // namespace content | 253 } // namespace content |
| 242 | 254 |
| 243 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_IMMEDIATE_INPUT_ROUTER_H_ | 255 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_IMMEDIATE_INPUT_ROUTER_H_ |
| OLD | NEW |