OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_CHILD_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | |
6 #define CONTENT_CHILD_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "third_party/npapi/bindings/npapi.h" | |
10 | |
11 namespace blink { | |
12 class WebInputEvent; | |
13 class WebKeyboardEvent; | |
14 class WebMouseEvent; | |
15 class WebMouseWheelEvent; | |
16 } | |
17 | |
18 namespace content { | |
19 | |
20 // Utility class to translating WebInputEvent structs to equivalent structures | |
21 // suitable for sending to Mac plugins (via NPP_HandleEvent). | |
22 class PluginWebEventConverter { | |
23 public: | |
24 PluginWebEventConverter(); | |
25 virtual ~PluginWebEventConverter(); | |
26 | |
27 // Initializes a converter for the given web event. Returns false if the event | |
28 // could not be converted. | |
29 bool InitWithEvent(const blink::WebInputEvent& web_event); | |
30 | |
31 // Returns a pointer to a plugin event--suitable for passing to | |
32 // NPP_HandleEvent--corresponding to the the web event this converter was | |
33 // created with. The pointer is valid only as long as this object is. | |
34 // Returns NULL iff InitWithEvent returned false. | |
35 NPCocoaEvent* plugin_event() { return &cocoa_event_; } | |
36 | |
37 private: | |
38 // Stores a converted plugin representation of the given web event, suitable | |
39 // for returning from plugin_event. | |
40 // Returns true if the event was successfully converted. | |
41 bool ConvertKeyboardEvent(const blink::WebKeyboardEvent& web_event); | |
42 bool ConvertMouseEvent(const blink::WebMouseEvent& web_event); | |
43 bool ConvertMouseWheelEvent(const blink::WebMouseWheelEvent& web_event); | |
44 | |
45 // Returns the Cocoa translation of web_event's modifiers. | |
46 static NSUInteger CocoaModifiers(const blink::WebInputEvent& web_event); | |
47 | |
48 NPCocoaEvent cocoa_event_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverter); | |
51 }; | |
52 | |
53 } // namespace content | |
54 | |
55 #endif // CONTENT_CHILD_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | |
OLD | NEW |