1// Copyright (c) 2012 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_RENDERER_PEPPER_EVENT_CONVERSION_H_
6#define CONTENT_RENDERER_PEPPER_EVENT_CONVERSION_H_
7
8#include <vector>
9
10#include "base/memory/linked_ptr.h"
11#include "content/common/content_export.h"
12#include "ppapi/c/ppb_input_event.h"
13#include "third_party/WebKit/public/web/WebInputEvent.h"
14
15struct PP_InputEvent;
16
17namespace ppapi {
18struct InputEventData;
19}
20
21namespace blink {
22class WebGamepads;
23class WebInputEvent;
24}
25
26namespace content {
27
28// Converts the given WebKit event to one or possibly multiple PP_InputEvents.
29// The generated events will be filled into the given vector. On failure, no
30// events will ge generated and the vector will be empty.
31CONTENT_EXPORT void CreateInputEventData(
32    const blink::WebInputEvent& event,
33    std::vector<ppapi::InputEventData>* pp_events);
34
35// Creates a WebInputEvent from the given PP_InputEvent.  If it fails, returns
36// NULL.  The caller owns the created object on success.
37CONTENT_EXPORT blink::WebInputEvent* CreateWebInputEvent(
38    const ppapi::InputEventData& event);
39
40// Creates an array of WebInputEvents to make the given event look like a user
41// input event on all platforms. |plugin_x| and |plugin_y| should be the
42// coordinates of a point within the plugin's area on the page.
43std::vector<linked_ptr<blink::WebInputEvent> > CreateSimulatedWebInputEvents(
44    const ppapi::InputEventData& event,
45    int plugin_x,
46    int plugin_y);
47
48// Returns the PPAPI event class for the given WebKit event type. The given
49// type should not be "Undefined" since there's no corresponding PPAPI class.
50PP_InputEvent_Class ClassifyInputEvent(blink::WebInputEvent::Type type);
51
52}  // namespace content
53
54#endif  // CONTENT_RENDERER_PEPPER_EVENT_CONVERSION_H_
55