|
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 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 mFilePath(aFilePath) |
|
38 { |
|
39 NS_ASSERTION(mLibrary, "need non-null lib"); |
|
40 // addref here?? |
|
41 } |
|
42 |
|
43 virtual ~PluginPRLibrary() |
|
44 { |
|
45 // unref here?? |
|
46 } |
|
47 |
|
48 virtual void SetPlugin(nsNPAPIPlugin*) { } |
|
49 |
|
50 virtual bool HasRequiredFunctions() { |
|
51 mNP_Initialize = (NP_InitializeFunc) |
|
52 PR_FindFunctionSymbol(mLibrary, "NP_Initialize"); |
|
53 if (!mNP_Initialize) |
|
54 return false; |
|
55 |
|
56 mNP_Shutdown = (NP_ShutdownFunc) |
|
57 PR_FindFunctionSymbol(mLibrary, "NP_Shutdown"); |
|
58 if (!mNP_Shutdown) |
|
59 return false; |
|
60 |
|
61 mNP_GetMIMEDescription = (NP_GetMIMEDescriptionFunc) |
|
62 PR_FindFunctionSymbol(mLibrary, "NP_GetMIMEDescription"); |
|
63 #ifndef XP_MACOSX |
|
64 if (!mNP_GetMIMEDescription) |
|
65 return false; |
|
66 #endif |
|
67 |
|
68 #if defined(XP_UNIX) && !defined(XP_MACOSX) |
|
69 mNP_GetValue = (NP_GetValueFunc) |
|
70 PR_FindFunctionSymbol(mLibrary, "NP_GetValue"); |
|
71 if (!mNP_GetValue) |
|
72 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 return true; |
|
82 } |
|
83 |
|
84 #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) |
|
85 virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, |
|
86 NPPluginFuncs* pFuncs, NPError* error); |
|
87 #else |
|
88 virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, |
|
89 NPError* error); |
|
90 #endif |
|
91 |
|
92 virtual nsresult NP_Shutdown(NPError* error); |
|
93 virtual nsresult NP_GetMIMEDescription(const char** mimeDesc); |
|
94 |
|
95 virtual nsresult NP_GetValue(void *future, NPPVariable aVariable, |
|
96 void *aValue, NPError* error); |
|
97 |
|
98 #if defined(XP_WIN) || defined(XP_MACOSX) |
|
99 virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error); |
|
100 #endif |
|
101 |
|
102 virtual nsresult NPP_New(NPMIMEType pluginType, NPP instance, |
|
103 uint16_t mode, int16_t argc, char* argn[], |
|
104 char* argv[], NPSavedData* saved, |
|
105 NPError* error); |
|
106 |
|
107 virtual nsresult NPP_ClearSiteData(const char* site, uint64_t flags, |
|
108 uint64_t maxAge); |
|
109 virtual nsresult NPP_GetSitesWithData(InfallibleTArray<nsCString>& result); |
|
110 |
|
111 virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window); |
|
112 virtual nsresult GetImageContainer(NPP instance, mozilla::layers::ImageContainer** aContainer); |
|
113 virtual nsresult GetImageSize(NPP instance, nsIntSize* aSize); |
|
114 virtual bool IsOOP() MOZ_OVERRIDE { return false; } |
|
115 #if defined(XP_MACOSX) |
|
116 virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing); |
|
117 virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor); |
|
118 #endif |
|
119 virtual nsresult SetBackgroundUnknown(NPP instance) MOZ_OVERRIDE; |
|
120 virtual nsresult BeginUpdateBackground(NPP instance, |
|
121 const nsIntRect&, gfxContext** aCtx) MOZ_OVERRIDE; |
|
122 virtual nsresult EndUpdateBackground(NPP instance, |
|
123 gfxContext* aCtx, const nsIntRect&) MOZ_OVERRIDE; |
|
124 virtual void GetLibraryPath(nsACString& aPath) { aPath.Assign(mFilePath); } |
|
125 |
|
126 private: |
|
127 NP_InitializeFunc mNP_Initialize; |
|
128 NP_ShutdownFunc mNP_Shutdown; |
|
129 NP_GetMIMEDescriptionFunc mNP_GetMIMEDescription; |
|
130 #if defined(XP_UNIX) && !defined(XP_MACOSX) |
|
131 NP_GetValueFunc mNP_GetValue; |
|
132 #endif |
|
133 #if defined(XP_WIN) || defined(XP_MACOSX) |
|
134 NP_GetEntryPointsFunc mNP_GetEntryPoints; |
|
135 #endif |
|
136 NPP_NewProcPtr mNPP_New; |
|
137 NPP_ClearSiteDataPtr mNPP_ClearSiteData; |
|
138 NPP_GetSitesWithDataPtr mNPP_GetSitesWithData; |
|
139 PRLibrary* mLibrary; |
|
140 nsCString mFilePath; |
|
141 }; |
|
142 |
|
143 |
|
144 } // namespace mozilla |
|
145 |
|
146 #endif // ifndef PluginPRLibrary_h |