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