rlanday | 7f2ec7f | 2016-12-14 02:28:34 | [diff] [blame^] | 1 | // Copyright 2016 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. |
| 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" |
| 9 | #include "ui/android/ui_android_export.h" |
| 10 | |
| 11 | namespace ui { |
| 12 | |
| 13 | class UI_ANDROID_EXPORT OverscrollRefreshHandler { |
| 14 | public: |
| 15 | explicit OverscrollRefreshHandler( |
| 16 | const base::android::JavaRef<jobject>& j_overscroll_refresh_handler); |
| 17 | |
| 18 | // Note: the following methods are virtual because this class is overridden |
| 19 | // for testing in overscroll_refresh_unittest.cc |
| 20 | |
| 21 | virtual ~OverscrollRefreshHandler(); |
| 22 | |
| 23 | // Signals the start of an overscrolling pull. Returns whether the handler |
| 24 | // will consume the overscroll gesture, in which case it will receive the |
| 25 | // remaining pull updates. |
| 26 | virtual bool PullStart(); |
| 27 | |
| 28 | // Signals a pull update, where |delta| is in device pixels. |
| 29 | virtual void PullUpdate(float delta); |
| 30 | |
| 31 | // Signals the release of the pull, and whether the release is allowed to |
| 32 | // trigger the refresh action. |
| 33 | virtual void PullRelease(bool allow_refresh); |
| 34 | |
| 35 | // Reset the active pull state. |
| 36 | virtual void PullReset(); |
| 37 | |
| 38 | private: |
| 39 | base::android::ScopedJavaGlobalRef<jobject> j_overscroll_refresh_handler_; |
| 40 | }; |
| 41 | |
| 42 | } // namespace ui |
| 43 | |
| 44 | #endif // UI_ANDROID_OVERSCROLL_REFRESH_HANDLER_H_ |