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

application layer into the webshell/docshell layer.

r=traivs


git-svn-id: svn://10.0.0.236/trunk@59759 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mscott%netscape.com 2000-02-04 08:44:46 +00:00
parent 5099d9d1c1
commit 8fadc39c51
3 changed files with 68 additions and 66 deletions

View File

@ -1610,17 +1610,20 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
if (nsnull != (const char *) ref) {
rv = NS_OpenURI(getter_AddRefs(dummyChannel), aUri, nsnull, interfaceRequestor);
if (NS_FAILED(rv)) return rv;
rv = OnStartDocumentLoad(mDocLoader, aUri, "load");
if (!mProcessedEndDocumentLoad)
rv = OnStartDocumentLoad(mDocLoader, aUri, "load");
// Go to the anchor in the current document
rv = presShell->GoToAnchor(nsAutoString(ref));
mProcessedEndDocumentLoad = PR_FALSE;
rv = presShell->GoToAnchor(nsAutoString(ref));
// Set the URL & referrer if the anchor was successfully visited
if (NS_SUCCEEDED(rv)) {
mURL = urlSpec;
mReferrer = aReferrer;
}
// Pass on status of scrolling/anchor visit to docloaderobserver
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, rv);
if (!mProcessedEndDocumentLoad)
{
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, rv);
}
return rv;
}
else if (aType == nsISessionHistory::LOAD_HISTORY)
@ -1770,6 +1773,17 @@ nsWebShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandl
return mContentListener->GetProtocolHandler(aURI, aProtocolHandler);
}
NS_IMETHODIMP nsWebShell::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
NS_ENSURE_SUCCESS(EnsureContentListener(), NS_ERROR_FAILURE);
return mContentListener->IsPreferred(aContentType, aCommand, aWindowTarget, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
@ -1777,21 +1791,9 @@ NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
PRBool * aCanHandleContent)
{
// the webshell knows nothing about content policy....pass this
// up to our parent content handler...
nsCOMPtr<nsIURIContentListener> parentListener;
nsresult rv = GetParentContentListener(getter_AddRefs(parentListener));
if (parentListener)
rv = parentListener->CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
aCanHandleContent);
else
// i'm going to try something interesting...if we don't have a parent to dictate whether we
// can handle the content, let's say that we CAN handle the content instead of saying that we
// can't. I was running into the scenario where we were running a chrome url to bring up the first window
// in the top level webshell. We didn't have a parent content listener yet because it was too early in
// the start up process...so we'd fail to load the url....
*aCanHandleContent = PR_TRUE;
return NS_OK;
NS_ENSURE_SUCCESS(EnsureContentListener(), NS_ERROR_FAILURE);
return mContentListener->CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP

View File

@ -1610,17 +1610,20 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
if (nsnull != (const char *) ref) {
rv = NS_OpenURI(getter_AddRefs(dummyChannel), aUri, nsnull, interfaceRequestor);
if (NS_FAILED(rv)) return rv;
rv = OnStartDocumentLoad(mDocLoader, aUri, "load");
if (!mProcessedEndDocumentLoad)
rv = OnStartDocumentLoad(mDocLoader, aUri, "load");
// Go to the anchor in the current document
rv = presShell->GoToAnchor(nsAutoString(ref));
mProcessedEndDocumentLoad = PR_FALSE;
rv = presShell->GoToAnchor(nsAutoString(ref));
// Set the URL & referrer if the anchor was successfully visited
if (NS_SUCCEEDED(rv)) {
mURL = urlSpec;
mReferrer = aReferrer;
}
// Pass on status of scrolling/anchor visit to docloaderobserver
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, rv);
if (!mProcessedEndDocumentLoad)
{
rv = OnEndDocumentLoad(mDocLoader, dummyChannel, rv);
}
return rv;
}
else if (aType == nsISessionHistory::LOAD_HISTORY)
@ -1770,6 +1773,17 @@ nsWebShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandl
return mContentListener->GetProtocolHandler(aURI, aProtocolHandler);
}
NS_IMETHODIMP nsWebShell::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
NS_ENSURE_SUCCESS(EnsureContentListener(), NS_ERROR_FAILURE);
return mContentListener->IsPreferred(aContentType, aCommand, aWindowTarget, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
@ -1777,21 +1791,9 @@ NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
PRBool * aCanHandleContent)
{
// the webshell knows nothing about content policy....pass this
// up to our parent content handler...
nsCOMPtr<nsIURIContentListener> parentListener;
nsresult rv = GetParentContentListener(getter_AddRefs(parentListener));
if (parentListener)
rv = parentListener->CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
aCanHandleContent);
else
// i'm going to try something interesting...if we don't have a parent to dictate whether we
// can handle the content, let's say that we CAN handle the content instead of saying that we
// can't. I was running into the scenario where we were running a chrome url to bring up the first window
// in the top level webshell. We didn't have a parent content listener yet because it was too early in
// the start up process...so we'd fail to load the url....
*aCanHandleContent = PR_TRUE;
return NS_OK;
NS_ENSURE_SUCCESS(EnsureContentListener(), NS_ERROR_FAILURE);
return mContentListener->CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP

View File

@ -85,9 +85,9 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
#include "nsIWalletService.h"
#include "nsCURILoader.h"
#include "nsIContentHandler.h"
#include "nsNetUtil.h"
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
@ -2313,12 +2313,11 @@ nsBrowserInstance::DoContent(const char *aContentType, nsURILoadCommand aCommand
}
NS_IMETHODIMP
nsBrowserInstance::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
nsBrowserInstance::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
// the browser 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!
@ -2334,12 +2333,6 @@ nsBrowserInstance::CanHandleContent(const char * aContentType,
// image/png
// image/tiff
// application/http-index-format
//
// the browser 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
// message/rfc822 text/xul
if (aContentType)
{
@ -2356,19 +2349,6 @@ nsBrowserInstance::CanHandleContent(const char * aContentType,
|| nsCRT::strcasecmp(aContentType, "image/tiff") == 0
|| nsCRT::strcasecmp(aContentType, "application/http-index-format") == 0)
*aCanHandleContent = PR_TRUE;
// (2) we aren't the desired content type handlers for these types; however,
// if we are given a view normal load command, we can view them if we have too....
if (aCommand == nsIURILoader::viewNormal)
{
if (nsCRT::strcasecmp(aContentType, "message/rfc822") == 0)
{
*aCanHandleContent = PR_TRUE;
*aDesiredContentType = nsCRT::strdup("text/xul");
}
}
}
else
*aCanHandleContent = PR_FALSE;
@ -2376,6 +2356,25 @@ nsBrowserInstance::CanHandleContent(const char * aContentType,
return NS_OK;
}
NS_IMETHODIMP
nsBrowserInstance::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
// can handle is really determined by what our docshell can
// load...so ask it....
nsCOMPtr<nsIURIContentListener> ctnListener (do_GetInterface(mContentAreaWebShell));
if (ctnListener)
return ctnListener->CanHandleContent(aContentType, aCommand, aWindowTarget, aDesiredContentType, aCanHandleContent);
else
*aCanHandleContent = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsBrowserInstance::GetParentContentListener(nsIURIContentListener** aParent)
{
@ -2404,8 +2403,6 @@ nsBrowserInstance::SetLoadCookie(nsISupports * aLoadCookie)
return NS_OK;
}
NS_DEFINE_MODULE_INSTANCE_COUNTER()
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBrowserInstance, Init)
@ -2418,3 +2415,4 @@ static nsModuleComponentInfo components[] = {
};
NS_IMPL_NSGETMODULE("nsBrowserModule", components)