Index: content/common/android/synchronous_input_event_filter.h |
diff --git a/content/common/android/synchronous_input_event_filter.h b/content/common/android/synchronous_input_event_filter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4c94fab203e9f8984e20a33b7d240e346ff7cb0b |
--- /dev/null |
+++ b/content/common/android/synchronous_input_event_filter.h |
@@ -0,0 +1,58 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_COMMON_ANDROID_SYNCHRONOUS_INPUT_EVENT_FILTER_H_ |
+#define CONTENT_COMMON_ANDROID_SYNCHRONOUS_INPUT_EVENT_FILTER_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/callback.h" |
+#include "base/compiler_specific.h" |
+#include "content/common/gpu/input_handler_manager_client.h" |
+#include "content/port/common/input_event_ack_state.h" |
+ |
+namespace WebKit { |
+class WebInputEvent; |
+} |
+ |
+namespace content { |
+ |
+// This class perform synchronous, in-process InputEvent handling. |
+// |
+// The user of this class provides an instance of InputEventFilter::Handler, |
+// which will be passed WebInputEvents on the compositing thread. If the event |
+// goes unhandled, that is reflected in the InputEventAckState; no forwarding |
+// is performed. |
+// |
+// It is up to the user to ensure thread-safety. |
+class SynchronousInputEventFilter : public InputHandlerManagerClient { |
+ public: |
+ typedef base::Callback<void(int /*routing_id*/, |
+ const WebKit::WebInputEvent*)> Handler; |
+ SynchronousInputEventFilter(const Handler& handler); |
+ virtual ~SynchronousInputEventFilter(); |
+ |
+ // Forward an input event to the |handler| and return the result. If the |
+ // |routing_id| is not associated with an InputHandler, or if the |
+ // |input_event| needs forwarding, it is reflected in the InputEventAckState. |
+ content::InputEventAckState HandleInputEvent( |
+ int routing_id, |
+ const WebKit::WebInputEvent& input_event); |
+ |
+ // InputHandlerManagerClient implementation. |
+ virtual void DidAddInputHandler(int routing_id) OVERRIDE {} |
+ virtual void DidRemoveInputHandler(int routing_id) OVERRIDE {} |
+ virtual void DidHandleInputEvent() OVERRIDE; |
+ virtual void DidNotHandleInputEvent(bool send_to_widget) OVERRIDE; |
+ |
+ private: |
+ Handler handler_; |
+ |
+ // A temporary result reflecting the intermediate callback sequence of |
+ // Did/DidNotHandleInputEvent, initiated by a call to HandleInputEvent. |
+ InputEventAckState event_result_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_COMMON_ANDROID_SYNCHRONOUS_INPUT_EVENT_FILTER_H_ |