From f59c24e4923e9c8f4dbacc2eaeb7543c6a0db7cf Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Thu, 14 Sep 2000 22:57:56 +0000 Subject: [PATCH] r=vidur, av a=brendan bug=49525 This simple fix just adds parameters to an existing method in an XPCOM safe way, by defining a new method at the end of the interface definition with the additional parameters. Original method: NS_IMETHOD GetURL(nsISupports* pluginInst, const char* url, const char* target = NULL, nsIPluginStreamListener* streamListener = NULL, const char* altHost = NULL, const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE) = 0; New method: NS_IMETHOD GetURLWithHeaders(nsISupports* pluginInst, const char* url, const char* target = NULL, nsIPluginStreamListener* streamListener = NULL, const char* altHost = NULL, const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE, PRUint32 getHeadersLength = 0, const char* getHeaders = NULL) = 0; I have modified nsPluginHostImpl.h to include this new method, and modified nsPluginHostImpl.cpp so that its GetURL calls GetURLWithHeaders with null values for the last two params. M modules/plugin/public/nsIPluginManager.h M modules/plugin/nglsrc/nsPluginHostImpl.cpp M modules/plugin/nglsrc/nsPluginHostImpl.h git-svn-id: svn://10.0.0.236/trunk@79207 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/public/nsIPluginManager.h | 40 +++++++++++++++++-- .../plugin/base/src/nsPluginHostImpl.cpp | 20 +++++++++- .../plugin/base/src/nsPluginHostImpl.h | 11 +++++ .../plugin/nglsrc/nsPluginHostImpl.cpp | 20 +++++++++- .../modules/plugin/nglsrc/nsPluginHostImpl.h | 11 +++++ .../modules/plugin/public/nsIPluginManager.h | 40 +++++++++++++++++-- 6 files changed, 130 insertions(+), 12 deletions(-) diff --git a/mozilla/modules/plugin/base/public/nsIPluginManager.h b/mozilla/modules/plugin/base/public/nsIPluginManager.h index b65328545bb..2bd3869dcde 100644 --- a/mozilla/modules/plugin/base/public/nsIPluginManager.h +++ b/mozilla/modules/plugin/base/public/nsIPluginManager.h @@ -162,10 +162,13 @@ public: * URLs, even if the user currently has JavaScript disabled (usually * specify PR_FALSE) * @param postHeadersLength - the length of postHeaders (if non-NULL) - * @param postHeaders - the headers to POST. NULL specifies that there - * are no post headers - * @result - NS_OK if this operation was successful - */ + + * @param postHeaders - the headers to POST. Must be in the form of + * "HeaderName: HeaderValue\r\n". Each header, including the last, + * must be followed by "\r\n". NULL specifies that there are no + * post headers + + * @result - NS_OK if this operation was successful */ NS_IMETHOD PostURL(nsISupports* pluginInst, @@ -221,6 +224,35 @@ public: NS_IMETHOD UnregisterPlugin(REFNSIID aCID) = 0; + + /** + * Fetches a URL, with Headers + + * @see GetURL. Identical except for additional params headers and + * headersLen + + * @param getHeadersLength - the length of getHeaders (if non-NULL) + + * @param getHeaders - the headers to GET. Must be in the form of + * "HeaderName: HeaderValue\r\n". Each header, including the last, + * must be followed by "\r\n". NULL specifies that there are no + * get headers + + * @result - NS_OK if this operation was successful + + */ + + NS_IMETHOD + GetURLWithHeaders(nsISupports* pluginInst, + const char* url, + const char* target = NULL, + nsIPluginStreamListener* streamListener = NULL, + const char* altHost = NULL, + const char* referrer = NULL, + PRBool forceJSEnabled = PR_FALSE, + PRUint32 getHeadersLength = 0, + const char* getHeaders = NULL) = 0; + }; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index a82d09f8d16..42ed29f8cab 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -1533,6 +1533,20 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, const char* altHost, const char* referrer, PRBool forceJSEnabled) +{ + return GetURLWithHeaders(pluginInst, url, target, streamListener, + altHost, referrer, forceJSEnabled, nsnull, nsnull); +} + +NS_IMETHODIMP nsPluginHostImpl::GetURLWithHeaders(nsISupports* pluginInst, + const char* url, + const char* target, + nsIPluginStreamListener* streamListener, + const char* altHost, + const char* referrer, + PRBool forceJSEnabled, + PRUint32 getHeadersLength, + const char* getHeaders) { nsAutoString string; string.AssignWithConversion(url); nsIPluginInstance *instance; @@ -1567,7 +1581,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, else if (0 == PL_strcmp(target, "_current")) target = "_self"; - rv = owner->GetURL(url, target, nsnull, 0, nsnull, nsnull); + rv = owner->GetURL(url, target, nsnull, 0, (void *) getHeaders, + getHeadersLength); } NS_RELEASE(peer); @@ -1575,7 +1590,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, } if (nsnull != streamListener) - rv = NewPluginURLStream(string, instance, streamListener); + rv = NewPluginURLStream(string, instance, streamListener, + nsnull, nsnull, getHeaders, getHeadersLength); NS_RELEASE(instance); } diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h index f872c822205..5a327e1e4c3 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.h @@ -148,6 +148,17 @@ public: const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE); + NS_IMETHOD + GetURLWithHeaders(nsISupports* pluginInst, + const char* url, + const char* target = NULL, + nsIPluginStreamListener* streamListener = NULL, + const char* altHost = NULL, + const char* referrer = NULL, + PRBool forceJSEnabled = PR_FALSE, + PRUint32 getHeadersLength = 0, + const char* getHeaders = NULL); + NS_IMETHOD PostURL(nsISupports* pluginInst, const char* url, diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index a82d09f8d16..42ed29f8cab 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -1533,6 +1533,20 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, const char* altHost, const char* referrer, PRBool forceJSEnabled) +{ + return GetURLWithHeaders(pluginInst, url, target, streamListener, + altHost, referrer, forceJSEnabled, nsnull, nsnull); +} + +NS_IMETHODIMP nsPluginHostImpl::GetURLWithHeaders(nsISupports* pluginInst, + const char* url, + const char* target, + nsIPluginStreamListener* streamListener, + const char* altHost, + const char* referrer, + PRBool forceJSEnabled, + PRUint32 getHeadersLength, + const char* getHeaders) { nsAutoString string; string.AssignWithConversion(url); nsIPluginInstance *instance; @@ -1567,7 +1581,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, else if (0 == PL_strcmp(target, "_current")) target = "_self"; - rv = owner->GetURL(url, target, nsnull, 0, nsnull, nsnull); + rv = owner->GetURL(url, target, nsnull, 0, (void *) getHeaders, + getHeadersLength); } NS_RELEASE(peer); @@ -1575,7 +1590,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetURL(nsISupports* pluginInst, } if (nsnull != streamListener) - rv = NewPluginURLStream(string, instance, streamListener); + rv = NewPluginURLStream(string, instance, streamListener, + nsnull, nsnull, getHeaders, getHeadersLength); NS_RELEASE(instance); } diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h index f872c822205..5a327e1e4c3 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.h @@ -148,6 +148,17 @@ public: const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE); + NS_IMETHOD + GetURLWithHeaders(nsISupports* pluginInst, + const char* url, + const char* target = NULL, + nsIPluginStreamListener* streamListener = NULL, + const char* altHost = NULL, + const char* referrer = NULL, + PRBool forceJSEnabled = PR_FALSE, + PRUint32 getHeadersLength = 0, + const char* getHeaders = NULL); + NS_IMETHOD PostURL(nsISupports* pluginInst, const char* url, diff --git a/mozilla/modules/plugin/public/nsIPluginManager.h b/mozilla/modules/plugin/public/nsIPluginManager.h index b65328545bb..2bd3869dcde 100644 --- a/mozilla/modules/plugin/public/nsIPluginManager.h +++ b/mozilla/modules/plugin/public/nsIPluginManager.h @@ -162,10 +162,13 @@ public: * URLs, even if the user currently has JavaScript disabled (usually * specify PR_FALSE) * @param postHeadersLength - the length of postHeaders (if non-NULL) - * @param postHeaders - the headers to POST. NULL specifies that there - * are no post headers - * @result - NS_OK if this operation was successful - */ + + * @param postHeaders - the headers to POST. Must be in the form of + * "HeaderName: HeaderValue\r\n". Each header, including the last, + * must be followed by "\r\n". NULL specifies that there are no + * post headers + + * @result - NS_OK if this operation was successful */ NS_IMETHOD PostURL(nsISupports* pluginInst, @@ -221,6 +224,35 @@ public: NS_IMETHOD UnregisterPlugin(REFNSIID aCID) = 0; + + /** + * Fetches a URL, with Headers + + * @see GetURL. Identical except for additional params headers and + * headersLen + + * @param getHeadersLength - the length of getHeaders (if non-NULL) + + * @param getHeaders - the headers to GET. Must be in the form of + * "HeaderName: HeaderValue\r\n". Each header, including the last, + * must be followed by "\r\n". NULL specifies that there are no + * get headers + + * @result - NS_OK if this operation was successful + + */ + + NS_IMETHOD + GetURLWithHeaders(nsISupports* pluginInst, + const char* url, + const char* target = NULL, + nsIPluginStreamListener* streamListener = NULL, + const char* altHost = NULL, + const char* referrer = NULL, + PRBool forceJSEnabled = PR_FALSE, + PRUint32 getHeadersLength = 0, + const char* getHeaders = NULL) = 0; + };