| 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_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ | 5 #ifndef CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ |
| 6 #define CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ | 6 #define CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/port/common/input_event_ack_state.h" | 14 #include "content/port/common/input_event_ack_state.h" |
| 15 #include "content/renderer/input/input_handler_manager_client.h" | 15 #include "content/renderer/input/input_handler_manager_client.h" |
| 16 #include "ipc/ipc_channel_proxy.h" | 16 #include "ipc/message_filter.h" |
| 17 #include "third_party/WebKit/public/web/WebInputEvent.h" | 17 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 18 | 18 |
| 19 namespace base { |
| 20 class MessageLoopProxy; |
| 21 } |
| 22 |
| 23 namespace IPC { |
| 24 class Listener; |
| 25 class Sender; |
| 26 } |
| 27 |
| 19 // This class can be used to intercept InputMsg_HandleInputEvent messages | 28 // This class can be used to intercept InputMsg_HandleInputEvent messages |
| 20 // and have them be delivered to a target thread. Input events are filtered | 29 // and have them be delivered to a target thread. Input events are filtered |
| 21 // based on routing_id (see AddRoute and RemoveRoute). | 30 // based on routing_id (see AddRoute and RemoveRoute). |
| 22 // | 31 // |
| 23 // The user of this class provides an instance of InputEventFilter::Handler, | 32 // The user of this class provides an instance of InputEventFilter::Handler, |
| 24 // which will be passed WebInputEvents on the target thread. | 33 // which will be passed WebInputEvents on the target thread. |
| 25 // | 34 // |
| 26 | 35 |
| 27 namespace content { | 36 namespace content { |
| 28 | 37 |
| 29 class CONTENT_EXPORT InputEventFilter | 38 class CONTENT_EXPORT InputEventFilter : public InputHandlerManagerClient, |
| 30 : public InputHandlerManagerClient, | 39 public IPC::MessageFilter { |
| 31 public IPC::ChannelProxy::MessageFilter { | |
| 32 public: | 40 public: |
| 33 InputEventFilter(IPC::Listener* main_listener, | 41 InputEventFilter(IPC::Listener* main_listener, |
| 34 const scoped_refptr<base::MessageLoopProxy>& target_loop); | 42 const scoped_refptr<base::MessageLoopProxy>& target_loop); |
| 35 | 43 |
| 36 // The |handler| is invoked on the thread associated with |target_loop| to | 44 // The |handler| is invoked on the thread associated with |target_loop| to |
| 37 // handle input events matching the filtered routes. | 45 // handle input events matching the filtered routes. |
| 38 // | 46 // |
| 39 // If INPUT_EVENT_ACK_STATE_NOT_CONSUMED is returned by the handler, | 47 // If INPUT_EVENT_ACK_STATE_NOT_CONSUMED is returned by the handler, |
| 40 // the original InputMsg_HandleInputEvent message will be delivered to | 48 // the original InputMsg_HandleInputEvent message will be delivered to |
| 41 // |main_listener| on the main thread. (The "main thread" in this context is | 49 // |main_listener| on the main thread. (The "main thread" in this context is |
| 42 // the thread where the InputEventFilter was constructed.) The responsibility | 50 // the thread where the InputEventFilter was constructed.) The responsibility |
| 43 // is left to the eventual handler to deliver the corresponding | 51 // is left to the eventual handler to deliver the corresponding |
| 44 // InputHostMsg_HandleInputEvent_ACK. | 52 // InputHostMsg_HandleInputEvent_ACK. |
| 45 // | 53 // |
| 46 virtual void SetBoundHandler(const Handler& handler) OVERRIDE; | 54 virtual void SetBoundHandler(const Handler& handler) OVERRIDE; |
| 47 virtual void DidAddInputHandler(int routing_id, | 55 virtual void DidAddInputHandler(int routing_id, |
| 48 cc::InputHandler* input_handler) OVERRIDE; | 56 cc::InputHandler* input_handler) OVERRIDE; |
| 49 virtual void DidRemoveInputHandler(int routing_id) OVERRIDE; | 57 virtual void DidRemoveInputHandler(int routing_id) OVERRIDE; |
| 50 virtual void DidOverscroll(int routing_id, | 58 virtual void DidOverscroll(int routing_id, |
| 51 const DidOverscrollParams& params) OVERRIDE; | 59 const DidOverscrollParams& params) OVERRIDE; |
| 52 virtual void DidStopFlinging(int routing_id) OVERRIDE; | 60 virtual void DidStopFlinging(int routing_id) OVERRIDE; |
| 53 | 61 |
| 54 // IPC::ChannelProxy::MessageFilter methods: | 62 // IPC::MessageFilter methods: |
| 55 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; | 63 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE; |
| 56 virtual void OnFilterRemoved() OVERRIDE; | 64 virtual void OnFilterRemoved() OVERRIDE; |
| 57 virtual void OnChannelClosing() OVERRIDE; | 65 virtual void OnChannelClosing() OVERRIDE; |
| 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 66 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 59 | 67 |
| 60 private: | 68 private: |
| 61 friend class IPC::ChannelProxy::MessageFilter; | |
| 62 virtual ~InputEventFilter(); | 69 virtual ~InputEventFilter(); |
| 63 | 70 |
| 64 void ForwardToMainListener(const IPC::Message& message); | 71 void ForwardToMainListener(const IPC::Message& message); |
| 65 void ForwardToHandler(const IPC::Message& message); | 72 void ForwardToHandler(const IPC::Message& message); |
| 66 void SendACK(blink::WebInputEvent::Type type, | 73 void SendACK(blink::WebInputEvent::Type type, |
| 67 InputEventAckState ack_result, | 74 InputEventAckState ack_result, |
| 68 const ui::LatencyInfo& latency_info, | 75 const ui::LatencyInfo& latency_info, |
| 69 int routing_id); | 76 int routing_id); |
| 70 void SendMessage(const IPC::Message& message); | 77 void SendMessage(const IPC::Message& message); |
| 71 void SendMessageOnIOThread(const IPC::Message& message); | 78 void SendMessageOnIOThread(const IPC::Message& message); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 87 // Indicates the routing_ids for which input events should be filtered. | 94 // Indicates the routing_ids for which input events should be filtered. |
| 88 std::set<int> routes_; | 95 std::set<int> routes_; |
| 89 | 96 |
| 90 // Specifies whether overscroll notifications are forwarded to the host. | 97 // Specifies whether overscroll notifications are forwarded to the host. |
| 91 bool overscroll_notifications_enabled_; | 98 bool overscroll_notifications_enabled_; |
| 92 }; | 99 }; |
| 93 | 100 |
| 94 } // namespace content | 101 } // namespace content |
| 95 | 102 |
| 96 #endif // CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ | 103 #endif // CONTENT_RENDERER_INPUT_INPUT_EVENT_FILTER_H_ |
| OLD | NEW |