From 59f513cbed35b291cc2a716d05ae66ef8773cd60 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Thu, 2 Nov 2017 11:03:24 +0100 Subject: [PATCH] Bug 1413845 - Remove PluginPRLibrary as it is unused. r=jimm --HG-- extra : rebase_source : 0eae0844e68ec1f1227c327903369d3ededa4058 --- dom/plugins/base/PluginPRLibrary.cpp | 306 -------------------------- dom/plugins/base/PluginPRLibrary.h | 158 ------------- dom/plugins/base/moz.build | 5 - dom/plugins/base/nsNPAPIPlugin.cpp | 14 +- dom/plugins/base/nsNPAPIPlugin.h | 2 - dom/plugins/base/nsPluginHost.cpp | 23 -- dom/plugins/ipc/PluginModuleChild.cpp | 2 - 7 files changed, 1 insertion(+), 509 deletions(-) delete mode 100644 dom/plugins/base/PluginPRLibrary.cpp delete mode 100644 dom/plugins/base/PluginPRLibrary.h diff --git a/dom/plugins/base/PluginPRLibrary.cpp b/dom/plugins/base/PluginPRLibrary.cpp deleted file mode 100644 index 45efa1e400c2..000000000000 --- a/dom/plugins/base/PluginPRLibrary.cpp +++ /dev/null @@ -1,306 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=8 et : - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Assertions.h" -#include "mozilla/PluginPRLibrary.h" -#include "nsNPAPIPluginInstance.h" - -// Some plugins on Windows, notably Quake Live, implement NP_Initialize using -// cdecl instead of the documented stdcall. In order to work around this, -// we force the caller to use a frame pointer. -#if defined(XP_WIN) && defined(_M_IX86) -#include - -// gNotOptimized exists so that the compiler will not optimize the alloca -// below. -static int gNotOptimized; -#define CALLING_CONVENTION_HACK void* foo MOZ_UNUSED_ATTRIBUTE = _alloca(gNotOptimized); -#else -#define CALLING_CONVENTION_HACK -#endif - -using namespace mozilla::layers; - -namespace mozilla { -#if defined(XP_UNIX) && !defined(XP_MACOSX) -nsresult -PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, - NPPluginFuncs* pFuncs, NPError* error) -{ - if (mNP_Initialize) { - *error = mNP_Initialize(bFuncs, pFuncs); - } else { - NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc) - PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); - if (!pfNP_Initialize) - return NS_ERROR_FAILURE; - *error = pfNP_Initialize(bFuncs, pFuncs); - } - - - // Save pointers to functions that get called through PluginLibrary itself. - mNPP_New = pFuncs->newp; - mNPP_ClearSiteData = pFuncs->clearsitedata; - mNPP_GetSitesWithData = pFuncs->getsiteswithdata; - return NS_OK; -} -#else -nsresult -PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) -{ - CALLING_CONVENTION_HACK - - if (mNP_Initialize) { - *error = mNP_Initialize(bFuncs); - } else { - NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc) - PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); - if (!pfNP_Initialize) - return NS_ERROR_FAILURE; - *error = pfNP_Initialize(bFuncs); - } - - return NS_OK; -} -#endif - -nsresult -PluginPRLibrary::NP_Shutdown(NPError* error) -{ - CALLING_CONVENTION_HACK - - if (mNP_Shutdown) { - *error = mNP_Shutdown(); - } else { - NP_ShutdownFunc pfNP_Shutdown = (NP_ShutdownFunc) - PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); - if (!pfNP_Shutdown) - return NS_ERROR_FAILURE; - *error = pfNP_Shutdown(); - } - - return NS_OK; -} - -nsresult -PluginPRLibrary::NP_GetMIMEDescription(const char** mimeDesc) -{ - CALLING_CONVENTION_HACK - - if (mNP_GetMIMEDescription) { - *mimeDesc = mNP_GetMIMEDescription(); - } - else { - NP_GetMIMEDescriptionFunc pfNP_GetMIMEDescription = - (NP_GetMIMEDescriptionFunc) - PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription"); - if (!pfNP_GetMIMEDescription) { - *mimeDesc = ""; - return NS_ERROR_FAILURE; - } - *mimeDesc = pfNP_GetMIMEDescription(); - } - - return NS_OK; -} - -nsresult -PluginPRLibrary::NP_GetValue(void *future, NPPVariable aVariable, - void *aValue, NPError* error) -{ -#if defined(XP_UNIX) && !defined(XP_MACOSX) - if (mNP_GetValue) { - *error = mNP_GetValue(future, aVariable, aValue); - } else { - NP_GetValueFunc pfNP_GetValue = (NP_GetValueFunc)PR_FindFunctionSymbol(mLibrary, "NP_GetValue"); - if (!pfNP_GetValue) - return NS_ERROR_FAILURE; - *error = pfNP_GetValue(future, aVariable, aValue); - } - return NS_OK; -#else - return NS_ERROR_NOT_IMPLEMENTED; -#endif -} - -#if defined(XP_WIN) || defined(XP_MACOSX) -nsresult -PluginPRLibrary::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) -{ - CALLING_CONVENTION_HACK - - if (mNP_GetEntryPoints) { - *error = mNP_GetEntryPoints(pFuncs); - } else { - NP_GetEntryPointsFunc pfNP_GetEntryPoints = (NP_GetEntryPointsFunc) - PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints"); - if (!pfNP_GetEntryPoints) - return NS_ERROR_FAILURE; - *error = pfNP_GetEntryPoints(pFuncs); - } - - // Save pointers to functions that get called through PluginLibrary itself. - mNPP_New = pFuncs->newp; - mNPP_ClearSiteData = pFuncs->clearsitedata; - mNPP_GetSitesWithData = pFuncs->getsiteswithdata; - return NS_OK; -} -#endif - -nsresult -PluginPRLibrary::NPP_New(NPMIMEType pluginType, NPP instance, - int16_t argc, char* argn[], - char* argv[], NPSavedData* saved, - NPError* error) -{ - if (!mNPP_New) - return NS_ERROR_FAILURE; - - *error = mNPP_New(pluginType, instance, NP_EMBED, argc, argn, argv, saved); - return NS_OK; -} - -nsresult -PluginPRLibrary::NPP_ClearSiteData(const char* site, uint64_t flags, - uint64_t maxAge, nsCOMPtr callback) -{ - if (!mNPP_ClearSiteData) { - return NS_ERROR_NOT_AVAILABLE; - } - - NPError result = mNPP_ClearSiteData(site, flags, maxAge); - - nsresult rv; - switch (result) { - case NPERR_NO_ERROR: - rv = NS_OK; - break; - case NPERR_TIME_RANGE_NOT_SUPPORTED: - rv = NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED; - break; - case NPERR_MALFORMED_SITE: - rv = NS_ERROR_INVALID_ARG; - break; - default: - rv = NS_ERROR_FAILURE; - } - callback->Callback(rv); - return NS_OK; -} - -nsresult -PluginPRLibrary::NPP_GetSitesWithData(nsCOMPtr callback) -{ - if (!mNPP_GetSitesWithData) { - return NS_ERROR_NOT_AVAILABLE; - } - - char** sites = mNPP_GetSitesWithData(); - if (!sites) { - return NS_OK; - } - InfallibleTArray result; - char** iterator = sites; - while (*iterator) { - result.AppendElement(*iterator); - free(*iterator); - ++iterator; - } - callback->SitesWithData(result); - free(sites); - - return NS_OK; -} - -nsresult -PluginPRLibrary::AsyncSetWindow(NPP instance, NPWindow* window) -{ - nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata; - NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER); - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -PluginPRLibrary::GetImageContainer(NPP instance, ImageContainer** aContainer) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -#if defined(XP_MACOSX) -nsresult -PluginPRLibrary::IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing) -{ - nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata; - NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER); - *aDrawing = false; - return NS_OK; -} -#endif -#if defined(XP_MACOSX) || defined(XP_WIN) -nsresult -PluginPRLibrary::ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor) -{ - nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata; - NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER); - return NS_OK; -} -#endif - -nsresult -PluginPRLibrary::GetImageSize(NPP instance, nsIntSize* aSize) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -PluginPRLibrary::SetBackgroundUnknown(NPP instance) -{ - nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata; - NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER); - NS_ERROR("Unexpected use of async APIs for in-process plugin."); - return NS_ERROR_NOT_IMPLEMENTED; -} - -nsresult -PluginPRLibrary::BeginUpdateBackground(NPP instance, const nsIntRect&, - DrawTarget** aDrawTarget) -{ - nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata; - NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER); - NS_ERROR("Unexpected use of async APIs for in-process plugin."); - *aDrawTarget = nullptr; - return NS_OK; -} - -nsresult -PluginPRLibrary::EndUpdateBackground(NPP instance, const nsIntRect&) -{ - MOZ_CRASH("This should never be called"); - return NS_ERROR_NOT_AVAILABLE; -} - -#if defined(XP_WIN) -nsresult -PluginPRLibrary::GetScrollCaptureContainer(NPP aInstance, ImageContainer** aContainer) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} -#endif - -nsresult -PluginPRLibrary::HandledWindowedPluginKeyEvent( - NPP aInstance, - const NativeEventData& aNativeKeyData, - bool aIsConsumed) -{ - nsNPAPIPluginInstance* instance = (nsNPAPIPluginInstance*)aInstance->ndata; - if (NS_WARN_IF(!instance)) { - return NS_ERROR_NULL_POINTER; - } - return NS_OK; -} - -} // namespace mozilla diff --git a/dom/plugins/base/PluginPRLibrary.h b/dom/plugins/base/PluginPRLibrary.h deleted file mode 100644 index 3356df150ad0..000000000000 --- a/dom/plugins/base/PluginPRLibrary.h +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef PluginPRLibrary_h -#define PluginPRLibrary_h 1 - -#include "mozilla/PluginLibrary.h" -#include "nsNPAPIPlugin.h" -#include "npfunctions.h" - -namespace mozilla { - -class PluginPRLibrary : public PluginLibrary -{ -public: - PluginPRLibrary(const char* aFilePath, PRLibrary* aLibrary) : -#if defined(XP_UNIX) && !defined(XP_MACOSX) - mNP_Initialize(nullptr), -#else - mNP_Initialize(nullptr), -#endif - mNP_Shutdown(nullptr), - mNP_GetMIMEDescription(nullptr), -#if defined(XP_UNIX) && !defined(XP_MACOSX) - mNP_GetValue(nullptr), -#endif -#if defined(XP_WIN) || defined(XP_MACOSX) - mNP_GetEntryPoints(nullptr), -#endif - mNPP_New(nullptr), - mNPP_ClearSiteData(nullptr), - mNPP_GetSitesWithData(nullptr), - mLibrary(aLibrary), - mFilePath(aFilePath) - { - NS_ASSERTION(mLibrary, "need non-null lib"); - // addref here?? - } - - virtual ~PluginPRLibrary() - { - // unref here?? - } - - virtual void SetPlugin(nsNPAPIPlugin*) override { } - - virtual bool HasRequiredFunctions() override { - mNP_Initialize = (NP_InitializeFunc) - PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); - if (!mNP_Initialize) - return false; - - mNP_Shutdown = (NP_ShutdownFunc) - PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); - if (!mNP_Shutdown) - return false; - - mNP_GetMIMEDescription = (NP_GetMIMEDescriptionFunc) - PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription"); -#ifndef XP_MACOSX - if (!mNP_GetMIMEDescription) - return false; -#endif - -#if defined(XP_UNIX) && !defined(XP_MACOSX) - mNP_GetValue = (NP_GetValueFunc) - PR_FindFunctionSymbol(mLibrary, "NP_GetValue"); - if (!mNP_GetValue) - return false; -#endif - -#if defined(XP_WIN) || defined(XP_MACOSX) - mNP_GetEntryPoints = (NP_GetEntryPointsFunc) - PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints"); - if (!mNP_GetEntryPoints) - return false; -#endif - return true; - } - -#if defined(XP_UNIX) && !defined(XP_MACOSX) - virtual nsresult NP_Initialize(NPNetscapeFuncs* aNetscapeFuncs, - NPPluginFuncs* aFuncs, NPError* aError) override; -#else - virtual nsresult NP_Initialize(NPNetscapeFuncs* aNetscapeFuncs, - NPError* aError) override; -#endif - - virtual nsresult NP_Shutdown(NPError* aError) override; - virtual nsresult NP_GetMIMEDescription(const char** aMimeDesc) override; - - virtual nsresult NP_GetValue(void* aFuture, NPPVariable aVariable, - void* aValue, NPError* aError) override; - -#if defined(XP_WIN) || defined(XP_MACOSX) - virtual nsresult NP_GetEntryPoints(NPPluginFuncs* aFuncs, NPError* aError) override; -#endif - - virtual nsresult NPP_New(NPMIMEType aPluginType, NPP aInstance, - int16_t aArgc, char* aArgn[], - char* aArgv[], NPSavedData* aSaved, - NPError* aError) override; - - virtual nsresult NPP_ClearSiteData(const char* aSite, uint64_t aFlags, - uint64_t aMaxAge, nsCOMPtr callback) override; - virtual nsresult NPP_GetSitesWithData(nsCOMPtr callback) override; - - virtual nsresult AsyncSetWindow(NPP aInstance, NPWindow* aWindow) override; - virtual nsresult GetImageContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override; - virtual nsresult GetImageSize(NPP aInstance, nsIntSize* aSize) override; - virtual bool IsOOP() override { return false; } -#if defined(XP_MACOSX) - virtual nsresult IsRemoteDrawingCoreAnimation(NPP aInstance, bool* aDrawing) override; -#endif -#if defined(XP_MACOSX) || defined(XP_WIN) - virtual nsresult ContentsScaleFactorChanged(NPP aInstance, double aContentsScaleFactor) override; -#endif - virtual nsresult SetBackgroundUnknown(NPP instance) override; - virtual nsresult BeginUpdateBackground(NPP instance, const nsIntRect&, - DrawTarget** aDrawTarget) override; - virtual nsresult EndUpdateBackground(NPP instance, - const nsIntRect&) override; - virtual void DidComposite(NPP aInstance) override { } - virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); } - virtual nsresult GetRunID(uint32_t* aRunID) override { return NS_ERROR_NOT_IMPLEMENTED; } - virtual void SetHasLocalInstance() override { } -#if defined(XP_WIN) - virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override; -#endif - virtual nsresult HandledWindowedPluginKeyEvent( - NPP aInstance, - const mozilla::NativeEventData& aNativeKeyData, - bool aIsCOnsumed) override; - -private: - NP_InitializeFunc mNP_Initialize; - NP_ShutdownFunc mNP_Shutdown; - NP_GetMIMEDescriptionFunc mNP_GetMIMEDescription; -#if defined(XP_UNIX) && !defined(XP_MACOSX) - NP_GetValueFunc mNP_GetValue; -#endif -#if defined(XP_WIN) || defined(XP_MACOSX) - NP_GetEntryPointsFunc mNP_GetEntryPoints; -#endif - NPP_NewProcPtr mNPP_New; - NPP_ClearSiteDataPtr mNPP_ClearSiteData; - NPP_GetSitesWithDataPtr mNPP_GetSitesWithData; - PRLibrary* mLibrary; - nsCString mFilePath; -}; - - -} // namespace mozilla - -#endif // ifndef PluginPRLibrary_h diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index 7f756db33b3c..fb57ecfdc29d 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -33,10 +33,6 @@ EXPORTS += [ 'nsPluginTags.h', ] -EXPORTS.mozilla += [ - 'PluginPRLibrary.h', -] - UNIFIED_SOURCES += [ 'nsJSNPRuntime.cpp', 'nsNPAPIPluginInstance.cpp', @@ -45,7 +41,6 @@ UNIFIED_SOURCES += [ 'nsPluginModule.cpp', 'nsPluginStreamListenerPeer.cpp', 'nsPluginTags.cpp', - 'PluginPRLibrary.cpp', ] SOURCES += [ diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index c0dab6a8918f..254d858b0438 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -76,9 +76,6 @@ #include "mozilla/PluginLibrary.h" using mozilla::PluginLibrary; -#include "mozilla/PluginPRLibrary.h" -using mozilla::PluginPRLibrary; - #include "mozilla/plugins/PluginModuleParent.h" using mozilla::plugins::PluginModuleChromeParent; using mozilla::plugins::PluginModuleContentParent; @@ -204,12 +201,6 @@ nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID, host->PluginCrashed(this, pluginDumpID, browserDumpID); } -bool -nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) -{ - return true; -} - inline PluginLibrary* GetNewPluginLibrary(nsPluginTag *aPluginTag) { @@ -223,10 +214,7 @@ GetNewPluginLibrary(nsPluginTag *aPluginTag) return PluginModuleContentParent::LoadModule(aPluginTag->mId, aPluginTag); } - if (nsNPAPIPlugin::RunPluginOOP(aPluginTag)) { - return PluginModuleChromeParent::LoadModule(aPluginTag->mFullPath.get(), aPluginTag->mId, aPluginTag); - } - return new PluginPRLibrary(aPluginTag->mFullPath.get(), aPluginTag->mLibrary); + return PluginModuleChromeParent::LoadModule(aPluginTag->mFullPath.get(), aPluginTag->mId, aPluginTag); } // Creates an nsNPAPIPlugin object. One nsNPAPIPlugin object exists per plugin (not instance). diff --git a/dom/plugins/base/nsNPAPIPlugin.h b/dom/plugins/base/nsNPAPIPlugin.h index 03d653ce9b61..e4ce44e2ed9a 100644 --- a/dom/plugins/base/nsNPAPIPlugin.h +++ b/dom/plugins/base/nsNPAPIPlugin.h @@ -56,8 +56,6 @@ public: void PluginCrashed(const nsAString& pluginDumpID, const nsAString& browserDumpID); - static bool RunPluginOOP(const nsPluginTag *aPluginTag); - nsresult Shutdown(); static nsresult RetainStream(NPStream *pstream, nsISupports **aRetainedPeer); diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index d93bf16d60f0..7e8429bb800f 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -1210,21 +1210,6 @@ nsPluginHost::FindNativePluginForExtension(const nsACString & aExtension, static nsresult CreateNPAPIPlugin(nsPluginTag *aPluginTag, nsNPAPIPlugin **aOutNPAPIPlugin) { - // If this is an in-process plugin we'll need to load it here if we haven't already. - if (!nsNPAPIPlugin::RunPluginOOP(aPluginTag)) { - if (aPluginTag->mFullPath.IsEmpty()) - return NS_ERROR_FAILURE; - nsCOMPtr file = do_CreateInstance("@mozilla.org/file/local;1"); - file->InitWithPath(NS_ConvertUTF8toUTF16(aPluginTag->mFullPath)); - nsPluginFile pluginFile(file); - PRLibrary* pluginLibrary = nullptr; - - if (NS_FAILED(pluginFile.LoadPlugin(&pluginLibrary)) || !pluginLibrary) - return NS_ERROR_FAILURE; - - aPluginTag->mLibrary = pluginLibrary; - } - nsresult rv; rv = nsNPAPIPlugin::CreatePlugin(aPluginTag, aOutNPAPIPlugin); @@ -2138,14 +2123,6 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir, *aPluginsChanged = true; } - // Avoid adding different versions of the same plugin if they are running - // in-process, otherwise we risk undefined behaviour. - if (!nsNPAPIPlugin::RunPluginOOP(pluginTag)) { - if (HaveSamePlugin(pluginTag)) { - continue; - } - } - // Don't add the same plugin again if it hasn't changed if (nsPluginTag* duplicate = FirstPluginWithPath(pluginTag->mFullPath)) { if (pluginTag->mLastModifiedTime == duplicate->mLastModifiedTime) { diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 98b1fa34d27e..0ee7895b98dd 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -301,8 +301,6 @@ PluginModuleChild::InitForChrome(const std::string& aPluginFilename, GetIPCChannel()->SetAbortOnError(true); - // TODO: use PluginPRLibrary here - #if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) mShutdownFunc = (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");