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:
gagan%netscape.com 1999-10-13 10:24:12 +00:00
Родитель be3ea9dd42
Коммит 7f425f1145
21 изменённых файлов: 465 добавлений и 99 удалений

Просмотреть файл

@ -32,6 +32,7 @@
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIScriptContextOwner.h" #include "nsIScriptContextOwner.h"
#include "nsIDocumentLoaderObserver.h" #include "nsIDocumentLoaderObserver.h"
#include "nsIProgressEventSink.h"
#include "nsDOMEvent.h" #include "nsDOMEvent.h"
#include "nsIPresContext.h" #include "nsIPresContext.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
@ -149,6 +150,7 @@ class nsWebShell : public nsIWebShell,
public nsILinkHandler, public nsILinkHandler,
public nsIScriptContextOwner, public nsIScriptContextOwner,
public nsIDocumentLoaderObserver, public nsIDocumentLoaderObserver,
public nsIProgressEventSink, // should go away (nsIDocLoaderObs)
public nsIPrompt, public nsIPrompt,
public nsIRefreshURI, public nsIRefreshURI,
public nsIClipboardCommands public nsIClipboardCommands
@ -349,6 +351,9 @@ public:
// nsIPrompt // nsIPrompt
NS_DECL_NSIPROMPT NS_DECL_NSIPROMPT
// nsIProgressEventSink
NS_DECL_NSIPROGRESSEVENTSINK
// nsIClipboardCommands // nsIClipboardCommands
NS_IMETHOD CanCutSelection (PRBool* aResult); NS_IMETHOD CanCutSelection (PRBool* aResult);
NS_IMETHOD CanCopySelection (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(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
// IID's // IID's
static NS_DEFINE_IID(kIContentViewerContainerIID, static NS_DEFINE_IID(kIContentViewerContainerIID,
NS_ICONTENT_VIEWER_CONTAINER_IID); NS_ICONTENT_VIEWER_CONTAINER_IID);
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, static NS_DEFINE_IID(kIDocumentLoaderObserverIID,
NS_IDOCUMENT_LOADER_OBSERVER_IID); 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(kIDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID); static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
@ -786,6 +791,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kIProgressEventSinkIID)) {
*aInstancePtr = (void*)(nsIProgressEventSink*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIWebShellContainerIID)) { if (aIID.Equals(kIWebShellContainerIID)) {
*aInstancePtr = (void*)(nsIWebShellContainer*)this; *aInstancePtr = (void*)(nsIWebShellContainer*)this;
NS_ADDREF_THIS(); NS_ADDREF_THIS();
@ -1959,6 +1969,7 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
if (!aUri) if (!aUri)
return NS_ERROR_NULL_POINTER; 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. // Ugh. It sucks that we have to hack webshell like this. Forgive me, Father.
do { do {
nsresult rv; nsresult rv;
@ -2051,9 +2062,6 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
mProcessedEndDocumentLoad = PR_FALSE; mProcessedEndDocumentLoad = PR_FALSE;
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this); rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this);
} }
return rv; return rv;
} }
@ -2121,7 +2129,7 @@ nsWebShell::LoadURI(nsIURI * aUri,
CancelRefreshURITimers(); CancelRefreshURITimers();
nsXPIDLCString scheme, CUriSpec; nsXPIDLCString scheme, CUriSpec;
if (!aUri) return NS_ERROR_NULL_POINTER; if (!aUri) return NS_ERROR_NULL_POINTER;
rv = aUri->GetScheme(getter_Copies(scheme)); rv = aUri->GetScheme(getter_Copies(scheme));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -2134,7 +2142,6 @@ nsWebShell::LoadURI(nsIURI * aUri,
rv = aUri->GetSpec(getter_Copies(spec)); rv = aUri->GetSpec(getter_Copies(spec));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsString* url = new nsString(uriSpec); nsString* url = new nsString(uriSpec);
if (aModifyHistory) { if (aModifyHistory) {
// Discard part of history that is no longer reachable // Discard part of history that is no longer reachable
@ -2186,6 +2193,12 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
{ {
nsresult rv; 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); nsAutoString urlStr(aURLSpec);
// first things first. try to create a uri out of the string. // first things first. try to create a uri out of the string.
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
@ -2447,6 +2460,7 @@ nsWebShell::CanForward(void)
NS_IMETHODIMP NS_IMETHODIMP
nsWebShell::GoTo(PRInt32 aHistoryIndex) nsWebShell::GoTo(PRInt32 aHistoryIndex)
{ {
#ifdef OLD_HISTORY
nsresult rv = NS_ERROR_ILLEGAL_VALUE; nsresult rv = NS_ERROR_ILLEGAL_VALUE;
if ((aHistoryIndex >= 0) && if ((aHistoryIndex >= 0) &&
(aHistoryIndex < mHistory.Count())) { (aHistoryIndex < mHistory.Count())) {
@ -2478,6 +2492,13 @@ nsWebShell::GoTo(PRInt32 aHistoryIndex)
nsnull); // referrer nsnull); // referrer
} }
return rv; 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 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)) 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); printf("nsWebShell::OnEndURLLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus);
#endif #endif
/* /*
*Fire the OnStartDocumentLoad of the webshell observer *Fire the OnEndDocumentLoad of the webshell observer
*/ */
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
{ {
@ -3713,8 +3734,6 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL)
return NS_OK; return NS_OK;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
NS_IMETHODIMP NS_IMETHODIMP
@ -4066,6 +4085,57 @@ nsWebShell::FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSe
return NS_ERROR_FAILURE; 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) nsresult nsWebShell::GetViewManager(nsIViewManager* *viewManager)
{ {

Просмотреть файл

@ -61,7 +61,7 @@ nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on
aURL->GetPort(&port); aURL->GetPort(&port);
aURL->GetHost(getter_Copies(hostName)); 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) if (NS_SUCCEEDED(rv) && m_channel)
{ {
m_socketIsOpen = PR_FALSE; m_socketIsOpen = PR_FALSE;

Просмотреть файл

@ -584,7 +584,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
aURL->GetHost(getter_Copies(hostName)); aURL->GetHost(getter_Copies(hostName));
ClearFlag(IMAP_CONNECTION_IS_OPEN); 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)) if (NS_SUCCEEDED(rv))
rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream)); rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream));

Просмотреть файл

@ -19,15 +19,26 @@
#include "nsISupports.idl" #include "nsISupports.idl"
interface nsIChannel; interface nsIChannel;
interface nsIEventSinkGetter;
[scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)] [scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)]
interface nsISocketTransportService : nsISupports 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, nsIChannel createTransport(in string host,
in long port); in long port,
in nsIEventSinkGetter eventSinkGetter);
nsIChannel createTransportOfType(in string socketType, nsIChannel createTransportOfType(in string socketType,
in string host, in string host,
in long port); in long port,
in nsIEventSinkGetter eventSinkGetter);
void shutdown(); void shutdown();
}; };

Просмотреть файл

@ -18,6 +18,7 @@
#include "nsISupports.idl" #include "nsISupports.idl"
interface nsIProgressEventSink;
interface nsIChannel; interface nsIChannel;
/** /**
@ -35,8 +36,9 @@ interface nsIStatusCodeEventSink : nsISupports
* Notify the EventSink with a status code for the URL load.<BR> * Notify the EventSink with a status code for the URL load.<BR>
* Use IOService to request converting that code to a string. * Use IOService to request converting that code to a string.
*/ */
void onStatus(in nsIChannel channel, void onStatus(in nsIProgressEventSink sink,
in nsISupports ctxt, in nsIChannel channel,
in unsigned long aCode); in nsISupports ctxt,
in unsigned long aCode);
}; };

Просмотреть файл

@ -40,10 +40,12 @@
#include "nsEscape.h" #include "nsEscape.h"
#include "nsIMIMEService.h" #include "nsIMIMEService.h"
#include "prlog.h" #include "prlog.h"
#include "nsProxyObjectManager.h"
static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID); static NS_DEFINE_CID(kMIMEServiceCID, NS_MIMESERVICE_CID);
static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID); static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
#if defined(PR_LOGGING) #if defined(PR_LOGGING)
// //
@ -294,8 +296,23 @@ nsFileTransport::Init(nsFileSpec& spec, const char* command, nsIEventSinkGetter*
return rv; return rv;
if (getter) { if (getter) {
nsCOMPtr<nsISupports> sink; nsCOMPtr<nsISupports> sink;
(void)getter->GetEventSink(command, nsIProgressEventSink::GetIID(), getter_AddRefs(sink)); (void)getter->GetEventSink(command,
mProgress = (nsIProgressEventSink*)sink.get(); 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; return NS_OK;
} }
@ -789,8 +806,8 @@ nsFileTransport::Process(void)
if (mProgress) { if (mProgress) {
nsresult rv = mProgress->OnProgress(this, mContext, nsresult rv = mProgress->OnProgress(this, mContext,
mTotalAmount - mTransferAmount, mTotalAmount - mTransferAmount,
mTotalAmount); mTotalAmount);
NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnProgress failure"); NS_ASSERTION(NS_SUCCEEDED(rv), "unexpected OnProgress failure");
} }
@ -826,7 +843,13 @@ nsFileTransport::Process(void)
// XXX fix up this message for i18n // XXX fix up this message for i18n
nsAutoString msg = "Read "; nsAutoString msg = "Read ";
msg += (const char*)mSpec; 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); (void)mProgress->OnStatus(this, mContext, msg.mUStr);
#endif
} }
mContext = null_nsCOMPtr(); mContext = null_nsCOMPtr();

Просмотреть файл

@ -432,5 +432,63 @@ nsIOService::NewInputStreamChannel(nsIURI* uri, const char *contentType,
*result = channel; *result = channel;
return NS_OK; 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 "nsISocketProvider.h"
#include "nsISocketProviderService.h" #include "nsISocketProviderService.h"
#include "nsStdURL.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(kSocketProviderService, NS_SOCKETPROVIDERSERVICE_CID);
static NS_DEFINE_CID(kDNSService, NS_DNSSERVICE_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 // This is the State table which maps current state to next state
// for each socket operation... // for each socket operation...
@ -205,13 +208,8 @@ nsSocketTransport::~nsSocketTransport()
NS_IF_RELEASE(mService); NS_IF_RELEASE(mService);
if (mHostName) { CRTFREEIF(mHostName);
nsCRT::free(mHostName); CRTFREEIF(mSocketType);
}
if (mSocketType) {
nsCRT::free(mSocketType);
}
if (mSocketFD) { if (mSocketFD) {
PR_Close(mSocketFD); PR_Close(mSocketFD);
@ -222,13 +220,15 @@ nsSocketTransport::~nsSocketTransport()
PR_DestroyLock(mLock); PR_DestroyLock(mLock);
mLock = nsnull; mLock = nsnull;
} }
} }
nsresult nsSocketTransport::Init(nsSocketTransportService* aService, nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
const char* aHost, const char* aHost,
PRInt32 aPort, PRInt32 aPort,
const char* aSocketType) const char* aSocketType,
nsIEventSinkGetter* eventSinkGetter)
{ {
nsresult rv = NS_OK; 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. // Create the lock used for synchronizing access to the transport instance.
// //
@ -465,6 +490,8 @@ nsresult nsSocketTransport::Process(PRInt16 aSelectFlags)
mStatus = NS_ERROR_FAILURE; mStatus = NS_ERROR_FAILURE;
break; break;
} }
fireStatus(mCurrentState);
// //
// If the current state has successfully completed, then move to the // If the current state has successfully completed, then move to the
// next state for the current operation... // 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 "nsIStreamListener.h"
#include "nsIDNSListener.h" #include "nsIDNSListener.h"
#include "nsIPipe.h" #include "nsIPipe.h"
#include "nsIProgressEventSink.h"
#define NS_SOCKET_TRANSPORT_SEGMENT_SIZE (2*1024) #define NS_SOCKET_TRANSPORT_SEGMENT_SIZE (2*1024)
#define NS_SOCKET_TRANSPORT_BUFFER_SIZE (8*1024) #define NS_SOCKET_TRANSPORT_BUFFER_SIZE (8*1024)
@ -107,6 +108,7 @@ enum nsSocketReadWriteInfo {
// Forward declarations... // Forward declarations...
class nsSocketTransportService; class nsSocketTransportService;
class nsIEventSinkGetter;
class nsSocketTransport : public nsIChannel, class nsSocketTransport : public nsIChannel,
public nsIDNSListener, public nsIDNSListener,
@ -130,7 +132,8 @@ public:
nsresult Init(nsSocketTransportService* aService, nsresult Init(nsSocketTransportService* aService,
const char* aHost, const char* aHost,
PRInt32 aPort, PRInt32 aPort,
const char* aSocketType); const char* aSocketType,
nsIEventSinkGetter* eventSinkGetter);
nsresult Process(PRInt16 aSelectFlags); nsresult Process(PRInt16 aSelectFlags);
nsresult CloseConnection(void); nsresult CloseConnection(void);
@ -151,6 +154,9 @@ protected:
nsresult doWriteFromBuffer(PRUint32 *aCount); nsresult doWriteFromBuffer(PRUint32 *aCount);
nsresult doWriteFromStream(PRUint32 *aCount); nsresult doWriteFromStream(PRUint32 *aCount);
nsresult fireStatus(PRUint32 aCode);
nsresult GetSocketErrorString(PRUint32 iCode, PRUnichar** oString) const;
private: private:
// Access methods for manipulating the ReadWriteInfo... // Access methods for manipulating the ReadWriteInfo...
inline void SetReadType(nsSocketReadWriteInfo aType) { inline void SetReadType(nsSocketReadWriteInfo aType) {
@ -177,6 +183,8 @@ private:
} }
protected: protected:
PRCList mListLink; PRCList mListLink;
PRLock* mLock; PRLock* mLock;
@ -217,6 +225,8 @@ protected:
nsCOMPtr<nsIRequest> mDNSRequest; nsCOMPtr<nsIRequest> mDNSRequest;
nsresult mStatus; nsresult mStatus;
nsCOMPtr<nsISupports> mOwner; nsCOMPtr<nsISupports> mOwner;
// For tracking connection progress and status
nsCOMPtr<nsIProgressEventSink> mEventSink;
}; };

Просмотреть файл

@ -158,7 +158,6 @@ nsresult nsSocketTransportService::Init(void)
mThreadRunning = PR_TRUE; mThreadRunning = PR_TRUE;
rv = NS_NewThread(&mThread, this, 0, PR_JOINABLE_THREAD); rv = NS_NewThread(&mThread, this, 0, PR_JOINABLE_THREAD);
} }
return rv; return rv;
} }
@ -483,16 +482,18 @@ nsSocketTransportService::Run(void)
NS_IMETHODIMP NS_IMETHODIMP
nsSocketTransportService::CreateTransport(const char* aHost, nsSocketTransportService::CreateTransport(const char* aHost,
PRInt32 aPort, PRInt32 aPort,
nsIEventSinkGetter* eventSinkGetter,
nsIChannel** aResult) nsIChannel** aResult)
{ {
return CreateTransportOfType(nsnull, aHost, aPort, aResult); return CreateTransportOfType(nsnull, aHost, aPort, eventSinkGetter, aResult);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsSocketTransportService::CreateTransportOfType(const char* aSocketType, nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
const char* aHost, const char* aHost,
PRInt32 aPort, PRInt32 aPort,
nsIChannel** aResult) nsIEventSinkGetter* eventSinkGetter,
nsIChannel** aResult)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsSocketTransport* transport = nsnull; nsSocketTransport* transport = nsnull;
@ -506,7 +507,7 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
// Create and initialize a new connection object... // Create and initialize a new connection object...
NS_NEWXPCOM(transport, nsSocketTransport); NS_NEWXPCOM(transport, nsSocketTransport);
if (transport) { if (transport) {
rv = transport->Init(this, aHost, aPort, aSocketType); rv = transport->Init(this, aHost, aPort, aSocketType, eventSinkGetter);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
delete transport; delete transport;
transport = nsnull; transport = nsnull;
@ -525,7 +526,6 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
return rv; return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsSocketTransportService::Shutdown(void) nsSocketTransportService::Shutdown(void)
{ {

Просмотреть файл

@ -1589,7 +1589,7 @@ nsFtpConnectionThread::R_pasv() {
host.Append(h3); host.Append(h3);
// now we know where to connect our data channel // 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 (NS_FAILED(rv)) return FTP_ERROR;
if (mAction == GET) { if (mAction == GET) {
@ -1763,7 +1763,7 @@ nsFtpConnectionThread::Run() {
mList = conn->mList; mList = conn->mList;
} else { } else {
// build our own // 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); nsAllocator::Free(host);
if (NS_FAILED(rv)) return rv; 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) { if (NS_ERROR_BUSY == rv) {
mState = HS_WAITING_FOR_OPEN; mState = HS_WAITING_FOR_OPEN;
return NS_OK; return NS_OK;
@ -861,12 +865,12 @@ nsHTTPChannel::Authenticate(const char *iChallenge, nsIChannel **oChannel)
{ {
nsXPIDLCString prehost; nsXPIDLCString prehost;
if (NS_SUCCEEDED(rv = mURI->GetPreHost(getter_Copies(prehost)))) if (NS_SUCCEEDED(rv = mURI->GetPreHost(getter_Copies(prehost))))
{ {
if (!(newUserPass = nsCRT::strdup(prehost))) if (!(newUserPass = nsCRT::strdup(prehost)))
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
} }
// Couldnt get one from prehost or has already been tried so...ask // Couldnt get one from prehost or has already been tried so...ask
if (!newUserPass || (0==PL_strlen(newUserPass))) if (!newUserPass || (0==PL_strlen(newUserPass)))
@ -875,32 +879,33 @@ nsHTTPChannel::Authenticate(const char *iChallenge, nsIChannel **oChannel)
Throw a modal dialog box asking for Throw a modal dialog box asking for
username, password. Prefill (!?!) username, password. Prefill (!?!)
*/ */
/* /*
Currently this is being thrown from here itself. Currently this is being thrown from here itself.
The correct way to do this is to push this on the The correct way to do this is to push this on the
HTTPEventSink and let that notify the window that HTTPEventSink and let that notify the window that
triggered this load to throw the userpass dialog triggered this load to throw the userpass dialog
*/ */
NS_WITH_PROXIED_SERVICE(nsIPrompt, authdialog, kNetSupportDialogCID, nsnull, &rv); NS_WITH_PROXIED_SERVICE(nsIPrompt, authdialog, kNetSupportDialogCID, nsnull, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
PRUnichar *user, *passwd; PRUnichar *user, *passwd;
PRBool retval; PRBool retval;
nsAutoString message = "Enter username for "; //TODO localize it! nsAutoString message = "Enter username for "; //TODO localize it!
message += iChallenge; // later on change to only show realm and then host's info. message += iChallenge; // later on change to only show realm and then host's info.
PRUnichar* msg = message.ToNewUnicode(); PRUnichar* msg = message.ToNewUnicode();
rv = authdialog->PromptUsernameAndPassword( rv = authdialog->PromptUsernameAndPassword(
msg, &user, &passwd, &retval); msg, &user, &passwd, &retval);
CRTFREEIF(msg); CRTFREEIF(msg);
if (retval) if (retval)
{ {
nsAutoString temp(user); nsAutoString temp(user);
temp += ':'; temp += ':';
temp += passwd; temp += passwd;
CRTFREEIF(newUserPass); CRTFREEIF(newUserPass);
newUserPass = temp.ToNewCString(); newUserPass = temp.ToNewCString();
} }
} }
// Construct the auth string request header based on info provided. // Construct the auth string request header based on info provided.
nsXPIDLCString authString; nsXPIDLCString authString;

Просмотреть файл

@ -359,8 +359,9 @@ nsHTTPHandler::NewPostDataStream(PRBool isFile, const char *data, PRUint32 encod
nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
nsHTTPChannel* i_Channel, nsHTTPChannel* i_Channel,
nsIChannel** o_pTrans) nsIEventSinkGetter* i_ESG,
nsIChannel** o_pTrans)
{ {
nsresult rv; nsresult rv;
PRUint32 count; PRUint32 count;
@ -413,18 +414,19 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
GetDefaultPort(&port); GetDefaultPort(&port);
} }
rv = sts->CreateTransport(host, port, &trans); rv = sts->CreateTransport(host, port, i_ESG, &trans);
i_Channel->SetUsingProxy(PR_FALSE); i_Channel->SetUsingProxy(PR_FALSE);
} }
else else
{ {
rv = sts->CreateTransport(mProxy, mProxyPort, &trans); rv = sts->CreateTransport(mProxy, mProxyPort, i_ESG, &trans);
i_Channel->SetUsingProxy(PR_TRUE); i_Channel->SetUsingProxy(PR_TRUE);
} }
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
// Put it in the table... // 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; if (NS_FAILED(rv)) return rv;
*o_pTrans = trans; *o_pTrans = trans;

Просмотреть файл

@ -77,8 +77,9 @@ public:
return NS_OK; return NS_OK;
}; };
NS_IMETHOD MakeAbsolute(const char *aRelativeSpec, nsIURI *aBaseURI, NS_IMETHOD MakeAbsolute(const char *aRelativeSpec,
char **_retval); nsIURI *aBaseURI,
char **_retval);
NS_IMETHOD NewChannel(const char* verb, nsIURI* url, NS_IMETHOD NewChannel(const char* verb, nsIURI* url,
nsILoadGroup *aGroup, nsILoadGroup *aGroup,
@ -90,7 +91,7 @@ public:
//Functions from nsIProxy //Functions from nsIProxy
/* /*
Get and Set the Proxy Host Get and Set the Proxy Host
*/ */
NS_IMETHOD GetProxyHost(const char* *o_ProxyHost) const; NS_IMETHOD GetProxyHost(const char* *o_ProxyHost) const;
@ -110,7 +111,10 @@ public:
return NS_OK; 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); NS_IMETHOD FollowRedirects(PRBool bFollow=PR_TRUE);
// Singleton function // Singleton function
@ -119,13 +123,15 @@ public:
// Functions from nsIHTTPProtocolHandler // Functions from nsIHTTPProtocolHandler
NS_DECL_NSIHTTPPROTOCOLHANDLER NS_DECL_NSIHTTPPROTOCOLHANDLER
/* /**
Pull out an existing transport from the list, or if none exists * Pull out an existing transport from the list, or if none exists
create one. * create one.
*/ */
virtual nsresult RequestTransport(nsIURI *i_Uri, virtual nsresult RequestTransport(nsIURI *i_Uri,
nsHTTPChannel* i_Channel, nsHTTPChannel* i_Channel,
nsIEventSinkGetter* i_ESG,
nsIChannel** o_pTrans); nsIChannel** o_pTrans);
/* /*
Remove this transport from the list. Remove this transport from the list.
*/ */

Просмотреть файл

@ -777,6 +777,8 @@ nsresult nsHTTPResponseListener::ProcessStatusCode(void)
PR_LOG(gHTTPLog, PR_LOG_ALWAYS, PR_LOG(gHTTPLog, PR_LOG_ALWAYS,
("ProcessStatusCode [this=%x].\tStatus - Successful: %d.\n", ("ProcessStatusCode [this=%x].\tStatus - Successful: %d.\n",
this, statusCode)); this, statusCode));
// If channel's AuthTriedWithPrehost then enter this user/pass and
// authstring into the auth list.
break; break;
// //

Просмотреть файл

@ -238,7 +238,7 @@ main(int argc, char* argv[])
// Create the socket transport... // Create the socket transport...
nsIChannel* 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 // This stuff is used to test the output stream
#if 0 #if 0

Просмотреть файл

@ -157,7 +157,7 @@ main(int argc, char* argv[])
nsIChannel* transport; nsIChannel* transport;
rv = sts->CreateTransport(hostName, port, &transport); rv = sts->CreateTransport(hostName, port, nsnull, &transport);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
transport->AsyncRead(0, -1, nsnull, new InputTestConsumer); transport->AsyncRead(0, -1, nsnull, new InputTestConsumer);

Просмотреть файл

@ -277,7 +277,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort,
// Create a socket transport... // Create a socket transport...
NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv); NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv);
if (NS_SUCCEEDED(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; boolean outDirty = false;
if (file != null) if (file != null)
{ {
DataInputStream in = BufferedReader in = new BufferedReader(
new DataInputStream( new InputStreamReader(
new BufferedInputStream( new FileInputStream(file)));
new FileInputStream(file)));
String s = new String(); String s = new String();
while((s = in.readLine())!= null) while((s = in.readLine())!= null)
@ -163,10 +162,9 @@ class ScriptFile {
} }
protected void WriteOutFile(String filename) throws IOException { protected void WriteOutFile(String filename) throws IOException {
DataInputStream incl = BufferedReader incl = new BufferedReader(
new DataInputStream( new InputStreamReader(
new BufferedInputStream( new FileInputStream(filename)));
new FileInputStream(filename)));
// This doesn't have to be line wise... change later TODO // This doesn't have to be line wise... change later TODO
String s; String s;
while ((s = incl.readLine()) != null) while ((s = incl.readLine()) != null)

Просмотреть файл

@ -87,10 +87,9 @@ class ScriptFile {
boolean outDirty = false; boolean outDirty = false;
if (file != null) if (file != null)
{ {
DataInputStream in = BufferedReader in = new BufferedReader(
new DataInputStream( new InputStreamReader(
new BufferedInputStream( new FileInputStream(file)));
new FileInputStream(file)));
String s = new String(); String s = new String();
while((s = in.readLine())!= null) while((s = in.readLine())!= null)
@ -163,10 +162,9 @@ class ScriptFile {
} }
protected void WriteOutFile(String filename) throws IOException { protected void WriteOutFile(String filename) throws IOException {
DataInputStream incl = BufferedReader incl = new BufferedReader(
new DataInputStream( new InputStreamReader(
new BufferedInputStream( new FileInputStream(filename)));
new FileInputStream(filename)));
// This doesn't have to be line wise... change later TODO // This doesn't have to be line wise... change later TODO
String s; String s;
while ((s = incl.readLine()) != null) while ((s = incl.readLine()) != null)

Просмотреть файл

@ -32,6 +32,7 @@
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIScriptContextOwner.h" #include "nsIScriptContextOwner.h"
#include "nsIDocumentLoaderObserver.h" #include "nsIDocumentLoaderObserver.h"
#include "nsIProgressEventSink.h"
#include "nsDOMEvent.h" #include "nsDOMEvent.h"
#include "nsIPresContext.h" #include "nsIPresContext.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"
@ -149,6 +150,7 @@ class nsWebShell : public nsIWebShell,
public nsILinkHandler, public nsILinkHandler,
public nsIScriptContextOwner, public nsIScriptContextOwner,
public nsIDocumentLoaderObserver, public nsIDocumentLoaderObserver,
public nsIProgressEventSink, // should go away (nsIDocLoaderObs)
public nsIPrompt, public nsIPrompt,
public nsIRefreshURI, public nsIRefreshURI,
public nsIClipboardCommands public nsIClipboardCommands
@ -349,6 +351,9 @@ public:
// nsIPrompt // nsIPrompt
NS_DECL_NSIPROMPT NS_DECL_NSIPROMPT
// nsIProgressEventSink
NS_DECL_NSIPROGRESSEVENTSINK
// nsIClipboardCommands // nsIClipboardCommands
NS_IMETHOD CanCutSelection (PRBool* aResult); NS_IMETHOD CanCutSelection (PRBool* aResult);
NS_IMETHOD CanCopySelection (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(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
// IID's // IID's
static NS_DEFINE_IID(kIContentViewerContainerIID, static NS_DEFINE_IID(kIContentViewerContainerIID,
NS_ICONTENT_VIEWER_CONTAINER_IID); NS_ICONTENT_VIEWER_CONTAINER_IID);
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, static NS_DEFINE_IID(kIDocumentLoaderObserverIID,
NS_IDOCUMENT_LOADER_OBSERVER_IID); 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(kIDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID); static NS_DEFINE_IID(kIDocumentLoaderIID, NS_IDOCUMENTLOADER_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
@ -786,6 +791,11 @@ nsWebShell::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kIProgressEventSinkIID)) {
*aInstancePtr = (void*)(nsIProgressEventSink*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIWebShellContainerIID)) { if (aIID.Equals(kIWebShellContainerIID)) {
*aInstancePtr = (void*)(nsIWebShellContainer*)this; *aInstancePtr = (void*)(nsIWebShellContainer*)this;
NS_ADDREF_THIS(); NS_ADDREF_THIS();
@ -1959,6 +1969,7 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
if (!aUri) if (!aUri)
return NS_ERROR_NULL_POINTER; 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. // Ugh. It sucks that we have to hack webshell like this. Forgive me, Father.
do { do {
nsresult rv; nsresult rv;
@ -2051,9 +2062,6 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
mProcessedEndDocumentLoad = PR_FALSE; mProcessedEndDocumentLoad = PR_FALSE;
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this); rv = OnEndDocumentLoad(mDocLoader, dummyChannel, 0, this);
} }
return rv; return rv;
} }
@ -2121,7 +2129,7 @@ nsWebShell::LoadURI(nsIURI * aUri,
CancelRefreshURITimers(); CancelRefreshURITimers();
nsXPIDLCString scheme, CUriSpec; nsXPIDLCString scheme, CUriSpec;
if (!aUri) return NS_ERROR_NULL_POINTER; if (!aUri) return NS_ERROR_NULL_POINTER;
rv = aUri->GetScheme(getter_Copies(scheme)); rv = aUri->GetScheme(getter_Copies(scheme));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -2134,7 +2142,6 @@ nsWebShell::LoadURI(nsIURI * aUri,
rv = aUri->GetSpec(getter_Copies(spec)); rv = aUri->GetSpec(getter_Copies(spec));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsString* url = new nsString(uriSpec); nsString* url = new nsString(uriSpec);
if (aModifyHistory) { if (aModifyHistory) {
// Discard part of history that is no longer reachable // Discard part of history that is no longer reachable
@ -2186,6 +2193,12 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
{ {
nsresult rv; 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); nsAutoString urlStr(aURLSpec);
// first things first. try to create a uri out of the string. // first things first. try to create a uri out of the string.
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
@ -2447,6 +2460,7 @@ nsWebShell::CanForward(void)
NS_IMETHODIMP NS_IMETHODIMP
nsWebShell::GoTo(PRInt32 aHistoryIndex) nsWebShell::GoTo(PRInt32 aHistoryIndex)
{ {
#ifdef OLD_HISTORY
nsresult rv = NS_ERROR_ILLEGAL_VALUE; nsresult rv = NS_ERROR_ILLEGAL_VALUE;
if ((aHistoryIndex >= 0) && if ((aHistoryIndex >= 0) &&
(aHistoryIndex < mHistory.Count())) { (aHistoryIndex < mHistory.Count())) {
@ -2478,6 +2492,13 @@ nsWebShell::GoTo(PRInt32 aHistoryIndex)
nsnull); // referrer nsnull); // referrer
} }
return rv; 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 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)) 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); printf("nsWebShell::OnEndURLLoad:%p: loader=%p url=%s status=%d\n", this, loader, spec, aStatus);
#endif #endif
/* /*
*Fire the OnStartDocumentLoad of the webshell observer *Fire the OnEndDocumentLoad of the webshell observer
*/ */
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver)) if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
{ {
@ -3713,8 +3734,6 @@ nsresult nsWebShell::CheckForTrailingSlash(nsIURI* aURL)
return NS_OK; return NS_OK;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
NS_IMETHODIMP NS_IMETHODIMP
@ -4066,6 +4085,57 @@ nsWebShell::FindNext(const PRUnichar * aSearchStr, PRBool aMatchCase, PRBool aSe
return NS_ERROR_FAILURE; 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) nsresult nsWebShell::GetViewManager(nsIViewManager* *viewManager)
{ {