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

Side by Side Diff: webkit/glue/plugins/npapi_extension_thunk.cc

Issue 5998002: Revert "Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/npapi_extension_thunk.h ('k') | webkit/glue/plugins/plugin_constants_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/npapi/npapi_extension_thunk.h" 5 #include "webkit/glue/plugins/npapi_extension_thunk.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "third_party/npapi/bindings/npapi_extensions.h" 10 #include "third_party/npapi/bindings/npapi_extensions.h"
11 #include "webkit/plugins/npapi/plugin_instance.h" 11 #include "webkit/glue/plugins/plugin_instance.h"
12 #include "webkit/plugins/npapi/webplugin.h" 12 #include "webkit/glue/plugins/webplugin.h"
13 #include "webkit/plugins/npapi/webplugin_delegate.h" 13 #include "webkit/glue/plugins/webplugin_delegate.h"
14 #include "webkit/glue/webkit_glue.h" 14 #include "webkit/glue/webkit_glue.h"
15 15
16 namespace webkit {
17 namespace npapi {
18
19 // FindInstance() 16 // FindInstance()
20 // Finds a PluginInstance from an NPP. 17 // Finds a PluginInstance from an NPP.
21 // The caller must take a reference if needed. 18 // The caller must take a reference if needed.
22 static PluginInstance* FindInstance(NPP id) { 19 static NPAPI::PluginInstance* FindInstance(NPP id) {
23 if (id == NULL) { 20 if (id == NULL) {
24 NOTREACHED(); 21 NOTREACHED();
25 return NULL; 22 return NULL;
26 } 23 }
27 return static_cast<PluginInstance*>(id->ndata); 24 return static_cast<NPAPI::PluginInstance*>(id->ndata);
28 } 25 }
29 26
30 // 2D device API --------------------------------------------------------------- 27 // 2D device API ---------------------------------------------------------------
31 28
32 static NPError Device2DQueryCapability(NPP id, int32_t capability, 29 static NPError Device2DQueryCapability(NPP id, int32_t capability,
33 int32_t* value) { 30 int32_t* value) {
34 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 31 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
35 if (plugin) { 32 if (plugin) {
36 plugin->webplugin()->delegate()->Device2DQueryCapability(capability, value); 33 plugin->webplugin()->delegate()->Device2DQueryCapability(capability, value);
37 return NPERR_NO_ERROR; 34 return NPERR_NO_ERROR;
38 } else { 35 } else {
39 return NPERR_GENERIC_ERROR; 36 return NPERR_GENERIC_ERROR;
40 } 37 }
41 } 38 }
42 39
43 static NPError Device2DQueryConfig(NPP id, 40 static NPError Device2DQueryConfig(NPP id,
44 const NPDeviceConfig* request, 41 const NPDeviceConfig* request,
45 NPDeviceConfig* obtain) { 42 NPDeviceConfig* obtain) {
46 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 43 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
47 if (plugin) { 44 if (plugin) {
48 return plugin->webplugin()->delegate()->Device2DQueryConfig( 45 return plugin->webplugin()->delegate()->Device2DQueryConfig(
49 static_cast<const NPDeviceContext2DConfig*>(request), 46 static_cast<const NPDeviceContext2DConfig*>(request),
50 static_cast<NPDeviceContext2DConfig*>(obtain)); 47 static_cast<NPDeviceContext2DConfig*>(obtain));
51 } 48 }
52 return NPERR_GENERIC_ERROR; 49 return NPERR_GENERIC_ERROR;
53 } 50 }
54 51
55 static NPError Device2DInitializeContext(NPP id, 52 static NPError Device2DInitializeContext(NPP id,
56 const NPDeviceConfig* config, 53 const NPDeviceConfig* config,
57 NPDeviceContext* context) { 54 NPDeviceContext* context) {
58 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 55 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
59 if (plugin) { 56 if (plugin) {
60 return plugin->webplugin()->delegate()->Device2DInitializeContext( 57 return plugin->webplugin()->delegate()->Device2DInitializeContext(
61 static_cast<const NPDeviceContext2DConfig*>(config), 58 static_cast<const NPDeviceContext2DConfig*>(config),
62 static_cast<NPDeviceContext2D*>(context)); 59 static_cast<NPDeviceContext2D*>(context));
63 } 60 }
64 return NPERR_GENERIC_ERROR; 61 return NPERR_GENERIC_ERROR;
65 } 62 }
66 63
67 static NPError Device2DSetStateContext(NPP id, 64 static NPError Device2DSetStateContext(NPP id,
68 NPDeviceContext* context, 65 NPDeviceContext* context,
69 int32_t state, 66 int32_t state,
70 intptr_t value) { 67 intptr_t value) {
71 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 68 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
72 if (plugin) { 69 if (plugin) {
73 return plugin->webplugin()->delegate()->Device2DSetStateContext( 70 return plugin->webplugin()->delegate()->Device2DSetStateContext(
74 static_cast<NPDeviceContext2D*>(context), state, value); 71 static_cast<NPDeviceContext2D*>(context), state, value);
75 } 72 }
76 return NPERR_GENERIC_ERROR; 73 return NPERR_GENERIC_ERROR;
77 } 74 }
78 75
79 static NPError Device2DGetStateContext(NPP id, 76 static NPError Device2DGetStateContext(NPP id,
80 NPDeviceContext* context, 77 NPDeviceContext* context,
81 int32_t state, 78 int32_t state,
82 intptr_t* value) { 79 intptr_t* value) {
83 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 80 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
84 if (plugin) { 81 if (plugin) {
85 return plugin->webplugin()->delegate()->Device2DGetStateContext( 82 return plugin->webplugin()->delegate()->Device2DGetStateContext(
86 static_cast<NPDeviceContext2D*>(context), state, value); 83 static_cast<NPDeviceContext2D*>(context), state, value);
87 } 84 }
88 return NPERR_GENERIC_ERROR; 85 return NPERR_GENERIC_ERROR;
89 } 86 }
90 87
91 static NPError Device2DFlushContext(NPP id, 88 static NPError Device2DFlushContext(NPP id,
92 NPDeviceContext* context, 89 NPDeviceContext* context,
93 NPDeviceFlushContextCallbackPtr callback, 90 NPDeviceFlushContextCallbackPtr callback,
94 void* user_data) { 91 void* user_data) {
95 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 92 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
96 if (plugin) { 93 if (plugin) {
97 NPError err = plugin->webplugin()->delegate()->Device2DFlushContext( 94 NPError err = plugin->webplugin()->delegate()->Device2DFlushContext(
98 id, static_cast<NPDeviceContext2D*>(context), callback, user_data); 95 id, static_cast<NPDeviceContext2D*>(context), callback, user_data);
99 96
100 // Invoke the callback to inform the caller the work was done. 97 // Invoke the callback to inform the caller the work was done.
101 // TODO(brettw) this is probably not how we want this to work, this should 98 // TODO(brettw) this is probably not how we want this to work, this should
102 // happen when the frame is painted so the plugin knows when it can draw 99 // happen when the frame is painted so the plugin knows when it can draw
103 // the next frame. 100 // the next frame.
104 if (callback != NULL) 101 if (callback != NULL)
105 (*callback)(id, context, err, user_data); 102 (*callback)(id, context, err, user_data);
106 103
107 // Return any errors. 104 // Return any errors.
108 return err; 105 return err;
109 } 106 }
110 return NPERR_GENERIC_ERROR; 107 return NPERR_GENERIC_ERROR;
111 } 108 }
112 109
113 static NPError Device2DDestroyContext(NPP id, 110 static NPError Device2DDestroyContext(NPP id,
114 NPDeviceContext* context) { 111 NPDeviceContext* context) {
115 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 112 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
116 if (plugin) { 113 if (plugin) {
117 return plugin->webplugin()->delegate()->Device2DDestroyContext( 114 return plugin->webplugin()->delegate()->Device2DDestroyContext(
118 static_cast<NPDeviceContext2D*>(context)); 115 static_cast<NPDeviceContext2D*>(context));
119 } 116 }
120 return NPERR_GENERIC_ERROR; 117 return NPERR_GENERIC_ERROR;
121 } 118 }
122 119
123 static NPError Device2DCreateBuffer(NPP id, 120 static NPError Device2DCreateBuffer(NPP id,
124 NPDeviceContext* context, 121 NPDeviceContext* context,
125 size_t size, 122 size_t size,
(...skipping 11 matching lines...) Expand all
137 NPDeviceContext* context, 134 NPDeviceContext* context,
138 int32_t buffer_id, 135 int32_t buffer_id,
139 NPDeviceBuffer* buffer) { 136 NPDeviceBuffer* buffer) {
140 return NPERR_GENERIC_ERROR; 137 return NPERR_GENERIC_ERROR;
141 } 138 }
142 139
143 // 3D device API --------------------------------------------------------------- 140 // 3D device API ---------------------------------------------------------------
144 141
145 static NPError Device3DQueryCapability(NPP id, int32_t capability, 142 static NPError Device3DQueryCapability(NPP id, int32_t capability,
146 int32_t* value) { 143 int32_t* value) {
147 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 144 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
148 if (plugin) { 145 if (plugin) {
149 plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value); 146 plugin->webplugin()->delegate()->Device3DQueryCapability(capability, value);
150 return NPERR_NO_ERROR; 147 return NPERR_NO_ERROR;
151 } else { 148 } else {
152 return NPERR_GENERIC_ERROR; 149 return NPERR_GENERIC_ERROR;
153 } 150 }
154 } 151 }
155 152
156 static NPError Device3DQueryConfig(NPP id, 153 static NPError Device3DQueryConfig(NPP id,
157 const NPDeviceConfig* request, 154 const NPDeviceConfig* request,
158 NPDeviceConfig* obtain) { 155 NPDeviceConfig* obtain) {
159 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 156 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
160 if (plugin) { 157 if (plugin) {
161 return plugin->webplugin()->delegate()->Device3DQueryConfig( 158 return plugin->webplugin()->delegate()->Device3DQueryConfig(
162 static_cast<const NPDeviceContext3DConfig*>(request), 159 static_cast<const NPDeviceContext3DConfig*>(request),
163 static_cast<NPDeviceContext3DConfig*>(obtain)); 160 static_cast<NPDeviceContext3DConfig*>(obtain));
164 } 161 }
165 return NPERR_GENERIC_ERROR; 162 return NPERR_GENERIC_ERROR;
166 } 163 }
167 164
168 static NPError Device3DInitializeContext(NPP id, 165 static NPError Device3DInitializeContext(NPP id,
169 const NPDeviceConfig* config, 166 const NPDeviceConfig* config,
170 NPDeviceContext* context) { 167 NPDeviceContext* context) {
171 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 168 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
172 if (plugin) { 169 if (plugin) {
173 return plugin->webplugin()->delegate()->Device3DInitializeContext( 170 return plugin->webplugin()->delegate()->Device3DInitializeContext(
174 static_cast<const NPDeviceContext3DConfig*>(config), 171 static_cast<const NPDeviceContext3DConfig*>(config),
175 static_cast<NPDeviceContext3D*>(context)); 172 static_cast<NPDeviceContext3D*>(context));
176 } 173 }
177 return NPERR_GENERIC_ERROR; 174 return NPERR_GENERIC_ERROR;
178 } 175 }
179 176
180 static NPError Device3DSetStateContext(NPP id, 177 static NPError Device3DSetStateContext(NPP id,
181 NPDeviceContext* context, 178 NPDeviceContext* context,
182 int32_t state, 179 int32_t state,
183 intptr_t value) { 180 intptr_t value) {
184 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 181 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
185 if (plugin) { 182 if (plugin) {
186 return plugin->webplugin()->delegate()->Device3DSetStateContext( 183 return plugin->webplugin()->delegate()->Device3DSetStateContext(
187 static_cast<NPDeviceContext3D*>(context), state, value); 184 static_cast<NPDeviceContext3D*>(context), state, value);
188 } 185 }
189 return NPERR_GENERIC_ERROR; 186 return NPERR_GENERIC_ERROR;
190 } 187 }
191 188
192 static NPError Device3DGetStateContext(NPP id, 189 static NPError Device3DGetStateContext(NPP id,
193 NPDeviceContext* context, 190 NPDeviceContext* context,
194 int32_t state, 191 int32_t state,
195 intptr_t* value) { 192 intptr_t* value) {
196 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 193 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
197 if (plugin) { 194 if (plugin) {
198 return plugin->webplugin()->delegate()->Device3DGetStateContext( 195 return plugin->webplugin()->delegate()->Device3DGetStateContext(
199 static_cast<NPDeviceContext3D*>(context), state, value); 196 static_cast<NPDeviceContext3D*>(context), state, value);
200 } 197 }
201 return NPERR_GENERIC_ERROR; 198 return NPERR_GENERIC_ERROR;
202 } 199 }
203 200
204 static NPError Device3DFlushContext(NPP id, 201 static NPError Device3DFlushContext(NPP id,
205 NPDeviceContext* context, 202 NPDeviceContext* context,
206 NPDeviceFlushContextCallbackPtr callback, 203 NPDeviceFlushContextCallbackPtr callback,
207 void* user_data) { 204 void* user_data) {
208 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 205 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
209 if (plugin) { 206 if (plugin) {
210 return plugin->webplugin()->delegate()->Device3DFlushContext( 207 return plugin->webplugin()->delegate()->Device3DFlushContext(
211 id, static_cast<NPDeviceContext3D*>(context), callback, user_data); 208 id, static_cast<NPDeviceContext3D*>(context), callback, user_data);
212 } 209 }
213 return NPERR_GENERIC_ERROR; 210 return NPERR_GENERIC_ERROR;
214 } 211 }
215 212
216 static NPError Device3DDestroyContext(NPP id, 213 static NPError Device3DDestroyContext(NPP id,
217 NPDeviceContext* context) { 214 NPDeviceContext* context) {
218 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 215 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
219 if (plugin) { 216 if (plugin) {
220 return plugin->webplugin()->delegate()->Device3DDestroyContext( 217 return plugin->webplugin()->delegate()->Device3DDestroyContext(
221 static_cast<NPDeviceContext3D*>(context)); 218 static_cast<NPDeviceContext3D*>(context));
222 } 219 }
223 return NPERR_GENERIC_ERROR; 220 return NPERR_GENERIC_ERROR;
224 } 221 }
225 222
226 static NPError Device3DCreateBuffer(NPP id, 223 static NPError Device3DCreateBuffer(NPP id,
227 NPDeviceContext* context, 224 NPDeviceContext* context,
228 size_t size, 225 size_t size,
229 int32_t* buffer_id) { 226 int32_t* buffer_id) {
230 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 227 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
231 if (plugin) { 228 if (plugin) {
232 return plugin->webplugin()->delegate()->Device3DCreateBuffer( 229 return plugin->webplugin()->delegate()->Device3DCreateBuffer(
233 static_cast<NPDeviceContext3D*>(context), size, buffer_id); 230 static_cast<NPDeviceContext3D*>(context), size, buffer_id);
234 } 231 }
235 return NPERR_GENERIC_ERROR; 232 return NPERR_GENERIC_ERROR;
236 } 233 }
237 234
238 static NPError Device3DDestroyBuffer(NPP id, 235 static NPError Device3DDestroyBuffer(NPP id,
239 NPDeviceContext* context, 236 NPDeviceContext* context,
240 int32_t buffer_id) { 237 int32_t buffer_id) {
241 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 238 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
242 if (plugin) { 239 if (plugin) {
243 return plugin->webplugin()->delegate()->Device3DDestroyBuffer( 240 return plugin->webplugin()->delegate()->Device3DDestroyBuffer(
244 static_cast<NPDeviceContext3D*>(context), buffer_id); 241 static_cast<NPDeviceContext3D*>(context), buffer_id);
245 } 242 }
246 return NPERR_GENERIC_ERROR; 243 return NPERR_GENERIC_ERROR;
247 } 244 }
248 245
249 static NPError Device3DMapBuffer(NPP id, 246 static NPError Device3DMapBuffer(NPP id,
250 NPDeviceContext* context, 247 NPDeviceContext* context,
251 int32_t buffer_id, 248 int32_t buffer_id,
252 NPDeviceBuffer* buffer) { 249 NPDeviceBuffer* buffer) {
253 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 250 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
254 if (plugin) { 251 if (plugin) {
255 return plugin->webplugin()->delegate()->Device3DMapBuffer( 252 return plugin->webplugin()->delegate()->Device3DMapBuffer(
256 static_cast<NPDeviceContext3D*>(context), buffer_id, buffer); 253 static_cast<NPDeviceContext3D*>(context), buffer_id, buffer);
257 } 254 }
258 return NPERR_GENERIC_ERROR; 255 return NPERR_GENERIC_ERROR;
259 } 256 }
260 257
261 // Experimental 3D device API -------------------------------------------------- 258 // Experimental 3D device API --------------------------------------------------
262 259
263 static NPError Device3DGetNumConfigs(NPP id, int32_t* num_configs) { 260 static NPError Device3DGetNumConfigs(NPP id, int32_t* num_configs) {
264 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 261 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
265 if (plugin) { 262 if (plugin) {
266 return plugin->webplugin()->delegate()->Device3DGetNumConfigs(num_configs); 263 return plugin->webplugin()->delegate()->Device3DGetNumConfigs(num_configs);
267 } 264 }
268 return NPERR_GENERIC_ERROR; 265 return NPERR_GENERIC_ERROR;
269 } 266 }
270 267
271 static NPError Device3DGetConfigAttribs(NPP id, 268 static NPError Device3DGetConfigAttribs(NPP id,
272 int32_t config, 269 int32_t config,
273 int32_t* attrib_list) { 270 int32_t* attrib_list) {
274 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 271 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
275 if (plugin) { 272 if (plugin) {
276 return plugin->webplugin()->delegate()->Device3DGetConfigAttribs( 273 return plugin->webplugin()->delegate()->Device3DGetConfigAttribs(
277 config, 274 config,
278 attrib_list); 275 attrib_list);
279 } 276 }
280 return NPERR_GENERIC_ERROR; 277 return NPERR_GENERIC_ERROR;
281 } 278 }
282 279
283 static NPError Device3DCreateContext(NPP id, 280 static NPError Device3DCreateContext(NPP id,
284 int32_t config, 281 int32_t config,
285 const int32_t* attrib_list, 282 const int32_t* attrib_list,
286 NPDeviceContext** context) { 283 NPDeviceContext** context) {
287 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 284 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
288 if (plugin) { 285 if (plugin) {
289 return plugin->webplugin()->delegate()->Device3DCreateContext( 286 return plugin->webplugin()->delegate()->Device3DCreateContext(
290 config, 287 config,
291 attrib_list, 288 attrib_list,
292 reinterpret_cast<NPDeviceContext3D**>(context)); 289 reinterpret_cast<NPDeviceContext3D**>(context));
293 } 290 }
294 return NPERR_GENERIC_ERROR; 291 return NPERR_GENERIC_ERROR;
295 } 292 }
296 293
297 static NPError Device3DSynchronizeContext( 294 static NPError Device3DSynchronizeContext(
298 NPP id, 295 NPP id,
299 NPDeviceContext* context, 296 NPDeviceContext* context,
300 NPDeviceSynchronizationMode mode, 297 NPDeviceSynchronizationMode mode,
301 const int32_t* input_attrib_list, 298 const int32_t* input_attrib_list,
302 int32_t* output_attrib_list, 299 int32_t* output_attrib_list,
303 NPDeviceSynchronizeContextCallbackPtr callback, 300 NPDeviceSynchronizeContextCallbackPtr callback,
304 void* callback_data) { 301 void* callback_data) {
305 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 302 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
306 if (plugin) { 303 if (plugin) {
307 return plugin->webplugin()->delegate()->Device3DSynchronizeContext( 304 return plugin->webplugin()->delegate()->Device3DSynchronizeContext(
308 id, 305 id,
309 static_cast<NPDeviceContext3D*>(context), 306 static_cast<NPDeviceContext3D*>(context),
310 mode, 307 mode,
311 input_attrib_list, 308 input_attrib_list,
312 output_attrib_list, 309 output_attrib_list,
313 callback, 310 callback,
314 callback_data); 311 callback_data);
315 } 312 }
316 return NPERR_GENERIC_ERROR; 313 return NPERR_GENERIC_ERROR;
317 } 314 }
318 315
319 static NPError Device3DRegisterCallback( 316 static NPError Device3DRegisterCallback(
320 NPP id, 317 NPP id,
321 NPDeviceContext* context, 318 NPDeviceContext* context,
322 int32_t callback_type, 319 int32_t callback_type,
323 NPDeviceGenericCallbackPtr callback, 320 NPDeviceGenericCallbackPtr callback,
324 void* callback_data) { 321 void* callback_data) {
325 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 322 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
326 if (plugin) { 323 if (plugin) {
327 return plugin->webplugin()->delegate()->Device3DRegisterCallback( 324 return plugin->webplugin()->delegate()->Device3DRegisterCallback(
328 id, 325 id,
329 static_cast<NPDeviceContext3D*>(context), 326 static_cast<NPDeviceContext3D*>(context),
330 callback_type, 327 callback_type,
331 callback, 328 callback,
332 callback_data); 329 callback_data);
333 } 330 }
334 return NPERR_GENERIC_ERROR; 331 return NPERR_GENERIC_ERROR;
335 } 332 }
336 333
337 // Audio device API ------------------------------------------------------------ 334 // Audio device API ------------------------------------------------------------
338 335
339 static NPError DeviceAudioQueryCapability(NPP id, int32_t capability, 336 static NPError DeviceAudioQueryCapability(NPP id, int32_t capability,
340 int32_t* value) { 337 int32_t* value) {
341 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 338 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
342 if (plugin) { 339 if (plugin) {
343 plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability, 340 plugin->webplugin()->delegate()->DeviceAudioQueryCapability(capability,
344 value); 341 value);
345 return NPERR_NO_ERROR; 342 return NPERR_NO_ERROR;
346 } else { 343 } else {
347 return NPERR_GENERIC_ERROR; 344 return NPERR_GENERIC_ERROR;
348 } 345 }
349 } 346 }
350 347
351 static NPError DeviceAudioQueryConfig(NPP id, 348 static NPError DeviceAudioQueryConfig(NPP id,
352 const NPDeviceConfig* request, 349 const NPDeviceConfig* request,
353 NPDeviceConfig* obtain) { 350 NPDeviceConfig* obtain) {
354 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 351 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
355 if (plugin) { 352 if (plugin) {
356 return plugin->webplugin()->delegate()->DeviceAudioQueryConfig( 353 return plugin->webplugin()->delegate()->DeviceAudioQueryConfig(
357 static_cast<const NPDeviceContextAudioConfig*>(request), 354 static_cast<const NPDeviceContextAudioConfig*>(request),
358 static_cast<NPDeviceContextAudioConfig*>(obtain)); 355 static_cast<NPDeviceContextAudioConfig*>(obtain));
359 } 356 }
360 return NPERR_GENERIC_ERROR; 357 return NPERR_GENERIC_ERROR;
361 } 358 }
362 359
363 static NPError DeviceAudioInitializeContext(NPP id, 360 static NPError DeviceAudioInitializeContext(NPP id,
364 const NPDeviceConfig* config, 361 const NPDeviceConfig* config,
365 NPDeviceContext* context) { 362 NPDeviceContext* context) {
366 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 363 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
367 if (plugin) { 364 if (plugin) {
368 return plugin->webplugin()->delegate()->DeviceAudioInitializeContext( 365 return plugin->webplugin()->delegate()->DeviceAudioInitializeContext(
369 static_cast<const NPDeviceContextAudioConfig*>(config), 366 static_cast<const NPDeviceContextAudioConfig*>(config),
370 static_cast<NPDeviceContextAudio*>(context)); 367 static_cast<NPDeviceContextAudio*>(context));
371 } 368 }
372 return NPERR_GENERIC_ERROR; 369 return NPERR_GENERIC_ERROR;
373 } 370 }
374 371
375 static NPError DeviceAudioSetStateContext(NPP id, 372 static NPError DeviceAudioSetStateContext(NPP id,
376 NPDeviceContext* context, 373 NPDeviceContext* context,
377 int32_t state, 374 int32_t state,
378 intptr_t value) { 375 intptr_t value) {
379 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 376 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
380 if (plugin) { 377 if (plugin) {
381 return plugin->webplugin()->delegate()->DeviceAudioSetStateContext( 378 return plugin->webplugin()->delegate()->DeviceAudioSetStateContext(
382 static_cast<NPDeviceContextAudio*>(context), state, value); 379 static_cast<NPDeviceContextAudio*>(context), state, value);
383 } 380 }
384 return NPERR_GENERIC_ERROR; 381 return NPERR_GENERIC_ERROR;
385 } 382 }
386 383
387 static NPError DeviceAudioGetStateContext(NPP id, 384 static NPError DeviceAudioGetStateContext(NPP id,
388 NPDeviceContext* context, 385 NPDeviceContext* context,
389 int32_t state, 386 int32_t state,
390 intptr_t* value) { 387 intptr_t* value) {
391 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 388 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
392 return plugin->webplugin()->delegate()->DeviceAudioGetStateContext( 389 return plugin->webplugin()->delegate()->DeviceAudioGetStateContext(
393 static_cast<NPDeviceContextAudio*>(context), state, value); 390 static_cast<NPDeviceContextAudio*>(context), state, value);
394 } 391 }
395 392
396 static NPError DeviceAudioFlushContext(NPP id, 393 static NPError DeviceAudioFlushContext(NPP id,
397 NPDeviceContext* context, 394 NPDeviceContext* context,
398 NPDeviceFlushContextCallbackPtr callback, 395 NPDeviceFlushContextCallbackPtr callback,
399 void* user_data) { 396 void* user_data) {
400 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 397 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
401 return plugin->webplugin()->delegate()->DeviceAudioFlushContext( 398 return plugin->webplugin()->delegate()->DeviceAudioFlushContext(
402 id, static_cast<NPDeviceContextAudio*>(context), callback, user_data); 399 id, static_cast<NPDeviceContextAudio*>(context), callback, user_data);
403 } 400 }
404 401
405 static NPError DeviceAudioDestroyContext(NPP id, 402 static NPError DeviceAudioDestroyContext(NPP id,
406 NPDeviceContext* context) { 403 NPDeviceContext* context) {
407 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 404 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
408 return plugin->webplugin()->delegate()->DeviceAudioDestroyContext( 405 return plugin->webplugin()->delegate()->DeviceAudioDestroyContext(
409 static_cast<NPDeviceContextAudio*>(context)); 406 static_cast<NPDeviceContextAudio*>(context));
410 } 407 }
411 // ----------------------------------------------------------------------------- 408 // -----------------------------------------------------------------------------
412 409
413 static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { 410 static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) {
414 static NPDevice device_2d = { 411 static NPDevice device_2d = {
415 Device2DQueryCapability, 412 Device2DQueryCapability,
416 Device2DQueryConfig, 413 Device2DQueryConfig,
417 Device2DInitializeContext, 414 Device2DInitializeContext,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 default: 470 default:
474 return NULL; 471 return NULL;
475 } 472 }
476 } 473 }
477 474
478 static NPError ChooseFile(NPP id, 475 static NPError ChooseFile(NPP id,
479 const char* mime_types, 476 const char* mime_types,
480 NPChooseFileMode mode, 477 NPChooseFileMode mode,
481 NPChooseFileCallback callback, 478 NPChooseFileCallback callback,
482 void* user_data) { 479 void* user_data) {
483 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 480 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
484 if (!plugin) 481 if (!plugin)
485 return NPERR_GENERIC_ERROR; 482 return NPERR_GENERIC_ERROR;
486 483
487 if (!plugin->webplugin()->delegate()->ChooseFile(mime_types, 484 if (!plugin->webplugin()->delegate()->ChooseFile(mime_types,
488 static_cast<int>(mode), 485 static_cast<int>(mode),
489 callback, user_data)) 486 callback, user_data))
490 return NPERR_GENERIC_ERROR; 487 return NPERR_GENERIC_ERROR;
491 488
492 return NPERR_NO_ERROR; 489 return NPERR_NO_ERROR;
493 } 490 }
494 491
495 static void NumberOfFindResultsChanged(NPP id, int total, bool final_result) { 492 static void NumberOfFindResultsChanged(NPP id, int total, bool final_result) {
496 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 493 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
497 if (plugin) { 494 if (plugin) {
498 plugin->webplugin()->delegate()->NumberOfFindResultsChanged( 495 plugin->webplugin()->delegate()->NumberOfFindResultsChanged(
499 total, final_result); 496 total, final_result);
500 } 497 }
501 } 498 }
502 499
503 static void SelectedFindResultChanged(NPP id, int index) { 500 static void SelectedFindResultChanged(NPP id, int index) {
504 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 501 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
505 if (plugin) 502 if (plugin)
506 plugin->webplugin()->delegate()->SelectedFindResultChanged(index); 503 plugin->webplugin()->delegate()->SelectedFindResultChanged(index);
507 } 504 }
508 505
509 static NPWidgetExtensions* GetWidgetExtensions(NPP id) { 506 static NPWidgetExtensions* GetWidgetExtensions(NPP id) {
510 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 507 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
511 if (!plugin) 508 if (!plugin)
512 return NULL; 509 return NULL;
513 510
514 return plugin->webplugin()->delegate()->GetWidgetExtensions(); 511 return plugin->webplugin()->delegate()->GetWidgetExtensions();
515 } 512 }
516 513
517 static NPError NPSetCursor(NPP id, NPCursorType type) { 514 static NPError NPSetCursor(NPP id, NPCursorType type) {
518 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 515 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
519 if (!plugin) 516 if (!plugin)
520 return NPERR_GENERIC_ERROR; 517 return NPERR_GENERIC_ERROR;
521 518
522 return plugin->webplugin()->delegate()->SetCursor(type) ? 519 return plugin->webplugin()->delegate()->SetCursor(type) ?
523 NPERR_NO_ERROR : NPERR_GENERIC_ERROR; 520 NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
524 } 521 }
525 522
526 static NPFontExtensions* GetFontExtensions(NPP id) { 523 static NPFontExtensions* GetFontExtensions(NPP id) {
527 scoped_refptr<PluginInstance> plugin(FindInstance(id)); 524 scoped_refptr<NPAPI::PluginInstance> plugin(FindInstance(id));
528 if (!plugin) 525 if (!plugin)
529 return NULL; 526 return NULL;
530 527
531 return plugin->webplugin()->delegate()->GetFontExtensions(); 528 return plugin->webplugin()->delegate()->GetFontExtensions();
532 } 529 }
533 530
531 namespace NPAPI {
532
534 NPError GetPepperExtensionsFunctions(void* value) { 533 NPError GetPepperExtensionsFunctions(void* value) {
535 static const NPNExtensions kExtensions = { 534 static const NPNExtensions kExtensions = {
536 &AcquireDevice, 535 &AcquireDevice,
537 &NumberOfFindResultsChanged, 536 &NumberOfFindResultsChanged,
538 &SelectedFindResultChanged, 537 &SelectedFindResultChanged,
539 &ChooseFile, 538 &ChooseFile,
540 &GetWidgetExtensions, 539 &GetWidgetExtensions,
541 &NPSetCursor, 540 &NPSetCursor,
542 &GetFontExtensions, 541 &GetFontExtensions,
543 }; 542 };
544 543
545 // Return a pointer to the canonical function table. 544 // Return a pointer to the canonical function table.
546 NPNExtensions* extensions = const_cast<NPNExtensions*>(&kExtensions); 545 NPNExtensions* extensions = const_cast<NPNExtensions*>(&kExtensions);
547 NPNExtensions** exts = reinterpret_cast<NPNExtensions**>(value); 546 NPNExtensions** exts = reinterpret_cast<NPNExtensions**>(value);
548 *exts = extensions; 547 *exts = extensions;
549 return NPERR_NO_ERROR; 548 return NPERR_NO_ERROR;
550 } 549 }
551 550
552 } // namespace npapi 551 } // namespace NPAPI
553 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/glue/plugins/npapi_extension_thunk.h ('k') | webkit/glue/plugins/plugin_constants_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698