• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_TARGET_ANDROID_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_TARGET_ANDROID_H_
7 
8 #include "base/android/jni_android.h"
9 #include "base/time/time.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
11 
12 namespace content {
13 
14 class ContentViewCoreImpl;
15 
16 class SyntheticGestureTargetAndroid : public SyntheticGestureTargetBase {
17  public:
18   SyntheticGestureTargetAndroid(
19       RenderWidgetHostImpl* host,
20       base::android::ScopedJavaLocalRef<jobject> touch_event_synthesizer);
21   virtual ~SyntheticGestureTargetAndroid();
22 
23   static bool RegisterTouchEventSynthesizer(JNIEnv* env);
24 
25   // SyntheticGestureTargetBase:
26   virtual void DispatchWebTouchEventToPlatform(
27       const blink::WebTouchEvent& web_touch,
28       const ui::LatencyInfo& latency_info) OVERRIDE;
29   virtual void DispatchWebMouseWheelEventToPlatform(
30       const blink::WebMouseWheelEvent& web_wheel,
31       const ui::LatencyInfo& latency_info) OVERRIDE;
32   virtual void DispatchWebMouseEventToPlatform(
33       const blink::WebMouseEvent& web_mouse,
34       const ui::LatencyInfo& latency_info) OVERRIDE;
35 
36   // SyntheticGestureTarget:
37   virtual SyntheticGestureParams::GestureSourceType
38       GetDefaultSyntheticGestureSourceType() const OVERRIDE;
39 
40   virtual float GetTouchSlopInDips() const OVERRIDE;
41 
42   virtual float GetMinScalingSpanInDips() const OVERRIDE;
43 
44  private:
45   // Enum values below need to be kept in sync with TouchEventSynthesizer.java
46   enum Action {
47     ActionInvalid = -1,
48     ActionStart = 0,
49     ActionMove = 1,
50     ActionCancel = 2,
51     ActionEnd = 3
52   };
53 
54   void TouchSetPointer(JNIEnv* env, int index, int x, int y, int id);
55   void TouchInject(
56       JNIEnv* env, Action action, int pointer_count, int64 time_in_ms);
57 
58   base::android::ScopedJavaGlobalRef<jobject> touch_event_synthesizer_;
59 
60   DISALLOW_COPY_AND_ASSIGN(SyntheticGestureTargetAndroid);
61 };
62 
63 }  // namespace content
64 
65 #endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_TARGET_ANDROID_H_
66