Skip to content
Permalink
Browse files
Implement NPN_GetURL and NPN_PostURL
https://bugs.webkit.org/show_bug.cgi?id=42650

Reviewed by Dan Bernstein.

* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::parsePostBuffer):
Add a FIXME about deleting the file.

(WebKit::makeURLString):
Move this static method before NPN_GetURL.

(WebKit::NPN_GetURL):
Call NetscapePLugin::LoadURL.

(WebKit::NPN_PostURL):
Ditto.

(WebKit::NPN_PostURLNotify):
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
Remove unreached code.

(WebKit::NetscapePluginStream::deliverDataToPlugin):
Stop the stream if the plug-in returns -1 from NPP_Write.

Canonical link: https://commits.webkit.org/54594@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63756 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Jul 20, 2010
1 parent b29f9da commit b2fd900940b6377b698f8c079f99bec2008bbcc2
Showing with 63 additions and 21 deletions.
  1. +27 −0 WebKit2/ChangeLog
  2. +34 −19 WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
  3. +2 −2 WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
@@ -1,3 +1,30 @@
2010-07-20 Anders Carlsson <andersca@apple.com>

Reviewed by Dan Bernstein.

Implement NPN_GetURL and NPN_PostURL
https://bugs.webkit.org/show_bug.cgi?id=42650

* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::parsePostBuffer):
Add a FIXME about deleting the file.

(WebKit::makeURLString):
Move this static method before NPN_GetURL.

(WebKit::NPN_GetURL):
Call NetscapePLugin::LoadURL.

(WebKit::NPN_PostURL):
Ditto.

(WebKit::NPN_PostURLNotify):
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
Remove unreached code.

(WebKit::NetscapePluginStream::deliverDataToPlugin):
Stop the stream if the plug-in returns -1 from NPP_Write.

2010-07-19 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.
@@ -209,6 +209,8 @@ static NPError parsePostBuffer(bool isFile, const char *buffer, uint32_t length,

postBuffer = fileContents->data();
postBufferSize = fileContents->size();

// FIXME: The NPAPI spec states that the file should be deleted here.
} else {
postBuffer = buffer;
postBufferSize = length;
@@ -247,18 +249,45 @@ static NPError parsePostBuffer(bool isFile, const char *buffer, uint32_t length,
return NPERR_NO_ERROR;
}

static NPError NPN_GetURL(NPP instance, const char* url, const char* target)
static String makeURLString(const char* url)
{
notImplemented();
return NPERR_GENERIC_ERROR;
String urlString(url);

// Strip return characters.
urlString.replace('\r', "");
urlString.replace('\n', "");

return urlString;
}

static NPError NPN_PostURL(NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file)
static NPError NPN_GetURL(NPP npp, const char* url, const char* target)
{
notImplemented();
if (!url)
return NPERR_GENERIC_ERROR;

RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
plugin->loadURL("GET", makeURLString(url), target, HTTPHeaderMap(), Vector<char>(), false, 0);

return NPERR_GENERIC_ERROR;
}

static NPError NPN_PostURL(NPP npp, const char* url, const char* target, uint32_t len, const char* buf, NPBool file)
{
HTTPHeaderMap headerFields;
Vector<char> postData;

// NPN_PostURL only allows headers if the post buffer points to a file.
bool parseHeaders = file;

NPError error = parsePostBuffer(file, buf, len, parseHeaders, headerFields, postData);
if (error != NPERR_NO_ERROR)
return error;

RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
plugin->loadURL("POST", makeURLString(url), target, headerFields, postData, false, 0);
return NPERR_NO_ERROR;
}

static NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
notImplemented();
@@ -334,17 +363,6 @@ static jref NPN_GetJavaPeer(NPP instance)
return 0;
}

static String makeURLString(const char* url)
{
String urlString(url);

// Strip return characters.
urlString.replace('\r', "");
urlString.replace('\n', "");

return urlString;
}

static NPError NPN_GetURLNotify(NPP npp, const char* url, const char* target, void* notifyData)
{
if (!url)
@@ -367,9 +385,6 @@ static NPError NPN_PostURLNotify(NPP npp, const char* url, const char* target, u
RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
plugin->loadURL("POST", makeURLString(url), target, headerFields, postData, true, notifyData);
return NPERR_NO_ERROR;

notImplemented();
return NPERR_GENERIC_ERROR;
}

static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
@@ -220,8 +220,8 @@ void NetscapePluginStream::deliverDataToPlugin()

int32_t numBytesWritten = m_plugin->NPP_Write(&m_npStream, m_offset, dataLength, data);
if (numBytesWritten < 0) {
// FIXME: Destroy the stream!
ASSERT_NOT_REACHED();
stop(NPRES_NETWORK_ERR);
return;
}

// NPP_Write could call NPN_DestroyStream and destroy the stream.

0 comments on commit b2fd900

Please sign in to comment.