[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / android / overscroll_controller_android.h
blob852f074a40f94ee491b7abcd6b3db9e64f079f1e
1 // Copyright 2014 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.
5 #ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_
6 #define CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_
8 #include "base/time/time.h"
9 #include "content/browser/android/overscroll_glow.h"
10 #include "content/browser/android/overscroll_refresh.h"
11 #include "content/common/input/input_event_ack_state.h"
12 #include "ui/gfx/geometry/vector2d_f.h"
14 namespace blink {
15 class WebGestureEvent;
18 namespace cc {
19 class CompositorFrameMetadata;
20 class Layer;
23 namespace ui {
24 class WindowAndroidCompositor;
27 namespace content {
29 class ContentViewCoreImpl;
30 struct DidOverscrollParams;
32 // Glue class for handling all inputs into Android-specific overscroll effects,
33 // both the passive overscroll glow and the active overscroll pull-to-refresh.
34 // Note that all input coordinates (both for events and overscroll) are in DIPs.
35 class OverscrollControllerAndroid : public OverscrollGlowClient {
36 public:
37 explicit OverscrollControllerAndroid(ContentViewCoreImpl* content_view_core);
38 ~OverscrollControllerAndroid() override;
40 // Returns true if |event| is consumed by an overscroll effect, in which
41 // case it should cease propagation.
42 bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
44 // To be called upon receipt of a gesture event ack.
45 void OnGestureEventAck(const blink::WebGestureEvent& event,
46 InputEventAckState ack_result);
48 // To be called upon receipt of an overscroll event.
49 void OnOverscrolled(const DidOverscrollParams& overscroll_params);
51 // Returns true if the effect still needs animation ticks.
52 // Note: The effect will detach itself when no further animation is required.
53 bool Animate(base::TimeTicks current_time, cc::Layer* parent_layer);
55 // To be called whenever the content frame has been updated.
56 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata);
58 // Toggle activity of any overscroll effects. When disabled, events will be
59 // ignored until the controller is re-enabled.
60 void Enable();
61 void Disable();
63 private:
64 // OverscrollGlowClient implementation.
65 scoped_ptr<EdgeEffectBase> CreateEdgeEffect() override;
67 void SetNeedsAnimate();
69 ui::WindowAndroidCompositor* const compositor_;
70 const float dpi_scale_;
72 bool enabled_;
74 // TODO(jdduke): Factor out a common API from the two overscroll effects.
75 scoped_ptr<OverscrollGlow> glow_effect_;
76 scoped_ptr<OverscrollRefresh> refresh_effect_;
78 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid);
81 } // namespace content
83 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_