#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_H_
#define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_H_
#include "base/functional/callback_forward.h"
#include "base/task/sequenced_task_runner.h"
#include "cc/input/touch_action.h"
#include "content/browser/renderer_host/event_with_latency_info.h"
#include "content/browser/renderer_host/input/gesture_event_queue.h"
#include "content/browser/renderer_host/input/passthrough_touch_event_queue.h"
#include "content/common/content_export.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/mojom/input/input_event_result.mojom-shared.h"
#include "third_party/blink/public/mojom/input/input_handler.mojom.h"
#include "third_party/blink/public/mojom/input/touch_event.mojom.h"
namespace content {
class InputRouter {
public:
struct CONTENT_EXPORT Config {
Config();
GestureEventQueue::Config gesture_config;
PassthroughTouchEventQueue::Config touch_config;
};
virtual ~InputRouter() = default;
using MouseEventCallback =
base::OnceCallback<void(const MouseEventWithLatencyInfo& event,
blink::mojom::InputEventResultSource ack_source,
blink::mojom::InputEventResultState ack_result)>;
virtual void SendMouseEvent(const MouseEventWithLatencyInfo& mouse_event,
MouseEventCallback event_result_callback) = 0;
virtual void SendWheelEvent(
const MouseWheelEventWithLatencyInfo& wheel_event) = 0;
virtual void DynamicFrameLossEvent(const std::string& sceneId, bool isStart) = 0;
using KeyboardEventCallback = base::OnceCallback<void(
const NativeWebKeyboardEventWithLatencyInfo& event,
blink::mojom::InputEventResultSource ack_source,
blink::mojom::InputEventResultState ack_result)>;
virtual void SendKeyboardEvent(
const NativeWebKeyboardEventWithLatencyInfo& key_event,
KeyboardEventCallback event_result_callback) = 0;
virtual void SendGestureEvent(
const GestureEventWithLatencyInfo& gesture_event) = 0;
virtual void SendTouchEvent(
const TouchEventWithLatencyInfo& touch_event) = 0;
virtual void NotifySiteIsMobileOptimized(bool is_mobile_optimized) = 0;
virtual bool HasPendingEvents() const = 0;
virtual void SetDeviceScaleFactor(float device_scale_factor) = 0;
virtual absl::optional<cc::TouchAction> AllowedTouchAction() = 0;
virtual absl::optional<cc::TouchAction> ActiveTouchAction() = 0;
virtual void SetForceEnableZoom(bool enabled) = 0;
virtual mojo::PendingRemote<blink::mojom::WidgetInputHandlerHost> BindNewHost(
scoped_refptr<base::SequencedTaskRunner> task_runner) = 0;
virtual void StopFling() = 0;
virtual void ForceSetTouchActionAuto() = 0;
virtual void OnHasTouchEventConsumers(
blink::mojom::TouchEventConsumersPtr consumers) = 0;
virtual void WaitForInputProcessed(base::OnceClosure callback) = 0;
virtual void FlushTouchEventQueue() = 0;
#if BUILDFLAG(IS_OHOS)
virtual void SetGestureEventResult(bool result, bool stopPropagation) = 0;
virtual void SetNativeEmbedMode(bool flag) = 0;
virtual void ScrollBy(float delta_x, float delta_y) = 0;
#endif
};
}
#endif