openuri now takes a nsURILoaderCommand

remove protocol scheme check before using the uri loader. this
means that all urls will run through the uriloader regardless of
 type when it gets turned on.
webshell:
doContent and canHandleContent now take a nsURILoaderCommand
modify the handle link click event method to pass in
in the nsIURILoader::viewUserClick command to the uri loader
r=travis


git-svn-id: svn://10.0.0.236/trunk@55042 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mscott%netscape.com
1999-12-02 07:00:17 +00:00
parent 9a83fb8aac
commit ead0de0810
4 changed files with 90 additions and 60 deletions

View File

@@ -82,6 +82,7 @@
#include "nsILocaleService.h"
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
#ifdef XP_PC
#include <windows.h>
@@ -1789,7 +1790,7 @@ nsWebShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandl
}
NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
const char * aCommand,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
@@ -1814,11 +1815,11 @@ NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
NS_IMETHODIMP
nsWebShell::DoContent(const char * aContentType,
const char * aCommand,
const char * aWindowTarget,
nsIChannel * aOpenedChannel,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsIChannel * aOpenedChannel,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
{
if (aAbortProcess)
*aAbortProcess = PR_FALSE;
@@ -1827,16 +1828,16 @@ nsWebShell::DoContent(const char * aContentType,
// had we gone through OpenURI
nsCOMPtr<nsIURI> aUri;
aOpenedChannel->GetURI(getter_AddRefs(aUri));
PrepareToLoadURI(aUri, aCommand, nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull);
PrepareToLoadURI(aUri, "view", nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull);
// mscott: when I called DoLoadURL I found that we ran into problems because
// we currently don't have channel retargeting yet. Basically, what happens is that
// DoLoadURL calls StopBeforeRequestingURL and this cancels the current load group
// however since we can't retarget yet, we were basically canceling our very
// own load group!!! So the request would get canceled out from under us...
// after retargeting we may be able to safely call DoLoadURL.
DoLoadURL(aUri, aCommand, nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE);
DoLoadURL(aUri, "view", nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE);
return mDocLoader->LoadOpenedDocument(aOpenedChannel,
aCommand,
"view",
this,
nsnull,
nsnull,
@@ -2754,9 +2755,27 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
if (nsnull != shell) {
// Allocate since mURL may change beneath us
PRUnichar* str = mURL.ToNewUnicode();
(void)shell->LoadURL(aURLSpec, aPostDataStream,
PR_TRUE, nsIChannel::LOAD_NORMAL,
0, nsnull, str);
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
PRBool useURILoader = PR_FALSE;
if (NS_SUCCEEDED(rv))
prefs->GetBoolPref("browser.uriloader", &useURILoader);
if (useURILoader)
{
// for now, just hack the verb to be view-link-clicked
// and down in the load document code we'll detect this and
// set the correct uri loader command
(void)shell->LoadURL(aURLSpec, "view-link-click", aPostDataStream,
PR_TRUE, nsIChannel::LOAD_NORMAL,
0, nsnull, str);
}
else
{
(void)shell->LoadURL(aURLSpec, aPostDataStream,
PR_TRUE, nsIChannel::LOAD_NORMAL,
0, nsnull, str);
}
Recycle(str);
NS_RELEASE(shell);
}

View File

@@ -560,16 +560,7 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
// dispatching code for those schemes which work with uri dispatching...
if (useURILoader && aUri)
{
if (nsCRT::strcasecmp(aUrlScheme, "imap") == 0
|| nsCRT::strcasecmp(aUrlScheme, "news") == 0
|| nsCRT::strcasecmp(aUrlScheme, "mailbox") == 0
|| nsCRT::strcasecmp(aUrlScheme, "mailboxMessage") ==0
|| nsCRT::strcasecmp(aUrlScheme, "mailto") == 0
|| nsCRT::strcasecmp(aUrlScheme, "http") == 0
|| nsCRT::strcasecmp(aUrlScheme, "chrome") == 0
|| nsCRT::strcasecmp(aUrlScheme, "res") == 0)
{
nsCOMPtr<nsISupports> aOpenContext = do_QueryInterface(mLoadGroup);
nsCOMPtr<nsISupports> aOpenContext = do_QueryInterface(mLoadGroup);
// let's try uri dispatching...
NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv);
@@ -583,6 +574,10 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
*/
mIsLoadingDocument = PR_TRUE;
nsURILoadCommand loadCmd = nsIURILoader::viewNormal;
if (nsCRT::strcasecmp(aCommand, "view-link-click") == 0)
loadCmd = nsIURILoader::viewUserClick;
// temporary hack for post data...eventually this snippet of code
// should be moved into the layout call when callers go through the
// uri loader directly!
@@ -592,16 +587,18 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
// query for private post data stream interface
nsCOMPtr<nsPIURILoaderWithPostData> postLoader = do_QueryInterface(pURILoader, &rv);
if (NS_SUCCEEDED(rv))
rv = postLoader->OpenURIWithPostData(aUri, nsnull /* window target */,
aContainer,
nsnull /* referring uri */,
aPostDataStream,
mLoadGroup,
getter_AddRefs(aOpenContext));
rv = postLoader->OpenURIWithPostData(aUri,
loadCmd,
nsnull /* window target */,
aContainer,
nsnull /* referring uri */,
aPostDataStream,
mLoadGroup,
getter_AddRefs(aOpenContext));
}
else
rv = pURILoader->OpenURI(aUri, nsnull /* window target */,
rv = pURILoader->OpenURI(aUri, loadCmd, nsnull /* window target */,
aContainer,
nsnull /* refferring URI */,
mLoadGroup,
@@ -611,7 +608,6 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
}
return rv;
}
} // end try uri loader code
nsDocumentBindInfo* loader = nsnull;

View File

@@ -560,16 +560,7 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
// dispatching code for those schemes which work with uri dispatching...
if (useURILoader && aUri)
{
if (nsCRT::strcasecmp(aUrlScheme, "imap") == 0
|| nsCRT::strcasecmp(aUrlScheme, "news") == 0
|| nsCRT::strcasecmp(aUrlScheme, "mailbox") == 0
|| nsCRT::strcasecmp(aUrlScheme, "mailboxMessage") ==0
|| nsCRT::strcasecmp(aUrlScheme, "mailto") == 0
|| nsCRT::strcasecmp(aUrlScheme, "http") == 0
|| nsCRT::strcasecmp(aUrlScheme, "chrome") == 0
|| nsCRT::strcasecmp(aUrlScheme, "res") == 0)
{
nsCOMPtr<nsISupports> aOpenContext = do_QueryInterface(mLoadGroup);
nsCOMPtr<nsISupports> aOpenContext = do_QueryInterface(mLoadGroup);
// let's try uri dispatching...
NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv);
@@ -583,6 +574,10 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
*/
mIsLoadingDocument = PR_TRUE;
nsURILoadCommand loadCmd = nsIURILoader::viewNormal;
if (nsCRT::strcasecmp(aCommand, "view-link-click") == 0)
loadCmd = nsIURILoader::viewUserClick;
// temporary hack for post data...eventually this snippet of code
// should be moved into the layout call when callers go through the
// uri loader directly!
@@ -592,16 +587,18 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
// query for private post data stream interface
nsCOMPtr<nsPIURILoaderWithPostData> postLoader = do_QueryInterface(pURILoader, &rv);
if (NS_SUCCEEDED(rv))
rv = postLoader->OpenURIWithPostData(aUri, nsnull /* window target */,
aContainer,
nsnull /* referring uri */,
aPostDataStream,
mLoadGroup,
getter_AddRefs(aOpenContext));
rv = postLoader->OpenURIWithPostData(aUri,
loadCmd,
nsnull /* window target */,
aContainer,
nsnull /* referring uri */,
aPostDataStream,
mLoadGroup,
getter_AddRefs(aOpenContext));
}
else
rv = pURILoader->OpenURI(aUri, nsnull /* window target */,
rv = pURILoader->OpenURI(aUri, loadCmd, nsnull /* window target */,
aContainer,
nsnull /* refferring URI */,
mLoadGroup,
@@ -611,7 +608,6 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
}
return rv;
}
} // end try uri loader code
nsDocumentBindInfo* loader = nsnull;

View File

@@ -82,6 +82,7 @@
#include "nsILocaleService.h"
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
#ifdef XP_PC
#include <windows.h>
@@ -1789,7 +1790,7 @@ nsWebShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandl
}
NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
const char * aCommand,
nsURILoadCommand aCommand,
const char * aWindowTarget,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
@@ -1814,11 +1815,11 @@ NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType,
NS_IMETHODIMP
nsWebShell::DoContent(const char * aContentType,
const char * aCommand,
const char * aWindowTarget,
nsIChannel * aOpenedChannel,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
nsURILoadCommand aCommand,
const char * aWindowTarget,
nsIChannel * aOpenedChannel,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
{
if (aAbortProcess)
*aAbortProcess = PR_FALSE;
@@ -1827,16 +1828,16 @@ nsWebShell::DoContent(const char * aContentType,
// had we gone through OpenURI
nsCOMPtr<nsIURI> aUri;
aOpenedChannel->GetURI(getter_AddRefs(aUri));
PrepareToLoadURI(aUri, aCommand, nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull);
PrepareToLoadURI(aUri, "view", nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull);
// mscott: when I called DoLoadURL I found that we ran into problems because
// we currently don't have channel retargeting yet. Basically, what happens is that
// DoLoadURL calls StopBeforeRequestingURL and this cancels the current load group
// however since we can't retarget yet, we were basically canceling our very
// own load group!!! So the request would get canceled out from under us...
// after retargeting we may be able to safely call DoLoadURL.
DoLoadURL(aUri, aCommand, nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE);
DoLoadURL(aUri, "view", nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE);
return mDocLoader->LoadOpenedDocument(aOpenedChannel,
aCommand,
"view",
this,
nsnull,
nsnull,
@@ -2754,9 +2755,27 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
if (nsnull != shell) {
// Allocate since mURL may change beneath us
PRUnichar* str = mURL.ToNewUnicode();
(void)shell->LoadURL(aURLSpec, aPostDataStream,
PR_TRUE, nsIChannel::LOAD_NORMAL,
0, nsnull, str);
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
PRBool useURILoader = PR_FALSE;
if (NS_SUCCEEDED(rv))
prefs->GetBoolPref("browser.uriloader", &useURILoader);
if (useURILoader)
{
// for now, just hack the verb to be view-link-clicked
// and down in the load document code we'll detect this and
// set the correct uri loader command
(void)shell->LoadURL(aURLSpec, "view-link-click", aPostDataStream,
PR_TRUE, nsIChannel::LOAD_NORMAL,
0, nsnull, str);
}
else
{
(void)shell->LoadURL(aURLSpec, aPostDataStream,
PR_TRUE, nsIChannel::LOAD_NORMAL,
0, nsnull, str);
}
Recycle(str);
NS_RELEASE(shell);
}