bug #99627 (r=valeski@netscape.com, sr=mscott@netscpae.com). Freeze the nsIURIContentListener interface...

This commit is contained in:
rpotts%netscape.com 2001-10-27 02:52:39 +00:00
parent 0b07320096
commit ae53430684
17 changed files with 166 additions and 228 deletions

View File

@ -76,7 +76,7 @@ nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
NS_IMETHODIMP
nsDSURIContentListener::DoContent(const char* aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsIRequest* request,
nsIStreamListener** aContentHandler,
PRBool* aAbortProcess)
@ -94,8 +94,7 @@ nsDSURIContentListener::DoContent(const char* aContentType,
if (aOpenedChannel)
aOpenedChannel->GetLoadFlags(&loadFlags);
PRUint32 loadType = mDocShell->ConvertDocShellLoadInfoToLoadType((nsDocShellInfoLoadType) aCommand);
mDocShell->SetLoadType(loadType);
mDocShell->SetLoadType(aIsContentPreferred ? LOAD_LINK : LOAD_NORMAL);
if(loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
{
@ -117,7 +116,6 @@ nsDSURIContentListener::DoContent(const char* aContentType,
NS_IMETHODIMP
nsDSURIContentListener::IsPreferred(const char* aContentType,
nsURILoadCommand aCommand,
char ** aDesiredContentType,
PRBool* aCanHandle)
{
@ -127,29 +125,31 @@ nsDSURIContentListener::IsPreferred(const char* aContentType,
// 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)
if(mParentContentListener) {
return mParentContentListener->IsPreferred(aContentType,
aCommand,
aDesiredContentType,
aCanHandle);
else
{
// we used to return false here if we didn't have a parent properly registered at the top of
// the docshell hierarchy to dictate what content types this docshell should be a preferred handler for.
// But this really makes it hard for developers using iframe or browser tags because then they need to
// make sure they implement nsIURIContentListener otherwise all link clicks would get sent to another window
// because we said we weren't the preferred handler type. I'm going to change the default now...if we can handle the
// content, and someone didn't EXPLICITLY set a nsIURIContentListener at the top of our docshell chain, then we'll
// now always attempt to process the content ourselves...
return CanHandleContent(aContentType, aCommand, aDesiredContentType, aCanHandle);
}
return NS_OK;
// we used to return false here if we didn't have a parent properly
// registered at the top of the docshell hierarchy to dictate what
// content types this docshell should be a preferred handler for. But
// this really makes it hard for developers using iframe or browser tags
// because then they need to make sure they implement
// nsIURIContentListener otherwise all link clicks would get sent to
// another window because we said we weren't the preferred handler type.
// I'm going to change the default now...if we can handle the content,
// and someone didn't EXPLICITLY set a nsIURIContentListener at the top
// of our docshell chain, then we'll now always attempt to process the
// content ourselves...
return CanHandleContent(aContentType,
PR_TRUE,
aDesiredContentType,
aCanHandle);
}
NS_IMETHODIMP
nsDSURIContentListener::CanHandleContent(const char* aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char ** aDesiredContentType,
PRBool* aCanHandleContent)
{

View File

@ -408,48 +408,6 @@ ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType)
return loadType;
}
nsDocShellInfoLoadType
nsDocShell::ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType)
{
nsDocShellInfoLoadType docShellLoadType = nsIDocShellLoadInfo::loadNormal;
switch (aLoadType) {
case LOAD_NORMAL:
docShellLoadType = nsIDocShellLoadInfo::loadNormal;
break;
case LOAD_NORMAL_REPLACE:
docShellLoadType = nsIDocShellLoadInfo::loadNormalReplace;
break;
case LOAD_HISTORY:
docShellLoadType = nsIDocShellLoadInfo::loadHistory;
break;
case LOAD_RELOAD_NORMAL:
docShellLoadType = nsIDocShellLoadInfo::loadReloadNormal;
break;
case LOAD_RELOAD_CHARSET_CHANGE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
break;
case LOAD_RELOAD_BYPASS_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassCache;
break;
case LOAD_RELOAD_BYPASS_PROXY:
docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
break;
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
break;
case LOAD_LINK:
docShellLoadType = nsIDocShellLoadInfo::loadLink;
break;
case LOAD_REFRESH:
docShellLoadType = nsIDocShellLoadInfo::loadRefresh;
break;
case LOAD_BYPASS_HISTORY:
docShellLoadType = nsIDocShellLoadInfo::loadBypassHistory;
break;
}
return docShellLoadType;
}
//*****************************************************************************
// nsDocShell::nsIDocShell
@ -636,9 +594,7 @@ nsDocShell::LoadStream(nsIInputStream * aStream, nsIURI * aURI,
uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID));
NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(DoChannelLoad
(channel, nsIURILoader::viewNormal, uriLoader),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(DoChannelLoad(channel, uriLoader), NS_ERROR_FAILURE);
return NS_OK;
}
@ -4085,10 +4041,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
// been called.
mLSHE = aSHEntry;
nsDocShellInfoLoadType loadCmd =
ConvertLoadTypeToDocShellLoadInfo(mLoadType);
rv = DoURILoad(aURI, aReferrer, owner, loadCmd, aPostData, aHeadersData);
rv = DoURILoad(aURI, aReferrer, owner, aPostData, aHeadersData);
return rv;
}
@ -4159,7 +4112,6 @@ nsDocShell::GetCurrentDocumentOwner(nsISupports ** aOwner)
nsresult nsDocShell::DoURILoad(nsIURI * aURI,
nsIURI * aReferrerURI,
nsISupports * aOwner,
nsURILoadCommand aLoadCmd,
nsIInputStream * aPostData,
nsIInputStream * aHeadersData)
{
@ -4274,7 +4226,7 @@ nsresult nsDocShell::DoURILoad(nsIURI * aURI,
channel->SetOwner(aOwner);
}
rv = DoChannelLoad(channel, aLoadCmd, uriLoader);
rv = DoChannelLoad(channel, uriLoader);
return rv;
}
@ -4433,7 +4385,6 @@ nsDocShell::AddHeadersToChannel(nsIInputStream * aHeadersData,
}
nsresult nsDocShell::DoChannelLoad(nsIChannel * aChannel,
nsURILoadCommand aLoadCmd,
nsIURILoader * aURILoader)
{
nsresult rv;
@ -4490,7 +4441,7 @@ nsresult nsDocShell::DoChannelLoad(nsIChannel * aChannel,
(void) aChannel->SetLoadFlags(loadFlags);
rv = aURILoader->OpenURI(aChannel,
aLoadCmd,
(mLoadType == LOAD_LINK),
NS_STATIC_CAST(nsIDocShell *, this));
if (rv == NS_ERROR_PORT_ACCESS_NOT_ALLOWED) {

View File

@ -40,6 +40,7 @@
#include "nsIDeviceContext.h"
#include "nsIDocumentLoader.h"
#include "nsIURILoader.h"
#include "nsWeakReference.h"
@ -189,7 +190,6 @@ public:
nsresult SetLoadCookie(nsISupports * aCookie);
nsresult GetLoadCookie(nsISupports ** aResult);
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType);
PRUint32 ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
protected:
@ -214,13 +214,11 @@ protected:
virtual nsresult DoURILoad(nsIURI * aURI,
nsIURI * aReferrer,
nsISupports * aOwner,
nsURILoadCommand aLoadCmd,
nsIInputStream * aPostData,
nsIInputStream * aHeadersData);
NS_IMETHOD AddHeadersToChannel(nsIInputStream * aHeadersData,
nsIChannel * aChannel);
virtual nsresult DoChannelLoad(nsIChannel * aChannel,
nsURILoadCommand aLoadCmd,
nsIURILoader * aURILoader);
NS_IMETHOD ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor);
NS_IMETHOD OnLoadingSite(nsIChannel * aChannel);

View File

@ -4751,8 +4751,8 @@ NS_IMETHODIMP nsEditorShell::OnStartURIOpen(nsIURI *aURI, PRBool *aAbortOpen)
return NS_OK;
}
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadCommand aCommand, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
/* void doContent (in string aContentType, in boolean aIsContentPreferred, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest* request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
{
NS_ENSURE_ARG_POINTER(aContentHandler);
NS_ENSURE_ARG_POINTER(aAbortProcess);
@ -4761,8 +4761,8 @@ NS_IMETHODIMP nsEditorShell::DoContent(const char *aContentType, nsURILoadComman
return NS_OK;
}
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
/* boolean isPreferred (in string aContentType, out string aDesiredContentType); */
NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(aDesiredContentType);
NS_ENSURE_ARG_POINTER(_retval);
@ -4771,8 +4771,8 @@ NS_IMETHODIMP nsEditorShell::IsPreferred(const char *aContentType, nsURILoadComm
return NS_OK;
}
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
NS_IMETHODIMP nsEditorShell::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
/* boolean canHandleContent (in string aContentType, in boolean aIsContentPreferred, out string aDesiredContentType); */
NS_IMETHODIMP nsEditorShell::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(aDesiredContentType);
NS_ENSURE_ARG_POINTER(_retval);

View File

@ -387,22 +387,22 @@ NS_IMETHODIMP CWebBrowserContainer::OnStartURIOpen(nsIURI *pURI, PRBool *aAbortO
return NS_OK;
}
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in nsIRequest request, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, nsURILoadCommand aCommand, nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
/* void doContent (in string aContentType, in boolean aIsContentPreferred, in nsIRequest request, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
/* boolean isPreferred (in string aContentType, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *_retval)
{
return CanHandleContent(aContentType, aCommand, aDesiredContentType, _retval);
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType, _retval);
}
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
/* boolean canHandleContent (in string aContentType, in PRBool aIsContentPreferred, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
{
if (aContentType)
{

View File

@ -71,7 +71,7 @@ EmbedContentListener::OnStartURIOpen(nsIURI *aURI,
NS_IMETHODIMP
EmbedContentListener::DoContent(const char *aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsIRequest *aRequest,
nsIStreamListener **aContentHandler,
PRBool *aAbortProcess)
@ -81,7 +81,6 @@ EmbedContentListener::DoContent(const char *aContentType,
NS_IMETHODIMP
EmbedContentListener::IsPreferred(const char *aContentType,
nsURILoadCommand aCommand,
char **aDesiredContentType,
PRBool *aCanHandleContent)
{
@ -110,7 +109,7 @@ EmbedContentListener::IsPreferred(const char *aContentType,
NS_IMETHODIMP
EmbedContentListener::CanHandleContent(const char *aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char **aDesiredContentType,
PRBool *_retval)
{

View File

@ -459,15 +459,15 @@ NS_IMETHODIMP CWebBrowserContainer::OnStartURIOpen(nsIURI *pURI, PRBool *aAbortO
}
/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in nsIRequest aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, nsURILoadCommand aCommand, nsIRequest *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
/* void doContent (in string aContentType, in boolean aIsContentPreferred, in nsIRequest aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */
NS_IMETHODIMP CWebBrowserContainer::DoContent(const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *aCanHandleContent)
/* boolean isPreferred (in string aContentType, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, char **aDesiredContentType, PRBool *aCanHandleContent)
{
if (aContentType &&
@ -492,8 +492,8 @@ NS_IMETHODIMP CWebBrowserContainer::IsPreferred(const char *aContentType, nsURIL
}
/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, char **aDesiredContentType, PRBool *_retval)
/* boolean canHandleContent (in string aContentType, in boolean aIsContentPreferred, out string aDesiredContentType); */
NS_IMETHODIMP CWebBrowserContainer::CanHandleContent(const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -321,18 +321,17 @@ nsAbSyncPostEngine::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
NS_IMETHODIMP
nsAbSyncPostEngine::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
return CanHandleContent(aContentType, aCommand, aDesiredContentType,
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP
nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
@ -347,7 +346,7 @@ nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
NS_IMETHODIMP
nsAbSyncPostEngine::DoContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsIRequest *request,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)

View File

@ -415,7 +415,7 @@ NS_IMETHODIMP nsMsgWindow::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
return NS_OK;
}
NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand aCommand,
NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, PRBool aIsContentPreferred,
nsIRequest *request, nsIStreamListener **aContentHandler, PRBool *aAbortProcess)
{
if (aContentType)
@ -440,7 +440,7 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand
if (mailnewsUrl)
mailnewsUrl->SetMsgWindow(this);
}
return ctnListener->DoContent(aContentType, aCommand, request, aContentHandler, aAbortProcess);
return ctnListener->DoContent(aContentType, aIsContentPreferred, request, aContentHandler, aAbortProcess);
}
}
return NS_OK;
@ -448,7 +448,6 @@ NS_IMETHODIMP nsMsgWindow::DoContent(const char *aContentType, nsURILoadCommand
NS_IMETHODIMP
nsMsgWindow::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
@ -457,7 +456,7 @@ nsMsgWindow::IsPreferred(const char * aContentType,
}
NS_IMETHODIMP nsMsgWindow::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
@ -470,7 +469,7 @@ NS_IMETHODIMP nsMsgWindow::CanHandleContent(const char * aContentType,
GetMessageWindowDocShell(getter_AddRefs(messageWindowDocShell));
nsCOMPtr<nsIURIContentListener> ctnListener (do_GetInterface(messageWindowDocShell));
if (ctnListener)
return ctnListener->CanHandleContent(aContentType, aCommand,
return ctnListener->CanHandleContent(aContentType, aIsContentPreferred,
aDesiredContentType, aCanHandleContent);
else
*aCanHandleContent = PR_FALSE;

View File

@ -120,18 +120,17 @@ nsURLFetcher::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
NS_IMETHODIMP
nsURLFetcher::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
return CanHandleContent(aContentType, aCommand, aDesiredContentType,
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP
nsURLFetcher::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
@ -146,7 +145,7 @@ nsURLFetcher::CanHandleContent(const char * aContentType,
NS_IMETHODIMP
nsURLFetcher::DoContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsIRequest *request,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
@ -367,7 +366,7 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsILocalFile *localFile, nsIFileOutpu
pURILoader->GetLoadGroupForContext(cntListener, getter_AddRefs(loadGroup));
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(channel), aURL, nsnull, loadGroup, this), NS_ERROR_FAILURE);
rv = pURILoader->OpenURI(channel, nsIURILoader::viewNormal, cntListener);
rv = pURILoader->OpenURI(channel, PR_FALSE, cntListener);
return NS_OK;
}

View File

@ -46,7 +46,6 @@
*/
#include "nsISupports.idl"
#include "nsIURILoader.idl"
interface nsIRequest;
interface nsIStreamListener;
@ -56,69 +55,66 @@ interface nsIURI;
interface nsIURIContentListener : nsISupports
{
/*
Gives the content listener first crack at stopping a load before it
happens.
aURI --> the uri we are going to try and open.
return value --> specifies if the open should be aborted.
Gives the content listener first crack at stopping a load before it
happens.
aURI --> the uri we are going to try and open.
return value --> specifies if the open should be aborted.
*/
boolean onStartURIOpen(in nsIURI aURI);
/* doContent --> When the content listener is expected to process the
content, the uri loader calls doContent. doContent needs to return a
nsIStreamListener which the uri loader will push the content into.
nsIStreamListener which the uri loader will push the content into.
aContentType --> the content type we need to handle
aCommand --> verb for the action (this comes from layout???)
aWindowTarget --> name of the target window if any
aIsContentPreferred --> indicates whether the content is preferred by
this listener.
aStreamListener --> the content viewer the content should be displayed in
You should return null for this out parameter if you do
not want to handle this content type.
return value --> If you want to handle the content yourself and you don't
want the dispatcher to do anything else, return
TRUE, else return false.
want the dispatcher to do anything else, return
TRUE, else return false.
*/
boolean doContent(in string aContentType,
in nsURILoadCommand aCommand,
in boolean aIsContentPreferred,
in nsIRequest request,
out nsIStreamListener aContentHandler);
/* When given a uri to dispatch, if the load type is a user click,
then the uri loader tries to find a preferred content handler
for this content type. The thought is that many content
listeners may be able to handle the same content type if they
have to. i.e. the mail content window can handle text/html just
like a browser window content listener. However, if the user
clicks on a link with text/html content, we'd like the browser
window to handle that content and not the mail window where the
user may have clicked the link. That's why we have isPreferred.
aContentType --> the content type to handle
aCommand --> verb for the action
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 --> return true if you are a preferred content handler
for aContentType and false otherwise.
*/
boolean isPreferred(in string aContentType,
in nsURILoadCommand aCommand,
out string aDesiredContentType);
/* When given a uri to dispatch, if the load type is a user click,
then the uri loader tries to find a preferred content handler
for this content type. The thought is that many content
listeners may be able to handle the same content type if they
have to. i.e. the mail content window can handle text/html just
like a browser window content listener. However, if the user
clicks on a link with text/html content, we'd like the browser
window to handle that content and not the mail window where the
user may have clicked the link. That's why we have isPreferred.
aContentType --> the content type to handle
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 --> return true if you are a preferred content handler
for aContentType and false otherwise.
*/
boolean isPreferred(in string aContentType, out string aDesiredContentType);
/* When given a uri to dispatch, if the load type is anything but
user click, the uri loader will call canHandleContent to see if
the content listener can handle the content. The arguments are
the same as isPreferred.
/* When given a uri to dispatch, if the load type is anything but
user click, the uri loader will call canHandleContent to see if
the content listener can handle the content. The arguments are
the same as isPreferred.
Note: I really envision canHandleContent as a method implemented
by the docshell as the implementation is generic to all doc
shells. The IsPreferred decision is a decision made by a top level
application content listener that sits at the top of the docshell
hiearchy.
*/
Note: I really envision canHandleContent as a method implemented
by the docshell as the implementation is generic to all doc
shells. The IsPreferred decision is a decision made by a top level
application content listener that sits at the top of the docshell
hiearchy.
*/
boolean canHandleContent(in string aContentType,
in nsURILoadCommand aCommand,
in boolean aIsContentPreferred,
out string aDesiredContentType);
/* Get/Set loadCookie are methods the uri loader calls on the
@ -126,6 +122,7 @@ interface nsIURIContentListener : nsISupports
* with this particular content listener...
*/
attribute nsISupports loadCookie;
/* if you are part of a chain of content listeners (i.e. if you are
* a docshell!) return your parent content listener
*/

View File

@ -67,8 +67,6 @@ interface nsIRequest;
interface nsIStreamListener;
interface nsIInputStream;
typedef long nsURILoadCommand;
[scriptable, uuid(40AECB53-8B65-11d3-989D-001083010E9B)]
interface nsIURILoader : nsISupports
{
@ -84,56 +82,52 @@ 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
you want to give first crack to, the uri loader needs to be able
to get it from the window context (we'll use nsIInterfaceRequestor).
we will also be using nsIInterfaceRequestor to get at the progress event
sink interface.
aReferringURI --> if a uri referral was involved....
aCommand --> should the content be displayed in a container that prefers
the content-type, or will any container do...
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 you want to give first crack to, the
uri loader needs to be able to get it from the window
context (we'll use nsIInterfaceRequestor). we will
also be using nsIInterfaceRequestor to get at the
progress event sink interface.
*/
void openURI(in nsIChannel aChannel,
in nsURILoadCommand aCommand,
in nsISupports aWindowContext);
void openURI(in nsIChannel aChannel,
in boolean aIsContentPreferred,
in nsISupports aWindowContext);
/* same call as OpenURI except this one takes an IP address to use as well...
adapterBinding -> the local IP address to bind to*/
adapterBinding -> the local IP address to bind to
*/
void openURIVia(in nsIChannel aChannel,
in nsURILoadCommand aCommand,
in nsISupports aWindowContext,
in unsigned long adapterBinding);
in boolean aIsContentPreferred,
in nsISupports aWindowContext,
in unsigned long adapterBinding);
/* stops an in progress load */
/* stops an in progress load
*/
void stop(in nsISupports aLoadCookie);
/* dirty little back door for sneaking the load group out in case you need
it to create the channel before calling openURI */
it to create the channel before calling openURI
*/
nsILoadGroup getLoadGroupForContext(in nsISupports aWindowContext);
nsIDocumentLoader getDocumentLoaderForContext (in nsISupports aWindowContext);
/* these are nsURILoadCommand */
const long viewNormal = 0;
const long viewUserClick = 7;
const long viewNormalBackground = 0;
/* mscott -> I'm going to move this out into a separate private interface
*/
void dispatchContent(in string aContentType,
in nsURILoadCommand aCommand,
in nsIRequest aRequest,
in nsISupports aCtxt,
in nsIURIContentListener aContentListener,
in nsISupports aSrcWindowContext,
out string aDesiredContentType,
out nsIURIContentListener aTargetListener,
out boolean abortDispatch);
in boolean aIsContentPreferred,
in nsIRequest aRequest,
in nsISupports aCtxt,
in nsIURIContentListener aContentListener,
in nsISupports aSrcWindowContext,
out string aDesiredContentType,
out nsIURIContentListener aTargetListener,
out boolean abortDispatch);
};

View File

@ -84,7 +84,7 @@ public:
NS_DECL_ISUPPORTS
nsresult Open(nsIChannel* channel,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsISupports * aWindowContext);
nsresult DispatchContent(nsIRequest *request, nsISupports * aCtxt);
@ -109,7 +109,7 @@ protected:
nsCOMPtr<nsIURIContentListener> m_contentListener;
nsCOMPtr<nsIStreamListener> m_targetStreamListener;
nsCOMPtr<nsISupports> m_originalContext;
nsURILoadCommand mCommand;
PRBool mIsContentPreferred;
};
NS_IMPL_THREADSAFE_ADDREF(nsDocumentOpenInfo);
@ -136,9 +136,9 @@ nsDocumentOpenInfo* nsDocumentOpenInfo::Clone()
newObject = new nsDocumentOpenInfo();
if (newObject) {
newObject->m_contentListener = m_contentListener;
newObject->mCommand = mCommand;
newObject->m_originalContext = m_originalContext;
newObject->m_contentListener = m_contentListener;
newObject->mIsContentPreferred = mIsContentPreferred;
newObject->m_originalContext = m_originalContext;
}
return newObject;
@ -172,7 +172,7 @@ PRBool nsDocumentOpenInfo::ProcessCanceledCase(nsIRequest *request)
}
nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsISupports * aWindowContext)
{
// this method is not complete!!! Eventually, we should first go
@ -182,10 +182,10 @@ nsresult nsDocumentOpenInfo::Open(nsIChannel *aChannel,
// But for now, I'm going to let necko do the work for us....
nsresult rv = NS_OK;
nsresult rv;
// store any local state
mCommand = aCommand;
mIsContentPreferred = aIsContentPreferred;
m_originalContext = aWindowContext;
@ -301,7 +301,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
// content type.
//
PRBool abortDispatch = PR_FALSE;
rv = uriLoader->DispatchContent(contentType, mCommand,
rv = uriLoader->DispatchContent(contentType, mIsContentPreferred,
request, aCtxt,
m_contentListener,
m_originalContext,
@ -362,8 +362,10 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
aChannel->SetLoadFlags(loadFlags);
}
rv = contentListener->DoContent(contentTypeToUse.get(), mCommand,
request, getter_AddRefs(contentStreamListener),
rv = contentListener->DoContent(contentTypeToUse.get(),
mIsContentPreferred,
request,
getter_AddRefs(contentStreamListener),
&bAbortProcess);
// Do not continue loading if nsIURIContentListener::DoContent(...)
@ -376,7 +378,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
}
// try to detect if there is a helper application we an use...
if (/* mCommand == nsIURILoader::viewUserClick && */ !contentStreamListener)
if (!contentStreamListener)
{
nsCOMPtr<nsIURI> uri;
PRBool abortProcess = PR_FALSE;
@ -500,14 +502,15 @@ NS_IMETHODIMP nsURILoader::UnRegisterContentListener(nsIURIContentListener * aCo
}
NS_IMETHODIMP nsURILoader::OpenURI(nsIChannel *channel,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsISupports * aWindowContext)
{
return OpenURIVia(channel, aCommand, aWindowContext, 0 /* ip address */);
return OpenURIVia(channel, aIsContentPreferred, aWindowContext,
0 /* ip address */);
}
NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsISupports * aWindowContext,
PRUint32 aLocalIP)
{
@ -542,7 +545,7 @@ NS_IMETHODIMP nsURILoader::OpenURIVia(nsIChannel *channel,
SetupLoadCookie(aWindowContext, getter_AddRefs(loadCookie));
// now instruct the loader to go ahead and open the url
rv = loader->Open(channel, aCommand, aWindowContext);
rv = loader->Open(channel, aIsContentPreferred, aWindowContext);
NS_RELEASE(loader);
return rv;
@ -673,23 +676,24 @@ nsresult nsURILoader::SetupLoadCookie(nsISupports * aWindowContext,
PRBool nsURILoader::ShouldHandleContent(nsIURIContentListener * aCntListener,
const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char ** aContentTypeToUse)
{
PRBool foundContentHandler = PR_FALSE;
if (aCommand == nsIURILoader::viewUserClick)
aCntListener->IsPreferred(aContentType, aCommand,
aContentTypeToUse,
&foundContentHandler);
else
aCntListener->CanHandleContent(aContentType, aCommand,
if (aIsContentPreferred) {
aCntListener->IsPreferred(aContentType,
aContentTypeToUse,
&foundContentHandler);
} else {
aCntListener->CanHandleContent(aContentType, PR_FALSE,
aContentTypeToUse,
&foundContentHandler);
}
return foundContentHandler;
}
NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsIRequest *request,
nsISupports * aCtxt,
nsIURIContentListener * aContentListener,
@ -722,7 +726,7 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
if (listenerToUse)
foundContentHandler = ShouldHandleContent(listenerToUse,
aContentType,
aCommand,
aIsContentPreferred,
aContentTypeToUse);
@ -749,7 +753,7 @@ NS_IMETHODIMP nsURILoader::DispatchContent(const char * aContentType,
{
foundContentHandler = ShouldHandleContent(listener,
aContentType,
aCommand,
aIsContentPreferred,
aContentTypeToUse);
if (foundContentHandler) {
listenerToUse = listener;

View File

@ -67,7 +67,7 @@ protected:
// a small helper function
PRBool ShouldHandleContent(nsIURIContentListener * aCntListener,
const char * aContentType,
nsURILoadCommand aCommand,
PRBool bIsContentPreferred,
char ** aContentTypeToUse);
};

View File

@ -1282,7 +1282,6 @@ nsExternalAppHandler::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
NS_IMETHODIMP
nsExternalAppHandler::IsPreferred(const char * aContentType,
nsURILoadCommand aCommand,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
@ -1293,7 +1292,7 @@ nsExternalAppHandler::IsPreferred(const char * aContentType,
NS_IMETHODIMP
nsExternalAppHandler::CanHandleContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
@ -1304,7 +1303,7 @@ nsExternalAppHandler::CanHandleContent(const char * aContentType,
NS_IMETHODIMP
nsExternalAppHandler::DoContent(const char * aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsIRequest * aRequest,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)

View File

@ -109,7 +109,7 @@ nsBrowserContentListener.prototype =
return false;
},
doContent: function(contentType, command, request, contentHandler)
doContent: function(contentType, isContentPrefered, request, contentHandler)
{
// forward the doContent to our content area webshell
var docShell = this.contentWindow.docShell;
@ -124,11 +124,11 @@ nsBrowserContentListener.prototype =
if (!contentListener) return false;
return contentListener.doContent(contentType, command, request, contentHandler);
return contentListener.doContent(contentType, isContentPreferred, request, contentHandler);
},
isPreferred: function(contentType, command, desiredContentType)
isPreferred: function(contentType, desiredContentType)
{
// seems like we should be getting this from helper apps or something
switch(contentType) {
@ -147,7 +147,7 @@ nsBrowserContentListener.prototype =
}
return false;
},
canHandleContent: function(contentType, command, desiredContentType)
canHandleContent: function(contentType, isContentPreferred, desiredContentType)
{
var docShell = this.contentWindow.docShell;
var contentListener;
@ -159,7 +159,7 @@ nsBrowserContentListener.prototype =
}
if (!contentListener) return false;
return contentListener.canHandleContent(contentType, command, desiredContentType);
return contentListener.canHandleContent(contentType, isContentPreferred, desiredContentType);
},
convertWindowToDocShell: function(win) {
// don't know how to do this

View File

@ -43,7 +43,7 @@ XRemoteContentListener::OnStartURIOpen(nsIURI *aURI, PRBool *_retval)
NS_IMETHODIMP
XRemoteContentListener::DoContent(const char *aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
nsIRequest *request,
nsIStreamListener **aContentHandler,
PRBool *_retval)
@ -54,7 +54,6 @@ XRemoteContentListener::DoContent(const char *aContentType,
NS_IMETHODIMP
XRemoteContentListener::IsPreferred(const char *aContentType,
nsURILoadCommand aCommand,
char **aDesiredContentType,
PRBool *_retval)
{
@ -63,7 +62,7 @@ XRemoteContentListener::IsPreferred(const char *aContentType,
NS_IMETHODIMP
XRemoteContentListener::CanHandleContent(const char *aContentType,
nsURILoadCommand aCommand,
PRBool aIsContentPreferred,
char **aDesiredContentType,
PRBool *_retval)
{