Stop QuickTime and Flip4Mac plugins directly when requested (not off an event). b=426524 r+sr=jst a1.9=beltzner

This commit is contained in:
mats.palmgren@bredband.net 2008-04-16 13:06:48 -07:00
parent dfb07f96dc
commit 1b3c4d7918
3 changed files with 50 additions and 15 deletions

View File

@ -427,6 +427,18 @@ public:
}
}
const char* GetPluginName()
{
if (mInstance && mPluginHost) {
nsCOMPtr<nsPIPluginHost> 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<nsIRunnable> 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<nsIRunnable> 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<nsIRunnable> evt = new nsStopPluginRunnable(aInstanceOwner);
NS_DispatchToCurrentThread(evt);
if (DoDelayedStop(aInstanceOwner, aDelayedStop))
return;
}
inst->Stop();
}

View File

@ -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);
};

View File

@ -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