Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: sw=4 ts=4 et :
3 : * This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef PluginPRLibrary_h
8 : #define PluginPRLibrary_h 1
9 :
10 : #include "mozilla/PluginLibrary.h"
11 : #include "nsNPAPIPlugin.h"
12 : #include "npfunctions.h"
13 :
14 : namespace mozilla {
15 :
16 : class PluginPRLibrary : public PluginLibrary
17 : {
18 : public:
19 0 : PluginPRLibrary(const char* aFilePath, PRLibrary* aLibrary) :
20 : #if defined(XP_UNIX) && !defined(XP_MACOSX)
21 : mNP_Initialize(nullptr),
22 : #else
23 : mNP_Initialize(nullptr),
24 : #endif
25 : mNP_Shutdown(nullptr),
26 : mNP_GetMIMEDescription(nullptr),
27 : #if defined(XP_UNIX) && !defined(XP_MACOSX)
28 : mNP_GetValue(nullptr),
29 : #endif
30 : #if defined(XP_WIN) || defined(XP_MACOSX)
31 : mNP_GetEntryPoints(nullptr),
32 : #endif
33 : mNPP_New(nullptr),
34 : mNPP_ClearSiteData(nullptr),
35 : mNPP_GetSitesWithData(nullptr),
36 : mLibrary(aLibrary),
37 0 : mFilePath(aFilePath)
38 : {
39 0 : NS_ASSERTION(mLibrary, "need non-null lib");
40 : // addref here??
41 0 : }
42 :
43 0 : virtual ~PluginPRLibrary()
44 0 : {
45 : // unref here??
46 0 : }
47 :
48 0 : virtual void SetPlugin(nsNPAPIPlugin*) override { }
49 :
50 0 : virtual bool HasRequiredFunctions() override {
51 0 : mNP_Initialize = (NP_InitializeFunc)
52 0 : PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
53 0 : if (!mNP_Initialize)
54 0 : return false;
55 :
56 0 : mNP_Shutdown = (NP_ShutdownFunc)
57 0 : PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
58 0 : if (!mNP_Shutdown)
59 0 : return false;
60 :
61 0 : mNP_GetMIMEDescription = (NP_GetMIMEDescriptionFunc)
62 0 : PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription");
63 : #ifndef XP_MACOSX
64 0 : if (!mNP_GetMIMEDescription)
65 0 : return false;
66 : #endif
67 :
68 : #if defined(XP_UNIX) && !defined(XP_MACOSX)
69 0 : mNP_GetValue = (NP_GetValueFunc)
70 0 : PR_FindFunctionSymbol(mLibrary, "NP_GetValue");
71 0 : if (!mNP_GetValue)
72 0 : return false;
73 : #endif
74 :
75 : #if defined(XP_WIN) || defined(XP_MACOSX)
76 : mNP_GetEntryPoints = (NP_GetEntryPointsFunc)
77 : PR_FindFunctionSymbol(mLibrary, "NP_GetEntryPoints");
78 : if (!mNP_GetEntryPoints)
79 : return false;
80 : #endif
81 0 : return true;
82 : }
83 :
84 : #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
85 : virtual nsresult NP_Initialize(NPNetscapeFuncs* aNetscapeFuncs,
86 : NPPluginFuncs* aFuncs, NPError* aError) override;
87 : #else
88 : virtual nsresult NP_Initialize(NPNetscapeFuncs* aNetscapeFuncs,
89 : NPError* aError) override;
90 : #endif
91 :
92 : virtual nsresult NP_Shutdown(NPError* aError) override;
93 : virtual nsresult NP_GetMIMEDescription(const char** aMimeDesc) override;
94 :
95 : virtual nsresult NP_GetValue(void* aFuture, NPPVariable aVariable,
96 : void* aValue, NPError* aError) override;
97 :
98 : #if defined(XP_WIN) || defined(XP_MACOSX)
99 : virtual nsresult NP_GetEntryPoints(NPPluginFuncs* aFuncs, NPError* aError) override;
100 : #endif
101 :
102 : virtual nsresult NPP_New(NPMIMEType aPluginType, NPP aInstance,
103 : int16_t aArgc, char* aArgn[],
104 : char* aArgv[], NPSavedData* aSaved,
105 : NPError* aError) override;
106 :
107 : virtual nsresult NPP_ClearSiteData(const char* aSite, uint64_t aFlags,
108 : uint64_t aMaxAge, nsCOMPtr<nsIClearSiteDataCallback> callback) override;
109 : virtual nsresult NPP_GetSitesWithData(nsCOMPtr<nsIGetSitesWithDataCallback> callback) override;
110 :
111 : virtual nsresult AsyncSetWindow(NPP aInstance, NPWindow* aWindow) override;
112 : virtual nsresult GetImageContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
113 : virtual nsresult GetImageSize(NPP aInstance, nsIntSize* aSize) override;
114 0 : virtual bool IsOOP() override { return false; }
115 : #if defined(XP_MACOSX)
116 : virtual nsresult IsRemoteDrawingCoreAnimation(NPP aInstance, bool* aDrawing) override;
117 : #endif
118 : #if defined(XP_MACOSX) || defined(XP_WIN)
119 : virtual nsresult ContentsScaleFactorChanged(NPP aInstance, double aContentsScaleFactor) override;
120 : #endif
121 : virtual nsresult SetBackgroundUnknown(NPP instance) override;
122 : virtual nsresult BeginUpdateBackground(NPP instance, const nsIntRect&,
123 : DrawTarget** aDrawTarget) override;
124 : virtual nsresult EndUpdateBackground(NPP instance,
125 : const nsIntRect&) override;
126 0 : virtual void DidComposite(NPP aInstance) override { }
127 0 : virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); }
128 0 : virtual nsresult GetRunID(uint32_t* aRunID) override { return NS_ERROR_NOT_IMPLEMENTED; }
129 0 : virtual void SetHasLocalInstance() override { }
130 : #if defined(XP_WIN)
131 : virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
132 : #endif
133 : virtual nsresult HandledWindowedPluginKeyEvent(
134 : NPP aInstance,
135 : const mozilla::NativeEventData& aNativeKeyData,
136 : bool aIsCOnsumed) override;
137 :
138 : private:
139 : NP_InitializeFunc mNP_Initialize;
140 : NP_ShutdownFunc mNP_Shutdown;
141 : NP_GetMIMEDescriptionFunc mNP_GetMIMEDescription;
142 : #if defined(XP_UNIX) && !defined(XP_MACOSX)
143 : NP_GetValueFunc mNP_GetValue;
144 : #endif
145 : #if defined(XP_WIN) || defined(XP_MACOSX)
146 : NP_GetEntryPointsFunc mNP_GetEntryPoints;
147 : #endif
148 : NPP_NewProcPtr mNPP_New;
149 : NPP_ClearSiteDataPtr mNPP_ClearSiteData;
150 : NPP_GetSitesWithDataPtr mNPP_GetSitesWithData;
151 : PRLibrary* mLibrary;
152 : nsCString mFilePath;
153 : };
154 :
155 :
156 : } // namespace mozilla
157 :
158 : #endif // ifndef PluginPRLibrary_h
|