From abdd03922594f2e27468290fcc6469c5ae5d7120 Mon Sep 17 00:00:00 2001 From: "peterlubczynski%netscape.com" Date: Thu, 4 Apr 2002 15:23:35 +0000 Subject: [PATCH] Fix for sending the correct URL from GetURLNotify/PostURLNotify to URLNotify and fixing a crash with Flash 6 when URLNotify is called before NewStream. Bug 131626 r=av sr=beard git-svn-id: svn://10.0.0.236/trunk@118123 18797224-902f-48f8-a5cc-f745e15eee43 --- .../modules/plugin/base/src/ns4xPlugin.cpp | 2 +- .../plugin/base/src/ns4xPluginInstance.cpp | 38 +++++++++++-------- .../plugin/base/src/ns4xPluginInstance.h | 5 ++- .../base/src/ns4xPluginStreamListener.h | 10 +++-- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp index bebc8ae5843..0444e0465d8 100644 --- a/mozilla/modules/plugin/base/src/ns4xPlugin.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPlugin.cpp @@ -770,7 +770,7 @@ NPError MakeNew4xStreamInternal (NPP npp, nsIPluginStreamListener* listener = nsnull; if(target == nsnull) - ((ns4xPluginInstance*)inst)->NewNotifyStream(&listener, notifyData, bDoNotify); + ((ns4xPluginInstance*)inst)->NewNotifyStream(&listener, notifyData, bDoNotify, relativeURL); switch (type) { case eNPPStreamTypeInternal_Get: diff --git a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp index e12a6c433f4..c962a593f51 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp +++ b/mozilla/modules/plugin/base/src/ns4xPluginInstance.cpp @@ -76,22 +76,27 @@ NS_IMPL_ISUPPORTS1(ns4xPluginStreamListener, nsIPluginStreamListener); /////////////////////////////////////////////////////////////////////////////// ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst, - void* notifyData) + void* notifyData, + const char* aURL) : mNotifyData(notifyData), + mStreamBuffer(nsnull), + mNotifyURL(nsnull), mStreamStarted(PR_FALSE), mStreamCleanedUp(PR_FALSE), - mStreamInfo(nsnull), - mCallNotify(PR_FALSE) + mCallNotify(PR_FALSE), + mStreamInfo(nsnull) { NS_INIT_REFCNT(); mInst = (ns4xPluginInstance*) inst; - mStreamBuffer=nsnull; mPosition = 0; mStreamBufferSize = 0; // Initialize the 4.x interface structure memset(&mNPStream, 0, sizeof(mNPStream)); NS_IF_ADDREF(mInst); + + if (aURL) + mNotifyURL = PL_strdup(aURL); } @@ -130,6 +135,9 @@ ns4xPluginStreamListener::~ns4xPluginStreamListener(void) NS_IF_RELEASE(inst); + + if (mNotifyURL) + PL_strfree(mNotifyURL); } /////////////////////////////////////////////////////////////////////////////// @@ -191,22 +199,21 @@ void ns4xPluginStreamListener::CallURLNotify(NPReason reason) mInst->GetCallbacks(&callbacks); if(!callbacks) return; - - NPP npp; - mInst->GetNPP(&npp); - + if (callbacks->urlnotify) { - PRLibrary* lib = mInst->fLibrary; + + NPP npp; + mInst->GetNPP(&npp); NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify, npp, - mNPStream.url, + mNotifyURL, reason, - mNotifyData), lib); + mNotifyData), mInst->fLibrary); NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPP URLNotify called: this=%p, npp=%p, notify=%p, reason=%d, url=%s\n", - this, npp, mNotifyData, reason, mNPStream.url)); + this, npp, mNotifyData, reason, mNotifyURL)); } // Let's not leak this stream listener. Release the reference to the stream listener @@ -981,7 +988,7 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window) // Create a normal stream, one without a urlnotify callback NS_IMETHODIMP ns4xPluginInstance::NewStream(nsIPluginStreamListener** listener) { - return NewNotifyStream(listener, nsnull, PR_FALSE); + return NewNotifyStream(listener, nsnull, PR_FALSE, nsnull); } @@ -989,9 +996,10 @@ NS_IMETHODIMP ns4xPluginInstance::NewStream(nsIPluginStreamListener** listener) // Create a stream that will notify when complete nsresult ns4xPluginInstance::NewNotifyStream(nsIPluginStreamListener** listener, void* notifyData, - PRBool aCallNotify) + PRBool aCallNotify, + const char* aURL) { - ns4xPluginStreamListener* stream = new ns4xPluginStreamListener(this, notifyData); + ns4xPluginStreamListener* stream = new ns4xPluginStreamListener(this, notifyData, aURL); NS_ENSURE_TRUE(stream, NS_ERROR_OUT_OF_MEMORY); // add it to the list diff --git a/mozilla/modules/plugin/base/src/ns4xPluginInstance.h b/mozilla/modules/plugin/base/src/ns4xPluginInstance.h index 452ba06d8e2..ab9c0618991 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginInstance.h +++ b/mozilla/modules/plugin/base/src/ns4xPluginInstance.h @@ -133,7 +133,10 @@ public: nsresult SetTransparent(PRBool aTransparent); - nsresult NewNotifyStream(nsIPluginStreamListener** listener, void* notifyData, PRBool aCallNotify); + nsresult NewNotifyStream(nsIPluginStreamListener** listener, + void* notifyData, + PRBool aCallNotify, + const char * aURL); /** * Construct a new 4.x plugin instance with the specified peer diff --git a/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h b/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h index 0837c916779..db6ab78b70e 100644 --- a/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h +++ b/mozilla/modules/plugin/base/src/ns4xPluginStreamListener.h @@ -56,7 +56,7 @@ public: NS_IMETHOD GetStreamType(nsPluginStreamType *result); // ns4xPluginStreamListener specific methods: - ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData); + ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData, const char* aURL); virtual ~ns4xPluginStreamListener(); PRBool IsStarted(); nsresult CleanUpStream(NPReason reason); @@ -66,14 +66,16 @@ public: protected: void* mNotifyData; char* mStreamBuffer; + char* mNotifyURL; ns4xPluginInstance* mInst; NPStream mNPStream; PRUint32 mPosition; PRUint32 mStreamBufferSize; nsPluginStreamType mStreamType; - PRBool mStreamStarted; - PRBool mStreamCleanedUp; - PRBool mCallNotify; + PRPackedBool mStreamStarted; + PRPackedBool mStreamCleanedUp; + PRPackedBool mCallNotify; + public: nsIPluginStreamInfo * mStreamInfo;