From d3c026453cd334afb25f3dbb430cca3885f34580 Mon Sep 17 00:00:00 2001 From: Felipe Gomes Date: Fri, 18 Feb 2011 13:31:59 -0800 Subject: [PATCH] Bug 626016. Prevent QuickTime plugin from stealing focus when it's hidden due to SetWindow call. r=bsmedberg a=blocking-final --- dom/plugins/PluginInstanceChild.cpp | 7 +++++++ dom/plugins/PluginModuleChild.cpp | 12 +++++++++--- dom/plugins/PluginModuleChild.h | 5 ++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dom/plugins/PluginInstanceChild.cpp b/dom/plugins/PluginInstanceChild.cpp index 6425ac93480..e602491f593 100644 --- a/dom/plugins/PluginInstanceChild.cpp +++ b/dom/plugins/PluginInstanceChild.cpp @@ -937,6 +937,13 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow) switch (aWindow.type) { case NPWindowTypeWindow: { + if ((GetQuirks() & PluginModuleChild::QUIRK_QUICKTIME_AVOID_SETWINDOW) && + aWindow.width == 0 && + aWindow.height == 0) { + // Skip SetWindow call for hidden QuickTime plugins + return true; + } + if (!CreatePluginWindow()) return false; diff --git a/dom/plugins/PluginModuleChild.cpp b/dom/plugins/PluginModuleChild.cpp index 8d1dad11e14..dec578bc13e 100644 --- a/dom/plugins/PluginModuleChild.cpp +++ b/dom/plugins/PluginModuleChild.cpp @@ -110,6 +110,7 @@ PluginModuleChild::PluginModuleChild() : mQuirks(QUIRKS_NOT_INITIALIZED), mShutdownFunc(0), mInitializeFunc(0) + , mPluginFilename("") #if defined(OS_WIN) || defined(OS_MACOSX) , mGetEntryPointsFunc(0) #elif defined(MOZ_WIDGET_GTK2) @@ -183,10 +184,9 @@ PluginModuleChild::Init(const std::string& aPluginFilename, if (!InitGraphics()) return false; - nsCString filename; - filename = aPluginFilename.c_str(); + mPluginFilename = aPluginFilename.c_str(); nsCOMPtr pluginFile; - NS_NewNativeLocalFile(filename, + NS_NewNativeLocalFile(mPluginFilename, PR_TRUE, getter_AddRefs(pluginFile)); @@ -1878,6 +1878,12 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType) mQuirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO; mQuirks |= QUIRK_FLASH_FIXUP_MOUSE_CAPTURE; } + + // QuickTime plugin usually loaded with audio/mpeg mimetype + NS_NAMED_LITERAL_CSTRING(quicktime, "npqtplugin"); + if (FindInReadable(quicktime, mPluginFilename)) { + mQuirks |= QUIRK_QUICKTIME_AVOID_SETWINDOW; + } #endif } diff --git a/dom/plugins/PluginModuleChild.h b/dom/plugins/PluginModuleChild.h index eec27346b48..ae3cc437451 100644 --- a/dom/plugins/PluginModuleChild.h +++ b/dom/plugins/PluginModuleChild.h @@ -249,6 +249,9 @@ public: // Win: Addresses a flash bug with mouse capture and full screen // windows. QUIRK_FLASH_FIXUP_MOUSE_CAPTURE = 1 << 6, + // Win: QuickTime steals focus on SetWindow calls even if it's hidden. + // Avoid calling SetWindow in that case. + QUIRK_QUICKTIME_AVOID_SETWINDOW = 1 << 7, }; int GetQuirks() { return mQuirks; } @@ -278,8 +281,8 @@ private: virtual void ExitedCxxStack(); #endif - std::string mPluginFilename; PRLibrary* mLibrary; + nsCString mPluginFilename; nsCString mUserAgent; int mQuirks;