Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / child / npapi / plugin_web_event_converter_mac.h
bloba1fc326ef0cd2a5b3e6ba6929895dd9ec38b8d42
1 // Copyright (c) 2010 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_CHILD_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_
6 #define CONTENT_CHILD_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_
8 #include "third_party/npapi/bindings/npapi.h"
10 namespace blink {
11 class WebInputEvent;
12 class WebKeyboardEvent;
13 class WebMouseEvent;
14 class WebMouseWheelEvent;
17 namespace content {
19 // Utility class to translating WebInputEvent structs to equivalent structures
20 // suitable for sending to Mac plugins (via NPP_HandleEvent).
21 class PluginWebEventConverter {
22 public:
23 PluginWebEventConverter();
24 virtual ~PluginWebEventConverter();
26 // Initializes a converter for the given web event. Returns false if the event
27 // could not be converted.
28 bool InitWithEvent(const blink::WebInputEvent& web_event);
30 // Returns a pointer to a plugin event--suitable for passing to
31 // NPP_HandleEvent--corresponding to the the web event this converter was
32 // created with. The pointer is valid only as long as this object is.
33 // Returns NULL iff InitWithEvent returned false.
34 NPCocoaEvent* plugin_event() { return &cocoa_event_; }
36 private:
37 // Stores a converted plugin representation of the given web event, suitable
38 // for returning from plugin_event.
39 // Returns true if the event was successfully converted.
40 bool ConvertKeyboardEvent(const blink::WebKeyboardEvent& web_event);
41 bool ConvertMouseEvent(const blink::WebMouseEvent& web_event);
42 bool ConvertMouseWheelEvent(const blink::WebMouseWheelEvent& web_event);
44 // Returns the Cocoa translation of web_event's modifiers.
45 static NSUInteger CocoaModifiers(const blink::WebInputEvent& web_event);
47 NPCocoaEvent cocoa_event_;
49 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverter);
52 } // namespace content
54 #endif // CONTENT_CHILD_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_