Bug 851378 - Notify owning content when we destroy plugins from under it. r=bsmedberg

This commit is contained in:
John Schoenick 2013-03-19 15:38:25 -07:00
Родитель 4b58995789
Коммит 96294aabb8
3 изменённых файлов: 29 добавлений и 4 удалений

Просмотреть файл

@ -111,6 +111,10 @@ interface nsIObjectLoadingContent : nsISupports
*/
[noscript] nsIFrame getPrintFrame();
/*
* Notifications from pluginhost that our instance crashed or was destroyed.
*/
[noscript] void pluginDestroyed();
[noscript] void pluginCrashed(in nsIPluginTag pluginTag,
in AString pluginDumpID,
in AString browserDumpID,

Просмотреть файл

@ -2266,6 +2266,18 @@ nsObjectLoadingContent::GetPrintFrame(nsIFrame** aFrame)
return NS_OK;
}
NS_IMETHODIMP
nsObjectLoadingContent::PluginDestroyed()
{
// Called when our plugin is destroyed from under us, usually when reloading
// plugins in plugin host. Invalidate instance owner / prototype but otherwise
// don't take any action.
TeardownProtoChain();
CloseChannel();
mInstanceOwner = nullptr;
return NS_OK;
}
NS_IMETHODIMP
nsObjectLoadingContent::PluginCrashed(nsIPluginTag* aPluginTag,
const nsAString& pluginDumpID,
@ -2275,10 +2287,7 @@ nsObjectLoadingContent::PluginCrashed(nsIPluginTag* aPluginTag,
LOG(("OBJLC [%p]: Plugin Crashed, queuing crash event", this));
NS_ASSERTION(mType == eType_Plugin, "PluginCrashed at non-plugin type");
// Instance is dead, clean up
TeardownProtoChain();
mInstanceOwner = nullptr;
CloseChannel();
PluginDestroyed();
// Switch to fallback/crashed state, notify
LoadFallback(eFallbackCrashed, true);

Просмотреть файл

@ -3782,9 +3782,21 @@ nsPluginHost::DestroyRunningInstances(nsTArray<nsCOMPtr<nsIDocument> >* aReloadD
// Get rid of all the instances without the possibility of caching.
nsPluginTag* pluginTag = TagForPlugin(instance->GetPlugin());
instance->SetWindow(nullptr);
nsCOMPtr<nsIDOMElement> domElement;
instance->GetDOMElement(getter_AddRefs(domElement));
nsCOMPtr<nsIObjectLoadingContent> objectContent =
do_QueryInterface(domElement);
instance->Destroy();
mInstances.RemoveElement(instance);
OnPluginInstanceDestroyed(pluginTag);
// Notify owning content that we destroyed its plugin out from under it
if (objectContent) {
objectContent->PluginDestroyed();
}
}
}
}