From 1bf5c1fd2f0cbe5c104b8826b25bf74e438bcdf2 Mon Sep 17 00:00:00 2001 From: "mats.palmgren@bredband.net" Date: Wed, 16 Apr 2008 13:06:48 -0700 Subject: [PATCH] Stop QuickTime and Flip4Mac plugins directly when requested (not off an event). b=426524 r+sr=jst a1.9=beltzner --- layout/generic/nsObjectFrame.cpp | 50 +++++++++++++------ modules/plugin/base/public/nsPIPluginHost.idl | 7 ++- modules/plugin/base/src/nsPluginHostImpl.cpp | 8 +++ 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 5d6f2d1f8e5..9f612866cc7 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -427,6 +427,18 @@ public: } } + const char* GetPluginName() + { + if (mInstance && mPluginHost) { + nsCOMPtr piPluginHost = do_QueryInterface(mPluginHost); + char* name = NULL; + if (NS_SUCCEEDED(piPluginHost->GetPluginName(mInstance, &name)) && + name) + return name; + } + return ""; + } + private: void FixUpURLS(const nsString &name, nsAString &value); @@ -1741,6 +1753,28 @@ GetMIMEType(nsIPluginInstance *aPluginInstance) return ""; } +static PRBool +MatchPluginName(nsPluginInstanceOwner *aInstanceOwner, const char *aPluginName) +{ + return strncmp(aInstanceOwner->GetPluginName(), + aPluginName, + strlen(aPluginName)) == 0; +} + +static PRBool +DoDelayedStop(nsPluginInstanceOwner *aInstanceOwner, PRBool aDelayedStop) +{ + // Don't delay stopping QuickTime (bug 425157), Flip4Mac (bug 426524). + if (aDelayedStop && + !::MatchPluginName(aInstanceOwner, "QuickTime") && + !::MatchPluginName(aInstanceOwner, "Flip4Mac")) { + nsCOMPtr evt = new nsStopPluginRunnable(aInstanceOwner); + NS_DispatchToCurrentThread(evt); + return PR_TRUE; + } + return PR_FALSE; +} + static void DoStopPlugin(nsPluginInstanceOwner *aInstanceOwner, PRBool aDelayedStop) { @@ -1779,14 +1813,8 @@ DoStopPlugin(nsPluginInstanceOwner *aInstanceOwner, PRBool aDelayedStop) else inst->SetWindow(nsnull); - // Don't delay stopping Quicktime (bug 425157). - if (aDelayedStop && - strcmp(::GetMIMEType(inst), "video/quicktime") != 0) { - nsCOMPtr evt = new nsStopPluginRunnable(aInstanceOwner); - NS_DispatchToCurrentThread(evt); - + if (DoDelayedStop(aInstanceOwner, aDelayedStop)) return; - } inst->Stop(); inst->Destroy(); @@ -1798,14 +1826,8 @@ DoStopPlugin(nsPluginInstanceOwner *aInstanceOwner, PRBool aDelayedStop) else inst->SetWindow(nsnull); - // Don't delay stopping Quicktime (bug 425157). - if (aDelayedStop && - strcmp(::GetMIMEType(inst), "video/quicktime") != 0) { - nsCOMPtr evt = new nsStopPluginRunnable(aInstanceOwner); - NS_DispatchToCurrentThread(evt); - + if (DoDelayedStop(aInstanceOwner, aDelayedStop)) return; - } inst->Stop(); } diff --git a/modules/plugin/base/public/nsPIPluginHost.idl b/modules/plugin/base/public/nsPIPluginHost.idl index cf0ea68091a..daa948ae28f 100644 --- a/modules/plugin/base/public/nsPIPluginHost.idl +++ b/modules/plugin/base/public/nsPIPluginHost.idl @@ -46,7 +46,7 @@ interface nsIPluginInstanceOwner; [ptr] native nsPluginNativeWindowPtr(nsPluginNativeWindow); -[uuid(42338435-a38f-4901-97b9-d7cba643d28d)] +[uuid(75d8fcd7-06d1-4767-9022-7f8dacf48a68)] interface nsPIPluginHost : nsISupports { /** @@ -103,4 +103,9 @@ interface nsPIPluginHost : nsISupports * be non-null, if not, it will be null. */ [noscript] void instantiateDummyJavaPlugin(in nsIPluginInstanceOwner aOwner); + + /** + * Get the plugin name for the plugin instance. + */ + [noscript] void getPluginName(in nsIPluginInstance aInstance, out string aPluginName); }; diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 73022dca498..4d1914c2389 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -6928,6 +6928,14 @@ nsPluginHostImpl::InstantiateDummyJavaPlugin(nsIPluginInstanceOwner *aOwner) return NS_OK; } +NS_IMETHODIMP +nsPluginHostImpl::GetPluginName(nsIPluginInstance *aPluginInstance, + char** aPluginName) +{ + *aPluginName = (char*)GetPluginName(aPluginInstance); + return NS_OK; +} + /* ----- end of nsPIPluginHost implementation ----- */ nsresult