Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1864)

Unified Diff: blimp/client/input/blimp_input_manager.h

Issue 1430623004: blimp: Add support for input handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/client/input/blimp_input_manager.h
diff --git a/blimp/client/input/blimp_input_manager.h b/blimp/client/input/blimp_input_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..faf90d2f5f13b067ee2c9f06e5af2631cc13e589
--- /dev/null
+++ b/blimp/client/input/blimp_input_manager.h
@@ -0,0 +1,94 @@
+// Copyright 2015 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 BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_
+#define BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "ui/events/blink/input_handler_proxy.h"
+#include "ui/events/blink/input_handler_proxy_client.h"
+#include "ui/events/gesture_detection/filtered_gesture_provider.h"
+#include "ui/events/gesture_detection/motion_event.h"
+
+namespace blimp {
+
+class BlimpInputManagerClient {
+ public:
+ virtual void SendWebInputEvent(
+ const blink::WebInputEvent& input_event) = 0;
+};
+
+// The BlimpInputManager handles input events for a specific render widget. The
+// class processes ui::events to generate web input events which are forwarded
+// to the compositor to be handled on the compositor thread. If the event can
+// not be handled locally by the compositor, it is given to the
+// BlimpInputManagerClient to be sent to the engine.
+class BlimpInputManager : public ui::InputHandlerProxyClient,
+ public ui::GestureProviderClient {
+ public:
+ static scoped_ptr<BlimpInputManager> Create(
+ BlimpInputManagerClient* client,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
+ const base::WeakPtr<cc::InputHandler>& input_handler);
+
+ ~BlimpInputManager();
+
+ // Called to process a ui::MotionEvent. Returns true if the event was
+ // successfully processed.
+ bool OnTouchEvent(const ui::MotionEvent& motion_event);
+
+ private:
+ BlimpInputManager(
+ BlimpInputManagerClient* client,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
+ const base::WeakPtr<cc::InputHandler>& input_handler);
+
+
+ // InputHandlerProxyClient implementation. Called on the compositor thread.
+ void WillShutdown() override;
+ void TransferActiveWheelFlingAnimation(
+ const blink::WebActiveWheelFlingParameters& params) override;
+ blink::WebGestureCurve* CreateFlingAnimationCurve(
+ blink::WebGestureDevice device_source,
+ const blink::WebFloatPoint& velocity,
+ const blink::WebSize& cumulative_scroll) override;
+ void DidOverscroll(const gfx::Vector2dF& accumulated_overscroll,
+ const gfx::Vector2dF& latest_overscroll_delta,
+ const gfx::Vector2dF& current_fling_velocity,
+ const gfx::PointF& causal_event_viewport_point) override;
+ void DidStopFlinging() override;
+ void DidAnimateForInput() override;
+
+ // ui::GestureProviderClient implementation. Called on main thread.
+ void OnGestureEvent(const ui::GestureEventData& gesture) override;
+
+ void CreateInputHandlerProxyOnCompositorThread(
+ const base::WeakPtr<cc::InputHandler>& input_handler);
+ void HandleWebInputEventOnCompositorThread(
+ const blink::WebInputEvent& input_event);
+ void SendWebInputEvent(const blink::WebInputEvent& input_event);
+
+ bool IsMainThread() const;
+ bool IsCompositorThread() const;
+
+ BlimpInputManagerClient* client_;
+
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
+
+ ui::FilteredGestureProvider gesture_provider_;
+
+ scoped_ptr<ui::InputHandlerProxy> input_handler_proxy_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlimpInputManager);
+};
+
+} // namespace blimp
+
+#endif // BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698