blob: 5427ca8d6f8b2f2b2b98cd27dcd4b4e2bd5ab293 [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"
David Bokan910d7032024-07-12 13:53:2111#include "ui/events/back_gesture_event.h"
rlanday7f2ec7f2016-12-14 02:28:3412
13namespace ui {
14
15class UI_ANDROID_EXPORT OverscrollRefreshHandler {
16 public:
17 explicit OverscrollRefreshHandler(
18 const base::android::JavaRef<jobject>& j_overscroll_refresh_handler);
19
20 // Note: the following methods are virtual because this class is overridden
21 // for testing in overscroll_refresh_unittest.cc
22
23 virtual ~OverscrollRefreshHandler();
24
25 // Signals the start of an overscrolling pull. Returns whether the handler
26 // will consume the overscroll gesture, in which case it will receive the
27 // remaining pull updates.
David Bokan910d7032024-07-12 13:53:2128 virtual bool PullStart(
29 OverscrollAction type,
David Bokan910d7032024-07-12 13:53:2130 std::optional<BackGestureEventSwipeEdge> initiating_edge);
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_