Home | History | Annotate | Download | only in input
      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.
      4 
      5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_CLIENT_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_CLIENT_H_
      7 
      8 #include "content/common/content_export.h"
      9 #include "content/port/browser/event_with_latency_info.h"
     10 #include "content/port/common/input_event_ack_state.h"
     11 #include "content/public/browser/native_web_keyboard_event.h"
     12 #include "third_party/WebKit/public/web/WebInputEvent.h"
     13 
     14 namespace ui {
     15 struct LatencyInfo;
     16 }
     17 
     18 namespace content {
     19 
     20 class CONTENT_EXPORT InputRouterClient {
     21  public:
     22   virtual ~InputRouterClient() {}
     23 
     24   // Called just prior to events being sent to the renderer, giving the client
     25   // a chance to perform in-process event filtering.
     26   // The returned disposition will yield the following behavior:
     27   //   * |NOT_CONSUMED| will result in |input_event| being sent as usual.
     28   //   * |CONSUMED| or |NO_CONSUMER_EXISTS| will trigger the appropriate ack.
     29   //   * |UNKNOWN| will result in |input_event| being dropped.
     30   virtual InputEventAckState FilterInputEvent(
     31       const WebKit::WebInputEvent& input_event,
     32       const ui::LatencyInfo& latency_info) = 0;
     33 
     34   // Called each time a WebInputEvent IPC is sent.
     35   virtual void IncrementInFlightEventCount() = 0;
     36 
     37   // Called each time a WebInputEvent ACK IPC is received.
     38   virtual void DecrementInFlightEventCount() = 0;
     39 
     40   // Called when the renderer notifies that it has touch event handlers.
     41   virtual void OnHasTouchEventHandlers(bool has_handlers) = 0;
     42 
     43   // Called upon Send*Event. Should return true if the event should be sent, and
     44   // false if the event should be dropped.
     45   virtual bool OnSendKeyboardEvent(
     46       const NativeWebKeyboardEvent& key_event,
     47       const ui::LatencyInfo& latency_info,
     48       bool* is_shortcut) = 0;
     49   virtual bool OnSendWheelEvent(
     50       const MouseWheelEventWithLatencyInfo& wheel_event) = 0;
     51   virtual bool OnSendMouseEvent(
     52       const MouseEventWithLatencyInfo& mouse_event) = 0;
     53   virtual bool OnSendTouchEvent(
     54       const TouchEventWithLatencyInfo& touch_event) = 0;
     55   virtual bool OnSendGestureEvent(
     56       const GestureEventWithLatencyInfo& gesture_event) = 0;
     57   virtual bool OnSendMouseEventImmediately(
     58       const MouseEventWithLatencyInfo& mouse_event) = 0;
     59   virtual bool OnSendTouchEventImmediately(
     60       const TouchEventWithLatencyInfo& touch_event) = 0;
     61   virtual bool OnSendGestureEventImmediately(
     62       const GestureEventWithLatencyInfo& gesture_event) = 0;
     63 
     64   // Called upon event ack receipt from the renderer.
     65   virtual void OnKeyboardEventAck(const NativeWebKeyboardEvent& event,
     66                                   InputEventAckState ack_result) = 0;
     67   virtual void OnWheelEventAck(const WebKit::WebMouseWheelEvent& event,
     68                                InputEventAckState ack_result) = 0;
     69   virtual void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
     70                                InputEventAckState ack_result) = 0;
     71   virtual void OnGestureEventAck(const WebKit::WebGestureEvent& event,
     72                                  InputEventAckState ack_result) = 0;
     73   virtual void OnUnexpectedEventAck(bool bad_message) = 0;
     74 };
     75 
     76 } // namespace content
     77 
     78 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_ROUTER_CLIENT_H_
     79