add enumerated type for uri load command. This will allow us

// to distinguish between incoming urls that are a result of user
						// clicks vs. normal views, view source and requires new window
nsIURIContentListener.idl--> doContent and canHandleContent now take a nsIURILoadCommand enum
nsURILoader.cpp --> changes to account for load command enum.
AsyncRead pass in the window context as the url context
(waterson will need this for his chrome cache work)
if we can't find a content handler for the content then go
back to the original window that loaded the url and force
them to handle the content...this is a HACK to force us to run
through the old code path for handling unknown content types
until the new version is online.
r=travis
This commit is contained in:
mscott%netscape.com 1999-12-02 06:59:39 +00:00
Родитель df62407466
Коммит 6a9f99b938
3 изменённых файлов: 54 добавлений и 12 удалений

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

@ -28,6 +28,7 @@
*/
#include "nsISupports.idl"
#include "nsIURILoader.idl"
interface nsIProtocolHandler;
interface nsIChannel;
@ -64,7 +65,8 @@ interface nsIURIContentListener : nsISupports
this parameter.
*/
void doContent(in string aContentType, in string aCommand,
void doContent(in string aContentType,
in nsURILoadCommand aCommand,
in string aWindowTarget,
in nsIChannel aOpenedChannel,
out nsIStreamListener aContentHandler,
@ -74,6 +76,8 @@ interface nsIURIContentListener : nsISupports
aDesiredContentType --> yes, we can accept aContentType but we would
like it converted to aDesiredContentType. This argument can be null if
you want the content directly as aContentType */
boolean canHandleContent(in string aContentType, in string aCommand,
in string aWindowTarget, out string aDesiredContentType);
boolean canHandleContent(in string aContentType,
in nsURILoadCommand aCommand,
in string aWindowTarget,
out string aDesiredContentType);
};

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

@ -49,6 +49,8 @@ interface nsIChannel;
interface nsIStreamListener;
interface nsIInputStream;
typedef long nsURILoadCommand;
[scriptable, uuid(40AECB53-8B65-11d3-989D-001083010E9B)]
interface nsIURILoader : nsISupports
{
@ -64,6 +66,9 @@ interface nsIURILoader : nsISupports
/* OpenURI requires the following parameters.....
aURI --> the uri you wish to open
aCommand --> describes the context of the url. most often, you want to pass viewNormal here.
but if it the action was from a user click or you want to view source, or you want
a new window, these are all passed in via aCommand.
aWindowTarget -> the name of the desired target window (can be null)
aWindowContext --> if you are running the url from a doc shell or a web shell,
this is your window context. If you have a content listener
@ -81,6 +86,7 @@ interface nsIURILoader : nsISupports
*/
void openURI(in nsIURI aURI,
in nsURILoadCommand aCommand,
in string aWindowTarget,
in nsISupports aWindowContext,
in nsIURI aReferringURI,
@ -92,6 +98,7 @@ interface nsIURILoader : nsISupports
adapterBinding -> the local IP address to bind to*/
void openURIVia(in nsIURI aURI,
in nsURILoadCommand aCommand,
in string aWindowTarget,
in nsISupports aWindowContext,
in nsIURI aReferringURI,
@ -99,10 +106,17 @@ interface nsIURILoader : nsISupports
out nsISupports aCurrentOpenContext,
in unsigned long adapterBinding);
/* these are nsURILoadCommand */
const long viewNormal = 0;
const long viewSource = 1;
const long viewUserClick = 2;
const long viewNewWindow = 3;
/* mscott -> I'm going to move this out into a separate private interface
*/
void dispatchContent(in string aContentType,
in string aCommand,
in nsURILoadCommand aCommand,
in string aWindowTarget,
in nsIChannel aChannel,
in nsISupports aCtxt,
@ -120,6 +134,7 @@ interface nsIURILoader : nsISupports
interface nsPIURILoaderWithPostData : nsISupports
{
void openURIWithPostData(in nsIURI aURI,
in nsURILoadCommand aCommand,
in string aWindowTarget,
in nsISupports aWindowContext,
in nsIURI aReferringURI,
@ -132,6 +147,7 @@ interface nsPIURILoaderWithPostData : nsISupports
adapterBinding -> the local IP address to bind to*/
void openURIWithPostDataVia(in nsIURI aURI,
in nsURILoadCommand aCommand,
in string aWindowTarget,
in nsISupports aWindowContext,
in nsIURI aReferringURI,

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

@ -60,6 +60,7 @@ public:
NS_DECL_ISUPPORTS
nsresult Open(nsIURI *aURL,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsISupports * aWindowContext,
nsIURI * aReferringURI,
@ -83,6 +84,7 @@ protected:
protected:
nsCOMPtr<nsIURIContentListener> m_contentListener;
nsCOMPtr<nsIStreamListener> m_targetStreamListener;
nsURILoadCommand mCommand;
nsCString m_windowTarget;
};
@ -90,6 +92,7 @@ NS_IMPL_ADDREF(nsDocumentOpenInfo);
NS_IMPL_RELEASE(nsDocumentOpenInfo);
NS_INTERFACE_MAP_BEGIN(nsDocumentOpenInfo)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamObserver)
NS_INTERFACE_MAP_ENTRY(nsIStreamObserver)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_END
@ -112,6 +115,7 @@ nsresult nsDocumentOpenInfo::Init(nsISupports * aWindowContext)
}
nsresult nsDocumentOpenInfo::Open(nsIURI *aURI,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsISupports * aWindowContext,
nsIURI * aReferringURI,
@ -128,6 +132,7 @@ nsresult nsDocumentOpenInfo::Open(nsIURI *aURI,
// store any local state
m_windowTarget = aWindowTarget;
mCommand = aCommand;
// get the requestor for the window context...
nsCOMPtr<nsIInterfaceRequestor> requestor = do_QueryInterface(aWindowContext);
@ -228,7 +233,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports
{
nsCOMPtr<nsIURIContentListener> aContentListener;
nsXPIDLCString aDesiredContentType;
rv = pURILoader->DispatchContent(aContentType, "view", m_windowTarget,
rv = pURILoader->DispatchContent(aContentType, mCommand, m_windowTarget,
aChannel, aCtxt,
m_contentListener,
getter_Copies(aDesiredContentType),
@ -243,7 +248,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIChannel * aChannel, nsISupports
else
contentTypeToUse = aContentType;
rv = aContentListener->DoContent(contentTypeToUse, "view", m_windowTarget,
rv = aContentListener->DoContent(contentTypeToUse, mCommand, m_windowTarget,
aChannel, getter_AddRefs(aContentStreamListener),
&aAbortProcess);
@ -305,6 +310,7 @@ NS_IMPL_ADDREF(nsURILoader);
NS_IMPL_RELEASE(nsURILoader);
NS_INTERFACE_MAP_BEGIN(nsURILoader)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURILoader)
NS_INTERFACE_MAP_ENTRY(nsIURILoader)
NS_INTERFACE_MAP_ENTRY(nsPIURILoaderWithPostData)
NS_INTERFACE_MAP_END
@ -329,17 +335,19 @@ NS_IMETHODIMP nsURILoader::UnRegisterContentListener(nsIURIContentListener * aCo
}
NS_IMETHODIMP nsURILoader::OpenURI(nsIURI *aURI,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsISupports * aWindowContext,
nsIURI *aReferringURI,
nsISupports *aOpenContext,
nsISupports **aCurrentOpenContext)
{
return OpenURIVia(aURI, aWindowTarget, aWindowContext, aReferringURI, aOpenContext,
return OpenURIVia(aURI, aCommand, aWindowTarget, aWindowContext, aReferringURI, aOpenContext,
aCurrentOpenContext, 0 /* ip address */);
}
NS_IMETHODIMP nsURILoader::OpenURIVia(nsIURI *aURI,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsISupports * aWindowContext,
nsIURI *aReferringURI,
@ -348,11 +356,12 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIURI *aURI,
PRUint32 aLocalIP)
{
// forward our call
return OpenURIWithPostDataVia(aURI, aWindowTarget, aWindowContext, aReferringURI, nsnull /* post stream */,
return OpenURIWithPostDataVia(aURI, aCommand, aWindowTarget, aWindowContext, aReferringURI, nsnull /* post stream */,
aOpenContext,aCurrentOpenContext, aLocalIP);
}
NS_IMETHODIMP nsURILoader::OpenURIWithPostData(nsIURI *aURI,
nsURILoadCommand aCommand,
const char *aWindowTarget,
nsISupports * aWindowContext,
nsIURI *aReferringURI,
@ -360,12 +369,13 @@ NS_IMETHODIMP nsURILoader::OpenURIWithPostData(nsIURI *aURI,
nsISupports *aOpenContext,
nsISupports **aCurrentOpenContext)
{
return OpenURIWithPostDataVia(aURI, aWindowTarget, aWindowContext, aReferringURI,
return OpenURIWithPostDataVia(aURI, aCommand, aWindowTarget, aWindowContext, aReferringURI,
aPostDataStream, aOpenContext, aCurrentOpenContext, 0);
}
NS_IMETHODIMP nsURILoader::OpenURIWithPostDataVia(nsIURI *aURI,
nsURILoadCommand aCommand,
const char *aWindowTarget,
nsISupports * aWindowContext,
nsIURI *aReferringURI,
@ -389,7 +399,7 @@ NS_IMETHODIMP nsURILoader::OpenURIWithPostDataVia(nsIURI *aURI,
loader->Init(aWindowContext); // Extra Info
// now instruct the loader to go ahead and open the url
rv = loader->Open(aURI, aWindowTarget, aWindowContext,
rv = loader->Open(aURI, aCommand, aWindowTarget, aWindowContext,
aReferringURI, aPostDataStream, aOpenContext, aCurrentOpenContext);
NS_RELEASE(loader);
@ -398,7 +408,7 @@ NS_IMETHODIMP nsURILoader::OpenURIWithPostDataVia(nsIURI *aURI,
nsresult nsURILoader::DispatchContent(const char * aContentType,
const char * aCommand,
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsIChannel * aChannel,
nsISupports * aCtxt,
@ -456,7 +466,19 @@ nsresult nsURILoader::DispatchContent(const char * aContentType,
nsCOMPtr<nsIContentHandler> aContentHandler;
rv = nsComponentManager::CreateInstance(handlerProgID, nsnull, NS_GET_IID(nsIContentHandler), getter_AddRefs(aContentHandler));
if (NS_SUCCEEDED(rv)) // we did indeed have a content handler for this type!! yippee...
rv = aContentHandler->HandleContent(aContentType, aCommand, aWindowTarget, aChannel);
rv = aContentHandler->HandleContent(aContentType, "view", aWindowTarget, aChannel);
else if (aContentListener)
{
// BIG TIME HACK ALERT!!!!! WE NEED THIS HACK IN PLACE UNTIL OUR NEW UNKNOWN CONTENT
// HANDLER COMES ONLINE!!!
// Until that day, if we couldn't find a handler for the content type, then go back to the listener who
// originated the url request and force them to handle the content....this forces us through the old code
// path for unknown content types which brings up the file save as dialog...
*aContentListenerToUse = aContentListener;
NS_IF_ADDREF(*aContentListenerToUse);
rv = NS_OK;
}
return rv;
}