зеркало из https://github.com/mozilla/pjs.git
Fix for bug # 10333. Made webshell a progress event sink as well so that now it redirects all progress messages from necko land to the appropriate docloader observer. The hack to delete strings which are being received in the status messages is a work around the current limitation of the proxy event code. When bug # 16273 is fixed that delete wont be necessary. In fixing this I also noticed that the nsFileTransport wasn't using the proxy events and was incorrectly firing status messages directly onto the UI thread. Fixed that as well. r=rpotts,warren
This commit is contained in:
Родитель
be3ea9dd42
Коммит
7f425f1145
|
@ -32,6 +32,7 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
@ -149,6 +150,7 @@ class nsWebShell : public nsIWebShell,
|
|||
public nsILinkHandler,
|
||||
public nsIScriptContextOwner,
|
||||
public nsIDocumentLoaderObserver,
|
||||
public nsIProgressEventSink, // should go away (nsIDocLoaderObs)
|
||||
public nsIPrompt,
|
||||
public nsIRefreshURI,
|
||||
public nsIClipboardCommands
|
||||
|
@ -349,6 +351,9 @@ public:
|
|||
// nsIPrompt
|
||||
NS_DECL_NSIPROMPT
|
||||
|
||||
// nsIProgressEventSink
|
||||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
|
||||
// nsIClipboardCommands
|
||||
NS_IMETHOD CanCutSelection (PRBool* aResult);
|
||||
NS_IMETHOD CanCopySelection (PRBool* aResult);
|
||||
|
@ -518,12 +523,12 @@ static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
|||
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
||||
|
||||
|
||||
// IID's
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID,
|
||||
NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverIID,
|
||||
NS_IDOCUMENT_LOADER_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIProgressEventSinkIID, NS_IPROGRESSEVENTSINK_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
@ -786,6 +791,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIProgressEventSinkIID)) {
|
||||
*aInstancePtr = (void*)(nsIProgressEventSink*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIWebShellContainerIID)) {
|
||||
*aInstancePtr = (void*)(nsIWebShellContainer*)this;
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -1959,6 +1969,7 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
if (!aUri)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// This should probably get saved in mHistoryService or something...
|
||||
// Ugh. It sucks that we have to hack webshell like this. Forgive me, Father.
|
||||
do {
|
||||
nsresult rv;
|
||||
|
@ -2051,9 +2062,6 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
mProcessedEndDocumentLoad = PR_FALSE;
|
||||
|
||||
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -2134,7 +2142,6 @@ nsWebShell::LoadURI(nsIURI * aUri,
|
|||
rv = aUri->GetSpec(getter_Copies(spec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
nsString* url = new nsString(uriSpec);
|
||||
if (aModifyHistory) {
|
||||
// Discard part of history that is no longer reachable
|
||||
|
@ -2186,6 +2193,12 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
/*
|
||||
TODO This doesnt belong here... The app should be doing all this
|
||||
URL play. The webshell should not have a clue about whats "mailto"
|
||||
If you insist that this should be here, then put in URL parsing
|
||||
optimizations here. -Gagan
|
||||
*/
|
||||
nsAutoString urlStr(aURLSpec);
|
||||
// first things first. try to create a uri out of the string.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -2447,6 +2460,7 @@ nsWebShell::CanForward(void)
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::GoTo(PRInt32 aHistoryIndex)
|
||||
{
|
||||
#ifdef OLD_HISTORY
|
||||
nsresult rv = NS_ERROR_ILLEGAL_VALUE;
|
||||
if ((aHistoryIndex >= 0) &&
|
||||
(aHistoryIndex < mHistory.Count())) {
|
||||
|
@ -2478,6 +2492,13 @@ nsWebShell::GoTo(PRInt32 aHistoryIndex)
|
|||
nsnull); // referrer
|
||||
}
|
||||
return rv;
|
||||
#else
|
||||
if (mSHist)
|
||||
return mSHist->Goto(aHistoryIndex, this, PR_FALSE);
|
||||
return NS_OK;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -3274,7 +3295,7 @@ nsWebShell::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
|||
dlObserver = do_QueryInterface(mDocLoaderObserver); // we need this to addref
|
||||
}
|
||||
/*
|
||||
*Fire the OnStartDocumentLoad of the webshell observer
|
||||
* Fire the OnStartDocumentLoad of the webshell observer
|
||||
*/
|
||||
if ((nsnull != mContainer) && (nsnull != dlObserver))
|
||||
{
|
||||
|
@ -3515,7 +3536,7 @@ nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader,
|
|||
printf("nsWebShell::OnEndURLLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus);
|
||||
#endif
|
||||
/*
|
||||
*Fire the OnStartDocumentLoad of the webshell observer
|
||||
*Fire the OnEndDocumentLoad of the webshell observer
|
||||
*/
|
||||
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
||||
{
|
||||
|
@ -3713,8 +3734,6 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4066,6 +4085,57 @@ nsWebShell::FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSe
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Methods from nsIProgressEventSink
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::OnProgress(nsIChannel* channel, nsISupports* ctxt,
|
||||
PRUint32 aProgress,
|
||||
PRUint32 aProgressMax)
|
||||
{
|
||||
if (nsnull != mDocLoaderObserver)
|
||||
{
|
||||
return mDocLoaderObserver->OnProgressURLLoad(
|
||||
mDocLoader,
|
||||
channel,
|
||||
aProgress,
|
||||
aProgressMax);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::OnStatus(nsIChannel* channel, nsISupports* ctxt,
|
||||
const PRUnichar* aMsg)
|
||||
{
|
||||
if (nsnull != mDocLoaderObserver)
|
||||
{
|
||||
nsAutoString temp(aMsg);
|
||||
#ifdef DEBUG_gagan
|
||||
|
||||
#ifdef XP_UNIX
|
||||
printf("\033[33m"); // Start yellow
|
||||
#endif
|
||||
|
||||
char* tmp = temp.ToNewCString();
|
||||
printf("%s\n",tmp);
|
||||
CRTFREEIF(tmp);
|
||||
#ifdef XP_UNIX
|
||||
printf("\033[0m"); // End colors
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_gagan
|
||||
nsresult rv = mDocLoaderObserver->OnStatusURLLoad(
|
||||
mDocLoader,
|
||||
channel,
|
||||
temp);
|
||||
|
||||
#ifndef BUG_16273_FIXED
|
||||
//free the message-
|
||||
CRTFREEIF((PRUnichar*)aMsg);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsWebShell::GetViewManager(nsIViewManager* *viewManager)
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on
|
|||
aURL->GetPort(&port);
|
||||
aURL->GetHost(getter_Copies(hostName));
|
||||
|
||||
rv = socketService->CreateTransport(hostName, port, getter_AddRefs(m_channel));
|
||||
rv = socketService->CreateTransport(hostName, port, nsnull, getter_AddRefs(m_channel));
|
||||
if (NS_SUCCEEDED(rv) && m_channel)
|
||||
{
|
||||
m_socketIsOpen = PR_FALSE;
|
||||
|
|
|
@ -584,7 +584,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
|
|||
aURL->GetHost(getter_Copies(hostName));
|
||||
|
||||
ClearFlag(IMAP_CONNECTION_IS_OPEN);
|
||||
rv = socketService->CreateTransport(hostName, port, getter_AddRefs(m_channel));
|
||||
rv = socketService->CreateTransport(hostName, port, nsnull, getter_AddRefs(m_channel));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream));
|
||||
|
|
|
@ -19,15 +19,26 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIChannel;
|
||||
interface nsIEventSinkGetter;
|
||||
|
||||
[scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)]
|
||||
interface nsISocketTransportService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Creates a transport for a specified host and port.
|
||||
* The eventSinkGetter is used to get the appropriate callbacks
|
||||
* for the socket activity from the application. These include
|
||||
* the progress and the status messages like "Contacting host.."
|
||||
* etc.
|
||||
*/
|
||||
nsIChannel createTransport(in string host,
|
||||
in long port);
|
||||
in long port,
|
||||
in nsIEventSinkGetter eventSinkGetter);
|
||||
nsIChannel createTransportOfType(in string socketType,
|
||||
in string host,
|
||||
in long port);
|
||||
in string host,
|
||||
in long port,
|
||||
in nsIEventSinkGetter eventSinkGetter);
|
||||
|
||||
void shutdown();
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIProgressEventSink;
|
||||
interface nsIChannel;
|
||||
|
||||
/**
|
||||
|
@ -35,8 +36,9 @@ interface nsIStatusCodeEventSink : nsISupports
|
|||
* Notify the EventSink with a status code for the URL load.<BR>
|
||||
* Use IOService to request converting that code to a string.
|
||||
*/
|
||||
void onStatus(in nsIChannel channel,
|
||||
in nsISupports ctxt,
|
||||
in unsigned long aCode);
|
||||
void onStatus(in nsIProgressEventSink sink,
|
||||
in nsIChannel channel,
|
||||
in nsISupports ctxt,
|
||||
in unsigned long aCode);
|
||||
|
||||
};
|
||||
|
|
|
@ -40,10 +40,12 @@
|
|||
#include "nsEscape.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "prlog.h"
|
||||
#include "nsProxyObjectManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
|
||||
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
//
|
||||
|
@ -294,8 +296,23 @@ nsFileTransport::Init(nsFileSpec& spec, const char* command, nsIEventSinkGetter*
|
|||
return rv;
|
||||
if (getter) {
|
||||
nsCOMPtr<nsISupports> sink;
|
||||
(void)getter->GetEventSink(command, nsIProgressEventSink::GetIID(), getter_AddRefs(sink));
|
||||
mProgress = (nsIProgressEventSink*)sink.get();
|
||||
(void)getter->GetEventSink(command,
|
||||
nsIProgressEventSink::GetIID(), getter_AddRefs(sink));
|
||||
if (sink)
|
||||
{
|
||||
// Now generate a proxied event sink-
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager,
|
||||
proxyMgr, kProxyObjectManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = proxyMgr->GetProxyObject(
|
||||
nsnull, // primordial thread - should change?
|
||||
NS_GET_IID(nsIProgressEventSink),
|
||||
sink,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(mProgress));
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -789,8 +806,8 @@ nsFileTransport::Process(void)
|
|||
|
||||
if (mProgress) {
|
||||
nsresult rv = mProgress->OnProgress(this, mContext,
|
||||
mTotalAmount - mTransferAmount,
|
||||
mTotalAmount);
|
||||
mTotalAmount - mTransferAmount,
|
||||
mTotalAmount);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnProgress failure");
|
||||
}
|
||||
|
||||
|
@ -826,7 +843,13 @@ nsFileTransport::Process(void)
|
|||
// XXX fix up this message for i18n
|
||||
nsAutoString msg = "Read ";
|
||||
msg += (const char*)mSpec;
|
||||
// this should just change to msg.mUStr instead once bug
|
||||
// # 16273 is fixed
|
||||
#ifndef BUG_16273_FIXED //TODO
|
||||
(void)mProgress->OnStatus(this, mContext, msg.ToNewUnicode());
|
||||
#else
|
||||
(void)mProgress->OnStatus(this, mContext, msg.mUStr);
|
||||
#endif
|
||||
}
|
||||
mContext = null_nsCOMPtr();
|
||||
|
||||
|
|
|
@ -432,5 +432,63 @@ nsIOService::NewInputStreamChannel(nsIURI* uri, const char *contentType,
|
|||
*result = channel;
|
||||
return NS_OK;
|
||||
}
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsIOService::GetSocketErrorString(PRUint32 iCode, PRUnichar** oString)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (!oString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*oString = nsnull;
|
||||
|
||||
switch (iCode) /* these are currently just nsSocketState
|
||||
(as in nsSocketTransport.h) */
|
||||
{
|
||||
case eSocketState_WaitDNS:
|
||||
{
|
||||
static nsAutoString mesg("Resolving host ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_Connected:
|
||||
{
|
||||
static nsAutoString mesg("Connected to ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_WaitReadWrite:
|
||||
{
|
||||
static nsAutoString mesg("Transfering data from ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_WaitConnect:
|
||||
{
|
||||
static nsAutoString mesg("Connecting to ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_Created:
|
||||
case eSocketState_Closed:
|
||||
case eSocketState_Done:
|
||||
case eSocketState_Timeout:
|
||||
case eSocketState_Error:
|
||||
case eSocketState_Max:
|
||||
default:
|
||||
return rv; // just return error, ie no status strings for this case
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -34,11 +34,14 @@
|
|||
#include "nsISocketProvider.h"
|
||||
#include "nsISocketProviderService.h"
|
||||
#include "nsStdURL.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsProxyObjectManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_CID(kSocketProviderService, NS_SOCKETPROVIDERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kDNSService, NS_DNSSERVICE_CID);
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
|
||||
//
|
||||
// This is the State table which maps current state to next state
|
||||
// for each socket operation...
|
||||
|
@ -205,13 +208,8 @@ nsSocketTransport::~nsSocketTransport()
|
|||
|
||||
NS_IF_RELEASE(mService);
|
||||
|
||||
if (mHostName) {
|
||||
nsCRT::free(mHostName);
|
||||
}
|
||||
|
||||
if (mSocketType) {
|
||||
nsCRT::free(mSocketType);
|
||||
}
|
||||
CRTFREEIF(mHostName);
|
||||
CRTFREEIF(mSocketType);
|
||||
|
||||
if (mSocketFD) {
|
||||
PR_Close(mSocketFD);
|
||||
|
@ -222,13 +220,15 @@ nsSocketTransport::~nsSocketTransport()
|
|||
PR_DestroyLock(mLock);
|
||||
mLock = nsnull;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
|
||||
const char* aHost,
|
||||
PRInt32 aPort,
|
||||
const char* aSocketType)
|
||||
const char* aSocketType,
|
||||
nsIEventSinkGetter* eventSinkGetter)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -254,6 +254,31 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
|
|||
}
|
||||
}
|
||||
|
||||
// Get a nsIProgressEventSink so that we can fire status/progress on it-
|
||||
if (eventSinkGetter)
|
||||
{
|
||||
nsIProgressEventSink* sink;
|
||||
(void) eventSinkGetter->GetEventSink("load", // Hmmm...
|
||||
nsIProgressEventSink::GetIID(),
|
||||
(nsISupports**)&sink);
|
||||
if (sink)
|
||||
{
|
||||
// Now generate a proxied event sink-
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager,
|
||||
proxyMgr, kProxyObjectManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = proxyMgr->GetProxyObject(
|
||||
nsnull, // primordial thread - should change?
|
||||
NS_GET_IID(nsIProgressEventSink),
|
||||
sink,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(mEventSink));
|
||||
}
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Create the lock used for synchronizing access to the transport instance.
|
||||
//
|
||||
|
@ -465,6 +490,8 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags)
|
|||
mStatus = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
fireStatus(mCurrentState);
|
||||
//
|
||||
// If the current state has successfully completed, then move to the
|
||||
// next state for the current operation...
|
||||
|
@ -1728,3 +1755,87 @@ nsSocketTransport::SetOwner(nsISupports * aOwner)
|
|||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsSocketTransport::fireStatus(PRUint32 aCode)
|
||||
{
|
||||
// need to optimize this - TODO
|
||||
nsXPIDLString tempmesg;
|
||||
nsresult rv = GetSocketErrorString(aCode, getter_Copies(tempmesg));
|
||||
|
||||
nsAutoString mesg(tempmesg);
|
||||
mesg.Append(mHostName);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifndef BUG_16273_FIXED //TODO
|
||||
return mEventSink ? mEventSink->OnStatus(this,
|
||||
mReadContext,
|
||||
mesg.ToNewUnicode()) // this gets freed elsewhere.
|
||||
: NS_ERROR_FAILURE;
|
||||
#else
|
||||
return mEventSink ? mEventSink->OnStatus(this,
|
||||
mReadContext,
|
||||
mesg.mUStr) // this gets freed elsewhere.
|
||||
: NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
//TODO l10n and i18n stuff here!
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetSocketErrorString(PRUint32 iCode,
|
||||
PRUnichar** oString) const
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (!oString)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*oString = nsnull;
|
||||
|
||||
switch (iCode) /* these are currently just nsSocketState
|
||||
(as in nsSocketTransport.h) */
|
||||
{
|
||||
case eSocketState_WaitDNS:
|
||||
{
|
||||
static nsAutoString mesg("Resolving host ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_Connected:
|
||||
{
|
||||
static nsAutoString mesg("Connected to ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_WaitReadWrite:
|
||||
{
|
||||
static nsAutoString mesg("Transfering data from ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_WaitConnect:
|
||||
{
|
||||
static nsAutoString mesg("Connecting to ");
|
||||
*oString = mesg.ToNewUnicode();
|
||||
if (!*oString) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = NS_OK;
|
||||
}
|
||||
break;
|
||||
case eSocketState_Created:
|
||||
case eSocketState_Closed:
|
||||
case eSocketState_Done:
|
||||
case eSocketState_Timeout:
|
||||
case eSocketState_Error:
|
||||
case eSocketState_Max:
|
||||
default:
|
||||
return rv; // just return error, ie no status strings for this case
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsIStreamListener.h"
|
||||
#include "nsIDNSListener.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
||||
#define NS_SOCKET_TRANSPORT_SEGMENT_SIZE (2*1024)
|
||||
#define NS_SOCKET_TRANSPORT_BUFFER_SIZE (8*1024)
|
||||
|
@ -107,6 +108,7 @@ enum nsSocketReadWriteInfo {
|
|||
|
||||
// Forward declarations...
|
||||
class nsSocketTransportService;
|
||||
class nsIEventSinkGetter;
|
||||
|
||||
class nsSocketTransport : public nsIChannel,
|
||||
public nsIDNSListener,
|
||||
|
@ -130,7 +132,8 @@ public:
|
|||
nsresult Init(nsSocketTransportService* aService,
|
||||
const char* aHost,
|
||||
PRInt32 aPort,
|
||||
const char* aSocketType);
|
||||
const char* aSocketType,
|
||||
nsIEventSinkGetter* eventSinkGetter);
|
||||
nsresult Process(PRInt16 aSelectFlags);
|
||||
|
||||
nsresult CloseConnection(void);
|
||||
|
@ -151,6 +154,9 @@ protected:
|
|||
nsresult doWriteFromBuffer(PRUint32 *aCount);
|
||||
nsresult doWriteFromStream(PRUint32 *aCount);
|
||||
|
||||
nsresult fireStatus(PRUint32 aCode);
|
||||
nsresult GetSocketErrorString(PRUint32 iCode, PRUnichar** oString) const;
|
||||
|
||||
private:
|
||||
// Access methods for manipulating the ReadWriteInfo...
|
||||
inline void SetReadType(nsSocketReadWriteInfo aType) {
|
||||
|
@ -177,6 +183,8 @@ private:
|
|||
}
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
PRCList mListLink;
|
||||
|
||||
PRLock* mLock;
|
||||
|
@ -217,6 +225,8 @@ protected:
|
|||
nsCOMPtr<nsIRequest> mDNSRequest;
|
||||
nsresult mStatus;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
// For tracking connection progress and status
|
||||
nsCOMPtr<nsIProgressEventSink> mEventSink;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -158,7 +158,6 @@ nsresult nsSocketTransportService::Init(void)
|
|||
mThreadRunning = PR_TRUE;
|
||||
rv = NS_NewThread(&mThread, this, 0, PR_JOINABLE_THREAD);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -483,16 +482,18 @@ nsSocketTransportService::Run(void)
|
|||
NS_IMETHODIMP
|
||||
nsSocketTransportService::CreateTransport(const char* aHost,
|
||||
PRInt32 aPort,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsIChannel** aResult)
|
||||
{
|
||||
return CreateTransportOfType(nsnull, aHost, aPort, aResult);
|
||||
return CreateTransportOfType(nsnull, aHost, aPort, eventSinkGetter, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
|
||||
const char* aHost,
|
||||
PRInt32 aPort,
|
||||
nsIChannel** aResult)
|
||||
const char* aHost,
|
||||
PRInt32 aPort,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsIChannel** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsSocketTransport* transport = nsnull;
|
||||
|
@ -506,7 +507,7 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
|
|||
// Create and initialize a new connection object...
|
||||
NS_NEWXPCOM(transport, nsSocketTransport);
|
||||
if (transport) {
|
||||
rv = transport->Init(this, aHost, aPort, aSocketType);
|
||||
rv = transport->Init(this, aHost, aPort, aSocketType, eventSinkGetter);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete transport;
|
||||
transport = nsnull;
|
||||
|
@ -525,7 +526,6 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::Shutdown(void)
|
||||
{
|
||||
|
|
|
@ -1589,7 +1589,7 @@ nsFtpConnectionThread::R_pasv() {
|
|||
host.Append(h3);
|
||||
|
||||
// now we know where to connect our data channel
|
||||
rv = mSTS->CreateTransport(host.GetBuffer(), port, &mDPipe); // the data channel
|
||||
rv = mSTS->CreateTransport(host.GetBuffer(), port, nsnull, &mDPipe); // the data channel
|
||||
if (NS_FAILED(rv)) return FTP_ERROR;
|
||||
|
||||
if (mAction == GET) {
|
||||
|
@ -1763,7 +1763,7 @@ nsFtpConnectionThread::Run() {
|
|||
mList = conn->mList;
|
||||
} else {
|
||||
// build our own
|
||||
rv = mSTS->CreateTransport(host, port, &mCPipe); // the command channel
|
||||
rv = mSTS->CreateTransport(host, port, nsnull, &mCPipe); // the command channel
|
||||
nsAllocator::Free(host);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
|
|
@ -573,7 +573,11 @@ nsHTTPChannel::Open(void)
|
|||
}
|
||||
}
|
||||
|
||||
rv = mHandler->RequestTransport(mURI, this, getter_AddRefs(channel));
|
||||
rv = mHandler->RequestTransport(mURI,
|
||||
this,
|
||||
mEventSinkGetter,
|
||||
getter_AddRefs(channel));
|
||||
|
||||
if (NS_ERROR_BUSY == rv) {
|
||||
mState = HS_WAITING_FOR_OPEN;
|
||||
return NS_OK;
|
||||
|
@ -861,12 +865,12 @@ nsHTTPChannel::Authenticate(const char *iChallenge, nsIChannel **oChannel)
|
|||
{
|
||||
nsXPIDLCString prehost;
|
||||
|
||||
if (NS_SUCCEEDED(rv = mURI->GetPreHost(getter_Copies(prehost))))
|
||||
{
|
||||
if (!(newUserPass = nsCRT::strdup(prehost)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (NS_SUCCEEDED(rv = mURI->GetPreHost(getter_Copies(prehost))))
|
||||
{
|
||||
if (!(newUserPass = nsCRT::strdup(prehost)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Couldnt get one from prehost or has already been tried so...ask
|
||||
if (!newUserPass || (0==PL_strlen(newUserPass)))
|
||||
|
@ -875,32 +879,33 @@ nsHTTPChannel::Authenticate(const char *iChallenge, nsIChannel **oChannel)
|
|||
Throw a modal dialog box asking for
|
||||
username, password. Prefill (!?!)
|
||||
*/
|
||||
/*
|
||||
Currently this is being thrown from here itself.
|
||||
The correct way to do this is to push this on the
|
||||
HTTPEventSink and let that notify the window that
|
||||
triggered this load to throw the userpass dialog
|
||||
*/
|
||||
/*
|
||||
Currently this is being thrown from here itself.
|
||||
The correct way to do this is to push this on the
|
||||
HTTPEventSink and let that notify the window that
|
||||
triggered this load to throw the userpass dialog
|
||||
*/
|
||||
NS_WITH_PROXIED_SERVICE(nsIPrompt, authdialog, kNetSupportDialogCID, nsnull, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUnichar *user, *passwd;
|
||||
PRBool retval;
|
||||
|
||||
nsAutoString message = "Enter username for "; //TODO localize it!
|
||||
message += iChallenge; // later on change to only show realm and then host's info.
|
||||
PRUnichar* msg = message.ToNewUnicode();
|
||||
rv = authdialog->PromptUsernameAndPassword(
|
||||
msg, &user, &passwd, &retval);
|
||||
CRTFREEIF(msg);
|
||||
CRTFREEIF(msg);
|
||||
if (retval)
|
||||
{
|
||||
nsAutoString temp(user);
|
||||
temp += ':';
|
||||
temp += passwd;
|
||||
CRTFREEIF(newUserPass);
|
||||
CRTFREEIF(newUserPass);
|
||||
newUserPass = temp.ToNewCString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Construct the auth string request header based on info provided.
|
||||
nsXPIDLCString authString;
|
||||
|
|
|
@ -359,8 +359,9 @@ nsHTTPHandler::NewPostDataStream(PRBool isFile, const char *data, PRUint32 encod
|
|||
|
||||
|
||||
nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
|
||||
nsHTTPChannel* i_Channel,
|
||||
nsIChannel** o_pTrans)
|
||||
nsHTTPChannel* i_Channel,
|
||||
nsIEventSinkGetter* i_ESG,
|
||||
nsIChannel** o_pTrans)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count;
|
||||
|
@ -413,18 +414,19 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
|
|||
GetDefaultPort(&port);
|
||||
}
|
||||
|
||||
rv = sts->CreateTransport(host, port, &trans);
|
||||
rv = sts->CreateTransport(host, port, i_ESG, &trans);
|
||||
i_Channel->SetUsingProxy(PR_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = sts->CreateTransport(mProxy, mProxyPort, &trans);
|
||||
rv = sts->CreateTransport(mProxy, mProxyPort, i_ESG, &trans);
|
||||
i_Channel->SetUsingProxy(PR_TRUE);
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Put it in the table...
|
||||
rv = mTransportList->AppendElement(trans) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
|
||||
// XXX this method incorrectly returns a bool
|
||||
rv = mTransportList->AppendElement(trans) ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*o_pTrans = trans;
|
||||
|
|
|
@ -77,8 +77,9 @@ public:
|
|||
return NS_OK;
|
||||
};
|
||||
|
||||
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI,
|
||||
char **_retval);
|
||||
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec,
|
||||
nsIURI *aBaseURI,
|
||||
char **_retval);
|
||||
|
||||
NS_IMETHOD NewChannel(const char* verb, nsIURI* url,
|
||||
nsILoadGroup *aGroup,
|
||||
|
@ -90,7 +91,7 @@ public:
|
|||
|
||||
//Functions from nsIProxy
|
||||
/*
|
||||
Get and Set the Proxy Host
|
||||
Get and Set the Proxy Host
|
||||
*/
|
||||
NS_IMETHOD GetProxyHost(const char* *o_ProxyHost) const;
|
||||
|
||||
|
@ -110,7 +111,10 @@ public:
|
|||
return NS_OK;
|
||||
};
|
||||
|
||||
// Follow the redirects automatically. This will trigger OnRedirect call on the sink
|
||||
/**
|
||||
* Follow the redirects automatically.
|
||||
* This will trigger OnRedirect call on the sink
|
||||
*/
|
||||
NS_IMETHOD FollowRedirects(PRBool bFollow=PR_TRUE);
|
||||
|
||||
// Singleton function
|
||||
|
@ -119,13 +123,15 @@ public:
|
|||
// Functions from nsIHTTPProtocolHandler
|
||||
NS_DECL_NSIHTTPPROTOCOLHANDLER
|
||||
|
||||
/*
|
||||
Pull out an existing transport from the list, or if none exists
|
||||
create one.
|
||||
/**
|
||||
* Pull out an existing transport from the list, or if none exists
|
||||
* create one.
|
||||
*/
|
||||
virtual nsresult RequestTransport(nsIURI *i_Uri,
|
||||
nsHTTPChannel* i_Channel,
|
||||
nsIEventSinkGetter* i_ESG,
|
||||
nsIChannel** o_pTrans);
|
||||
|
||||
/*
|
||||
Remove this transport from the list.
|
||||
*/
|
||||
|
|
|
@ -777,6 +777,8 @@ nsresult nsHTTPResponseListener::ProcessStatusCode(void)
|
|||
PR_LOG(gHTTPLog, PR_LOG_ALWAYS,
|
||||
("ProcessStatusCode [this=%x].\tStatus - Successful: %d.\n",
|
||||
this, statusCode));
|
||||
// If channel's AuthTriedWithPrehost then enter this user/pass and
|
||||
// authstring into the auth list.
|
||||
break;
|
||||
|
||||
//
|
||||
|
|
|
@ -238,7 +238,7 @@ main(int argc, char* argv[])
|
|||
|
||||
// Create the socket transport...
|
||||
nsIChannel* transport;
|
||||
rv = sts->CreateTransport(hostName, port, &transport);
|
||||
rv = sts->CreateTransport(hostName, port, nsnull, &transport);
|
||||
|
||||
// This stuff is used to test the output stream
|
||||
#if 0
|
||||
|
|
|
@ -157,7 +157,7 @@ main(int argc, char* argv[])
|
|||
|
||||
nsIChannel* transport;
|
||||
|
||||
rv = sts->CreateTransport(hostName, port, &transport);
|
||||
rv = sts->CreateTransport(hostName, port, nsnull, &transport);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
transport->AsyncRead(0, -1, nsnull, new InputTestConsumer);
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort,
|
|||
// Create a socket transport...
|
||||
NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = sts->CreateTransport(aHostName, aPort, &mTransport);
|
||||
rv = sts->CreateTransport(aHostName, aPort, nsnull, &mTransport);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -87,10 +87,9 @@ class ScriptFile {
|
|||
boolean outDirty = false;
|
||||
if (file != null)
|
||||
{
|
||||
DataInputStream in =
|
||||
new DataInputStream(
|
||||
new BufferedInputStream(
|
||||
new FileInputStream(file)));
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file)));
|
||||
|
||||
String s = new String();
|
||||
while((s = in.readLine())!= null)
|
||||
|
@ -163,10 +162,9 @@ class ScriptFile {
|
|||
}
|
||||
|
||||
protected void WriteOutFile(String filename) throws IOException {
|
||||
DataInputStream incl =
|
||||
new DataInputStream(
|
||||
new BufferedInputStream(
|
||||
new FileInputStream(filename)));
|
||||
BufferedReader incl = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(filename)));
|
||||
// This doesn't have to be line wise... change later TODO
|
||||
String s;
|
||||
while ((s = incl.readLine()) != null)
|
||||
|
|
|
@ -87,10 +87,9 @@ class ScriptFile {
|
|||
boolean outDirty = false;
|
||||
if (file != null)
|
||||
{
|
||||
DataInputStream in =
|
||||
new DataInputStream(
|
||||
new BufferedInputStream(
|
||||
new FileInputStream(file)));
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file)));
|
||||
|
||||
String s = new String();
|
||||
while((s = in.readLine())!= null)
|
||||
|
@ -163,10 +162,9 @@ class ScriptFile {
|
|||
}
|
||||
|
||||
protected void WriteOutFile(String filename) throws IOException {
|
||||
DataInputStream incl =
|
||||
new DataInputStream(
|
||||
new BufferedInputStream(
|
||||
new FileInputStream(filename)));
|
||||
BufferedReader incl = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(filename)));
|
||||
// This doesn't have to be line wise... change later TODO
|
||||
String s;
|
||||
while ((s = incl.readLine()) != null)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
@ -149,6 +150,7 @@ class nsWebShell : public nsIWebShell,
|
|||
public nsILinkHandler,
|
||||
public nsIScriptContextOwner,
|
||||
public nsIDocumentLoaderObserver,
|
||||
public nsIProgressEventSink, // should go away (nsIDocLoaderObs)
|
||||
public nsIPrompt,
|
||||
public nsIRefreshURI,
|
||||
public nsIClipboardCommands
|
||||
|
@ -349,6 +351,9 @@ public:
|
|||
// nsIPrompt
|
||||
NS_DECL_NSIPROMPT
|
||||
|
||||
// nsIProgressEventSink
|
||||
NS_DECL_NSIPROGRESSEVENTSINK
|
||||
|
||||
// nsIClipboardCommands
|
||||
NS_IMETHOD CanCutSelection (PRBool* aResult);
|
||||
NS_IMETHOD CanCopySelection (PRBool* aResult);
|
||||
|
@ -518,12 +523,12 @@ static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
|||
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
|
||||
|
||||
|
||||
// IID's
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID,
|
||||
NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverIID,
|
||||
NS_IDOCUMENT_LOADER_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIProgressEventSinkIID, NS_IPROGRESSEVENTSINK_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
@ -786,6 +791,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIProgressEventSinkIID)) {
|
||||
*aInstancePtr = (void*)(nsIProgressEventSink*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIWebShellContainerIID)) {
|
||||
*aInstancePtr = (void*)(nsIWebShellContainer*)this;
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -1959,6 +1969,7 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
if (!aUri)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// This should probably get saved in mHistoryService or something...
|
||||
// Ugh. It sucks that we have to hack webshell like this. Forgive me, Father.
|
||||
do {
|
||||
nsresult rv;
|
||||
|
@ -2051,9 +2062,6 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
mProcessedEndDocumentLoad = PR_FALSE;
|
||||
|
||||
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -2134,7 +2142,6 @@ nsWebShell::LoadURI(nsIURI * aUri,
|
|||
rv = aUri->GetSpec(getter_Copies(spec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
nsString* url = new nsString(uriSpec);
|
||||
if (aModifyHistory) {
|
||||
// Discard part of history that is no longer reachable
|
||||
|
@ -2186,6 +2193,12 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
/*
|
||||
TODO This doesnt belong here... The app should be doing all this
|
||||
URL play. The webshell should not have a clue about whats "mailto"
|
||||
If you insist that this should be here, then put in URL parsing
|
||||
optimizations here. -Gagan
|
||||
*/
|
||||
nsAutoString urlStr(aURLSpec);
|
||||
// first things first. try to create a uri out of the string.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -2447,6 +2460,7 @@ nsWebShell::CanForward(void)
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::GoTo(PRInt32 aHistoryIndex)
|
||||
{
|
||||
#ifdef OLD_HISTORY
|
||||
nsresult rv = NS_ERROR_ILLEGAL_VALUE;
|
||||
if ((aHistoryIndex >= 0) &&
|
||||
(aHistoryIndex < mHistory.Count())) {
|
||||
|
@ -2478,6 +2492,13 @@ nsWebShell::GoTo(PRInt32 aHistoryIndex)
|
|||
nsnull); // referrer
|
||||
}
|
||||
return rv;
|
||||
#else
|
||||
if (mSHist)
|
||||
return mSHist->Goto(aHistoryIndex, this, PR_FALSE);
|
||||
return NS_OK;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -3274,7 +3295,7 @@ nsWebShell::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
|||
dlObserver = do_QueryInterface(mDocLoaderObserver); // we need this to addref
|
||||
}
|
||||
/*
|
||||
*Fire the OnStartDocumentLoad of the webshell observer
|
||||
* Fire the OnStartDocumentLoad of the webshell observer
|
||||
*/
|
||||
if ((nsnull != mContainer) && (nsnull != dlObserver))
|
||||
{
|
||||
|
@ -3515,7 +3536,7 @@ nsWebShell::OnEndURLLoad(nsIDocumentLoader* loader,
|
|||
printf("nsWebShell::OnEndURLLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus);
|
||||
#endif
|
||||
/*
|
||||
*Fire the OnStartDocumentLoad of the webshell observer
|
||||
*Fire the OnEndDocumentLoad of the webshell observer
|
||||
*/
|
||||
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
||||
{
|
||||
|
@ -3713,8 +3734,6 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4066,6 +4085,57 @@ nsWebShell::FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSe
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Methods from nsIProgressEventSink
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::OnProgress(nsIChannel* channel, nsISupports* ctxt,
|
||||
PRUint32 aProgress,
|
||||
PRUint32 aProgressMax)
|
||||
{
|
||||
if (nsnull != mDocLoaderObserver)
|
||||
{
|
||||
return mDocLoaderObserver->OnProgressURLLoad(
|
||||
mDocLoader,
|
||||
channel,
|
||||
aProgress,
|
||||
aProgressMax);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebShell::OnStatus(nsIChannel* channel, nsISupports* ctxt,
|
||||
const PRUnichar* aMsg)
|
||||
{
|
||||
if (nsnull != mDocLoaderObserver)
|
||||
{
|
||||
nsAutoString temp(aMsg);
|
||||
#ifdef DEBUG_gagan
|
||||
|
||||
#ifdef XP_UNIX
|
||||
printf("\033[33m"); // Start yellow
|
||||
#endif
|
||||
|
||||
char* tmp = temp.ToNewCString();
|
||||
printf("%s\n",tmp);
|
||||
CRTFREEIF(tmp);
|
||||
#ifdef XP_UNIX
|
||||
printf("\033[0m"); // End colors
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_gagan
|
||||
nsresult rv = mDocLoaderObserver->OnStatusURLLoad(
|
||||
mDocLoader,
|
||||
channel,
|
||||
temp);
|
||||
|
||||
#ifndef BUG_16273_FIXED
|
||||
//free the message-
|
||||
CRTFREEIF((PRUnichar*)aMsg);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsWebShell::GetViewManager(nsIViewManager* *viewManager)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче