Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: content/browser/android/overscroll_controller_android.h

Issue 679493002: [Android] Add a native pull-to-refresh overscroll effect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix findbugs... Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 ui {
25 class WindowAndroidCompositor;
26 }
27
28 namespace content {
29
30 struct DidOverscrollParams;
31
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 OverscrollRefreshClient,
36 public WebContentsObserver {
37 public:
38 OverscrollControllerAndroid(WebContents* web_contents,
39 ui::WindowAndroidCompositor* compositor,
40 float dpi_scale);
41 virtual ~OverscrollControllerAndroid();
42
43 // Returns true if |event| is consumed by an overscroll effect, in which
44 // case it should cease propagation.
45 bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
46
47 // To be called upon receipt of a gesture event ack.
48 void OnGestureEventAck(const blink::WebGestureEvent& event,
49 InputEventAckState ack_result);
50
51 // To be called upon receipt of an overscroll event.
52 void OnOverscrolled(const DidOverscrollParams& overscroll_params);
53
54 // Returns true if the effect still needs animation ticks.
55 // Note: The effect will detach itself when no further animation is required.
56 bool Animate(base::TimeTicks current_time, cc::Layer* parent_layer);
57
58 // To be called whenever the content frame has been updated.
59 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata);
60
61 // Toggle activity of any overscroll effects. When disabled, events will be
62 // ignored until the controller is re-enabled.
63 void Enable();
64 void Disable();
65
66 private:
67 // WebContentsObserver implementation.
68 void DidNavigateMainFrame(const LoadCommittedDetails& details,
69 const FrameNavigateParams& params) override;
70
71 // OverscrollRefreshClient implementation.
72 void TriggerRefresh() override;
73 bool IsStillRefreshing() const override;
74
75 void SetNeedsAnimate();
76
77 ui::WindowAndroidCompositor* compositor_;
78 const float dpi_scale_;
79
80 bool enabled_;
81
82 // TODO(jdduke): Factor out a common API from the two overscroll effects.
83 OverscrollGlow glow_effect_;
84 OverscrollRefresh refresh_effect_;
85 bool triggered_refresh_active_;
86
87 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid);
88 };
89
90 } // namespace content
91
92 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_
OLDNEW
« no previous file with comments | « content/browser/android/edge_effect_l.cc ('k') | content/browser/android/overscroll_controller_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698