summaryrefslogtreecommitdiffstats
path: root/content/child/npapi
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-19 01:53:20 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-19 01:53:20 +0000
commit9c85baf9bcacff38dc490aa17261f5a421b31f92 (patch)
tree0a6f8ffeef7a28e63f263689102bb84683fe3762 /content/child/npapi
parent298cacdbf8424d109409bc8174100bb2862d7560 (diff)
downloadchromium_src-9c85baf9bcacff38dc490aa17261f5a421b31f92.zip
chromium_src-9c85baf9bcacff38dc490aa17261f5a421b31f92.tar.gz
chromium_src-9c85baf9bcacff38dc490aa17261f5a421b31f92.tar.bz2
Fix windowless mouse events not working in NPAPI Flash in Chrome desktop Windows AURA.
Flash assumes the container window which is returned via the NPNVnetscapeWindow property corresponds to the bounds of the webpage. This is not true in AURA where we return the HWND of the main AURA window. This causes the translations done by NPAPI flash to break. The fixes are as below:- 1. Create a dummy empty window which corresponds to the bounds of the webpage in the RenderWidgetHostViewAura class. We return this window to the plugin when it requests the NPNVnetscapeWindow property. 2. Intercept the WindowFromPoint API and return the dummy parent window to flash. BUG=301548 R=jam@chromium.org, jam Review URL: https://codereview.chromium.org/69953030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/child/npapi')
-rw-r--r--content/child/npapi/webplugin_delegate_impl.h9
-rw-r--r--content/child/npapi/webplugin_delegate_impl_win.cc27
2 files changed, 36 insertions, 0 deletions
diff --git a/content/child/npapi/webplugin_delegate_impl.h b/content/child/npapi/webplugin_delegate_impl.h
index ea26204..e3bfc46 100644
--- a/content/child/npapi/webplugin_delegate_impl.h
+++ b/content/child/npapi/webplugin_delegate_impl.h
@@ -75,6 +75,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
PLUGIN_QUIRK_WINDOWLESS_NO_RIGHT_CLICK = 32768, // Linux
PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL = 65536, // Windows.
PLUGIN_QUIRK_EMULATE_IME = 131072, // Windows.
+ PLUGIN_QUIRK_FAKE_WINDOW_FROM_POINT = 262144, // Windows.
};
static WebPluginDelegateImpl* Create(WebPlugin* plugin,
@@ -385,6 +386,14 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
// GetProcAddress intercepter for windowless plugins.
static FARPROC WINAPI GetProcAddressPatch(HMODULE module, LPCSTR name);
+#if defined(USE_AURA)
+ // WindowFromPoint patch for Flash windowless plugins. When flash receives
+ // mouse move messages it calls the WindowFromPoint API to eventually convert
+ // the mouse coordinates to screen. We need to return the dummy plugin parent
+ // window for Aura to ensure that these conversions occur correctly.
+ static HWND WINAPI WindowFromPointPatch(POINT point);
+#endif
+
// The mouse hook proc which handles mouse capture in windowed plugins.
static LRESULT CALLBACK MouseHookProc(int code, WPARAM wParam,
LPARAM lParam);
diff --git a/content/child/npapi/webplugin_delegate_impl_win.cc b/content/child/npapi/webplugin_delegate_impl_win.cc
index 3f6287e..7ea19e8 100644
--- a/content/child/npapi/webplugin_delegate_impl_win.cc
+++ b/content/child/npapi/webplugin_delegate_impl_win.cc
@@ -88,6 +88,9 @@ base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_reg_enum_key_ex_w =
base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_get_proc_address =
LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_window_from_point =
+ LAZY_INSTANCE_INITIALIZER;
+
// http://crbug.com/16114
// Enforces providing a valid device context in NPWindow, so that NPP_SetWindow
// is never called with NPNWindoTypeDrawable and NPWindow set to NULL.
@@ -261,6 +264,9 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS;
quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE;
quirks_ |= PLUGIN_QUIRK_EMULATE_IME;
+#if defined(USE_AURA)
+ quirks_ |= PLUGIN_QUIRK_FAKE_WINDOW_FROM_POINT;
+#endif
} else if (filename == kAcrobatReaderPlugin) {
// Check for the version number above or equal 9.
int major_version = GetPluginMajorVersion(plugin_info);
@@ -414,6 +420,13 @@ bool WebPluginDelegateImpl::PlatformInitialize() {
GetProcAddressPatch);
}
+ if (windowless_ && !g_iat_patch_window_from_point.Pointer()->is_patched() &&
+ (quirks_ & PLUGIN_QUIRK_FAKE_WINDOW_FROM_POINT)) {
+ g_iat_patch_window_from_point.Pointer()->Patch(
+ GetPluginPath().value().c_str(), "user32.dll", "WindowFromPoint",
+ WebPluginDelegateImpl::WindowFromPointPatch);
+ }
+
return true;
}
@@ -434,6 +447,9 @@ void WebPluginDelegateImpl::PlatformDestroyInstance() {
if (g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched())
g_iat_patch_reg_enum_key_ex_w.Pointer()->Unpatch();
+ if (g_iat_patch_window_from_point.Pointer()->is_patched())
+ g_iat_patch_window_from_point.Pointer()->Unpatch();
+
if (mouse_hook_) {
UnhookWindowsHookEx(mouse_hook_);
mouse_hook_ = NULL;
@@ -1460,6 +1476,17 @@ FARPROC WINAPI WebPluginDelegateImpl::GetProcAddressPatch(HMODULE module,
return ::GetProcAddress(module, name);
}
+#if defined(USE_AURA)
+HWND WINAPI WebPluginDelegateImpl::WindowFromPointPatch(POINT point) {
+ HWND window = WindowFromPoint(point);
+ HWND child = GetWindow(window, GW_CHILD);
+ if (::IsWindow(child) &&
+ ::GetProp(child, content::kPluginDummyParentProperty))
+ return child;
+ return window;
+}
+#endif
+
void WebPluginDelegateImpl::HandleCaptureForMessage(HWND window,
UINT message) {
if (gfx::GetClassName(window) != base::string16(kNativeWindowClassName))