event_conversion.h revision a02191e04bc25c4935f804f2c080ae28663d096d
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// Use of this source code is governed by a BSD-style license that can be
35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// found in the LICENSE file.
45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner#ifndef CONTENT_RENDERER_PEPPER_EVENT_CONVERSION_H_
60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner#define CONTENT_RENDERER_PEPPER_EVENT_CONVERSION_H_
75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <vector>
95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "base/memory/linked_ptr.h"
115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "ppapi/c/ppb_input_event.h"
125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "third_party/WebKit/public/web/WebInputEvent.h"
135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
14c4a1dea2dc56bd1357ec91b829a0b9e68229a13eDaniel Dunbarstruct PP_InputEvent;
150979c805475d1ba49b5d6ef93c4d2ce6d2eab6edDouglas Gregor
16a4d55d89c8076b402bb168e3edeef0c2cd2a78c3Chris Lattnernamespace ppapi {
172eadfb638eb1bb6ccfd6fd0453e764d47e27eed9Chris Lattnerstruct InputEventData;
18a4d55d89c8076b402bb168e3edeef0c2cd2a78c3Chris Lattner}
1998cd599ee8a9b259ed7388ee2921a20d97658864Douglas Gregor
20aaba5e346dffdbad5d1c42765a89e4a7afb0da67Douglas Gregornamespace blink {
2119cc4abea06a9b49e0e16a50d335c064cd723572Anders Carlssonclass WebGamepads;
225f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass WebInputEvent;
2308f92e3a5dead1f1ee656678a7f06e43279d6e50Chris Lattner}
2408f92e3a5dead1f1ee656678a7f06e43279d6e50Chris Lattner
257a614d8380297fcd2bc23986241905d97222948cRichard Smithnamespace content {
261b63e4f732dbc73d90abf886b4d21f8e3a165f6dChris Lattner
2708f92e3a5dead1f1ee656678a7f06e43279d6e50Chris Lattner// Converts the given WebKit event to one or possibly multiple PP_InputEvents.
28da5a6b6d9fd52899499d5b7b46273ec844dcaa6eChris Lattner// The generated events will be filled into the given vector. On failure, no
29cf3293eaeb3853d12cff47e648bbe835004e929fDouglas Gregor// events will ge generated and the vector will be empty.
303a082d81006e7a2e01a6e431a22e21c78490ff8fAnders Carlssonvoid CreateInputEventData(const blink::WebInputEvent& event,
31ffb4b6e299069139908540ce97be4462e16b53a4Douglas Gregor                          std::vector<ppapi::InputEventData>* pp_events);
325f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer
335f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// Creates a WebInputEvent from the given PP_InputEvent.  If it fails, returns
342b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner// NULL.  The caller owns the created object on success.
352b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattnerblink::WebInputEvent* CreateWebInputEvent(const ppapi::InputEventData& event);
362b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner
372b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner// Creates an array of WebInputEvents to make the given event look like a user
382b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner// input event on all platforms. |plugin_x| and |plugin_y| should be the
39f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne// coordinates of a point within the plugin's area on the page.
40f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbournestd::vector<linked_ptr<blink::WebInputEvent> > CreateSimulatedWebInputEvents(
412b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner    const ppapi::InputEventData& event,
42f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne    int plugin_x,
43c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt    int plugin_y);
44f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne
45c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt// Returns the PPAPI event class for the given WebKit event type. The given
46f111d935722ed488144600cea5ed03a6b5069e8fPeter Collingbourne// type should not be "Undefined" since there's no corresponding PPAPI class.
472b334bb3126a67895813e49e6228dad4aec0b4d6Chris LattnerPP_InputEvent_Class ClassifyInputEvent(blink::WebInputEvent::Type type);
482de56d1d0c3a504ad1529de2677628bdfbb95cd4John McCall
492b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner}  // namespace content
502b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner
512b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner#endif  // CONTENT_RENDERER_PEPPER_EVENT_CONVERSION_H_
522b334bb3126a67895813e49e6228dad4aec0b4d6Chris Lattner