| Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc
|
| ===================================================================
|
| --- webkit/plugins/ppapi/ppapi_plugin_instance.cc (revision 91372)
|
| +++ webkit/plugins/ppapi/ppapi_plugin_instance.cc (working copy)
|
| @@ -23,6 +23,7 @@
|
| #include "ppapi/c/ppb_core.h"
|
| #include "ppapi/c/ppb_instance.h"
|
| #include "ppapi/c/ppb_messaging.h"
|
| +#include "ppapi/c/ppp_input_event.h"
|
| #include "ppapi/c/ppp_instance.h"
|
| #include "ppapi/c/ppp_messaging.h"
|
| #include "ppapi/c/private/ppb_instance_private.h"
|
| @@ -55,6 +56,7 @@
|
| #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_image_data_impl.h"
|
| +#include "webkit/plugins/ppapi/ppb_input_event_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
|
| #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
|
| @@ -276,10 +278,12 @@
|
| find_identifier_(-1),
|
| plugin_find_interface_(NULL),
|
| plugin_messaging_interface_(NULL),
|
| + plugin_input_event_interface_(NULL),
|
| + plugin_private_interface_(NULL),
|
| plugin_pdf_interface_(NULL),
|
| - plugin_private_interface_(NULL),
|
| plugin_selection_interface_(NULL),
|
| plugin_zoom_interface_(NULL),
|
| + checked_for_plugin_input_event_interface_(false),
|
| checked_for_plugin_messaging_interface_(false),
|
| plugin_print_interface_(NULL),
|
| plugin_graphics_3d_interface_(NULL),
|
| @@ -287,7 +291,9 @@
|
| fullscreen_container_(NULL),
|
| fullscreen_(false),
|
| message_channel_(NULL),
|
| - sad_plugin_(NULL) {
|
| + sad_plugin_(NULL),
|
| + input_event_mask_(0),
|
| + filtered_input_event_mask_(0) {
|
| pp_instance_ = ResourceTracker::Get()->AddInstance(this);
|
|
|
| memset(¤t_print_settings_, 0, sizeof(current_print_settings_));
|
| @@ -504,11 +510,43 @@
|
| WebCursorInfo* cursor_info) {
|
| // Keep a reference on the stack. See NOTE above.
|
| scoped_refptr<PluginInstance> ref(this);
|
| +
|
| + bool rv = false;
|
| + if (LoadInputEventInterface()) {
|
| + PP_InputEvent_Class event_class = ClassifyInputEvent(event.type);
|
| + if (!event_class)
|
| + return false;
|
| +
|
| + if ((filtered_input_event_mask_ & event_class) ||
|
| + (input_event_mask_ & event_class)) {
|
| + // Actually send the event.
|
| + std::vector< ::ppapi::InputEventData > events;
|
| + CreateInputEventData(event, &events);
|
| +
|
| + // Each input event may generate more than one PP_InputEvent.
|
| + ResourceTracker* tracker = ResourceTracker::Get();
|
| + for (size_t i = 0; i < events.size(); i++) {
|
| + if (filtered_input_event_mask_ & event_class)
|
| + events[i].is_filtered = true;
|
| + scoped_refptr<PPB_InputEvent_Impl> event_resource(
|
| + new PPB_InputEvent_Impl(this, events[i]));
|
| + PP_Resource resource = event_resource->GetReference();
|
| +
|
| + rv |= PPBoolToBool(plugin_input_event_interface_->HandleInputEvent(
|
| + pp_instance(), event_resource->GetReference()));
|
| +
|
| + // Release the reference we took above.
|
| + tracker->UnrefResource(resource);
|
| + }
|
| + }
|
| + }
|
| +
|
| + // For compatibility, also send all input events through the old interface.
|
| + // TODO(brettw) remove this.
|
| std::vector<PP_InputEvent> pp_events;
|
| CreatePPEvent(event, &pp_events);
|
|
|
| // Each input event may generate more than one PP_InputEvent.
|
| - bool rv = false;
|
| for (size_t i = 0; i < pp_events.size(); i++) {
|
| rv |= PPBoolToBool(instance_interface_->HandleInputEvent(pp_instance(),
|
| &pp_events[i]));
|
| @@ -715,6 +753,16 @@
|
| return !!plugin_find_interface_;
|
| }
|
|
|
| +bool PluginInstance::LoadInputEventInterface() {
|
| + if (!checked_for_plugin_input_event_interface_) {
|
| + checked_for_plugin_input_event_interface_ = true;
|
| + plugin_input_event_interface_ =
|
| + static_cast<const PPP_InputEvent*>(module_->GetPluginInterface(
|
| + PPP_INPUT_EVENT_INTERFACE));
|
| + }
|
| + return !!plugin_input_event_interface_;
|
| +}
|
| +
|
| bool PluginInstance::LoadMessagingInterface() {
|
| if (!checked_for_plugin_messaging_interface_) {
|
| checked_for_plugin_messaging_interface_ = true;
|
| @@ -1508,5 +1556,32 @@
|
| return PP_TRUE;
|
| }
|
|
|
| +int32_t PluginInstance::RequestInputEvents(PP_Instance instance,
|
| + uint32_t event_classes) {
|
| + // Don't allow unfiltered keyboard access. The error return value will be
|
| + // generated by ValidateRequestInputEvents.
|
| + uint32_t fixed_classes =
|
| + event_classes & ~uint32_t(PP_INPUTEVENT_CLASS_KEYBOARD);
|
| +
|
| + input_event_mask_ |= fixed_classes;
|
| + filtered_input_event_mask_ &= ~(fixed_classes);
|
| +
|
| + // Validate based on the original input to catch errors.
|
| + return ValidateRequestInputEvents(false, event_classes);
|
| +}
|
| +
|
| +int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance,
|
| + uint32_t event_classes) {
|
| + filtered_input_event_mask_ |= event_classes;
|
| + input_event_mask_ &= ~(event_classes);
|
| + return ValidateRequestInputEvents(true, event_classes);
|
| +}
|
| +
|
| +void PluginInstance::ClearInputEventRequest(PP_Instance instance,
|
| + uint32_t event_classes) {
|
| + input_event_mask_ &= ~(event_classes);
|
| + filtered_input_event_mask_ &= ~(event_classes);
|
| +}
|
| +
|
| } // namespace ppapi
|
| } // namespace webkit
|
|
|