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.
5 #include "content/browser/renderer_host/generic_touch_gesture_android.h"
7 #include "base/debug/trace_event.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h"
9 #include "jni/GenericTouchGesture_jni.h"
12 bool g_jni_initialized = false;
14 void RegisterNativesIfNeeded(JNIEnv* env) {
15 if (!g_jni_initialized) {
16 content::RegisterNativesImpl(env);
17 g_jni_initialized = true;
24 GenericTouchGestureAndroid::GenericTouchGestureAndroid(
25 RenderWidgetHost* rwh,
26 base::android::ScopedJavaLocalRef<jobject> java_touch_gesture)
27 : has_started_(false),
30 java_touch_gesture_(java_touch_gesture) {
31 JNIEnv* env = base::android::AttachCurrentThread();
32 RegisterNativesIfNeeded(env);
35 GenericTouchGestureAndroid::~GenericTouchGestureAndroid() {
38 bool GenericTouchGestureAndroid::ForwardInputEvents(
39 base::TimeTicks now, RenderWidgetHost* host) {
42 JNIEnv* env = base::android::AttachCurrentThread();
43 Java_GenericTouchGesture_start(
44 env, java_touch_gesture_.obj(), reinterpret_cast<intptr_t>(this));
47 return !has_finished_;
50 float GenericTouchGestureAndroid::GetDelta(
51 JNIEnv* env, jobject obj, float scale) {
52 return synthetic_gesture_calculator_.GetDelta(
53 base::TimeTicks::Now(),
54 RenderWidgetHostImpl::From(rwh_)->GetSyntheticGestureMessageInterval()) *
58 void GenericTouchGestureAndroid::SetHasFinished(JNIEnv* env, jobject obj) {
62 } // namespace content