Remove mime restriction of plugins

This commit is contained in:
Fedor 2024-05-04 16:28:35 +03:00
parent e7eb1bb855
commit c36eb2f154
3 changed files with 0 additions and 65 deletions

View File

@ -51,12 +51,6 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
return rv;
}
// As of FF 52, we only support flash and test plugins, so if the mime types
// don't match for that, exit before we start loading plugins.
if (!nsPluginHost::CanUsePluginForMIMEType(aType)) {
return NS_OK;
}
// If this request is for a docShell that isn't going to allow plugins,
// there's no need to try and find a plugin to handle it.
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));

View File

@ -1153,12 +1153,6 @@ nsPluginTag* nsPluginHost::FindNativePluginForType(const nsACString& aMimeType,
return nullptr;
}
// As of FF 52, we only support flash and test plugins, so if the mime types
// don't match for that, exit before we start loading plugins.
if (!nsPluginHost::CanUsePluginForMIMEType(aMimeType)) {
return nullptr;
}
LoadPlugins();
nsTArray<nsPluginTag*> matchingPlugins;
@ -1432,29 +1426,6 @@ nsresult nsPluginHost::EnumerateSiteData(const nsACString& domain,
return NS_OK;
}
static bool MimeTypeIsAllowedForFakePlugin(const nsString& aMimeType) {
static const char* const allowedFakePlugins[] = {
// Flash
"application/x-shockwave-flash",
// PDF
"application/pdf",
"application/vnd.adobe.pdf",
"application/vnd.adobe.pdfxml",
"application/vnd.adobe.x-mars",
"application/vnd.adobe.xdp+xml",
"application/vnd.adobe.xfdf",
"application/vnd.adobe.xfd+xml",
"application/vnd.fdf",
};
for (const auto allowed : allowedFakePlugins) {
if (aMimeType.EqualsASCII(allowed)) {
return true;
}
}
return false;
}
NS_IMETHODIMP
nsPluginHost::RegisterFakePlugin(JS::Handle<JS::Value> aInitDictionary,
JSContext* aCx, nsIFakePluginTag** aResult) {
@ -1463,12 +1434,6 @@ nsPluginHost::RegisterFakePlugin(JS::Handle<JS::Value> aInitDictionary,
return NS_ERROR_FAILURE;
}
for (const FakePluginMimeEntry& mimeEntry : initDictionary.mMimeEntries) {
if (!MimeTypeIsAllowedForFakePlugin(mimeEntry.mType)) {
return NS_ERROR_FAILURE;
}
}
RefPtr<nsFakePluginTag> newTag;
nsresult rv = nsFakePluginTag::Create(initDictionary, getter_AddRefs(newTag));
NS_ENSURE_SUCCESS(rv, rv);
@ -3683,24 +3648,6 @@ void nsPluginHost::DestroyRunningInstances(nsPluginTag* aPluginTag) {
}
}
/* static */
bool nsPluginHost::CanUsePluginForMIMEType(const nsACString& aMIMEType) {
// We only support flash as a plugin, so if the mime types don't match for
// those, exit before we start loading plugins.
//
// XXX: Remove test/java cases when bug 1351885 lands.
if (nsPluginHost::GetSpecialType(aMIMEType) ==
nsPluginHost::eSpecialType_Flash ||
MimeTypeIsAllowedForFakePlugin(NS_ConvertUTF8toUTF16(aMIMEType)) ||
aMIMEType.LowerCaseEqualsLiteral("application/x-test") ||
aMIMEType.LowerCaseEqualsLiteral("application/x-second-test") ||
aMIMEType.LowerCaseEqualsLiteral("application/x-third-test")) {
return true;
}
return false;
}
// Runnable that does an async destroy of a plugin.
class nsPluginDestroyRunnable

View File

@ -179,12 +179,6 @@ class nsPluginHost final : public nsIPluginHost,
// Always returns false if plugin.load_in_parent_process.<mime> is not set.
static bool ShouldLoadTypeInParent(const nsACString& aMimeType);
/**
* Returns true if a plugin can be used to load the requested MIME type. Used
* for short circuiting before sending things to plugin code.
*/
static bool CanUsePluginForMIMEType(const nsACString& aMIMEType);
// checks whether aType is a type we recognize for potential special handling
enum SpecialType {
eSpecialType_None,