OLD | NEW |
1 /* | 1 /* |
2 IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Ap
ple") in | 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, | 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 | 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 | 5 terms. If you do not agree with these terms, please do not use, install, modif
y or |
6 redistribute this Apple software. | 6 redistribute this Apple software. |
7 | 7 |
8 In consideration of your agreement to abide by the following terms, and subject
to these | 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 | 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 | 10 this original Apple software (the "Apple Software"), to use, reproduce, modify
and |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #if defined(__GNUC__) && __GNUC__ >= 4 | 46 #if defined(__GNUC__) && __GNUC__ >= 4 |
47 #define EXPORT __attribute__((visibility ("default"))) | 47 #define EXPORT __attribute__((visibility ("default"))) |
48 #else | 48 #else |
49 #define EXPORT | 49 #define EXPORT |
50 #endif | 50 #endif |
51 | 51 |
52 #if defined(OS_LINUX) | 52 #if defined(OS_LINUX) |
53 #include <X11/Xlib.h> | 53 #include <X11/Xlib.h> |
54 #endif | 54 #endif |
55 | 55 |
56 static void log(NPP instance, const char* format, ...) | |
57 { | |
58 va_list args; | |
59 va_start(args, format); | |
60 char message[2048] = "PLUGIN: "; | |
61 vsprintf(message + strlen(message), format, args); | |
62 va_end(args); | |
63 | |
64 NPObject* windowObject = 0; | |
65 NPError error = browser->getvalue(instance, NPNVWindowNPObject, &windowObjec
t); | |
66 if (error != NPERR_NO_ERROR) { | |
67 fprintf(stderr, "Failed to retrieve window object while logging: %s\n",
message); | |
68 return; | |
69 } | |
70 | |
71 NPVariant consoleVariant; | |
72 if (!browser->getproperty(instance, windowObject, browser->getstringidentifi
er("console"), &consoleVariant)) { | |
73 fprintf(stderr, "Failed to retrieve console object while logging: %s\n",
message); | |
74 browser->releaseobject(windowObject); | |
75 return; | |
76 } | |
77 | |
78 NPObject* consoleObject = NPVARIANT_TO_OBJECT(consoleVariant); | |
79 | |
80 NPVariant messageVariant; | |
81 STRINGZ_TO_NPVARIANT(message, messageVariant); | |
82 | |
83 NPVariant result; | |
84 if (!browser->invoke(instance, consoleObject, browser->getstringidentifier("
log"), &messageVariant, 1, &result)) { | |
85 fprintf(stderr, "Failed to invoke console.log while logging: %s\n", mess
age); | |
86 browser->releaseobject(consoleObject); | |
87 browser->releaseobject(windowObject); | |
88 return; | |
89 } | |
90 | |
91 browser->releasevariantvalue(&result); | |
92 browser->releaseobject(consoleObject); | |
93 browser->releaseobject(windowObject); | |
94 } | |
95 | |
96 // Plugin entry points | 56 // Plugin entry points |
97 extern "C" { | 57 extern "C" { |
98 EXPORT NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs | 58 EXPORT NPError NPAPI NP_Initialize(NPNetscapeFuncs *browserFuncs |
99 #if defined(OS_LINUX) | 59 #if defined(OS_LINUX) |
100 , NPPluginFuncs *pluginFuncs | 60 , NPPluginFuncs *pluginFuncs |
101 #endif | 61 #endif |
102 ); | 62 ); |
103 EXPORT NPError NPAPI NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); | 63 EXPORT NPError NPAPI NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); |
104 EXPORT void NPAPI NP_Shutdown(void); | 64 EXPORT void NPAPI NP_Shutdown(void); |
105 | 65 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 obj->logSetWindow = TRUE; | 127 obj->logSetWindow = TRUE; |
168 else if (strcasecmp(argn[i], "testnpruntime") == 0) | 128 else if (strcasecmp(argn[i], "testnpruntime") == 0) |
169 testNPRuntime(instance); | 129 testNPRuntime(instance); |
170 else if (strcasecmp(argn[i], "logSrc") == 0) { | 130 else if (strcasecmp(argn[i], "logSrc") == 0) { |
171 for (int i = 0; i < argc; i++) { | 131 for (int i = 0; i < argc; i++) { |
172 if (strcasecmp(argn[i], "src") == 0) { | 132 if (strcasecmp(argn[i], "src") == 0) { |
173 log(instance, "src: %s", argv[i]); | 133 log(instance, "src: %s", argv[i]); |
174 fflush(stdout); | 134 fflush(stdout); |
175 } | 135 } |
176 } | 136 } |
177 } else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0) | 137 } else if (strcasecmp(argn[i], "cleardocumentduringnew") == 0) { |
178 executeScript(obj, "document.body.innerHTML = ''"); | 138 executeScript(obj, "document.body.innerHTML = ''"); |
| 139 } else if (strcasecmp(argn[i], "testdocumentopenindestroystream") ==
0) { |
| 140 obj->testDocumentOpenInDestroyStream = TRUE; |
| 141 } else if (strcasecmp(argn[i], "testwindowopen") == 0) { |
| 142 obj->testWindowOpen = TRUE; |
| 143 } |
179 } | 144 } |
180 | 145 |
181 instance->pdata = obj; | 146 instance->pdata = obj; |
182 } | 147 } |
183 | 148 |
184 // On Windows and Unix, plugins only get events if they are windowless. | 149 // On Windows and Unix, plugins only get events if they are windowless. |
185 return browser->setvalue(instance, NPPVpluginWindowBool, NULL); | 150 return browser->setvalue(instance, NPPVpluginWindowBool, NULL); |
186 } | 151 } |
187 | 152 |
188 NPError NPP_Destroy(NPP instance, NPSavedData **save) | 153 NPError NPP_Destroy(NPP instance, NPSavedData **save) |
(...skipping 23 matching lines...) Expand all Loading... |
212 NPError NPP_SetWindow(NPP instance, NPWindow *window) | 177 NPError NPP_SetWindow(NPP instance, NPWindow *window) |
213 { | 178 { |
214 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | 179 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); |
215 | 180 |
216 if (obj) { | 181 if (obj) { |
217 if (obj->logSetWindow) { | 182 if (obj->logSetWindow) { |
218 log(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)windo
w->height); | 183 log(instance, "NPP_SetWindow: %d %d", (int)window->width, (int)windo
w->height); |
219 fflush(stdout); | 184 fflush(stdout); |
220 obj->logSetWindow = false; | 185 obj->logSetWindow = false; |
221 } | 186 } |
| 187 |
| 188 if (obj->testWindowOpen) { |
| 189 testWindowOpen(instance); |
| 190 obj->testWindowOpen = FALSE; |
| 191 } |
222 } | 192 } |
223 | 193 |
224 return NPERR_NO_ERROR; | 194 return NPERR_NO_ERROR; |
225 } | 195 } |
226 | 196 |
227 static void executeScript(const PluginObject* obj, const char* script) | 197 static void executeScript(const PluginObject* obj, const char* script) |
228 { | 198 { |
229 NPObject *windowScriptObject; | 199 NPObject *windowScriptObject; |
230 browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject); | 200 browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject); |
231 | 201 |
(...skipping 25 matching lines...) Expand all Loading... |
257 return NPERR_NO_ERROR; | 227 return NPERR_NO_ERROR; |
258 } | 228 } |
259 | 229 |
260 NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) | 230 NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) |
261 { | 231 { |
262 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); | 232 PluginObject* obj = static_cast<PluginObject*>(instance->pdata); |
263 | 233 |
264 if (obj->onStreamDestroy) | 234 if (obj->onStreamDestroy) |
265 executeScript(obj, obj->onStreamDestroy); | 235 executeScript(obj, obj->onStreamDestroy); |
266 | 236 |
| 237 if (obj->testDocumentOpenInDestroyStream) { |
| 238 testDocumentOpen(instance); |
| 239 obj->testDocumentOpenInDestroyStream = FALSE; |
| 240 } |
| 241 |
267 return NPERR_NO_ERROR; | 242 return NPERR_NO_ERROR; |
268 } | 243 } |
269 | 244 |
270 int32 NPP_WriteReady(NPP instance, NPStream *stream) | 245 int32 NPP_WriteReady(NPP instance, NPStream *stream) |
271 { | 246 { |
272 return 0; | 247 return 0; |
273 } | 248 } |
274 | 249 |
275 int32 NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *b
uffer) | 250 int32 NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *b
uffer) |
276 { | 251 { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 EXPORT const char* NPAPI NP_GetMIMEDescription(void) { | 487 EXPORT const char* NPAPI NP_GetMIMEDescription(void) { |
513 // The layout test LayoutTests/fast/js/navigator-mimeTypes-length.html | 488 // The layout test LayoutTests/fast/js/navigator-mimeTypes-length.html |
514 // asserts that the number of mimetypes handled by plugins should be | 489 // asserts that the number of mimetypes handled by plugins should be |
515 // greater than the number of plugins. This isn't true if we're | 490 // greater than the number of plugins. This isn't true if we're |
516 // the only plugin and we only handle one mimetype, so specify | 491 // the only plugin and we only handle one mimetype, so specify |
517 // multiple mimetypes here. | 492 // multiple mimetypes here. |
518 return "application/x-webkit-test-netscape:testnetscape:test netscape conten
t;" | 493 return "application/x-webkit-test-netscape:testnetscape:test netscape conten
t;" |
519 "application/x-webkit-test-netscape2:testnetscape2:test netscape cont
ent2"; | 494 "application/x-webkit-test-netscape2:testnetscape2:test netscape cont
ent2"; |
520 } | 495 } |
521 #endif | 496 #endif |
OLD | NEW |