| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Ap
ple") in | |
| 3 consideration of your agreement to the following terms, and your use, installat
ion, | |
| 4 modification or redistribution of this Apple software constitutes acceptance of
these | |
| 5 terms. If you do not agree with these terms, please do not use, install, modif
y or | |
| 6 redistribute this Apple software. | |
| 7 | |
| 8 In consideration of your agreement to abide by the following terms, and subject
to these | |
| 9 terms, Apple grants you a personal, non-exclusive license, under Appleās copyri
ghts in | |
| 10 this original Apple software (the "Apple Software"), to use, reproduce, modify
and | |
| 11 redistribute the Apple Software, with or without modifications, in source and/o
r binary | |
| 12 forms; provided that if you redistribute the Apple Software in its entirety and
without | |
| 13 modifications, you must retain this notice and the following text and disclaime
rs in all | |
| 14 such redistributions of the Apple Software. Neither the name, trademarks, serv
ice marks | |
| 15 or logos of Apple Computer, Inc. may be used to endorse or promote products der
ived from | |
| 16 the Apple Software without specific prior written permission from Apple. Except
as expressly | |
| 17 stated in this notice, no other rights or licenses, express or implied, are gra
nted by Apple | |
| 18 herein, including but not limited to any patent rights that may be infringed by
your | |
| 19 derivative works or by other works in which the Apple Software may be incorpora
ted. | |
| 20 | |
| 21 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WA
RRANTIES, | |
| 22 EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-
INFRINGEMENT, | |
| 23 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTW
ARE OR ITS | |
| 24 USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. | |
| 25 | |
| 26 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONS
EQUENTIAL | |
| 27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERV
ICES; LOSS | |
| 28 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY
OUT OF THE USE, | |
| 29 REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER C
AUSED AND | |
| 30 WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY
OR | |
| 31 OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 32 */ | |
| 33 | |
| 34 #include <stdlib.h> | |
| 35 #include <stdio.h> | |
| 36 #include <string.h> | |
| 37 #include <wtf/Platform.h> | |
| 38 #include "PluginObject.h" | |
| 39 | |
| 40 #ifdef WIN32 | |
| 41 #define strcasecmp _stricmp | |
| 42 #define NPAPI WINAPI | |
| 43 #else | |
| 44 #define NPAPI | |
| 45 #endif | |
| 46 | |
| 47 #if defined(__GNUC__) && __GNUC__ >= 4 | |
| 48 #define EXPORT __attribute__((visibility ("default"))) | |
| 49 #else | |
| 50 #define EXPORT | |
| 51 #endif | |
| 52 | |
| 53 #if defined(USE_X11) | |
| 54 #include <X11/Xlib.h> | |
| 55 #endif | |
| 56 | |
| 57 // Plugin entry points | |
| 58 extern "C" { | |
| 59 EXPORT NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs | |
| 60 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 61 , NPPluginFuncs *pluginFuncs | |
| 62 #endif | |
| 63 ); | |
| 64 EXPORT NPError NPAPI NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); | |
| 65 EXPORT void NPAPI NP_Shutdown(void); | |
| 66 | |
| 67 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 68 EXPORT NPError NPAPI NP_GetValue(NPP instance, NPPVariable variable, void *v
alue); | |
| 69 EXPORT const char* NPAPI NP_GetMIMEDescription(void); | |
| 70 #endif | |
| 71 } | |
| 72 | |
| 73 // Plugin entry points | |
| 74 EXPORT NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs | |
| 75 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 76 , NPPluginFuncs *pluginFuncs | |
| 77 #endif | |
| 78 ) | |
| 79 { | |
| 80 browser = browserFuncs; | |
| 81 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 82 return NP_GetEntryPoints(pluginFuncs); | |
| 83 #else | |
| 84 return NPERR_NO_ERROR; | |
| 85 #endif | |
| 86 } | |
| 87 | |
| 88 EXPORT NPError NPAPI NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) | |
| 89 { | |
| 90 pluginFuncs->version = 11; | |
| 91 pluginFuncs->size = sizeof(pluginFuncs); | |
| 92 pluginFuncs->newp = NPP_New; | |
| 93 pluginFuncs->destroy = NPP_Destroy; | |
| 94 pluginFuncs->setwindow = NPP_SetWindow; | |
| 95 pluginFuncs->newstream = NPP_NewStream; | |
| 96 pluginFuncs->destroystream = NPP_DestroyStream; | |
| 97 pluginFuncs->asfile = NPP_StreamAsFile; | |
| 98 pluginFuncs->writeready = NPP_WriteReady; | |
| 99 pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write; | |
| 100 pluginFuncs->print = NPP_Print; | |
| 101 pluginFuncs->event = NPP_HandleEvent; | |
| 102 pluginFuncs->urlnotify = NPP_URLNotify; | |
| 103 pluginFuncs->getvalue = NPP_GetValue; | |
| 104 pluginFuncs->setvalue = NPP_SetValue; | |
| 105 | |
| 106 return NPERR_NO_ERROR; | |
| 107 } | |
| 108 | |
| 109 EXPORT void NPAPI NP_Shutdown(void) | |
| 110 { | |
| 111 } | |
| 112 | |
| 113 static void executeScript(const PluginObject* obj, const char* script); | |
| 114 | |
| 115 NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc
, char *argn[], char *argv[], NPSavedData *saved) | |
| 116 { | |
| 117 if (browser->version >= 14) { | |
| 118 PluginObject* obj = (PluginObject*)browser->createobject(instance, getPl
uginClass()); | |
| 119 | |
| 120 for (int i = 0; i < argc; i++) { | |
| 121 if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad) | |
| 122 obj->onStreamLoad = strdup(argv[i]); | |
| 123 else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStre
amDestroy) | |
| 124 obj->onStreamDestroy = strdup(argv[i]); | |
| 125 else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotif
y) | |
| 126 obj->onURLNotify = strdup(argv[i]); | |
| 127 else if (strcasecmp(argn[i], "logfirstsetwindow") == 0) | |
| 128 obj->logSetWindow = true; | |
| 129 else if (strcasecmp(argn[i], "testnpruntime") == 0) | |
| 130 testNPRuntime(instance); | |
| 131 else if (strcasecmp(argn[i], "logSrc") == 0) { | |
| 132 for (int i = 0; i < argc; i++) { | |
| 133 if (strcasecmp(argn[i], "src") == 0) { | |
| 134 log(instance, "src: %s", argv[i]); | |
| 135 fflush(stdout); | |
| 136 } | |
| 137 } | |
| 138 } else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0) { | |
| 139 executeScript(obj, "document.body.innerHTML = ''"); | |
| 140 } else if (strcasecmp(argn[i], "testdocumentopenindestroystream") ==
0) { | |
| 141 obj->testDocumentOpenInDestroyStream = true; | |
| 142 } else if (strcasecmp(argn[i], "testwindowopen") == 0) { | |
| 143 obj->testWindowOpen = true; | |
| 144 } else if (strcasecmp(argn[i], "src") == 0 && strstr(argv[i], "plugi
n-document-has-focus.pl")) { | |
| 145 obj->testKeyboardFocusForPlugins = true; | |
| 146 } else if (strcasecmp(argn[i], "evaluatescript") == 0) { | |
| 147 char* script = argv[i]; | |
| 148 if (script == strstr(script, "mouse::")) { | |
| 149 obj->mouseDownForEvaluateScript = true; | |
| 150 obj->evaluateScriptOnMouseDownOrKeyDown = strdup(script + si
zeof("mouse::") - 1); | |
| 151 } else if (script == strstr(script, "key::")) { | |
| 152 obj->evaluateScriptOnMouseDownOrKeyDown = strdup(script + si
zeof("key::") - 1); | |
| 153 } | |
| 154 // When testing evaluate script on mouse-down or key-down, allow
event logging. | |
| 155 if (obj->evaluateScriptOnMouseDownOrKeyDown) | |
| 156 obj->eventLogging = true; | |
| 157 } | |
| 158 } | |
| 159 | |
| 160 instance->pdata = obj; | |
| 161 } | |
| 162 | |
| 163 // On Windows and Unix, plugins only get events if they are windowless. | |
| 164 return browser->setvalue(instance, NPPVpluginWindowBool, NULL); | |
| 165 } | |
| 166 | |
| 167 NPError NPP_Destroy(NPP instance, NPSavedData **save) | |
| 168 { | |
| 169 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | |
| 170 if (obj) { | |
| 171 if (obj->onStreamLoad) | |
| 172 free(obj->onStreamLoad); | |
| 173 | |
| 174 if (obj->onURLNotify) | |
| 175 free(obj->onURLNotify); | |
| 176 | |
| 177 if (obj->onStreamDestroy) | |
| 178 free(obj->onStreamDestroy); | |
| 179 | |
| 180 if (obj->logDestroy) | |
| 181 log(instance, "NPP_Destroy"); | |
| 182 | |
| 183 browser->releaseobject(&obj->header); | |
| 184 } | |
| 185 | |
| 186 fflush(stdout); | |
| 187 | |
| 188 return NPERR_NO_ERROR; | |
| 189 } | |
| 190 | |
| 191 NPError NPP_SetWindow(NPP instance, NPWindow *window) | |
| 192 { | |
| 193 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | |
| 194 | |
| 195 if (obj) { | |
| 196 if (obj->logSetWindow) { | |
| 197 log(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)windo
w->height); | |
| 198 fflush(stdout); | |
| 199 obj->logSetWindow = false; | |
| 200 } | |
| 201 | |
| 202 if (obj->testWindowOpen) { | |
| 203 testWindowOpen(instance); | |
| 204 obj->testWindowOpen = false; | |
| 205 } | |
| 206 | |
| 207 if (obj->testKeyboardFocusForPlugins) { | |
| 208 obj->eventLogging = true; | |
| 209 executeScript(obj, "eventSender.keyDown('A');"); | |
| 210 } | |
| 211 } | |
| 212 | |
| 213 return NPERR_NO_ERROR; | |
| 214 } | |
| 215 | |
| 216 static void executeScript(const PluginObject* obj, const char* script) | |
| 217 { | |
| 218 NPObject *windowScriptObject; | |
| 219 browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject); | |
| 220 | |
| 221 NPString npScript; | |
| 222 npScript.UTF8Characters = script; | |
| 223 npScript.UTF8Length = strlen(script); | |
| 224 | |
| 225 NPVariant browserResult; | |
| 226 browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult); | |
| 227 browser->releasevariantvalue(&browserResult); | |
| 228 } | |
| 229 | |
| 230 NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool se
ekable, uint16_t *stype) | |
| 231 { | |
| 232 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | |
| 233 | |
| 234 if (obj->returnErrorFromNewStream) | |
| 235 return NPERR_GENERIC_ERROR; | |
| 236 | |
| 237 obj->stream = stream; | |
| 238 *stype = NP_ASFILEONLY; | |
| 239 | |
| 240 if (browser->version >= NPVERS_HAS_RESPONSE_HEADERS) | |
| 241 notifyStream(obj, stream->url, stream->headers); | |
| 242 | |
| 243 if (obj->onStreamLoad) | |
| 244 executeScript(obj, obj->onStreamLoad); | |
| 245 | |
| 246 return NPERR_NO_ERROR; | |
| 247 } | |
| 248 | |
| 249 NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) | |
| 250 { | |
| 251 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | |
| 252 | |
| 253 if (obj->onStreamDestroy) | |
| 254 executeScript(obj, obj->onStreamDestroy); | |
| 255 | |
| 256 if (obj->testDocumentOpenInDestroyStream) { | |
| 257 testDocumentOpen(instance); | |
| 258 obj->testDocumentOpenInDestroyStream = false; | |
| 259 } | |
| 260 | |
| 261 return NPERR_NO_ERROR; | |
| 262 } | |
| 263 | |
| 264 int32_t NPP_WriteReady(NPP instance, NPStream *stream) | |
| 265 { | |
| 266 return 0; | |
| 267 } | |
| 268 | |
| 269 int32_t NPP_Write(NPP instance, NPStream *stream, int32_t offset, int32_t len, v
oid *buffer) | |
| 270 { | |
| 271 return 0; | |
| 272 } | |
| 273 | |
| 274 void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) | |
| 275 { | |
| 276 } | |
| 277 | |
| 278 void NPP_Print(NPP instance, NPPrint *platformPrint) | |
| 279 { | |
| 280 } | |
| 281 | |
| 282 int16_t NPP_HandleEvent(NPP instance, void *event) | |
| 283 { | |
| 284 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | |
| 285 if (!obj->eventLogging) | |
| 286 return 0; | |
| 287 | |
| 288 #ifdef WIN32 | |
| 289 // Below is the event handling code. Per the NPAPI spec, the events don't | |
| 290 // map directly between operating systems: | |
| 291 // http://devedge-temp.mozilla.org/library/manuals/2002/plugin/1.0/structure
s5.html#1000000 | |
| 292 NPEvent* evt = static_cast<NPEvent*>(event); | |
| 293 short x = static_cast<short>(evt->lParam & 0xffff); | |
| 294 short y = static_cast<short>(evt->lParam >> 16); | |
| 295 switch (evt->event) { | |
| 296 case WM_PAINT: | |
| 297 log(instance, "updateEvt"); | |
| 298 break; | |
| 299 case WM_LBUTTONDOWN: | |
| 300 case WM_MBUTTONDOWN: | |
| 301 case WM_RBUTTONDOWN: | |
| 302 log(instance, "mouseDown at (%d, %d)", x, y); | |
| 303 if (obj->evaluateScriptOnMouseDownOrKeyDown && | |
| 304 obj->mouseDownForEvaluateScript) | |
| 305 executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown); | |
| 306 break; | |
| 307 case WM_LBUTTONUP: | |
| 308 case WM_MBUTTONUP: | |
| 309 case WM_RBUTTONUP: | |
| 310 log(instance, "mouseUp at (%d, %d)", x, y); | |
| 311 break; | |
| 312 case WM_LBUTTONDBLCLK: | |
| 313 case WM_MBUTTONDBLCLK: | |
| 314 case WM_RBUTTONDBLCLK: | |
| 315 break; | |
| 316 case WM_MOUSEMOVE: | |
| 317 break; | |
| 318 case WM_KEYUP: | |
| 319 log(instance, "keyUp '%c'", MapVirtualKey(evt->wParam, MAPVK_VK_TO_C
HAR)); | |
| 320 if (obj->testKeyboardFocusForPlugins) { | |
| 321 obj->eventLogging = false; | |
| 322 obj->testKeyboardFocusForPlugins = false; | |
| 323 executeScript(obj, "layoutTestController.notifyDone();"); | |
| 324 } | |
| 325 break; | |
| 326 case WM_CHAR: | |
| 327 break; | |
| 328 case WM_KEYDOWN: | |
| 329 log(instance, "keyDown '%c'", MapVirtualKey(evt->wParam, MAPVK_VK_TO
_CHAR)); | |
| 330 if (obj->evaluateScriptOnMouseDownOrKeyDown && | |
| 331 !obj->mouseDownForEvaluateScript) | |
| 332 executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown); | |
| 333 break; | |
| 334 case WM_SETCURSOR: | |
| 335 break; | |
| 336 case WM_SETFOCUS: | |
| 337 log(instance, "getFocusEvent"); | |
| 338 break; | |
| 339 case WM_KILLFOCUS: | |
| 340 log(instance, "loseFocusEvent"); | |
| 341 break; | |
| 342 default: | |
| 343 log(instance, "event %d", evt->event); | |
| 344 } | |
| 345 | |
| 346 fflush(stdout); | |
| 347 | |
| 348 #elif defined(USE_X11) | |
| 349 XEvent* evt = static_cast<XEvent*>(event); | |
| 350 XButtonPressedEvent* bpress_evt = reinterpret_cast<XButtonPressedEvent*>(evt
); | |
| 351 XButtonReleasedEvent* brelease_evt = reinterpret_cast<XButtonReleasedEvent*>
(evt); | |
| 352 switch (evt->type) { | |
| 353 case ButtonPress: | |
| 354 log(instance, "mouseDown at (%d, %d)", bpress_evt->x, bpress_evt->y)
; | |
| 355 if (obj->evaluateScriptOnMouseDownOrKeyDown && | |
| 356 obj->mouseDownForEvaluateScript) | |
| 357 executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown); | |
| 358 break; | |
| 359 case ButtonRelease: | |
| 360 log(instance, "mouseUp at (%d, %d)", brelease_evt->x, brelease_evt->
y); | |
| 361 break; | |
| 362 case KeyPress: | |
| 363 // TODO: extract key code | |
| 364 log(instance, "NOTIMPLEMENTED: keyDown '%c'", ' '); | |
| 365 if (obj->evaluateScriptOnMouseDownOrKeyDown && | |
| 366 !obj->mouseDownForEvaluateScript) | |
| 367 executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown); | |
| 368 break; | |
| 369 case KeyRelease: | |
| 370 // TODO: extract key code | |
| 371 log(instance, "NOTIMPLEMENTED: keyUp '%c'", ' '); | |
| 372 break; | |
| 373 case GraphicsExpose: | |
| 374 log(instance, "updateEvt"); | |
| 375 break; | |
| 376 // NPAPI events | |
| 377 case FocusIn: | |
| 378 log(instance, "getFocusEvent"); | |
| 379 break; | |
| 380 case FocusOut: | |
| 381 log(instance, "loseFocusEvent"); | |
| 382 break; | |
| 383 case EnterNotify: | |
| 384 case LeaveNotify: | |
| 385 case MotionNotify: | |
| 386 log(instance, "adjustCursorEvent"); | |
| 387 break; | |
| 388 default: | |
| 389 log(instance, "event %d", evt->type); | |
| 390 } | |
| 391 | |
| 392 fflush(stdout); | |
| 393 #else | |
| 394 | |
| 395 #ifdef MAC_EVENT_CODE_DISABLED_DUE_TO_ERRORS | |
| 396 // This code apparently never built on Mac, but Mac was previously | |
| 397 // using the Linux branch. It doesn't quite build. | |
| 398 // warning: 'GlobalToLocal' is deprecated (declared at | |
| 399 // .../Frameworks/QD.framework/Headers/QuickdrawAPI.h:2181) | |
| 400 EventRecord* evt = static_cast<EventRecord*>(event); | |
| 401 Point pt = { evt->where.v, evt->where.h }; | |
| 402 switch (evt->what) { | |
| 403 case nullEvent: | |
| 404 // these are delivered non-deterministically, don't log. | |
| 405 break; | |
| 406 case mouseDown: | |
| 407 GlobalToLocal(&pt); | |
| 408 log(instance, "mouseDown at (%d, %d)", pt.h, pt.v); | |
| 409 if (obj->evaluateScriptOnMouseDownOrKeyDown && | |
| 410 obj->mouseDownForEvaluateScript) | |
| 411 executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown); | |
| 412 break; | |
| 413 case mouseUp: | |
| 414 GlobalToLocal(&pt); | |
| 415 log(instance, "mouseUp at (%d, %d)", pt.h, pt.v); | |
| 416 break; | |
| 417 case keyDown: | |
| 418 log(instance, "keyDown '%c'", (char)(evt->message & 0xFF)); | |
| 419 if (obj->evaluateScriptOnMouseDownOrKeyDown && | |
| 420 !obj->mouseDownForEvaluateScript) | |
| 421 executeScript(obj, obj->evaluateScriptOnMouseDownOrKeyDown); | |
| 422 break; | |
| 423 case keyUp: | |
| 424 log(instance, "keyUp '%c'", (char)(evt->message & 0xFF)); | |
| 425 break; | |
| 426 case autoKey: | |
| 427 log(instance, "autoKey '%c'", (char)(evt->message & 0xFF)); | |
| 428 break; | |
| 429 case updateEvt: | |
| 430 log(instance, "updateEvt"); | |
| 431 break; | |
| 432 case diskEvt: | |
| 433 log(instance, "diskEvt"); | |
| 434 break; | |
| 435 case activateEvt: | |
| 436 log(instance, "activateEvt"); | |
| 437 break; | |
| 438 case osEvt: | |
| 439 switch ((evt->message & 0xFF000000) >> 24) { | |
| 440 case suspendResumeMessage: | |
| 441 log(instance, "osEvt - %s", (evt->message & 0x1) ? "resume"
: "suspend"); | |
| 442 break; | |
| 443 case mouseMovedMessage: | |
| 444 log(instance, "osEvt - mouseMoved"); | |
| 445 break; | |
| 446 default: | |
| 447 log(instance, "osEvt - %08lX", evt->message); | |
| 448 } | |
| 449 break; | |
| 450 case kHighLevelEvent: | |
| 451 log(instance, "kHighLevelEvent"); | |
| 452 break; | |
| 453 // NPAPI events | |
| 454 case getFocusEvent: | |
| 455 log(instance, "getFocusEvent"); | |
| 456 break; | |
| 457 case loseFocusEvent: | |
| 458 log(instance, "loseFocusEvent"); | |
| 459 break; | |
| 460 case adjustCursorEvent: | |
| 461 log(instance, "adjustCursorEvent"); | |
| 462 break; | |
| 463 default: | |
| 464 log(instance, "event %d", evt->what); | |
| 465 } | |
| 466 #endif // MAC_EVENT_CODE_DISABLED_DUE_TO_ERRORS | |
| 467 | |
| 468 #endif | |
| 469 | |
| 470 return 0; | |
| 471 } | |
| 472 | |
| 473 void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyD
ata) | |
| 474 { | |
| 475 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | |
| 476 if (obj->onURLNotify) | |
| 477 executeScript(obj, obj->onURLNotify); | |
| 478 | |
| 479 handleCallback(obj, url, reason, notifyData); | |
| 480 } | |
| 481 | |
| 482 NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) | |
| 483 { | |
| 484 NPError err = NPERR_NO_ERROR; | |
| 485 | |
| 486 switch (variable) { | |
| 487 #if defined(USE_X11) | |
| 488 case NPPVpluginNameString: | |
| 489 *((const char **)value) = "WebKit Test PlugIn"; | |
| 490 break; | |
| 491 case NPPVpluginDescriptionString: | |
| 492 *((const char **)value) = "Simple Netscape plug-in that handles test
content for WebKit"; | |
| 493 break; | |
| 494 case NPPVpluginNeedsXEmbed: | |
| 495 *((NPBool *)value) = true; | |
| 496 break; | |
| 497 #endif | |
| 498 case NPPVpluginScriptableNPObject: { | |
| 499 void **v = (void **)value; | |
| 500 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | |
| 501 // Return value is expected to be retained | |
| 502 browser->retainobject((NPObject *)obj); | |
| 503 *v = obj; | |
| 504 break; | |
| 505 } | |
| 506 default: | |
| 507 fprintf(stderr, "Unhandled variable to NPP_GetValue\n"); | |
| 508 err = NPERR_GENERIC_ERROR; | |
| 509 break; | |
| 510 } | |
| 511 | |
| 512 return err; | |
| 513 } | |
| 514 | |
| 515 NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) | |
| 516 { | |
| 517 return NPERR_GENERIC_ERROR; | |
| 518 } | |
| 519 | |
| 520 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
| 521 EXPORT NPError NPAPI NP_GetValue(NPP instance, NPPVariable variable, void *value
) | |
| 522 { | |
| 523 return NPP_GetValue(instance, variable, value); | |
| 524 } | |
| 525 | |
| 526 EXPORT const char* NPAPI NP_GetMIMEDescription(void) { | |
| 527 // The layout test LayoutTests/fast/js/navigator-mimeTypes-length.html | |
| 528 // asserts that the number of mimetypes handled by plugins should be | |
| 529 // greater than the number of plugins. This isn't true if we're | |
| 530 // the only plugin and we only handle one mimetype, so specify | |
| 531 // multiple mimetypes here. | |
| 532 return "application/x-webkit-test-netscape:testnetscape:test netscape conten
t;" | |
| 533 "application/x-webkit-test-netscape2:testnetscape2:test netscape cont
ent2"; | |
| 534 } | |
| 535 #endif | |
| OLD | NEW |