Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: sw=4 ts=4 et : |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef PluginPRLibrary_h |
michael@0 | 8 | #define PluginPRLibrary_h 1 |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/PluginLibrary.h" |
michael@0 | 11 | #include "nsNPAPIPlugin.h" |
michael@0 | 12 | #include "npfunctions.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | |
michael@0 | 16 | class PluginPRLibrary : public PluginLibrary |
michael@0 | 17 | { |
michael@0 | 18 | public: |
michael@0 | 19 | PluginPRLibrary(const char* aFilePath, PRLibrary* aLibrary) : |
michael@0 | 20 | #if defined(XP_UNIX) && !defined(XP_MACOSX) |
michael@0 | 21 | mNP_Initialize(nullptr), |
michael@0 | 22 | #else |
michael@0 | 23 | mNP_Initialize(nullptr), |
michael@0 | 24 | #endif |
michael@0 | 25 | mNP_Shutdown(nullptr), |
michael@0 | 26 | mNP_GetMIMEDescription(nullptr), |
michael@0 | 27 | #if defined(XP_UNIX) && !defined(XP_MACOSX) |
michael@0 | 28 | mNP_GetValue(nullptr), |
michael@0 | 29 | #endif |
michael@0 | 30 | #if defined(XP_WIN) || defined(XP_MACOSX) |
michael@0 | 31 | mNP_GetEntryPoints(nullptr), |
michael@0 | 32 | #endif |
michael@0 | 33 | mNPP_New(nullptr), |
michael@0 | 34 | mNPP_ClearSiteData(nullptr), |
michael@0 | 35 | mNPP_GetSitesWithData(nullptr), |
michael@0 | 36 | mLibrary(aLibrary), |
michael@0 | 37 | mFilePath(aFilePath) |
michael@0 | 38 | { |
michael@0 | 39 | NS_ASSERTION(mLibrary, "need non-null lib"); |
michael@0 | 40 | // addref here?? |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | virtual ~PluginPRLibrary() |
michael@0 | 44 | { |
michael@0 | 45 | // unref here?? |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | virtual void SetPlugin(nsNPAPIPlugin*) { } |
michael@0 | 49 | |
michael@0 | 50 | virtual bool HasRequiredFunctions() { |
michael@0 | 51 | mNP_Initialize = (NP_InitializeFunc) |
michael@0 | 52 | PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); |
michael@0 | 53 | if (!mNP_Initialize) |
michael@0 | 54 | return false; |
michael@0 | 55 | |
michael@0 | 56 | mNP_Shutdown = (NP_ShutdownFunc) |
michael@0 | 57 | PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); |
michael@0 | 58 | if (!mNP_Shutdown) |
michael@0 | 59 | return false; |
michael@0 | 60 | |
michael@0 | 61 | mNP_GetMIMEDescription = (NP_GetMIMEDescriptionFunc) |
michael@0 | 62 | PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription"); |
michael@0 | 63 | #ifndef XP_MACOSX |
michael@0 | 64 | if (!mNP_GetMIMEDescription) |
michael@0 | 65 | return false; |
michael@0 | 66 | #endif |
michael@0 | 67 | |
michael@0 | 68 | #if defined(XP_UNIX) && !defined(XP_MACOSX) |
michael@0 | 69 | mNP_GetValue = (NP_GetValueFunc) |
michael@0 | 70 | PR_FindFunctionSymbol(mLibrary, "NP_GetValue"); |
michael@0 | 71 | if (!mNP_GetValue) |
michael@0 | 72 | return false; |
michael@0 | 73 | #endif |
michael@0 | 74 | |
michael@0 | 75 | #if defined(XP_WIN) || defined(XP_MACOSX) |
michael@0 | 76 | mNP_GetEntryPoints = (NP_GetEntryPointsFunc) |
michael@0 | 77 | PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints"); |
michael@0 | 78 | if (!mNP_GetEntryPoints) |
michael@0 | 79 | return false; |
michael@0 | 80 | #endif |
michael@0 | 81 | return true; |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) |
michael@0 | 85 | virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, |
michael@0 | 86 | NPPluginFuncs* pFuncs, NPError* error); |
michael@0 | 87 | #else |
michael@0 | 88 | virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, |
michael@0 | 89 | NPError* error); |
michael@0 | 90 | #endif |
michael@0 | 91 | |
michael@0 | 92 | virtual nsresult NP_Shutdown(NPError* error); |
michael@0 | 93 | virtual nsresult NP_GetMIMEDescription(const char** mimeDesc); |
michael@0 | 94 | |
michael@0 | 95 | virtual nsresult NP_GetValue(void *future, NPPVariable aVariable, |
michael@0 | 96 | void *aValue, NPError* error); |
michael@0 | 97 | |
michael@0 | 98 | #if defined(XP_WIN) || defined(XP_MACOSX) |
michael@0 | 99 | virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error); |
michael@0 | 100 | #endif |
michael@0 | 101 | |
michael@0 | 102 | virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance, |
michael@0 | 103 | uint16_t mode, int16_t argc, char* argn[], |
michael@0 | 104 | char* argv[], NPSavedData* saved, |
michael@0 | 105 | NPError* error); |
michael@0 | 106 | |
michael@0 | 107 | virtual nsresult NPP_ClearSiteData(const char* site, uint64_t flags, |
michael@0 | 108 | uint64_t maxAge); |
michael@0 | 109 | virtual nsresult NPP_GetSitesWithData(InfallibleTArray<nsCString>& result); |
michael@0 | 110 | |
michael@0 | 111 | virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window); |
michael@0 | 112 | virtual nsresult GetImageContainer(NPP instance, mozilla::layers::ImageContainer** aContainer); |
michael@0 | 113 | virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize); |
michael@0 | 114 | virtual bool IsOOP() MOZ_OVERRIDE { return false; } |
michael@0 | 115 | #if defined(XP_MACOSX) |
michael@0 | 116 | virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing); |
michael@0 | 117 | virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor); |
michael@0 | 118 | #endif |
michael@0 | 119 | virtual nsresult SetBackgroundUnknown(NPP instance) MOZ_OVERRIDE; |
michael@0 | 120 | virtual nsresult BeginUpdateBackground(NPP instance, |
michael@0 | 121 | const nsIntRect&, gfxContext** aCtx) MOZ_OVERRIDE; |
michael@0 | 122 | virtual nsresult EndUpdateBackground(NPP instance, |
michael@0 | 123 | gfxContext* aCtx, const nsIntRect&) MOZ_OVERRIDE; |
michael@0 | 124 | virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); } |
michael@0 | 125 | |
michael@0 | 126 | private: |
michael@0 | 127 | NP_InitializeFunc mNP_Initialize; |
michael@0 | 128 | NP_ShutdownFunc mNP_Shutdown; |
michael@0 | 129 | NP_GetMIMEDescriptionFunc mNP_GetMIMEDescription; |
michael@0 | 130 | #if defined(XP_UNIX) && !defined(XP_MACOSX) |
michael@0 | 131 | NP_GetValueFunc mNP_GetValue; |
michael@0 | 132 | #endif |
michael@0 | 133 | #if defined(XP_WIN) || defined(XP_MACOSX) |
michael@0 | 134 | NP_GetEntryPointsFunc mNP_GetEntryPoints; |
michael@0 | 135 | #endif |
michael@0 | 136 | NPP_NewProcPtr mNPP_New; |
michael@0 | 137 | NPP_ClearSiteDataPtr mNPP_ClearSiteData; |
michael@0 | 138 | NPP_GetSitesWithDataPtr mNPP_GetSitesWithData; |
michael@0 | 139 | PRLibrary* mLibrary; |
michael@0 | 140 | nsCString mFilePath; |
michael@0 | 141 | }; |
michael@0 | 142 | |
michael@0 | 143 | |
michael@0 | 144 | } // namespace mozilla |
michael@0 | 145 | |
michael@0 | 146 | #endif // ifndef PluginPRLibrary_h |