| 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_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ |
| 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | 6 #define WEBKIT_PLUGINS_NPAPI_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 { | 17 namespace webkit { |
| 18 namespace npapi { | 18 namespace npapi { |
| 19 | 19 |
| 20 // Utility class to translating WebInputEvent structs to equivalent structures | 20 // Utility class to translating WebInputEvent structs to equivalent structures |
| 21 // suitable for sending to Mac plugins (via NPP_HandleEvent). | 21 // suitable for sending to Mac plugins (via NPP_HandleEvent). |
| 22 class PluginWebEventConverter { | 22 class PluginWebEventConverter { |
| 23 public: | 23 public: |
| 24 PluginWebEventConverter() {} | 24 PluginWebEventConverter(); |
| 25 virtual ~PluginWebEventConverter() {} | 25 virtual ~PluginWebEventConverter(); |
| 26 | 26 |
| 27 // Initializes a converter for the given web event. Returns false if the event | 27 // Initializes a converter for the given web event. Returns false if the event |
| 28 // could not be converted. | 28 // could not be converted. |
| 29 virtual bool InitWithEvent(const WebKit::WebInputEvent& web_event); | 29 bool InitWithEvent(const WebKit::WebInputEvent& web_event); |
| 30 | 30 |
| 31 // Returns a pointer to a plugin event--suitable for passing to | 31 // Returns a pointer to a plugin event--suitable for passing to |
| 32 // NPP_HandleEvent--corresponding to the the web event this converter was | 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. | 33 // created with. The pointer is valid only as long as this object is. |
| 34 // Returns NULL iff InitWithEvent returned false. | 34 // Returns NULL iff InitWithEvent returned false. |
| 35 virtual void* plugin_event() = 0; | 35 NPCocoaEvent* plugin_event() { return &cocoa_event_; } |
| 36 | |
| 37 protected: | |
| 38 // To be overridden by subclasses to store a converted plugin representation | |
| 39 // of the given web event, suitable for returning from plugin_event. | |
| 40 // Returns true if the event was successfully converted. | |
| 41 virtual bool ConvertKeyboardEvent( | |
| 42 const WebKit::WebKeyboardEvent& web_event) = 0; | |
| 43 virtual bool ConvertMouseEvent(const WebKit::WebMouseEvent& web_event) = 0; | |
| 44 virtual bool ConvertMouseWheelEvent( | |
| 45 const WebKit::WebMouseWheelEvent& web_event) = 0; | |
| 46 | 36 |
| 47 private: | 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 WebKit::WebKeyboardEvent& web_event); |
| 42 bool ConvertMouseEvent(const WebKit::WebMouseEvent& web_event); |
| 43 bool ConvertMouseWheelEvent(const WebKit::WebMouseWheelEvent& web_event); |
| 44 |
| 45 // Returns the Cocoa translation of web_event's modifiers. |
| 46 static NSUInteger CocoaModifiers(const WebKit::WebInputEvent& web_event); |
| 47 |
| 48 NPCocoaEvent cocoa_event_; |
| 49 |
| 48 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverter); | 50 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverter); |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 // Factory for generating PluginWebEventConverter objects by event model. | |
| 52 class PluginWebEventConverterFactory { | |
| 53 public: | |
| 54 // Returns a new PluginWebEventConverter corresponding to the given plugin | |
| 55 // event model. | |
| 56 static PluginWebEventConverter* | |
| 57 CreateConverterForModel(NPEventModel event_model); | |
| 58 | |
| 59 private: | |
| 60 DISALLOW_COPY_AND_ASSIGN(PluginWebEventConverterFactory); | |
| 61 }; | |
| 62 | |
| 63 } // namespace npapi | 53 } // namespace npapi |
| 64 } // namespace webkit | 54 } // namespace webkit |
| 65 | 55 |
| 66 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ | 56 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_WEB_EVENT_CONVERTER_MAC_H_ |
| OLD | NEW |