bug=36212

a=waterson,av
r=av,waterson

Here is what I believe to be the correct fix.
This post correspondes to the fix,
second iteration attachments.
M modules/plugin/nglsrc/nsIPluginInstanceOwner.h
M modules/plugin/nglsrc/nsPluginHostImpl.cpp
M modules/plugin/nglsrc/nsPluginInstancePeer.cpp
M modules/plugin/nglsrc/nsPluginViewer.cpp
M layout/html/base/src/nsObjectFrame.cpp

This checkin modifies nsIPluginInstanceOwner::GetURL
to have a length parameter for the post data.
This commit is contained in:
edburns%acm.org 2000-08-24 19:49:08 +00:00
parent f62888744c
commit 6929c922f5
10 changed files with 86 additions and 52 deletions

View File

@ -46,6 +46,7 @@
#include "nsIWebShell.h"
#include "nsINameSpaceManager.h"
#include "nsIEventListener.h"
#include "nsIStringStream.h" // for NS_NewCharInputStream
#include "nsITimer.h"
#include "nsITimerCallback.h"
#include "nsLayoutAtoms.h"
@ -87,7 +88,8 @@ public:
NS_IMETHOD CreateWidget(void);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
PRUint32 aPostDataLen);
NS_IMETHOD ShowStatus(const char *aStatusMsg);
@ -1661,7 +1663,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData)
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen)
{
nsISupports *container;
nsILinkHandler *lh;
@ -1698,7 +1700,19 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
if (NS_OK == rv) {
nsIContent* content = nsnull;
mOwner->GetContent(&content);
rv = lh->OnLinkClick(content, eLinkVerb_Replace, fullurl.GetUnicode(), unitarget.GetUnicode(), nsnull);
nsCOMPtr<nsISupports> result = nsnull;
nsCOMPtr<nsIInputStream> postDataStream = nsnull;
if (aPostData) {
NS_NewByteInputStream(getter_AddRefs(result),
(const char *) aPostData, aPostDataLen);
if (result) {
postDataStream = do_QueryInterface(result, &rv);
}
}
rv = lh->OnLinkClick(content, eLinkVerb_Replace,
fullurl.GetUnicode(),
unitarget.GetUnicode(),
postDataStream ? postDataStream : nsnull);
NS_IF_RELEASE(content);
}
NS_RELEASE(lh);

View File

@ -46,6 +46,7 @@
#include "nsIWebShell.h"
#include "nsINameSpaceManager.h"
#include "nsIEventListener.h"
#include "nsIStringStream.h" // for NS_NewCharInputStream
#include "nsITimer.h"
#include "nsITimerCallback.h"
#include "nsLayoutAtoms.h"
@ -87,7 +88,8 @@ public:
NS_IMETHOD CreateWidget(void);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
PRUint32 aPostDataLen);
NS_IMETHOD ShowStatus(const char *aStatusMsg);
@ -1661,7 +1663,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData)
NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen)
{
nsISupports *container;
nsILinkHandler *lh;
@ -1698,7 +1700,19 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL, const char *aTarge
if (NS_OK == rv) {
nsIContent* content = nsnull;
mOwner->GetContent(&content);
rv = lh->OnLinkClick(content, eLinkVerb_Replace, fullurl.GetUnicode(), unitarget.GetUnicode(), nsnull);
nsCOMPtr<nsISupports> result = nsnull;
nsCOMPtr<nsIInputStream> postDataStream = nsnull;
if (aPostData) {
NS_NewByteInputStream(getter_AddRefs(result),
(const char *) aPostData, aPostDataLen);
if (result) {
postDataStream = do_QueryInterface(result, &rv);
}
}
rv = lh->OnLinkClick(content, eLinkVerb_Replace,
fullurl.GetUnicode(),
unitarget.GetUnicode(),
postDataStream ? postDataStream : nsnull);
NS_IF_RELEASE(content);
}
NS_RELEASE(lh);

View File

@ -81,7 +81,8 @@ public:
*
*/
NS_IMETHOD
GetURL(const char *aURL, const char *aTarget, void *aPostData) = 0;
GetURL(const char *aURL, const char *aTarget, void *aPostData,
PRUint32 aPostDataLen) = 0;
/**
* Show a status message in the host environment.

View File

@ -1484,7 +1484,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst,
else if (0 == PL_strcmp(target, "_current"))
target = "_self";
rv = owner->GetURL(url, target, nsnull);
rv = owner->GetURL(url, target, nsnull, 0);
}
NS_RELEASE(peer);
@ -1516,19 +1516,17 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst,
nsAutoString string; string.AssignWithConversion(url);
nsIPluginInstance *instance;
nsresult rv;
// we can only send a stream back to the plugin (as specified
// by a null target) if we also have a nsIPluginStreamListener
// to talk to also
if(target == nsnull && streamListener == nsnull)
return NS_ERROR_ILLEGAL_VALUE;
rv = pluginInst->QueryInterface(kIPluginInstanceIID, (void **)&instance);
if (NS_SUCCEEDED(rv))
{
if (nsnull != target)
{
nsPluginInstancePeerImpl *peer;
rv = instance->GetPeer(NS_REINTERPRET_CAST(nsIPluginInstancePeer **, &peer));
@ -1540,20 +1538,23 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst,
rv = peer->GetOwner(*getter_AddRefs(owner));
if (NS_SUCCEEDED(rv))
{
if ((0 == PL_strcmp(target, "newwindow")) ||
(0 == PL_strcmp(target, "_new")))
target = "_blank";
else if (0 == PL_strcmp(target, "_current"))
target = "_self";
rv = owner->GetURL(url, target, (void*)postData);
}
{
if (!target) {
target = "_self";
}
else {
if ((0 == PL_strcmp(target, "newwindow")) ||
(0 == PL_strcmp(target, "_new")))
target = "_blank";
else if (0 == PL_strcmp(target, "_current"))
target = "_self";
}
rv = owner->GetURL(url, target, (void*)postData, postDataLen);
}
NS_RELEASE(peer);
}
}
if (streamListener != nsnull)
rv = NewPluginURLStream(string, instance, streamListener);

View File

@ -270,7 +270,7 @@ nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteC
PRUint32 actualCount;
mFileThing->Write(aBuf, aCount, &actualCount);
mFileThing->Close();
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0);
return NS_OK;
}
@ -320,7 +320,7 @@ nsPluginStreamToFile::SetObserver(nsIOutputStreamObserver * aObserver)
NS_IMETHODIMP
nsPluginStreamToFile::Close(void)
{
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0);
return NS_OK;
}

View File

@ -100,7 +100,8 @@ public:
NS_IMETHOD CreateWidget(void);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
PRUint32 aPostDataLen);
NS_IMETHOD ShowStatus(const char *aStatusMsg);
@ -815,7 +816,7 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
return NS_OK;
}
NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData)
NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen)
{
nsresult rv;

View File

@ -81,7 +81,8 @@ public:
*
*/
NS_IMETHOD
GetURL(const char *aURL, const char *aTarget, void *aPostData) = 0;
GetURL(const char *aURL, const char *aTarget, void *aPostData,
PRUint32 aPostDataLen) = 0;
/**
* Show a status message in the host environment.

View File

@ -1484,7 +1484,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst,
else if (0 == PL_strcmp(target, "_current"))
target = "_self";
rv = owner->GetURL(url, target, nsnull);
rv = owner->GetURL(url, target, nsnull, 0);
}
NS_RELEASE(peer);
@ -1516,19 +1516,17 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst,
nsAutoString string; string.AssignWithConversion(url);
nsIPluginInstance *instance;
nsresult rv;
// we can only send a stream back to the plugin (as specified
// by a null target) if we also have a nsIPluginStreamListener
// to talk to also
if(target == nsnull && streamListener == nsnull)
return NS_ERROR_ILLEGAL_VALUE;
rv = pluginInst->QueryInterface(kIPluginInstanceIID, (void **)&instance);
if (NS_SUCCEEDED(rv))
{
if (nsnull != target)
{
nsPluginInstancePeerImpl *peer;
rv = instance->GetPeer(NS_REINTERPRET_CAST(nsIPluginInstancePeer **, &peer));
@ -1540,20 +1538,23 @@ NS_IMETHODIMP nsPluginHostImpl::PostURL(nsISupports* pluginInst,
rv = peer->GetOwner(*getter_AddRefs(owner));
if (NS_SUCCEEDED(rv))
{
if ((0 == PL_strcmp(target, "newwindow")) ||
(0 == PL_strcmp(target, "_new")))
target = "_blank";
else if (0 == PL_strcmp(target, "_current"))
target = "_self";
rv = owner->GetURL(url, target, (void*)postData);
}
{
if (!target) {
target = "_self";
}
else {
if ((0 == PL_strcmp(target, "newwindow")) ||
(0 == PL_strcmp(target, "_new")))
target = "_blank";
else if (0 == PL_strcmp(target, "_current"))
target = "_self";
}
rv = owner->GetURL(url, target, (void*)postData, postDataLen);
}
NS_RELEASE(peer);
}
}
if (streamListener != nsnull)
rv = NewPluginURLStream(string, instance, streamListener);

View File

@ -270,7 +270,7 @@ nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteC
PRUint32 actualCount;
mFileThing->Write(aBuf, aCount, &actualCount);
mFileThing->Close();
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0);
return NS_OK;
}
@ -320,7 +320,7 @@ nsPluginStreamToFile::SetObserver(nsIOutputStreamObserver * aObserver)
NS_IMETHODIMP
nsPluginStreamToFile::Close(void)
{
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull, 0);
return NS_OK;
}

View File

@ -100,7 +100,8 @@ public:
NS_IMETHOD CreateWidget(void);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData);
NS_IMETHOD GetURL(const char *aURL, const char *aTarget, void *aPostData,
PRUint32 aPostDataLen);
NS_IMETHOD ShowStatus(const char *aStatusMsg);
@ -815,7 +816,7 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
return NS_OK;
}
NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData)
NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarget, void *aPostData, PRUint32 aPostDataLen)
{
nsresult rv;