From c36eb2f154a630524f5fd8256b220fb7770f9d17 Mon Sep 17 00:00:00 2001 From: Fedor Date: Sat, 4 May 2024 16:28:35 +0300 Subject: [PATCH] Remove mime restriction of plugins --- docshell/base/nsWebNavigationInfo.cpp | 6 --- dom/plugins/base/nsPluginHost.cpp | 53 --------------------------- dom/plugins/base/nsPluginHost.h | 6 --- 3 files changed, 65 deletions(-) diff --git a/docshell/base/nsWebNavigationInfo.cpp b/docshell/base/nsWebNavigationInfo.cpp index a0da0db7ab..7c4ad7386a 100644 --- a/docshell/base/nsWebNavigationInfo.cpp +++ b/docshell/base/nsWebNavigationInfo.cpp @@ -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 docShell(do_QueryInterface(aWebNav)); diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index f23761d28e..36747c3631 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -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 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 aInitDictionary, JSContext* aCx, nsIFakePluginTag** aResult) { @@ -1463,12 +1434,6 @@ nsPluginHost::RegisterFakePlugin(JS::Handle aInitDictionary, return NS_ERROR_FAILURE; } - for (const FakePluginMimeEntry& mimeEntry : initDictionary.mMimeEntries) { - if (!MimeTypeIsAllowedForFakePlugin(mimeEntry.mType)) { - return NS_ERROR_FAILURE; - } - } - RefPtr 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 diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h index f55c8c9786..731b542f54 100644 --- a/dom/plugins/base/nsPluginHost.h +++ b/dom/plugins/base/nsPluginHost.h @@ -179,12 +179,6 @@ class nsPluginHost final : public nsIPluginHost, // Always returns false if plugin.load_in_parent_process. 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,