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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_target_android.cc

Issue 26664002: SyntheticGestureTarget implementation for injecting synthetic input events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 7 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
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 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h "
6
7 #include "content/browser/android/content_view_core_impl.h"
8 #include "jni/TouchEventSynthesizer_jni.h"
9 #include "third_party/WebKit/public/web/WebInputEvent.h"
10
11 using WebKit::WebTouchEvent;
12
13 namespace content {
14
15 SyntheticGestureTargetAndroid::SyntheticGestureTargetAndroid(
16 RenderWidgetHostImpl* host,
17 base::android::ScopedJavaLocalRef<jobject> touch_event_synthesizer)
18 : SyntheticGestureTargetBase(host),
19 touch_event_synthesizer_(touch_event_synthesizer) {
20 DCHECK(!touch_event_synthesizer_.is_null());
21 }
22
23 SyntheticGestureTargetAndroid::~SyntheticGestureTargetAndroid() {
24 }
25
26 bool SyntheticGestureTargetAndroid::RegisterTouchEventSynthesizer(JNIEnv* env) {
27 return RegisterNativesImpl(env);
28 }
29
30 void SyntheticGestureTargetAndroid::TouchSetPointer(
31 JNIEnv* env, int index, int x, int y, int id) {
32 Java_TouchEventSynthesizer_setPointer(env, touch_event_synthesizer_.obj(),
33 index, x, y, id);
34 }
35
36 void SyntheticGestureTargetAndroid::TouchInject(
37 JNIEnv* env, Action action, int pointer_count) {
38 Java_TouchEventSynthesizer_inject(env, touch_event_synthesizer_.obj(),
39 static_cast<int>(action), pointer_count);
40 }
41
42 void SyntheticGestureTargetAndroid::QueueWebTouchEventToPlatform(
43 const WebKit::WebTouchEvent& web_touch, const ui::LatencyInfo&) {
44 JNIEnv* env = base::android::AttachCurrentThread();
45
46 SyntheticGestureTargetAndroid::Action action =
47 SyntheticGestureTargetAndroid::ActionInvalid;
48 switch (web_touch.type) {
49 case WebKit::WebInputEvent::TouchStart:
50 action = SyntheticGestureTargetAndroid::ActionStart;
51 break;
52 case WebKit::WebInputEvent::TouchMove:
53 action = SyntheticGestureTargetAndroid::ActionMove;
54 break;
55 case WebKit::WebInputEvent::TouchCancel:
56 action = SyntheticGestureTargetAndroid::ActionCancel;
57 break;
58 case WebKit::WebInputEvent::TouchEnd:
59 action = SyntheticGestureTargetAndroid::ActionEnd;
60 break;
61 default:
62 NOTREACHED();
63 }
64 const unsigned num_touches = web_touch.touchesLength;
65 for (unsigned i = 0; i < num_touches; ++i) {
66 const WebKit::WebTouchPoint* point = &web_touch.touches[i];
67 TouchSetPointer(env, i, point->position.x, point->position.y, point->id);
68 }
69
70 TouchInject(env, action, num_touches);
71 }
72
73 SyntheticGestureParams::GestureSourceType
74 SyntheticGestureTargetAndroid::GetDefaultSyntheticGestureSourceType() const {
75 return SyntheticGestureParams::TOUCH_INPUT;
76 }
77
78 bool SyntheticGestureTargetAndroid::SupportsSyntheticGestureSourceType(
79 SyntheticGestureParams::GestureSourceType gesture_source_type) const {
80 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT;
81 }
82
83 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698