blob: a25e69498675fee5655f501139073da0d23d17ec [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2016 The Chromium Authors
rlanday7f2ec7f2016-12-14 02:28:342// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef UI_ANDROID_OVERSCROLL_REFRESH_HANDLER_H_
6#define UI_ANDROID_OVERSCROLL_REFRESH_HANDLER_H_
7
8#include "base/android/scoped_java_ref.h"
Jinsuk Kimd04b59e42019-01-25 02:44:369#include "ui/android/overscroll_refresh.h"
rlanday7f2ec7f2016-12-14 02:28:3410#include "ui/android/ui_android_export.h"
11
12namespace ui {
13
14class UI_ANDROID_EXPORT OverscrollRefreshHandler {
15 public:
16 explicit OverscrollRefreshHandler(
17 const base::android::JavaRef<jobject>& j_overscroll_refresh_handler);
18
19 // Note: the following methods are virtual because this class is overridden
20 // for testing in overscroll_refresh_unittest.cc
21
22 virtual ~OverscrollRefreshHandler();
23
24 // Signals the start of an overscrolling pull. Returns whether the handler
25 // will consume the overscroll gesture, in which case it will receive the
26 // remaining pull updates.
Jinsuk Kimbec0ae072019-05-07 23:16:3227 virtual bool PullStart(OverscrollAction type,
28 float startx,
29 float starty,
30 bool navigate_forward);
rlanday7f2ec7f2016-12-14 02:28:3431
Jinsuk Kim1bf0f752019-01-18 00:05:3032 // Signals a pull update, where |x_delta| and |y_delta| are in device pixels.
33 virtual void PullUpdate(float x_delta, float y_delta);
rlanday7f2ec7f2016-12-14 02:28:3434
35 // Signals the release of the pull, and whether the release is allowed to
36 // trigger the refresh action.
37 virtual void PullRelease(bool allow_refresh);
38
39 // Reset the active pull state.
40 virtual void PullReset();
41
42 private:
43 base::android::ScopedJavaGlobalRef<jobject> j_overscroll_refresh_handler_;
44};
45
46} // namespace ui
47
48#endif // UI_ANDROID_OVERSCROLL_REFRESH_HANDLER_H_