Implement backend changes for web-based protocol handlers a la WhatWG HTML5 draft (bug 380415). r=cbiesinger@gmx.at, sr=jonas@sicking.cc
git-svn-id: svn://10.0.0.236/trunk@227015 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
61289e581a
commit
3dc245e9c4
@ -62,9 +62,9 @@ nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService()
|
||||
nsOSHelperAppService::~nsOSHelperAppService()
|
||||
{}
|
||||
|
||||
NS_IMETHODIMP nsOSHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
{
|
||||
LOG(("-- nsOSHelperAppService::ExternalProtocolHandlerExists for '%s'\n",
|
||||
LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n",
|
||||
aProtocolScheme));
|
||||
// look up the protocol scheme in the MIME database
|
||||
*aHandlerExists = PR_FALSE;
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, PRBool *aFound);
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
NS_IMETHOD ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
nsresult LoadUriInternal(nsIURI * aURL);
|
||||
|
||||
protected:
|
||||
|
||||
@ -74,7 +74,7 @@ nsOSHelperAppService::nsOSHelperAppService() : nsExternalHelperAppService()
|
||||
nsOSHelperAppService::~nsOSHelperAppService()
|
||||
{}
|
||||
|
||||
NS_IMETHODIMP nsOSHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
{
|
||||
// look up the protocol scheme in Internet Config....if we find a match then we have a handler for it...
|
||||
*aHandlerExists = PR_FALSE;
|
||||
|
||||
@ -56,7 +56,6 @@ public:
|
||||
virtual ~nsOSHelperAppService();
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
NS_IMETHOD ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
|
||||
nsresult LoadUriInternal(nsIURI * aURL);
|
||||
|
||||
@ -69,11 +68,13 @@ public:
|
||||
// rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform
|
||||
// aFile --> an nsIFile representation of that platform application path.
|
||||
virtual nsresult GetFileTokenForPath(const PRUnichar * platformAppPath, nsIFile ** aFile);
|
||||
|
||||
|
||||
nsresult OSProtocolHandlerExists(const char * aScheme,
|
||||
PRBool * aHandlerExists);
|
||||
|
||||
protected:
|
||||
// add any mac specific service state here
|
||||
void UpdateCreatorInfo(nsIMIMEInfo * aMIMEInfo);
|
||||
|
||||
};
|
||||
|
||||
#endif // nsOSHelperAppService_h__
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
* Scott MacGregor <mscott@netscape.com>
|
||||
* Bill Law <law@netscape.com>
|
||||
* Christian Biesinger <cbiesinger@web.de>
|
||||
* Dan Mosedale <dmose@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -142,7 +143,7 @@ static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
/**
|
||||
* Contains a pointer to the helper app service, set in its constructor
|
||||
*/
|
||||
static nsExternalHelperAppService* sSrv;
|
||||
nsExternalHelperAppService* gExtProtSvc;
|
||||
|
||||
// Helper functions for Content-Disposition headers
|
||||
|
||||
@ -492,7 +493,7 @@ NS_IMPL_ISUPPORTS6(
|
||||
nsExternalHelperAppService::nsExternalHelperAppService()
|
||||
: mDataSourceInitialized(PR_FALSE)
|
||||
{
|
||||
sSrv = this;
|
||||
gExtProtSvc = this;
|
||||
}
|
||||
nsresult nsExternalHelperAppService::Init()
|
||||
{
|
||||
@ -514,7 +515,7 @@ nsresult nsExternalHelperAppService::Init()
|
||||
|
||||
nsExternalHelperAppService::~nsExternalHelperAppService()
|
||||
{
|
||||
sSrv = nsnull;
|
||||
gExtProtSvc = nsnull;
|
||||
}
|
||||
|
||||
nsresult nsExternalHelperAppService::InitDataSource()
|
||||
@ -1051,9 +1052,17 @@ nsresult nsExternalHelperAppService::GetFileTokenForPath(const PRUnichar * aPlat
|
||||
NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme,
|
||||
PRBool * aHandlerExists)
|
||||
{
|
||||
// this method should only be implemented by each OS specific implementation of this service.
|
||||
*aHandlerExists = PR_FALSE;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
// check for web-based handler
|
||||
nsCAutoString uriTemplate;
|
||||
nsresult rv = GetWebProtocolHandlerURITemplate(
|
||||
nsDependentCString(aProtocolScheme), uriTemplate);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
*aHandlerExists = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// fall back on an os-based handler
|
||||
return OSProtocolHandlerExists(aProtocolScheme, aHandlerExists);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExternalHelperAppService::IsExposedProtocol(const char * aProtocolScheme, PRBool * aResult)
|
||||
@ -1106,8 +1115,8 @@ class nsExternalLoadRequest : public nsRunnable {
|
||||
: mURI(uri), mPrompt(prompt) {}
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
if (sSrv && sSrv->isExternalLoadOK(mURI, mPrompt))
|
||||
sSrv->LoadUriInternal(mURI);
|
||||
if (gExtProtSvc && gExtProtSvc->isExternalLoadOK(mURI, mPrompt))
|
||||
gExtProtSvc->LoadUriInternal(mURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1366,6 +1375,42 @@ nsresult nsExternalHelperAppService::ExpungeTemporaryFiles()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsExternalHelperAppService::GetWebProtocolHandlerURITemplate(const nsACString &aScheme,
|
||||
nsACString &aUriTemplate)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID,
|
||||
&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// before we expose this to the UI, we need sort out our strategy re
|
||||
// the "warning" and "exposed" prefs
|
||||
|
||||
// XXX enterprise customers should be able to turn this support off with a
|
||||
// single master pref (maybe use one of the "exposed" prefs here?)
|
||||
|
||||
// do we have an automatic handler for this protocol?
|
||||
nsCAutoString autoTemplatePref("network.protocol-handler.web.auto.");
|
||||
autoTemplatePref += aScheme;
|
||||
|
||||
nsCAutoString autoTemplate;
|
||||
rv = prefBranch->GetCharPref(autoTemplatePref.get(),
|
||||
getter_Copies(autoTemplate));
|
||||
// if so, return it.
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aUriTemplate.Assign(autoTemplate);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX since there's no automatic handler, if we have any choices, offer them
|
||||
// up as well as including the option to make one of the choices automatic.
|
||||
// do so by returning "about:protoHandlerChooser?uri=%s" as the template or
|
||||
// perhaps by opening a dialog
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// XPCOM profile change observer
|
||||
NS_IMETHODIMP
|
||||
nsExternalHelperAppService::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData )
|
||||
@ -1431,13 +1476,13 @@ nsExternalAppHandler::nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo,
|
||||
// Make sure extension is correct.
|
||||
EnsureSuggestedFileName();
|
||||
|
||||
sSrv->AddRef();
|
||||
gExtProtSvc->AddRef();
|
||||
}
|
||||
|
||||
nsExternalAppHandler::~nsExternalAppHandler()
|
||||
{
|
||||
// Not using NS_RELEASE, since we don't want to set sSrv to NULL
|
||||
sSrv->Release();
|
||||
// Not using NS_RELEASE, since we don't want to set gExtProtSvc to NULL
|
||||
gExtProtSvc->Release();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExternalAppHandler::SetWebProgressListener(nsIWebProgressListener2 * aWebProgressListener)
|
||||
@ -1755,10 +1800,9 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
|
||||
rv = encEnum->GetNext(encType);
|
||||
if (NS_SUCCEEDED(rv) && !encType.IsEmpty())
|
||||
{
|
||||
NS_ASSERTION(sSrv, "Where did the service go?");
|
||||
sSrv->ApplyDecodingForExtension(extension,
|
||||
encType,
|
||||
&applyConversion);
|
||||
NS_ASSERTION(gExtProtSvc, "Where did the service go?");
|
||||
gExtProtSvc->ApplyDecodingForExtension(extension, encType,
|
||||
&applyConversion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1791,8 +1835,8 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
|
||||
// at some point in the distant past that they don't
|
||||
// want to be asked. The latter fact would have been
|
||||
// stored in pref strings back in the old days.
|
||||
NS_ASSERTION(sSrv, "Service gone away!?");
|
||||
if (!sSrv->MIMETypeIsInDataSource(MIMEType.get()))
|
||||
NS_ASSERTION(gExtProtSvc, "Service gone away!?");
|
||||
if (!gExtProtSvc->MIMETypeIsInDataSource(MIMEType.get()))
|
||||
{
|
||||
if (!GetNeverAskFlagFromPref(NEVER_ASK_FOR_SAVE_TO_DISK_PREF, MIMEType.get()))
|
||||
{
|
||||
@ -2148,7 +2192,7 @@ nsresult nsExternalAppHandler::ExecuteDesiredAction()
|
||||
if (NS_SUCCEEDED(rv) && action == nsIMIMEInfo::saveToDisk)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> destfile(do_QueryInterface(mFinalFileDestination));
|
||||
sSrv->FixFilePermissions(destfile);
|
||||
gExtProtSvc->FixFilePermissions(destfile);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2454,8 +2498,8 @@ nsresult nsExternalAppHandler::OpenWithApplication()
|
||||
#endif
|
||||
}
|
||||
if (deleteTempFileOnExit) {
|
||||
NS_ASSERTION(sSrv, "Service gone away!?");
|
||||
sSrv->DeleteTemporaryFileOnExit(mFinalFileDestination);
|
||||
NS_ASSERTION(gExtProtSvc, "Service gone away!?");
|
||||
gExtProtSvc->DeleteTemporaryFileOnExit(mFinalFileDestination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
* Contributor(s):
|
||||
* Scott MacGregor <mscott@netscape.com>
|
||||
* Christian Biesinger <cbiesinger@web.de>
|
||||
* Dan Mosedale <dmose@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -191,6 +192,16 @@ public:
|
||||
*/
|
||||
NS_HIDDEN_(PRBool) MIMETypeIsInDataSource(const char * aContentType);
|
||||
|
||||
/**
|
||||
* Return the URI template for any configured web handler. This will
|
||||
* probably be replaced by something on nsIWebContentConverterService soon.
|
||||
*/
|
||||
static NS_HIDDEN_(nsresult) GetWebProtocolHandlerURITemplate(const nsACString &aScheme,
|
||||
nsACString &aUriTemplate);
|
||||
|
||||
virtual NS_HIDDEN_(nsresult) OSProtocolHandlerExists(const char *aScheme,
|
||||
PRBool *aExists) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Pointer to the datasource that contains the user override information.
|
||||
@ -512,4 +523,6 @@ protected:
|
||||
nsIRequest* mRequest;
|
||||
};
|
||||
|
||||
extern NS_HIDDEN_(nsExternalHelperAppService*) gExtProtSvc;
|
||||
|
||||
#endif // nsExternalHelperAppService_h__
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott MacGregor <mscott@netscape.com>
|
||||
* Dan Mosedale <dmose@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -52,6 +53,10 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIChannelEventSink.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsExternalHelperAppService.h"
|
||||
|
||||
// used to dispatch urls to default protocol handlers
|
||||
#include "nsCExternalHandlerService.h"
|
||||
@ -64,8 +69,9 @@
|
||||
|
||||
class nsExtProtocolChannel : public nsIChannel
|
||||
{
|
||||
public:
|
||||
friend class nsWebProtocolRedirect;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICHANNEL
|
||||
NS_DECL_NSIREQUEST
|
||||
@ -81,6 +87,7 @@ private:
|
||||
nsCOMPtr<nsIURI> mUrl;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsresult mStatus;
|
||||
nsLoadFlags mLoadFlags;
|
||||
|
||||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
@ -158,7 +165,7 @@ nsresult nsExtProtocolChannel::SetURI(nsIURI* aURI)
|
||||
mUrl = aURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsExtProtocolChannel::OpenURL()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
@ -192,20 +199,152 @@ NS_IMETHODIMP nsExtProtocolChannel::Open(nsIInputStream **_retval)
|
||||
return NS_ERROR_NO_CONTENT; // force caller to abort.
|
||||
}
|
||||
|
||||
class nsWebProtocolRedirect : public nsRunnable {
|
||||
public:
|
||||
nsWebProtocolRedirect(nsIURI *aURI, const nsACString & aUriTemplate,
|
||||
nsIStreamListener *aListener, nsISupports *aContext,
|
||||
nsExtProtocolChannel *aOriginalChannel)
|
||||
: mURI(aURI), mUriTemplate(aUriTemplate), mListener(aListener),
|
||||
mContext(aContext), mOriginalChannel(aOriginalChannel) {}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
// get the URI spec so we can escape it for insertion into the template
|
||||
nsCAutoString uriSpecToHandle;
|
||||
nsresult rv = mURI->GetSpec(uriSpecToHandle);
|
||||
if (NS_FAILED(rv)) {
|
||||
AbandonOriginalChannel(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX need to strip passwd & username from URI to handle, as per the
|
||||
// WhatWG HTML5 draft. nsSimpleURL, which is what we're going to get,
|
||||
// can't do this directly. Ideally, we'd fix nsStandardURL to make it
|
||||
// possible to turn off all of its quirks handling, and use that...
|
||||
|
||||
// XXX this doesn't exactly match how the HTML5 draft is requesting us to
|
||||
// escape; at the very least, it should be escaping @ signs, and there
|
||||
// may well be more issues. However, this code will probably be thrown
|
||||
// out when we do the front-end work, as we'll be using a refactored
|
||||
// nsIWebContentConverterInfo to do this work for us
|
||||
nsCAutoString escapedUriSpecToHandle;
|
||||
NS_EscapeURL(uriSpecToHandle, esc_Minimal | esc_Forced | esc_Colon,
|
||||
escapedUriSpecToHandle);
|
||||
|
||||
// Note that this replace all occurrences of %s with the URL to be
|
||||
// handled. The HTML5 draft doesn't prohibit %s from occurring more than
|
||||
// once, and if it does, I can't think of any problems that could
|
||||
// cause, (though I don't know why anyone would need or want to do it).
|
||||
mUriTemplate.ReplaceSubstring(NS_LITERAL_CSTRING("%s"),
|
||||
escapedUriSpecToHandle);
|
||||
|
||||
// convert spec to URI; no original charset needed since there's no way
|
||||
// to communicate that information to any handler
|
||||
nsCOMPtr<nsIURI> uriToSend;
|
||||
rv = NS_NewURI(getter_AddRefs(uriToSend), mUriTemplate);
|
||||
if (NS_FAILED(rv)) {
|
||||
AbandonOriginalChannel(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// create a channel
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
rv = NS_NewChannel(getter_AddRefs(newChannel), uriToSend, nsnull,
|
||||
mOriginalChannel->mLoadGroup,
|
||||
mOriginalChannel->mCallbacks,
|
||||
mOriginalChannel->mLoadFlags);
|
||||
if (NS_FAILED(rv)) {
|
||||
AbandonOriginalChannel(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannelEventSink> eventSink;
|
||||
NS_QueryNotificationCallbacks(mOriginalChannel->mCallbacks,
|
||||
mOriginalChannel->mLoadGroup, eventSink);
|
||||
|
||||
if (eventSink) {
|
||||
// XXX decide on and audit for correct session & global hist behavior
|
||||
rv = eventSink->OnChannelRedirect(mOriginalChannel, newChannel,
|
||||
nsIChannelEventSink::REDIRECT_TEMPORARY |
|
||||
nsIChannelEventSink::REDIRECT_INTERNAL);
|
||||
if (NS_FAILED(rv)) {
|
||||
AbandonOriginalChannel(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
rv = newChannel->AsyncOpen(mListener, mContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
AbandonOriginalChannel(rv);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mOriginalChannel->mStatus = NS_BINDING_REDIRECTED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCString mUriTemplate;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
nsCOMPtr<nsISupports> mContext;
|
||||
nsCOMPtr<nsExtProtocolChannel> mOriginalChannel;
|
||||
|
||||
// necko guarantees that after an AsyncOpen has succeeded, OnStartRequest
|
||||
// and OnStopRequest will get called
|
||||
void AbandonOriginalChannel(const nsresult aStatus)
|
||||
{
|
||||
mOriginalChannel->mStatus = aStatus;
|
||||
(void)mListener->OnStartRequest(mOriginalChannel, mContext);
|
||||
(void)mListener->OnStopRequest(mOriginalChannel, mContext, aStatus);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctxt)
|
||||
{
|
||||
// check whether the scheme is one that we have a web handler for
|
||||
nsCAutoString urlScheme;
|
||||
nsresult rv = mUrl->GetScheme(urlScheme);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIExternalProtocolService> extProtService =
|
||||
do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCAutoString uriTemplate;
|
||||
rv = nsExternalHelperAppService::GetWebProtocolHandlerURITemplate(urlScheme,
|
||||
uriTemplate);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
// redirecting to the web handler involvegs calling OnChannelRedirect,
|
||||
// which is supposed to happen after AsyncOpen completes, so we do it in an
|
||||
// event
|
||||
nsCOMPtr<nsIRunnable> event = new nsWebProtocolRedirect(mUrl, uriTemplate,
|
||||
listener, ctxt,
|
||||
this);
|
||||
rv = NS_DispatchToCurrentThread(event);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// try for an OS-provided handler
|
||||
OpenURL();
|
||||
return NS_ERROR_NO_CONTENT; // force caller to abort.
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::GetLoadFlags(nsLoadFlags *aLoadFlags)
|
||||
{
|
||||
*aLoadFlags = 0;
|
||||
*aLoadFlags = mLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::SetLoadFlags(nsLoadFlags aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -260,8 +399,7 @@ NS_IMETHODIMP nsExtProtocolChannel::SetOwner(nsISupports * aPrincipal)
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::GetName(nsACString &result)
|
||||
{
|
||||
NS_NOTREACHED("nsExtProtocolChannel::GetName");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return mUrl->GetSpec(result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExtProtocolChannel::IsPending(PRBool *result)
|
||||
@ -301,7 +439,6 @@ NS_IMETHODIMP nsExtProtocolChannel::Resume()
|
||||
nsExternalProtocolHandler::nsExternalProtocolHandler()
|
||||
{
|
||||
m_schemeName = "default";
|
||||
m_extProtService = do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID);
|
||||
}
|
||||
|
||||
|
||||
@ -338,15 +475,15 @@ nsExternalProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_
|
||||
return NS_OK;
|
||||
}
|
||||
// returns TRUE if the OS can handle this protocol scheme and false otherwise.
|
||||
PRBool nsExternalProtocolHandler::HaveProtocolHandler(nsIURI * aURI)
|
||||
PRBool nsExternalProtocolHandler::HaveOSProtocolHandler(nsIURI * aURI)
|
||||
{
|
||||
PRBool haveHandler = PR_FALSE;
|
||||
if (aURI)
|
||||
{
|
||||
nsCAutoString scheme;
|
||||
aURI->GetScheme(scheme);
|
||||
if (m_extProtService)
|
||||
m_extProtService->ExternalProtocolHandlerExists(scheme.get(), &haveHandler);
|
||||
if (gExtProtSvc)
|
||||
gExtProtSvc->OSProtocolHandlerExists(scheme.get(), &haveHandler);
|
||||
}
|
||||
|
||||
return haveHandler;
|
||||
@ -380,8 +517,8 @@ NS_IMETHODIMP nsExternalProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_
|
||||
{
|
||||
// only try to return a channel if we have a protocol handler for the url
|
||||
|
||||
PRBool haveHandler = HaveProtocolHandler(aURI);
|
||||
if (haveHandler)
|
||||
PRBool haveOSHandler = HaveOSProtocolHandler(aURI);
|
||||
if (haveOSHandler)
|
||||
{
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
NS_NEWXPCOM(channel, nsExtProtocolChannel);
|
||||
@ -406,8 +543,9 @@ NS_IMETHODIMP nsExternalProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHODIMP nsExternalProtocolHandler::ExternalAppExistsForScheme(const nsACString& aScheme, PRBool *_retval)
|
||||
{
|
||||
if (m_extProtService)
|
||||
return m_extProtService->ExternalProtocolHandlerExists(PromiseFlatCString(aScheme).get(), _retval);
|
||||
if (gExtProtSvc)
|
||||
return gExtProtSvc->ExternalProtocolHandlerExists(
|
||||
PromiseFlatCString(aScheme).get(), _retval);
|
||||
|
||||
// In case we don't have external protocol service.
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott MacGregor <mscott@netscape.com>
|
||||
* Dan Mosedale <dmose@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
@ -61,7 +62,7 @@ public:
|
||||
|
||||
protected:
|
||||
// helper function
|
||||
PRBool HaveProtocolHandler(nsIURI * aURI);
|
||||
PRBool HaveOSProtocolHandler(nsIURI * aURI);
|
||||
nsCString m_schemeName;
|
||||
nsCOMPtr<nsIExternalProtocolService> m_extProtService;
|
||||
};
|
||||
|
||||
@ -45,7 +45,8 @@ interface nsIPrompt;
|
||||
|
||||
/**
|
||||
* The external protocol service is used for finding and launching
|
||||
* platform specific applications for particular protocols.
|
||||
* web handlers (a la registerProtocolHandler in the HTML5 draft) or
|
||||
* platform-specific applications for handling particular protocols.
|
||||
*
|
||||
* You can ask the external protocol service if it has an external
|
||||
* handler for a given protocol scheme. And you can ask it to load
|
||||
|
||||
@ -1240,9 +1240,9 @@ nsOSHelperAppService::GetApplicationAndParametersFromINI(const nsACString& aProt
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOSHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
{
|
||||
LOG(("-- nsOSHelperAppService::ExternalProtocolHandlerExists for '%s'\n",
|
||||
LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n",
|
||||
aProtocolScheme));
|
||||
*aHandlerExists = PR_FALSE;
|
||||
|
||||
|
||||
@ -64,10 +64,10 @@ public:
|
||||
PRBool *aFound);
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
NS_IMETHOD ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
nsresult LoadUriInternal(nsIURI * aURL);
|
||||
NS_IMETHODIMP GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
|
||||
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
protected:
|
||||
already_AddRefed<nsMIMEInfoOS2> GetFromType(const nsCString& aMimeType);
|
||||
already_AddRefed<nsMIMEInfoOS2> GetFromExtension(const nsCString& aFileExt);
|
||||
|
||||
@ -1233,9 +1233,9 @@ nsOSHelperAppService::GetHandlerAppFromPrefs(const char* aScheme, /*out*/ nsIFil
|
||||
return GetFileTokenForPath(utf16AppPath.get(), aApp);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOSHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
{
|
||||
LOG(("-- nsOSHelperAppService::ExternalProtocolHandlerExists for '%s'\n",
|
||||
LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n",
|
||||
aProtocolScheme));
|
||||
*aHandlerExists = PR_FALSE;
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ public:
|
||||
PRBool *aFound);
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
NS_IMETHOD ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
nsresult LoadUriInternal(nsIURI * aURL);
|
||||
NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
|
||||
|
||||
|
||||
@ -137,7 +137,7 @@ static nsresult GetExtensionFrom4xRegistryInfo(const nsACString& aMimeType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOSHelperAppService::ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
|
||||
{
|
||||
// look up the protocol scheme in the windows registry....if we find a match then we have a handler for it...
|
||||
*aHandlerExists = PR_FALSE;
|
||||
|
||||
@ -57,7 +57,7 @@ public:
|
||||
virtual ~nsOSHelperAppService();
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
NS_IMETHOD ExternalProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
nsresult LoadUriInternal(nsIURI * aURL);
|
||||
NS_IMETHOD GetApplicationDescription(const nsACString& aScheme, nsAString& _retval);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user