synthetic_gesture_target_android.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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
12namespace content {
13
14class ContentViewCoreImpl;
15
16class 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  virtual void DispatchWebTouchEventToPlatform(
26      const blink::WebTouchEvent& web_touch,
27      const ui::LatencyInfo& latency_info) OVERRIDE;
28
29  // SyntheticGestureTarget:
30  virtual SyntheticGestureParams::GestureSourceType
31      GetDefaultSyntheticGestureSourceType() const OVERRIDE;
32  virtual bool SupportsSyntheticGestureSourceType(
33      SyntheticGestureParams::GestureSourceType gesture_source_type) const
34      OVERRIDE;
35
36  virtual int GetTouchSlopInDips() const OVERRIDE;
37
38 private:
39  // Enum values below need to be kept in sync with TouchEventSynthesizer.java
40  enum Action {
41    ActionInvalid = -1,
42    ActionStart = 0,
43    ActionMove = 1,
44    ActionCancel = 2,
45    ActionEnd = 3
46  };
47
48  void TouchSetPointer(JNIEnv* env, int index, int x, int y, int id);
49  void TouchInject(
50      JNIEnv* env, Action action, int pointer_count, int64 time_in_ms);
51
52  base::android::ScopedJavaGlobalRef<jobject> touch_event_synthesizer_;
53
54  DISALLOW_COPY_AND_ASSIGN(SyntheticGestureTargetAndroid);
55};
56
57}  // namespace content
58
59#endif  // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_TARGET_ANDROID_H_
60