OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ | |
6 #define CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ | |
7 | |
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 "content/public/browser/web_contents_observer.h" | |
13 #include "ui/gfx/geometry/vector2d_f.h" | |
14 | |
15 namespace blink { | |
16 class WebGestureEvent; | |
17 } | |
18 | |
19 namespace cc { | |
20 class CompositorFrameMetadata; | |
21 class Layer; | |
22 } | |
23 | |
24 namespace content { | |
25 | |
26 class ContentViewCoreImpl; | |
27 struct DidOverscrollParams; | |
28 | |
29 // Glue class for handling all inputs into Android-specific overscroll effects, | |
30 // both the passive overscroll glow and the active overscroll pull-to-refresh. | |
31 // Note that all input coordinates (both for events and overscroll) are in DIPs. | |
32 class OverscrollControllerAndroid : public OverscrollRefreshClient, | |
33 public WebContentsObserver { | |
34 public: | |
35 explicit OverscrollControllerAndroid(ContentViewCoreImpl* content_view_core); | |
36 virtual ~OverscrollControllerAndroid(); | |
37 | |
38 // Returns true if |event| is consumed by an overscroll effect, in which | |
39 // case it should cease propagation. | |
40 bool WillHandleGestureEvent(const blink::WebGestureEvent& event); | |
41 | |
42 // To be called upon receipt of a gesture event ack. | |
43 void OnGestureEventAck(const blink::WebGestureEvent& event, | |
44 InputEventAckState ack_result); | |
45 | |
46 // Te be called upon receipt of an overscroll event. | |
Ted C
2014/10/31 23:52:05
s/Te/To
jdduke (slow)
2014/11/06 00:10:37
Done.
| |
47 void OnOverscrolled(const DidOverscrollParams& overscroll_params); | |
48 | |
49 // Returns true if the effect still needs animation ticks. | |
50 // Note: The effect will detach itself when no further animation is required. | |
51 bool Animate(base::TimeTicks current_time); | |
52 | |
53 // To be called whenever the content frame has been updated. | |
54 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata); | |
55 | |
56 // Toggle activity of any overscroll effects. When disabled, events will be | |
57 // ignored until the controller is re-enabled. | |
58 void Enable(); | |
59 void Disable(); | |
60 | |
61 private: | |
62 // WebContentsObserver implementation. | |
63 void DidNavigateMainFrame(const LoadCommittedDetails& details, | |
64 const FrameNavigateParams& params) override; | |
65 | |
66 // OverscrollRefreshClient implementation. | |
67 void TriggerRefresh() override; | |
68 bool IsTriggeredRefreshActive() const override; | |
69 | |
70 float GetDpiScale() const; | |
71 | |
72 ContentViewCoreImpl* const content_view_core_; | |
73 | |
74 bool enabled_; | |
75 | |
76 // TODO(jdduke): Factor out a common API from the two overscroll effects. | |
77 OverscrollGlow glow_effect_; | |
78 OverscrollRefresh refresh_effect_; | |
79 bool triggered_refresh_active_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid); | |
82 }; | |
83 | |
84 } // namespace content | |
85 | |
86 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_ | |
OLD | NEW |