Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: plugins/base/npp_gate.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « plugins/base/npn_gate.cc ('k') | plugins/base/npplat.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Netscape Public License
6 * Version 1.1 (the "License"); you may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/NPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the NPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the NPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38
39 ////////////////////////////////////////////////////////////
40 //
41 // Implementation of plugin entry points (NPP_*)
42 //
43 #include "omaha/plugins/base/pluginbase.h"
44
45 // here the plugin creates a plugin instance object which
46 // will be associated with this newly created NPP instance and
47 // will do all the neccessary job
48 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch ar* argn[], char* argv[], NPSavedData* saved)
49 {
50 if(instance == NULL)
51 return NPERR_INVALID_INSTANCE_ERROR;
52
53 NPError rv = NPERR_NO_ERROR;
54
55 // create a new plugin instance object
56 // initialization will be done when the associated window is ready
57 nsPluginCreateData ds;
58
59 ds.instance = instance;
60 ds.type = pluginType;
61 ds.mode = mode;
62 ds.argc = argc;
63 ds.argn = argn;
64 ds.argv = argv;
65 ds.saved = saved;
66
67 nsPluginInstanceBase * plugin = NS_NewPluginInstance(&ds);
68 if(plugin == NULL)
69 return NPERR_OUT_OF_MEMORY_ERROR;
70
71 // associate the plugin instance object with NPP instance
72 instance->pdata = (void *)plugin;
73 return rv;
74 }
75
76 // here is the place to clean up and destroy the nsPluginInstance object
77 NPError NPP_Destroy (NPP instance, NPSavedData** save)
78 {
79 if(instance == NULL)
80 return NPERR_INVALID_INSTANCE_ERROR;
81
82 NPError rv = NPERR_NO_ERROR;
83
84 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
85 if(plugin != NULL) {
86 plugin->shut();
87 NS_DestroyPluginInstance(plugin);
88 }
89 return rv;
90 }
91
92 // during this call we know when the plugin window is ready or
93 // is about to be destroyed so we can do some gui specific
94 // initialization and shutdown
95 NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
96 {
97 if(instance == NULL)
98 return NPERR_INVALID_INSTANCE_ERROR;
99
100 NPError rv = NPERR_NO_ERROR;
101
102 if(pNPWindow == NULL)
103 return NPERR_GENERIC_ERROR;
104
105 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
106
107 if(plugin == NULL)
108 return NPERR_GENERIC_ERROR;
109
110 // window just created
111 if(!plugin->isInitialized() && (pNPWindow->window != NULL)) {
112 if(!plugin->init(pNPWindow)) {
113 NS_DestroyPluginInstance(plugin);
114 return NPERR_MODULE_LOAD_FAILED_ERROR;
115 }
116 }
117
118 // window goes away
119 if((pNPWindow->window == NULL) && plugin->isInitialized())
120 return plugin->SetWindow(pNPWindow);
121
122 // window resized?
123 if(plugin->isInitialized() && (pNPWindow->window != NULL))
124 return plugin->SetWindow(pNPWindow);
125
126 // this should not happen, nothing to do
127 if((pNPWindow->window == NULL) && !plugin->isInitialized())
128 return plugin->SetWindow(pNPWindow);
129
130 return rv;
131 }
132
133 NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool se ekable, uint16* stype)
134 {
135 if(instance == NULL)
136 return NPERR_INVALID_INSTANCE_ERROR;
137
138 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
139 if(plugin == NULL)
140 return NPERR_GENERIC_ERROR;
141
142 NPError rv = plugin->NewStream(type, stream, seekable, stype);
143 return rv;
144 }
145
146 int32 NPP_WriteReady (NPP instance, NPStream *stream)
147 {
148 if(instance == NULL)
149 return 0x0fffffff;
150
151 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
152 if(plugin == NULL)
153 return 0x0fffffff;
154
155 int32 rv = plugin->WriteReady(stream);
156 return rv;
157 }
158
159 int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void * buffer)
160 {
161 if(instance == NULL)
162 return len;
163
164 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
165 if(plugin == NULL)
166 return len;
167
168 int32 rv = plugin->Write(stream, offset, len, buffer);
169 return rv;
170 }
171
172 NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
173 {
174 if(instance == NULL)
175 return NPERR_INVALID_INSTANCE_ERROR;
176
177 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
178 if(plugin == NULL)
179 return NPERR_GENERIC_ERROR;
180
181 NPError rv = plugin->DestroyStream(stream, reason);
182 return rv;
183 }
184
185 void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
186 {
187 if(instance == NULL)
188 return;
189
190 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
191 if(plugin == NULL)
192 return;
193
194 plugin->StreamAsFile(stream, fname);
195 }
196
197 void NPP_Print (NPP instance, NPPrint* printInfo)
198 {
199 if(instance == NULL)
200 return;
201
202 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
203 if(plugin == NULL)
204 return;
205
206 plugin->Print(printInfo);
207 }
208
209 void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyD ata)
210 {
211 if(instance == NULL)
212 return;
213
214 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
215 if(plugin == NULL)
216 return;
217
218 plugin->URLNotify(url, reason, notifyData);
219 }
220
221 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
222 {
223 if(instance == NULL)
224 return NPERR_INVALID_INSTANCE_ERROR;
225
226 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
227 if(plugin == NULL)
228 return NPERR_GENERIC_ERROR;
229
230 NPError rv = plugin->GetValue(variable, value);
231 return rv;
232 }
233
234 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
235 {
236 if(instance == NULL)
237 return NPERR_INVALID_INSTANCE_ERROR;
238
239 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
240 if(plugin == NULL)
241 return NPERR_GENERIC_ERROR;
242
243 NPError rv = plugin->SetValue(variable, value);
244 return rv;
245 }
246
247 int16 NPP_HandleEvent(NPP instance, void* event)
248 {
249 if(instance == NULL)
250 return 0;
251
252 nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
253 if(plugin == NULL)
254 return 0;
255
256 uint16 rv = plugin->HandleEvent(event);
257 return rv;
258 }
259
260 #ifdef OJI
261 jref NPP_GetJavaClass (void)
262 {
263 return NULL;
264 }
265 #endif
266
267 /**************************************************/
268 /* */
269 /* Mac */
270 /* */
271 /**************************************************/
272
273 // Mac needs these wrappers, see npplat.h for more info
274
275 #ifdef XP_MAC
276
277 NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc , char* argn[], char* argv[], NPSavedData* saved)
278 {
279 NPError rv = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
280 return rv;
281 }
282
283 NPError Private_Destroy(NPP instance, NPSavedData** save)
284 {
285 NPError rv = NPP_Destroy(instance, save);
286 return rv;
287 }
288
289 NPError Private_SetWindow(NPP instance, NPWindow* window)
290 {
291 NPError rv = NPP_SetWindow(instance, window);
292 return rv;
293 }
294
295 NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBoo l seekable, uint16* stype)
296 {
297 NPError rv = NPP_NewStream(instance, type, stream, seekable, stype);
298 return rv;
299 }
300
301 int32 Private_WriteReady(NPP instance, NPStream* stream)
302 {
303 int32 rv = NPP_WriteReady(instance, stream);
304 return rv;
305 }
306
307 int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, voi d* buffer)
308 {
309 int32 rv = NPP_Write(instance, stream, offset, len, buffer);
310 return rv;
311 }
312
313 void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
314 {
315 NPP_StreamAsFile(instance, stream, fname);
316 }
317
318
319 NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
320 {
321 NPError rv = NPP_DestroyStream(instance, stream, reason);
322 return rv;
323 }
324
325 int16 Private_HandleEvent(NPP instance, void* event)
326 {
327 int16 rv = NPP_HandleEvent(instance, event);
328 return rv;
329 }
330
331 void Private_Print(NPP instance, NPPrint* platformPrint)
332 {
333 NPP_Print(instance, platformPrint);
334 }
335
336 void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* not ifyData)
337 {
338 NPP_URLNotify(instance, url, reason, notifyData);
339 }
340
341 jref Private_GetJavaClass(void)
342 {
343 return NULL;
344 }
345
346 NPError Private_GetValue(NPP instance, NPPVariable variable, void *result)
347 {
348 NPError rv = NPP_GetValue(instance, variable, result);
349 return rv;
350 }
351
352 NPError Private_SetValue(NPP instance, NPNVariable variable, void *value)
353 {
354 NPError rv = NPP_SetValue(instance, variable, value);
355 return rv;
356 }
357
358 #endif //XP_MAC
OLDNEW
« no previous file with comments | « plugins/base/npn_gate.cc ('k') | plugins/base/npplat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698