OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | 5 #ifndef WEBKIT_GLUE_PLUGIN_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ |
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | 6 #define WEBKIT_GLUE_PLUGIN_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ |
7 | 7 |
8 #include "third_party/npapi/bindings/npapi.h" | 8 #include "third_party/npapi/bindings/npapi.h" |
9 | 9 |
10 namespace WebKit { | 10 namespace WebKit { |
11 class WebInputEvent; | 11 class WebInputEvent; |
12 class WebKeyboardEvent; | 12 class WebKeyboardEvent; |
13 class WebMouseEvent; | 13 class WebMouseEvent; |
14 class WebMouseWheelEvent; | 14 class WebMouseWheelEvent; |
15 } | 15 } |
16 | 16 |
17 namespace webkit { | |
18 namespace npapi { | |
19 | |
20 // Utility class to translating WebInputEvent structs to equivalent structures | 17 // Utility class to translating WebInputEvent structs to equivalent structures |
21 // suitable for sending to Mac plugins (via NPP_HandleEvent). | 18 // suitable for sending to Mac plugins (via NPP_HandleEvent). |
22 class PluginWebEventConverter { | 19 class PluginWebEventConverter { |
23 public: | 20 public: |
24 PluginWebEventConverter() {} | 21 PluginWebEventConverter() {} |
25 virtual ~PluginWebEventConverter() {} | 22 virtual ~PluginWebEventConverter() {} |
26 | 23 |
27 // Initializes a converter for the given web event. Returns false if the event | 24 // Initializes a converter for the given web event. Returns false if the event |
28 // could not be converted. | 25 // could not be converted. |
29 virtual bool InitWithEvent(const WebKit::WebInputEvent& web_event); | 26 virtual bool InitWithEvent(const WebKit::WebInputEvent& web_event); |
30 | 27 |
31 // Returns a pointer to a plugin event--suitable for passing to | 28 // Returns a pointer to a plugin event--suitable for passing to |
32 // NPP_HandleEvent--corresponding to the the web event this converter was | 29 // 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. | 30 // created with. The pointer is valid only as long as this object is. |
34 // Returns NULL iff InitWithEvent returned false. | 31 // Returns NULL iff InitWithEvent returned false. |
35 virtual void* plugin_event() = 0; | 32 virtual void* plugin_event() = 0; |
36 | 33 |
37 protected: | 34 protected: |
38 // To be overridden by subclasses to store a converted plugin representation | 35 // To be overridden by subclasses to store a converted plugin representation |
39 // of the given web event, suitable for returning from plugin_event. | 36 // of the given web event, suitable for returning from plugin_event. |
40 // Returns true if the event was successfully converted. | 37 // Returns true if the event was successfully converted. |
41 virtual bool ConvertKeyboardEvent( | 38 virtual bool ConvertKeyboardEvent( |
42 const WebKit::WebKeyboardEvent& web_event) = 0; | 39 const WebKit::WebKeyboardEvent& web_event) = 0; |
43 virtual bool ConvertMouseEvent(const WebKit::WebMouseEvent& web_event) = 0; | 40 virtual bool ConvertMouseEvent(const WebKit::WebMouseEvent& web_event) = 0; |
44 virtual bool ConvertMouseWheelEvent( | 41 virtual bool ConvertMouseWheelEvent( |
45 const WebKit::WebMouseWheelEvent& web_event) = 0; | 42 const WebKit::WebMouseWheelEvent& web_event) = 0; |
46 | 43 |
47 private: | 44 private: |
48 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverter); | 45 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverter); |
49 }; | 46 }; |
50 | 47 |
51 // Factory for generating PluginWebEventConverter objects by event model. | 48 // Factory for generating PluginWebEventConverter objects by event model. |
52 class PluginWebEventConverterFactory { | 49 class PluginWebEventConverterFactory { |
53 public: | 50 public: |
54 // Returns a new PluginWebEventConverter corresponding to the given plugin | 51 // Returns a new PluginWebEventConverter corresponding to the given plugin |
55 // event model. | 52 // event model. |
56 static PluginWebEventConverter* | 53 static PluginWebEventConverter* |
57 CreateConverterForModel(NPEventModel event_model); | 54 CreateConverterForModel(NPEventModel event_model); |
58 | 55 |
59 private: | 56 private: |
60 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverterFactory); | 57 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverterFactory); |
61 }; | 58 }; |
62 | 59 |
63 } // namespace npapi | 60 #endif // WEBKIT_GLUE_PLUGIN_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ |
64 } // namespace webkit | |
65 | |
66 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | |
OLD | NEW |