1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/base/PluginPRLibrary.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,146 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: sw=4 ts=4 et : 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef PluginPRLibrary_h 1.11 +#define PluginPRLibrary_h 1 1.12 + 1.13 +#include "mozilla/PluginLibrary.h" 1.14 +#include "nsNPAPIPlugin.h" 1.15 +#include "npfunctions.h" 1.16 + 1.17 +namespace mozilla { 1.18 + 1.19 +class PluginPRLibrary : public PluginLibrary 1.20 +{ 1.21 +public: 1.22 + PluginPRLibrary(const char* aFilePath, PRLibrary* aLibrary) : 1.23 +#if defined(XP_UNIX) && !defined(XP_MACOSX) 1.24 + mNP_Initialize(nullptr), 1.25 +#else 1.26 + mNP_Initialize(nullptr), 1.27 +#endif 1.28 + mNP_Shutdown(nullptr), 1.29 + mNP_GetMIMEDescription(nullptr), 1.30 +#if defined(XP_UNIX) && !defined(XP_MACOSX) 1.31 + mNP_GetValue(nullptr), 1.32 +#endif 1.33 +#if defined(XP_WIN) || defined(XP_MACOSX) 1.34 + mNP_GetEntryPoints(nullptr), 1.35 +#endif 1.36 + mNPP_New(nullptr), 1.37 + mNPP_ClearSiteData(nullptr), 1.38 + mNPP_GetSitesWithData(nullptr), 1.39 + mLibrary(aLibrary), 1.40 + mFilePath(aFilePath) 1.41 + { 1.42 + NS_ASSERTION(mLibrary, "need non-null lib"); 1.43 + // addref here?? 1.44 + } 1.45 + 1.46 + virtual ~PluginPRLibrary() 1.47 + { 1.48 + // unref here?? 1.49 + } 1.50 + 1.51 + virtual void SetPlugin(nsNPAPIPlugin*) { } 1.52 + 1.53 + virtual bool HasRequiredFunctions() { 1.54 + mNP_Initialize = (NP_InitializeFunc) 1.55 + PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); 1.56 + if (!mNP_Initialize) 1.57 + return false; 1.58 + 1.59 + mNP_Shutdown = (NP_ShutdownFunc) 1.60 + PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); 1.61 + if (!mNP_Shutdown) 1.62 + return false; 1.63 + 1.64 + mNP_GetMIMEDescription = (NP_GetMIMEDescriptionFunc) 1.65 + PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription"); 1.66 +#ifndef XP_MACOSX 1.67 + if (!mNP_GetMIMEDescription) 1.68 + return false; 1.69 +#endif 1.70 + 1.71 +#if defined(XP_UNIX) && !defined(XP_MACOSX) 1.72 + mNP_GetValue = (NP_GetValueFunc) 1.73 + PR_FindFunctionSymbol(mLibrary, "NP_GetValue"); 1.74 + if (!mNP_GetValue) 1.75 + return false; 1.76 +#endif 1.77 + 1.78 +#if defined(XP_WIN) || defined(XP_MACOSX) 1.79 + mNP_GetEntryPoints = (NP_GetEntryPointsFunc) 1.80 + PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints"); 1.81 + if (!mNP_GetEntryPoints) 1.82 + return false; 1.83 +#endif 1.84 + return true; 1.85 + } 1.86 + 1.87 +#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) 1.88 + virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, 1.89 + NPPluginFuncs* pFuncs, NPError* error); 1.90 +#else 1.91 + virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, 1.92 + NPError* error); 1.93 +#endif 1.94 + 1.95 + virtual nsresult NP_Shutdown(NPError* error); 1.96 + virtual nsresult NP_GetMIMEDescription(const char** mimeDesc); 1.97 + 1.98 + virtual nsresult NP_GetValue(void *future, NPPVariable aVariable, 1.99 + void *aValue, NPError* error); 1.100 + 1.101 +#if defined(XP_WIN) || defined(XP_MACOSX) 1.102 + virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error); 1.103 +#endif 1.104 + 1.105 + virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance, 1.106 + uint16_t mode, int16_t argc, char* argn[], 1.107 + char* argv[], NPSavedData* saved, 1.108 + NPError* error); 1.109 + 1.110 + virtual nsresult NPP_ClearSiteData(const char* site, uint64_t flags, 1.111 + uint64_t maxAge); 1.112 + virtual nsresult NPP_GetSitesWithData(InfallibleTArray<nsCString>& result); 1.113 + 1.114 + virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window); 1.115 + virtual nsresult GetImageContainer(NPP instance, mozilla::layers::ImageContainer** aContainer); 1.116 + virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize); 1.117 + virtual bool IsOOP() MOZ_OVERRIDE { return false; } 1.118 +#if defined(XP_MACOSX) 1.119 + virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing); 1.120 + virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor); 1.121 +#endif 1.122 + virtual nsresult SetBackgroundUnknown(NPP instance) MOZ_OVERRIDE; 1.123 + virtual nsresult BeginUpdateBackground(NPP instance, 1.124 + const nsIntRect&, gfxContext** aCtx) MOZ_OVERRIDE; 1.125 + virtual nsresult EndUpdateBackground(NPP instance, 1.126 + gfxContext* aCtx, const nsIntRect&) MOZ_OVERRIDE; 1.127 + virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); } 1.128 + 1.129 +private: 1.130 + NP_InitializeFunc mNP_Initialize; 1.131 + NP_ShutdownFunc mNP_Shutdown; 1.132 + NP_GetMIMEDescriptionFunc mNP_GetMIMEDescription; 1.133 +#if defined(XP_UNIX) && !defined(XP_MACOSX) 1.134 + NP_GetValueFunc mNP_GetValue; 1.135 +#endif 1.136 +#if defined(XP_WIN) || defined(XP_MACOSX) 1.137 + NP_GetEntryPointsFunc mNP_GetEntryPoints; 1.138 +#endif 1.139 + NPP_NewProcPtr mNPP_New; 1.140 + NPP_ClearSiteDataPtr mNPP_ClearSiteData; 1.141 + NPP_GetSitesWithDataPtr mNPP_GetSitesWithData; 1.142 + PRLibrary* mLibrary; 1.143 + nsCString mFilePath; 1.144 +}; 1.145 + 1.146 + 1.147 +} // namespace mozilla 1.148 + 1.149 +#endif // ifndef PluginPRLibrary_h