namespace content {
+TapSuppressionController::Config::Config()
+ : enabled(false),
+ max_cancel_to_down_time(base::TimeDelta::FromMilliseconds(180)),
+ max_tap_gap_time(base::TimeDelta::FromMilliseconds(500)) {
+}
+
TapSuppressionController::TapSuppressionController(
- TapSuppressionControllerClient* client)
+ TapSuppressionControllerClient* client,
+ const Config& config)
: client_(client),
- state_(TapSuppressionController::NOTHING) {
+ state_(config.enabled ? NOTHING : DISABLED),
+ max_cancel_to_down_time_(config.max_cancel_to_down_time),
+ max_tap_gap_time_(config.max_tap_gap_time) {
}
TapSuppressionController::~TapSuppressionController() {}
void TapSuppressionController::GestureFlingCancel() {
switch (state_) {
+ case DISABLED:
+ break;
case NOTHING:
case GFC_IN_PROGRESS:
case LAST_CANCEL_STOPPED_FLING:
void TapSuppressionController::GestureFlingCancelAck(bool processed) {
base::TimeTicks event_time = Now();
switch (state_) {
+ case DISABLED:
case NOTHING:
break;
case GFC_IN_PROGRESS:
bool TapSuppressionController::ShouldDeferTapDown() {
base::TimeTicks event_time = Now();
switch (state_) {
+ case DISABLED:
case NOTHING:
return false;
case GFC_IN_PROGRESS:
state_ = TAP_DOWN_STASHED;
- StartTapDownTimer(
- base::TimeDelta::FromMilliseconds(client_->MaxTapGapTimeInMs()));
+ StartTapDownTimer(max_tap_gap_time_);
return true;
case TAP_DOWN_STASHED:
NOTREACHED() << "TapDown on TAP_DOWN_STASHED state";
state_ = NOTHING;
return false;
case LAST_CANCEL_STOPPED_FLING:
- if ((event_time - fling_cancel_time_).InMilliseconds()
- < client_->MaxCancelToDownTimeInMs()) {
+ if ((event_time - fling_cancel_time_) < max_cancel_to_down_time_) {
state_ = TAP_DOWN_STASHED;
- StartTapDownTimer(
- base::TimeDelta::FromMilliseconds(client_->MaxTapGapTimeInMs()));
+ StartTapDownTimer(max_tap_gap_time_);
return true;
} else {
state_ = NOTHING;
bool TapSuppressionController::ShouldSuppressTapEnd() {
switch (state_) {
+ case DISABLED:
case NOTHING:
case GFC_IN_PROGRESS:
return false;
void TapSuppressionController::TapDownTimerExpired() {
switch (state_) {
+ case DISABLED:
case NOTHING:
+ NOTREACHED() << "Timer fired on invalid state.";
+ break;
case GFC_IN_PROGRESS:
case LAST_CANCEL_STOPPED_FLING:
NOTREACHED() << "Timer fired on invalid state.";