summaryrefslogtreecommitdiff
path: root/chromium/content/public/browser/overscroll_configuration.h
blob: c4262178fda2575e359635c145d5e601f2a25922 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_BROWSER_OVERSCROLL_CONFIGURATION_H_
#define CONTENT_PUBLIC_BROWSER_OVERSCROLL_CONFIGURATION_H_

#include "base/macros.h"
#include "base/time/time.h"
#include "content/common/content_export.h"

namespace content {

class CONTENT_EXPORT OverscrollConfig {
 public:
  // Determines pull-to-refresh mode according to --pull-to-refresh flag.
  enum class PullToRefreshMode {
    // Pull-to-refresh is disabled.
    kDisabled,

    // Pull-to-refresh is enabled for both touchscreen and touchpad.
    kEnabled,

    // Pull-to-refresh is enabled only for touchscreen.
    kEnabledTouchschreen,
  };

  // These are percentages of the display size.
  static const float kCompleteTouchpadThresholdPercent;
  static const float kCompleteTouchscreenThresholdPercent;

  static const float kStartTouchpadThresholdDips;
  static const float kStartTouchscreenThresholdDips;

  static PullToRefreshMode GetPullToRefreshMode();

  static bool TouchpadOverscrollHistoryNavigationEnabled();

  static base::TimeDelta MaxInertialEventsBeforeOverscrollCancellation();

 private:
  friend class ScopedPullToRefreshMode;
  friend class OverscrollControllerTest;

  // Helper functions used by |ScopedPullToRefreshMode| to set and reset mode in
  // tests.
  static void SetPullToRefreshMode(PullToRefreshMode mode);
  static void ResetPullToRefreshMode();

  // Helper functions to reset TouchpadOverscrollHistoryNavigationEnabled in
  // tests.
  static void ResetTouchpadOverscrollHistoryNavigationEnabled();

  DISALLOW_IMPLICIT_CONSTRUCTORS(OverscrollConfig);
};

}  // namespace content

#endif  // CONTENT_PUBLIC_BROWSER_OVERSCROLL_CONFIGURATION_H_