[Android] Disable the refresh effect for fullscreen HTML5 scenarios
[chromium-blink-merge.git] / content / browser / android / overscroll_controller_android.h
blob128b803eca23cae9b4dcc7397dab7a73c7c9cc84
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 "content/public/browser/web_contents_observer.h"
13 #include "ui/gfx/geometry/vector2d_f.h"
15 namespace blink {
16 class WebGestureEvent;
19 namespace cc {
20 class CompositorFrameMetadata;
21 class Layer;
24 namespace ui {
25 class WindowAndroidCompositor;
28 namespace content {
30 class ContentViewCoreImpl;
31 struct DidOverscrollParams;
33 // Glue class for handling all inputs into Android-specific overscroll effects,
34 // both the passive overscroll glow and the active overscroll pull-to-refresh.
35 // Note that all input coordinates (both for events and overscroll) are in DIPs.
36 class OverscrollControllerAndroid : public OverscrollGlowClient,
37 public WebContentsObserver {
38 public:
39 explicit OverscrollControllerAndroid(ContentViewCoreImpl* content_view_core);
40 ~OverscrollControllerAndroid() override;
42 // Returns true if |event| is consumed by an overscroll effect, in which
43 // case it should cease propagation.
44 bool WillHandleGestureEvent(const blink::WebGestureEvent& event);
46 // To be called upon receipt of a gesture event ack.
47 void OnGestureEventAck(const blink::WebGestureEvent& event,
48 InputEventAckState ack_result);
50 // To be called upon receipt of an overscroll event.
51 void OnOverscrolled(const DidOverscrollParams& overscroll_params);
53 // Returns true if the effect still needs animation ticks.
54 // Note: The effect will detach itself when no further animation is required.
55 bool Animate(base::TimeTicks current_time, cc::Layer* parent_layer);
57 // To be called whenever the content frame has been updated.
58 void OnFrameMetadataUpdated(const cc::CompositorFrameMetadata& metadata);
60 // Toggle activity of any overscroll effects. When disabled, events will be
61 // ignored until the controller is re-enabled.
62 void Enable();
63 void Disable();
65 private:
66 // WebContentsObserver implementation.
67 void DidToggleFullscreenModeForTab(bool entered_fullscreen) override;
69 // OverscrollGlowClient implementation.
70 scoped_ptr<EdgeEffectBase> CreateEdgeEffect() override;
72 void SetNeedsAnimate();
74 ui::WindowAndroidCompositor* const compositor_;
75 const float dpi_scale_;
77 bool enabled_;
79 // TODO(jdduke): Factor out a common API from the two overscroll effects.
80 scoped_ptr<OverscrollGlow> glow_effect_;
81 scoped_ptr<OverscrollRefresh> refresh_effect_;
83 // For fullscreen HTML5 scenarios, the refresh effect will be disabled.
84 bool is_fullscreen_;
86 DISALLOW_COPY_AND_ASSIGN(OverscrollControllerAndroid);
89 } // namespace content
91 #endif // CONTENT_BROWSER_ANDROID_OVERSCROLL_CONTROLLER_ANDROID_H_