Renamed nsIURL to nsIURI in preperation for necko. More NECKO ifdefs too.
This commit is contained in:
@@ -26,8 +26,10 @@
|
||||
#include "nsIURL.h"
|
||||
#ifdef NECKO
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#endif // NECKO
|
||||
#include "nsIComponentManager.h"
|
||||
@@ -64,15 +66,25 @@ public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
#ifdef NECKO
|
||||
// nsIStreamObserver methods:
|
||||
NS_IMETHOD OnStartBinding(nsISupports *ctxt);
|
||||
NS_IMETHOD OnStopBinding(nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg);
|
||||
NS_IMETHOD OnStartRequest(nsISupports *ctxt) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD OnStopRequest(nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
// nsIStreamListener methods:
|
||||
NS_IMETHOD OnDataAvailable(nsISupports *ctxt, nsIBufferInputStream *inStr, PRUint32 sourceOffset, PRUint32 count);
|
||||
#else
|
||||
// nsIStreamListener
|
||||
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
|
||||
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg);
|
||||
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus,
|
||||
NS_IMETHOD OnStartBinding(nsIURI* aURL, const char *aContentType);
|
||||
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg);
|
||||
NS_IMETHOD OnStopBinding(nsIURI* aURL, nsresult aStatus,
|
||||
const PRUnichar* aMsg);
|
||||
NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo);
|
||||
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream,
|
||||
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo);
|
||||
NS_IMETHOD OnDataAvailable(nsIURI* aURL, nsIInputStream* aStream,
|
||||
PRUint32 aCount);
|
||||
#endif
|
||||
|
||||
PluginViewerImpl* mViewer;
|
||||
nsIStreamListener* mNextStream;
|
||||
@@ -153,20 +165,32 @@ public:
|
||||
nsIDeviceContext* aDeviceContext,
|
||||
const nsRect& aBounds);
|
||||
|
||||
nsresult StartLoad(nsIURL* aURL, const char* aContentType,
|
||||
#ifdef NECKO
|
||||
nsresult StartLoad(nsIChannel* channel, nsIStreamListener*& aResult);
|
||||
#else
|
||||
nsresult StartLoad(nsIURI* aURL, const char* aContentType,
|
||||
nsIStreamListener*& aResult);
|
||||
#endif
|
||||
|
||||
void ForceRefresh(void);
|
||||
|
||||
nsresult GetURL(nsIURL *&aURL);
|
||||
#ifdef NECKO
|
||||
nsresult GetURI(nsIURI* *aURI);
|
||||
#else
|
||||
nsresult GetURL(nsIURI *&aURL);
|
||||
#endif
|
||||
|
||||
nsresult GetDocument(nsIDocument* *aDocument);
|
||||
|
||||
nsIWidget* mWindow;
|
||||
nsIDocument* mDocument;
|
||||
nsIContentViewerContainer* mContainer;
|
||||
nsIURL* mURL;
|
||||
#ifdef NECKO
|
||||
nsIChannel* mChannel;
|
||||
#else
|
||||
nsIURI* mURL;
|
||||
nsString mContentType;
|
||||
#endif
|
||||
pluginInstanceOwner *mOwner;
|
||||
PRBool mEnableRendering;
|
||||
};
|
||||
@@ -230,7 +254,11 @@ PluginViewerImpl::~PluginViewerImpl()
|
||||
}
|
||||
NS_IF_RELEASE(mDocument);
|
||||
NS_IF_RELEASE(mContainer);
|
||||
#ifdef NECKO
|
||||
NS_IF_RELEASE(mChannel);
|
||||
#else
|
||||
NS_IF_RELEASE(mURL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -285,15 +313,33 @@ PluginViewerImpl::Init(nsNativeWidget aNativeParent,
|
||||
}
|
||||
|
||||
nsresult
|
||||
PluginViewerImpl::StartLoad(nsIURL* aURL, const char* aContentType,
|
||||
#ifdef NECKO
|
||||
PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult)
|
||||
#else
|
||||
PluginViewerImpl::StartLoad(nsIURI* aURL, const char* aContentType,
|
||||
nsIStreamListener*& aResult)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
NS_IF_RELEASE(mChannel);
|
||||
mChannel = channel;
|
||||
NS_ADDREF(mChannel);
|
||||
|
||||
#ifdef DEBUG
|
||||
char* contentType;
|
||||
mChannel->GetContentType(&contentType);
|
||||
printf("PluginViewerImpl::StartLoad: content-type=%s\n", contentType);
|
||||
nsCRT::free(contentType);
|
||||
#endif
|
||||
|
||||
#else
|
||||
printf("PluginViewerImpl::StartLoad: content-type=%s\n", aContentType);
|
||||
|
||||
NS_IF_RELEASE(mURL);
|
||||
mURL = aURL;
|
||||
NS_IF_ADDREF(aURL);
|
||||
mContentType = aContentType;
|
||||
#endif
|
||||
|
||||
aResult = nsnull;
|
||||
|
||||
@@ -333,13 +379,30 @@ PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds,
|
||||
win->ws_info = nsnull; //XXX need to figure out what this is. MMP
|
||||
#endif
|
||||
|
||||
#ifdef NECKO
|
||||
nsIURI* uri;
|
||||
rv = mChannel->GetURI(&uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char* spec;
|
||||
rv = uri->GetSpec(&spec);
|
||||
NS_RELEASE(uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsAutoString str(spec);
|
||||
nsCRT::free(spec);
|
||||
|
||||
char* ct;
|
||||
rv = mChannel->GetContentType(&ct);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aHost->InstantiateFullPagePlugin(ct, str, aResult, mOwner);
|
||||
#else
|
||||
PRUnichar* fullurl;
|
||||
mURL->ToString(&fullurl);
|
||||
|
||||
char* ct = mContentType.ToNewCString();
|
||||
nsAutoString str = fullurl;
|
||||
rv = aHost->InstantiateFullPagePlugin(ct, str, aResult, mOwner);
|
||||
delete fullurl;
|
||||
#endif
|
||||
delete[] ct;
|
||||
}
|
||||
|
||||
@@ -507,12 +570,19 @@ PluginViewerImpl::ForceRefresh()
|
||||
mWindow->Invalidate(PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult PluginViewerImpl::GetURL(nsIURL *&aURL)
|
||||
#ifdef NECKO
|
||||
nsresult PluginViewerImpl::GetURI(nsIURI* *aURI)
|
||||
{
|
||||
return mChannel->GetURI(aURI);
|
||||
}
|
||||
#else
|
||||
nsresult PluginViewerImpl::GetURL(nsIURI *&aURL)
|
||||
{
|
||||
NS_IF_ADDREF(mURL);
|
||||
aURL = mURL;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult PluginViewerImpl::GetDocument(nsIDocument* *aDocument)
|
||||
{
|
||||
@@ -540,17 +610,43 @@ PluginListener::~PluginListener()
|
||||
NS_IMPL_ISUPPORTS(PluginListener, kIStreamListenerIID)
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginListener::OnStartBinding(nsIURL* aURL, const char *aContentType)
|
||||
#ifdef NECKO
|
||||
PluginListener::OnStartBinding(nsISupports *ctxt)
|
||||
#else
|
||||
PluginListener::OnStartBinding(nsIURI* aURL, const char *contentType)
|
||||
#endif
|
||||
{
|
||||
mViewer->StartLoad(aURL, aContentType, mNextStream);
|
||||
#ifdef NECKO
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
char* contentType = nsnull;
|
||||
|
||||
rv = ctxt->QueryInterface(nsIChannel::GetIID(), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = channel->GetContentType(&contentType);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
rv = mViewer->StartLoad(channel, mNextStream);
|
||||
NS_RELEASE(channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#else
|
||||
mViewer->StartLoad(aURL, contentType, mNextStream);
|
||||
#endif
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return mNextStream->OnStartBinding(aURL, aContentType);
|
||||
#ifdef NECKO
|
||||
return mNextStream->OnStartBinding(ctxt);
|
||||
#else
|
||||
return mNextStream->OnStartBinding(aURL, contentType);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NECKO
|
||||
NS_IMETHODIMP
|
||||
PluginListener::OnProgress(nsIURL* aURL, PRUint32 aProgress,
|
||||
PluginListener::OnProgress(nsIURI* aURL, PRUint32 aProgress,
|
||||
PRUint32 aProgressMax)
|
||||
{
|
||||
if (nsnull == mNextStream) {
|
||||
@@ -560,41 +656,60 @@ PluginListener::OnProgress(nsIURL* aURL, PRUint32 aProgress,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginListener::OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
|
||||
PluginListener::OnStatus(nsIURI* aURL, const PRUnichar* aMsg)
|
||||
{
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return mNextStream->OnStatus(aURL, aMsg);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginListener::OnStopBinding(nsIURL* aURL, nsresult aStatus,
|
||||
#ifdef NECKO
|
||||
PluginListener::OnStopBinding(nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg)
|
||||
#else
|
||||
PluginListener::OnStopBinding(nsIURI* aURL, nsresult aStatus,
|
||||
const PRUnichar* aMsg)
|
||||
#endif
|
||||
{
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#ifdef NECKO
|
||||
return mNextStream->OnStopBinding(ctxt, status, errorMsg);
|
||||
#else
|
||||
return mNextStream->OnStopBinding(aURL, aStatus, aMsg);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NECKO
|
||||
NS_IMETHODIMP
|
||||
PluginListener::GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo)
|
||||
PluginListener::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo)
|
||||
{
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return mNextStream->GetBindInfo(aURL, aInfo);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
PluginListener::OnDataAvailable(nsIURL* aURL, nsIInputStream* aStream,
|
||||
#ifdef NECKO
|
||||
PluginListener::OnDataAvailable(nsISupports *ctxt, nsIBufferInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
||||
#else
|
||||
PluginListener::OnDataAvailable(nsIURI* aURL, nsIInputStream* aStream,
|
||||
PRUint32 aCount)
|
||||
#endif
|
||||
{
|
||||
if (nsnull == mNextStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#ifdef NECKO
|
||||
return mNextStream->OnDataAvailable(ctxt, inStr, sourceOffset, count);
|
||||
#else
|
||||
return mNextStream->OnDataAvailable(aURL, aStream, aCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -698,44 +813,37 @@ NS_IMETHODIMP pluginInstanceOwner :: GetURL(const char *aURL, const char *aTarge
|
||||
|
||||
if (NS_OK == rv)
|
||||
{
|
||||
nsIURL *url;
|
||||
|
||||
#ifdef NECKO
|
||||
nsIURI *uri;
|
||||
rv = mViewer->GetURI(&uri);
|
||||
#else
|
||||
nsIURI *url;
|
||||
rv = mViewer->GetURL(url);
|
||||
#endif
|
||||
|
||||
if (NS_OK == rv)
|
||||
{
|
||||
// Create an absolute URL
|
||||
#ifdef NECKO
|
||||
char* absURIStr;
|
||||
rv = NS_MakeAbsoluteURI(aURL, uri, &absURIStr);
|
||||
NS_RELEASE(uri);
|
||||
nsAutoString fullurl(absURIStr);
|
||||
nsCRT::free(absURIStr);
|
||||
#else
|
||||
nsAutoString uniurl = nsAutoString(aURL);
|
||||
nsAutoString unitarget = nsAutoString(aTarget);
|
||||
const char* spec;
|
||||
(void)url->GetSpec(&spec);
|
||||
nsAutoString base = nsAutoString(spec);
|
||||
nsAutoString fullurl;
|
||||
|
||||
// Create an absolute URL
|
||||
#ifndef NECKO
|
||||
rv = NS_MakeAbsoluteURL(url, base, uniurl, fullurl);
|
||||
#else
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIURI *baseUri = nsnull;
|
||||
const char *uriStr = uniurl.GetBuffer();
|
||||
rv = service->NewURI(uriStr, nsnull, &baseUri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char *absUrl = nsnull;
|
||||
const char *urlSpec = base.GetBuffer();
|
||||
rv = service->MakeAbsolute(urlSpec, baseUri, &absUrl);
|
||||
NS_RELEASE(baseUri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
fullurl = absUrl;
|
||||
delete [] absUrl;
|
||||
#endif // NECKO
|
||||
|
||||
if (NS_OK == rv)
|
||||
rv = lh->OnLinkClick(nsnull, eLinkVerb_Replace, fullurl.GetUnicode(), unitarget.GetUnicode(), nsnull);
|
||||
|
||||
NS_RELEASE(url);
|
||||
#endif
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsAutoString unitarget = nsAutoString(aTarget);
|
||||
rv = lh->OnLinkClick(nsnull, eLinkVerb_Replace, fullurl.GetUnicode(), unitarget.GetUnicode(), nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(lh);
|
||||
|
||||
Reference in New Issue
Block a user