summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-11 09:36:35 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-11 09:36:35 +0000
commitde9b559da8f3b2bb3ea79d31571a42249c678aa6 (patch)
tree389b5a97c7c43d5503ff8d8a70c744ac3844b6af
parent322099e0cdfb35bf2ce63108a29aa4c449aa34e2 (diff)
downloadchromium_src-de9b559da8f3b2bb3ea79d31571a42249c678aa6.zip
chromium_src-de9b559da8f3b2bb3ea79d31571a42249c678aa6.tar.gz
chromium_src-de9b559da8f3b2bb3ea79d31571a42249c678aa6.tar.bz2
content_shell: Add event filtering to PluginObject
For testing input event filtering in plugins, this change adds a "alwaysFilterEvents" argument to PluginObject. That argument causes the plugin to always return a non-zero value from HandleEvent, which requests the event be "filtered" to stop propagating it to other handlers on the page. BUG=324351 Review URL: https://codereview.chromium.org/191383005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256163 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/shell/tools/plugin/PluginObject.h1
-rw-r--r--content/shell/tools/plugin/main.cpp22
2 files changed, 17 insertions, 6 deletions
diff --git a/content/shell/tools/plugin/PluginObject.h b/content/shell/tools/plugin/PluginObject.h
index ff40a46..0c037e8 100644
--- a/content/shell/tools/plugin/PluginObject.h
+++ b/content/shell/tools/plugin/PluginObject.h
@@ -74,6 +74,7 @@ typedef struct {
void* coreAnimationLayer;
#endif
NPWindow lastWindow;
+ NPBool alwaysFilterEvents;
} PluginObject;
extern NPClass* createPluginClass(void);
diff --git a/content/shell/tools/plugin/main.cpp b/content/shell/tools/plugin/main.cpp
index 3236df6..0a4c3b8 100644
--- a/content/shell/tools/plugin/main.cpp
+++ b/content/shell/tools/plugin/main.cpp
@@ -199,6 +199,7 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
obj->eventModel = eventModel;
obj->coreAnimationLayer = 0;
#endif // XP_MACOSX
+ obj->alwaysFilterEvents = false;
string testIdentifier;
const char* onNewScript = 0;
@@ -292,6 +293,8 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
else
assert(false);
browser->setvalue(instance, NPPVpluginWindowBool, windowed);
+ } else if (!strcasecmp(argn[i], "alwaysFilterEvents")) {
+ obj->alwaysFilterEvents = true;
}
}
@@ -786,22 +789,29 @@ int16_t NPP_HandleEvent(NPP instance, void *event)
if (obj->pluginTest->NPP_HandleEvent(event) == 1)
return 1;
+ int16_t ret = 0;
#ifdef XP_MACOSX
#ifndef NP_NO_CARBON
if (obj->eventModel == NPEventModelCarbon)
- return handleEventCarbon(instance, obj, static_cast<EventRecord*>(event));
+ ret = handleEventCarbon(instance, obj, static_cast<EventRecord*>(event));
#endif
+ assert(obj->eventModel == NPEventModelCarbon ||
+ obj->eventModel == NPEventModelCocoa);
+ if (obj->eventModel == NPEventModelCocoa)
+ ret = handleEventCocoa(instance, obj, static_cast<NPCocoaEvent*>(event));
- assert(obj->eventModel == NPEventModelCocoa);
- return handleEventCocoa(instance, obj, static_cast<NPCocoaEvent*>(event));
#elif defined(XP_UNIX)
- return handleEventX11(instance, obj, static_cast<XEvent*>(event));
+ ret = handleEventX11(instance, obj, static_cast<XEvent*>(event));
#elif defined(XP_WIN)
- return handleEventWin(instance, obj, static_cast<NPEvent*>(event));
+ ret = handleEventWin(instance, obj, static_cast<NPEvent*>(event));
#else
// FIXME: Implement for other platforms.
- return 0;
+ return obj->alwaysFilterEvents;
#endif // XP_MACOSX
+
+ if (ret == 0 && obj->alwaysFilterEvents)
+ return 1;
+ return ret;
}
void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData)