1 // Copyright 2013 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_RENDERER_HOST_INPUT_INPUT_ROUTER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_H_
8 #include "base/basictypes.h"
9 #include "content/browser/renderer_host/event_with_latency_info.h"
10 #include "content/common/input/input_event_ack_state.h"
11 #include "content/public/browser/native_web_keyboard_event.h"
12 #include "ipc/ipc_listener.h"
13 #include "third_party/WebKit/public/web/WebInputEvent.h"
17 class InputRouterClient
;
19 // The InputRouter allows the embedder to customize how input events are
20 // sent to the renderer, and how responses are dispatched to the browser.
21 // While the router should respect the relative order in which events are
22 // received, it is free to customize when those events are dispatched.
23 class InputRouter
: public IPC::Listener
{
25 ~InputRouter() override
{}
27 // Send and take ownership of the the given InputMsg_*. This should be used
28 // only for event types not associated with a WebInputEvent. Returns true on
29 // success and false otherwise.
30 virtual bool SendInput(scoped_ptr
<IPC::Message
> message
) = 0;
33 virtual void SendMouseEvent(
34 const MouseEventWithLatencyInfo
& mouse_event
) = 0;
35 virtual void SendWheelEvent(
36 const MouseWheelEventWithLatencyInfo
& wheel_event
) = 0;
37 virtual void SendKeyboardEvent(
38 const NativeWebKeyboardEvent
& key_event
,
39 const ui::LatencyInfo
& latency_info
,
40 bool is_shortcut
) = 0;
41 virtual void SendGestureEvent(
42 const GestureEventWithLatencyInfo
& gesture_event
) = 0;
43 virtual void SendTouchEvent(
44 const TouchEventWithLatencyInfo
& touch_event
) = 0;
46 // Returns the oldest queued or in-flight keyboard event sent to the router.
47 virtual const NativeWebKeyboardEvent
* GetLastKeyboardEvent() const = 0;
49 // Allow the router to make more informed input handling decisions based on
53 FIXED_PAGE_SCALE
= 1 << 0,
54 MOBILE_VIEWPORT
= 1 << 1
56 virtual void OnViewUpdated(int view_flags
) = 0;
58 // Request a notification from the input router when all events have been
59 // fully dispatched and there are no longer any pending events.
60 // Note: This may trigger a synchronous notification if the router is empty.
61 virtual void RequestNotificationWhenFlushed() = 0;
63 // Whether there are any events pending dispatch to or ack from the renderer.
64 virtual bool HasPendingEvents() const = 0;
67 } // namespace content
69 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_H_