summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/touch_smooth_scroll_gesture_android.h
blob: 457f34172229e41a6d732bb9a28a31c6bff7552a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2013 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 CONTENT_BROWSER_RENDERER_HOST_TOUCH_SMOOTH_GESTURE_ANDROID_H_
#define CONTENT_BROWSER_RENDERER_HOST_TOUCH_SMOOTH_GESTURE_ANDROID_H_

#include "base/android/jni_android.h"
#include "base/time.h"
#include "content/browser/renderer_host/smooth_scroll_calculator.h"
#include "content/port/browser/smooth_scroll_gesture.h"

namespace content {

class ContentViewCore;
class RenderWidgetHost;

class TouchSmoothScrollGestureAndroid : public SmoothScrollGesture {
 public:
  TouchSmoothScrollGestureAndroid(
      int pixels_to_scroll,
      RenderWidgetHost* rwh,
      base::android::ScopedJavaLocalRef<jobject> java_scroller);

  // Called by the java side once the TimeAnimator ticks.
  double GetScrollDelta(JNIEnv* env, jobject obj, double scale);
  bool HasFinished(JNIEnv* env, jobject obj);
  void SetHasSentMotionUp(JNIEnv* env, jobject obj);

  // SmoothScrollGesture
  virtual bool ForwardInputEvents(base::TimeTicks now,
                                  RenderWidgetHost* host) OVERRIDE;

 private:
  virtual ~TouchSmoothScrollGestureAndroid();

  SmoothScrollCalculator smooth_scroll_calculator_;

  int pixels_scrolled_;
  bool has_started_;
  bool has_sent_motion_up_;

  int pixels_to_scroll_;
  RenderWidgetHost* rwh_;
  base::android::ScopedJavaGlobalRef<jobject> java_scroller_;

  DISALLOW_COPY_AND_ASSIGN(TouchSmoothScrollGestureAndroid);
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_TOUCH_SMOOTH_GESTURE_ANDROID_H_