more prepation for docshell landing. Implement IsPreferred and move implemtation of CanHandlecontent from the

application layer into the webshell/docshell layer.

r=travis


git-svn-id: svn://10.0.0.236/trunk@59760 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mscott%netscape.com 2000-02-04 08:45:34 +00:00
parent 8fadc39c51
commit c8948a35f6
4 changed files with 115 additions and 47 deletions

View File

@ -92,18 +92,78 @@ NS_IMETHODIMP nsDSURIContentListener::DoContent(const char* aContentType, nsURIL
return NS_OK;
}
NS_IMETHODIMP nsDSURIContentListener::CanHandleContent(const char* aContentType,
NS_IMETHODIMP nsDSURIContentListener::IsPreferred(const char* aContentType,
nsURILoadCommand aCommand, const char* aWindowTarget, char ** aDesiredContentType, PRBool* aCanHandle)
{
NS_ENSURE_ARG_POINTER(aCanHandle);
NS_ENSURE_ARG_POINTER(aDesiredContentType);
*aDesiredContentType = nsnull;
// the docshell has no idea if it is the preferred content provider or not.
// It needs to ask it's parent if it is the preferred content handler or not...
if(mParentContentListener)
return mParentContentListener->IsPreferred(aContentType, aCommand,
aWindowTarget, aDesiredContentType, aCanHandle);
else
*aCanHandle = PR_FALSE;
*aCanHandle = PR_TRUE; // Always say true and let DoContent decide.
return NS_OK;
}
NS_IMETHODIMP nsDSURIContentListener::CanHandleContent(const char* aContentType,
nsURILoadCommand aCommand, const char* aWindowTarget, char ** aDesiredContentType, PRBool* aCanHandleContent)
{
NS_ENSURE_ARG_POINTER(aCanHandleContent);
NS_ENSURE_ARG_POINTER(aDesiredContentType);
// this implementation should be the same for all webshell's so no need to pass it up the chain...
// although I suspect if aWindowTarget has a value, we will need to pass it up the chain in order to find
// the desired window target.
// a webshell can handle the following types. Eventually I think we want to get this information
// from the registry and in addition, we want to
// incoming Type Preferred type
// text/html
// text/xul
// text/rdf
// text/xml
// text/css
// image/gif
// image/jpeg
// image/png
// image/tiff
// application/http-index-format
// message/rfc822 text/xul
if (aContentType)
{
// (1) list all content types we want to be the primary handler for....
// and suggest a desired content type if appropriate...
if (nsCRT::strcasecmp(aContentType, "text/html") == 0
|| nsCRT::strcasecmp(aContentType, "text/xul") == 0
|| nsCRT::strcasecmp(aContentType, "text/rdf") == 0
|| nsCRT::strcasecmp(aContentType, "text/xml") == 0
|| nsCRT::strcasecmp(aContentType, "text/css") == 0
|| nsCRT::strcasecmp(aContentType, "image/gif") == 0
|| nsCRT::strcasecmp(aContentType, "image/jpeg") == 0
|| nsCRT::strcasecmp(aContentType, "image/png") == 0
|| nsCRT::strcasecmp(aContentType, "image/tiff") == 0
|| nsCRT::strcasecmp(aContentType, "application/http-index-format") == 0)
*aCanHandleContent = PR_TRUE;
if (nsCRT::strcasecmp(aContentType, "message/rfc822") == 0)
{
*aCanHandleContent = PR_TRUE;
*aDesiredContentType = nsCRT::strdup("text/html");
}
}
else
*aCanHandleContent = PR_FALSE;
// we may need to ask the plugin manager for this webshell if it can handle the content type too...
return NS_OK;
}
NS_IMETHODIMP
nsDSURIContentListener::GetParentContentListener(nsIURIContentListener**
aParentListener)

View File

@ -209,6 +209,17 @@ ImageConsumer::SetLoadCookie(nsISupports * aLoadCookie)
return NS_OK;
}
NS_IMETHODIMP
ImageConsumer::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
return CanHandleContent(aContentType, aCommand, aWindowTarget,
aDesiredContentType, aCanHandleContent);
}
NS_IMETHODIMP
ImageConsumer::CanHandleContent(const char * aContentType,

View File

@ -32,6 +32,7 @@
#include "nsIDocumentLoader.h"
#include "nsILoadGroup.h"
#include "nsIMsgMailNewsUrl.h"
#include "nsIInterfaceRequestor.h"
static NS_DEFINE_CID(kTransactionManagerCID, NS_TRANSACTIONMANAGER_CID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
@ -268,36 +269,20 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
NS_IMETHODIMP
nsMsgWindow::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
// the mail window is the primary content handler for the following types:
// If we are asked to handle any of these types, we will always say Yes!
// regardlesss of the uri load command.
// Incoming Type Preferred type
// message/rfc822 text/xul
// message/rfc822 text/html
//
// the mail window can also show the following content types. However, it isn't
// the primary content handler for these types. So we won't try to accept this content
// unless the uri load command is viewNormal (which implies that we are trying to view a url inline)
// incoming Type Preferred type
// text/html
// text/xul
// image/gif
// image/jpeg
// image/png
// image/tiff
*aCanHandleContent = PR_FALSE;
// (1) list all content types we want to be the primary handler for....
// and suggest a desired content type if appropriate...
if (aContentType && nsCRT::strcasecmp(aContentType, "message/rfc822") == 0)
{
// we can handle this content type...but we would prefer it to be
@ -306,31 +291,31 @@ NS_IMETHODIMP nsMsgWindow::CanHandleContent(const char * aContentType,
*aDesiredContentType = nsCRT::strdup("text/html");
}
else
{
// (2) list all the content types we can handle IF we really have too....i.e.
// if the load command is viewNormal. This includes text/xul, text/html right now.
// I'm sure it will grow.
// for right now, if the load command is viewNormal just say we can handle it...
if (aCommand == nsIURILoader::viewNormal)
{
if (nsCRT::strcasecmp(aContentType, "text/html") == 0
|| nsCRT::strcasecmp(aContentType, "text/xul") == 0
|| nsCRT::strcasecmp(aContentType, "text/rdf") == 0
|| nsCRT::strcasecmp(aContentType, "text/xml") == 0
|| nsCRT::strcasecmp(aContentType, "text/css") == 0
|| nsCRT::strcasecmp(aContentType, "image/gif") == 0
|| nsCRT::strcasecmp(aContentType, "image/jpeg") == 0
|| nsCRT::strcasecmp(aContentType, "image/png") == 0
|| nsCRT::strcasecmp(aContentType, "image/tiff") == 0
|| nsCRT::strcasecmp(aContentType, "application/http-index-format") == 0)
*aCanHandleContent = PR_TRUE;
}
}
*aCanHandleContent = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
// the mail window knows nothing about the default content types
// it's docshell can handle...ask the content area if it can handle
// the content type...
nsCOMPtr<nsIURIContentListener> ctnListener (do_GetInterface(mMessageWindowWebShell));
if (ctnListener)
return ctnListener->CanHandleContent(aContentType, aCommand, aWindowTarget,
aDesiredContentType, aCanHandleContent);
else
*aCanHandleContent = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::GetParentContentListener(nsIURIContentListener** aParent)
{
*aParent = nsnull;

View File

@ -110,6 +110,18 @@ nsURLFetcher::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHan
return NS_OK;
}
NS_IMETHODIMP
nsURLFetcher::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
return CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP
nsURLFetcher::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,