| Index: content/renderer/android/synchronous_input_event_filter.cc
|
| diff --git a/content/renderer/android/synchronous_input_event_filter.cc b/content/renderer/android/synchronous_input_event_filter.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e889d762e8f9ea095fd1bd9421fe023d3b2d6905
|
| --- /dev/null
|
| +++ b/content/renderer/android/synchronous_input_event_filter.cc
|
| @@ -0,0 +1,47 @@
|
| +// 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.
|
| +
|
| +#include "content/renderer/android/synchronous_input_event_filter.h"
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/logging.h"
|
| +
|
| +using WebKit::WebInputEvent;
|
| +
|
| +namespace content {
|
| +
|
| +SynchronousInputEventFilter::SynchronousInputEventFilter(
|
| + const Handler& handler)
|
| + : handler_(handler) {
|
| + DCHECK(!handler_.is_null());
|
| +}
|
| +
|
| +SynchronousInputEventFilter::~SynchronousInputEventFilter() {
|
| +}
|
| +
|
| +InputEventAckState SynchronousInputEventFilter::HandleInputEvent(
|
| + int routing_id,
|
| + const WebKit::WebInputEvent* input_event) {
|
| + // Clear the result for the (unexpected) case that callbacks to
|
| + // did/didNotHandleInputEvent are not made synchronously.
|
| + event_result_ = INPUT_EVENT_ACK_STATE_UNKNOWN;
|
| +
|
| + // It is expected that handler_ initiates a synchronous callback to
|
| + // Did/DidNotHandleInputEvent.
|
| + handler_.Run(routing_id, input_event);
|
| + DCHECK(event_result_ != INPUT_EVENT_ACK_STATE_UNKNOWN);
|
| +
|
| + return event_result_;
|
| +}
|
| +
|
| +void SynchronousInputEventFilter::DidHandleInputEvent() {
|
| + event_result_ = INPUT_EVENT_ACK_STATE_CONSUMED;
|
| +}
|
| +
|
| +void SynchronousInputEventFilter::DidNotHandleInputEvent(bool send_to_widget) {
|
| + event_result_ = send_to_widget ? INPUT_EVENT_ACK_STATE_NOT_CONSUMED
|
| + : INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
|
| +}
|
| +
|
| +} // namespace content
|
|
|