Commit be3a861c authored by jhoneycutt@apple.com's avatar jhoneycutt@apple.com

2008-07-08 Jon Honeycutt <jhoneycutt@apple.com>

        Reviewed by Anders.

        Port r34988 to Mac: don't call NPP_DestroyStream if NPP_NewStream was
        unsuccessful.

        * Plugins/WebBaseNetscapePluginStream.h: Added new member,
        newStreamSuccessful.
        * Plugins/WebBaseNetscapePluginStream.mm:
        (-[WebBaseNetscapePluginStream initWithRequestURL:plugin:notifyData:sendNotification:]): Initialize new member.
        (-[WebBaseNetscapePluginStream startStreamResponseURL:expectedContentLength:lastModifiedDate:MIMEType:headers:]): If NPP_NewStream is successful, set
        newStreamSuccessful to YES.
        (-[WebBaseNetscapePluginStream _destroyStream]): Only call
        NPP_DestroyStream if newStreamSuccessful is true.

        Port r34988 to Mac: allow tests to define JavaScript to execute when
        NPP_DestroyStream or NPP_URLNotify is called.

        * DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
        (NPP_New): Remove initialization that happens in pluginAllocate. Look
        for new arguments onStreamDestroy and onURLNotify.
        (NPP_Destroy): Free onStreamDestroy and onURLNotify.
        (executeScript): Code moved from onStreamLoad.
        (NPP_NewStream): Call executeScript.
        (NPP_DestroyStream): Same.
        (NPP_URLNotify): Same.




git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35067 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f62a3e6b
2008-07-08 Jon Honeycutt <jhoneycutt@apple.com>
Reviewed by Anders.
Port r34988 to Mac: don't call NPP_DestroyStream if NPP_NewStream was
unsuccessful.
* Plugins/WebBaseNetscapePluginStream.h: Added new member,
newStreamSuccessful.
* Plugins/WebBaseNetscapePluginStream.mm:
(-[WebBaseNetscapePluginStream initWithRequestURL:plugin:notifyData:sendNotification:]): Initialize new member.
(-[WebBaseNetscapePluginStream startStreamResponseURL:expectedContentLength:lastModifiedDate:MIMEType:headers:]): If NPP_NewStream is successful, set
newStreamSuccessful to YES.
(-[WebBaseNetscapePluginStream _destroyStream]): Only call
NPP_DestroyStream if newStreamSuccessful is true.
2008-07-08 Dan Bernstein <mitz@apple.com>
Reviewed by John Sullivan.
......
......@@ -54,7 +54,8 @@
WebBaseNetscapePluginView *pluginView;
NPReason reason;
BOOL isTerminated;
BOOL newStreamSuccessful;
NPP_NewStreamProcPtr NPP_NewStream;
NPP_DestroyStreamProcPtr NPP_DestroyStream;
NPP_StreamAsFileProcPtr NPP_StreamAsFile;
......
......@@ -118,6 +118,7 @@ static StreamMap& streams()
notifyData = theNotifyData;
sendNotification = flag;
fileDescriptor = -1;
newStreamSuccessful = NO;
streams().add(&stream, thePlugin);
......@@ -278,6 +279,8 @@ static StreamMap& streams()
return;
}
newStreamSuccessful = YES;
switch (transferMode) {
case NP_NORMAL:
LOG(Plugins, "Stream type: NP_NORMAL");
......@@ -399,12 +402,14 @@ static StreamMap& streams()
fileDescriptor = -1;
}
NPError npErr;
WebBaseNetscapePluginView *pv = pluginView;
[pv willCallPlugInFunction];
npErr = NPP_DestroyStream(plugin, &stream, reason);
[pv didCallPlugInFunction];
LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", responseURL, npErr);
if (newStreamSuccessful) {
NPError npErr;
WebBaseNetscapePluginView *pv = pluginView;
[pv willCallPlugInFunction];
npErr = NPP_DestroyStream(plugin, &stream, reason);
[pv didCallPlugInFunction];
LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", responseURL, npErr);
}
free(headers);
headers = NULL;
......
2008-07-08 Jon Honeycutt <jhoneycutt@apple.com>
Reviewed by Anders.
Port r34988 to Mac: allow tests to define JavaScript to execute when
NPP_DestroyStream or NPP_URLNotify is called.
* DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
(NPP_New): Remove initialization that happens in pluginAllocate. Look
for new arguments onStreamDestroy and onURLNotify.
(NPP_Destroy): Free onStreamDestroy and onURLNotify.
(executeScript): Code moved from onStreamLoad.
(NPP_NewStream): Call executeScript.
(NPP_DestroyStream): Same.
(NPP_URLNotify): Same.
2008-07-07 Beth Dakin <bdakin@apple.com>
Reviewed by Anders.
......
......@@ -84,12 +84,14 @@ NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ch
if (browser->version >= 14) {
PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
obj->onStreamLoad = NULL;
for (int i = 0; i < argc; i++) {
if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
obj->onStreamLoad = strdup(argv[i]);
else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
obj->onStreamDestroy = strdup(argv[i]);
else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
obj->onURLNotify = strdup(argv[i]);
else if (strcasecmp(argn[i], "src") == 0 &&
strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
obj->returnErrorFromNewStream = TRUE;
......@@ -109,6 +111,12 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save)
if (obj) {
if (obj->onStreamLoad)
free(obj->onStreamLoad);
if (obj->onStreamDestroy)
free(obj->onStreamDestroy);
if (obj->onURLNotify)
free(obj->onURLNotify);
if (obj->logDestroy)
printf("PLUGIN: NPP_Destroy\n");
......@@ -132,6 +140,20 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window)
return NPERR_NO_ERROR;
}
static void executeScript(const PluginObject* obj, const char* script)
{
NPObject *windowScriptObject;
browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
NPString npScript;
npScript.UTF8Characters = script;
npScript.UTF8Length = strlen(script);
NPVariant browserResult;
browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult);
browser->releasevariantvalue(&browserResult);
}
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
{
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
......@@ -144,24 +166,19 @@ NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool se
if (browser->version >= NPVERS_HAS_RESPONSE_HEADERS)
notifyStream(obj, stream->url, stream->headers);
if (obj->onStreamLoad) {
NPObject *windowScriptObject;
browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
NPString script;
script.UTF8Characters = obj->onStreamLoad;
script.UTF8Length = strlen(obj->onStreamLoad);
NPVariant browserResult;
browser->evaluate(obj->npp, windowScriptObject, &script, &browserResult);
browser->releasevariantvalue(&browserResult);
}
if (obj->onStreamLoad)
executeScript(obj, obj->onStreamLoad);
return NPERR_NO_ERROR;
}
NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
{
PluginObject* obj = (PluginObject*)instance->pdata;
if (obj->onStreamDestroy)
executeScript(obj, obj->onStreamDestroy);
return NPERR_NO_ERROR;
}
......@@ -285,7 +302,10 @@ int16 NPP_HandleEvent(NPP instance, void *event)
void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData)
{
PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
if (obj->onURLNotify)
executeScript(obj, obj->onURLNotify);
handleCallback(obj, url, reason, notifyData);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment