Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors |
rlanday | 7f2ec7f | 2016-12-14 02:28:34 | [diff] [blame] | 2 | // 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 Kim | d04b59e4 | 2019-01-25 02:44:36 | [diff] [blame] | 9 | #include "ui/android/overscroll_refresh.h" |
rlanday | 7f2ec7f | 2016-12-14 02:28:34 | [diff] [blame] | 10 | #include "ui/android/ui_android_export.h" |
David Bokan | 910d703 | 2024-07-12 13:53:21 | [diff] [blame] | 11 | #include "ui/events/back_gesture_event.h" |
rlanday | 7f2ec7f | 2016-12-14 02:28:34 | [diff] [blame] | 12 | |
| 13 | namespace ui { |
| 14 | |
| 15 | class 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 Bokan | 910d703 | 2024-07-12 13:53:21 | [diff] [blame] | 28 | virtual bool PullStart( |
| 29 | OverscrollAction type, |
David Bokan | 910d703 | 2024-07-12 13:53:21 | [diff] [blame] | 30 | std::optional<BackGestureEventSwipeEdge> initiating_edge); |
rlanday | 7f2ec7f | 2016-12-14 02:28:34 | [diff] [blame] | 31 | |
Jinsuk Kim | 1bf0f75 | 2019-01-18 00:05:30 | [diff] [blame] | 32 | // Signals a pull update, where |x_delta| and |y_delta| are in device pixels. |
| 33 | virtual void PullUpdate(float x_delta, float y_delta); |
rlanday | 7f2ec7f | 2016-12-14 02:28:34 | [diff] [blame] | 34 | |
| 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_ |