overscroll_refresh_handler.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #ifndef UI_ANDROID_OVERSCROLL_REFRESH_HANDLER_H_
  5. #define UI_ANDROID_OVERSCROLL_REFRESH_HANDLER_H_
  6. #include "base/android/scoped_java_ref.h"
  7. #include "ui/android/overscroll_refresh.h"
  8. #include "ui/android/ui_android_export.h"
  9. namespace ui {
  10. class UI_ANDROID_EXPORT OverscrollRefreshHandler {
  11. public:
  12. explicit OverscrollRefreshHandler(
  13. const base::android::JavaRef<jobject>& j_overscroll_refresh_handler);
  14. // Note: the following methods are virtual because this class is overridden
  15. // for testing in overscroll_refresh_unittest.cc
  16. virtual ~OverscrollRefreshHandler();
  17. // Signals the start of an overscrolling pull. Returns whether the handler
  18. // will consume the overscroll gesture, in which case it will receive the
  19. // remaining pull updates.
  20. virtual bool PullStart(OverscrollAction type,
  21. float startx,
  22. float starty,
  23. bool navigate_forward);
  24. // Signals a pull update, where |x_delta| and |y_delta| are in device pixels.
  25. virtual void PullUpdate(float x_delta, float y_delta);
  26. // Signals the release of the pull, and whether the release is allowed to
  27. // trigger the refresh action.
  28. virtual void PullRelease(bool allow_refresh);
  29. // Reset the active pull state.
  30. virtual void PullReset();
  31. private:
  32. base::android::ScopedJavaGlobalRef<jobject> j_overscroll_refresh_handler_;
  33. };
  34. } // namespace ui
  35. #endif // UI_ANDROID_OVERSCROLL_REFRESH_HANDLER_H_