mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1382323 - Remote OSProtocolHandlerExists. r=jld,smaug
MozReview-Commit-ID: Gml7cjbgUvK --HG-- extra : rebase_source : 6ee7dfc8b5c05aec1ed268011fbec2ef64760554
This commit is contained in:
parent
5fde947458
commit
bc7dfc9353
@ -1051,6 +1051,8 @@ description =
|
||||
description =
|
||||
[PHandlerService::FillHandlerInfo]
|
||||
description =
|
||||
[PHandlerService::ExistsForProtocol]
|
||||
description = bug 1382323
|
||||
[PHandlerService::Exists]
|
||||
description =
|
||||
[PHandlerService::GetTypeFromExtension]
|
||||
|
@ -154,6 +154,14 @@ NS_IMETHODIMP ContentHandlerService::Remove(nsIHandlerInfo *aHandlerInfo)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContentHandlerService::ExistsForProtocol(const nsACString& aProtocolScheme, bool* aRetval)
|
||||
{
|
||||
if (!mHandlerServiceChild->SendExistsForProtocol(nsCString(aProtocolScheme), aRetval)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ContentHandlerService::GetTypeFromExtension(const nsACString & aFileExtension, nsACString & _retval)
|
||||
{
|
||||
|
@ -1,7 +1,11 @@
|
||||
#include "mozilla/Logging.h"
|
||||
#include "HandlerServiceParent.h"
|
||||
#include "nsIHandlerService.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "ContentHandlerService.h"
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include "unix/nsGNOMERegistry.h"
|
||||
#endif
|
||||
|
||||
using mozilla::dom::HandlerInfo;
|
||||
using mozilla::dom::HandlerApp;
|
||||
@ -259,6 +263,19 @@ HandlerServiceParent::RecvExists(const HandlerInfo& aHandlerInfo,
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
HandlerServiceParent::RecvExistsForProtocol(const nsCString& aProtocolScheme,
|
||||
bool* aHandlerExists)
|
||||
{
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// Check the GNOME registry for a protocol handler
|
||||
*aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme.get());
|
||||
#else
|
||||
*aHandlerExists = false;
|
||||
#endif
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
HandlerServiceParent::RecvGetTypeFromExtension(const nsCString& aFileExtension,
|
||||
nsCString* type)
|
||||
|
@ -26,6 +26,9 @@ class HandlerServiceParent final : public mozilla::dom::PHandlerServiceParent
|
||||
virtual mozilla::ipc::IPCResult RecvGetTypeFromExtension(const nsCString& aFileExtension,
|
||||
nsCString* type) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvExistsForProtocol(const nsCString& aProtocolScheme,
|
||||
bool* aHandlerExists) override;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,6 +30,8 @@ parent:
|
||||
sync FillHandlerInfo(HandlerInfo aHandlerInfoData,
|
||||
nsCString aOverrideType)
|
||||
returns (HandlerInfo handlerInfoData);
|
||||
sync ExistsForProtocol(nsCString aProtocolScheme)
|
||||
returns (bool exists);
|
||||
sync Exists(HandlerInfo aHandlerInfo)
|
||||
returns (bool exists);
|
||||
sync GetTypeFromExtension(nsCString aFileExtension)
|
||||
|
@ -903,17 +903,17 @@ NS_IMETHODIMP nsExternalHelperAppService::ExternalProtocolHandlerExists(const ch
|
||||
nsCOMPtr<nsIHandlerInfo> handlerInfo;
|
||||
nsresult rv = GetProtocolHandlerInfo(nsDependentCString(aProtocolScheme),
|
||||
getter_AddRefs(handlerInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// See if we have any known possible handler apps for this
|
||||
nsCOMPtr<nsIMutableArray> possibleHandlers;
|
||||
handlerInfo->GetPossibleApplicationHandlers(getter_AddRefs(possibleHandlers));
|
||||
|
||||
// See if we have any known possible handler apps for this
|
||||
nsCOMPtr<nsIMutableArray> possibleHandlers;
|
||||
handlerInfo->GetPossibleApplicationHandlers(getter_AddRefs(possibleHandlers));
|
||||
|
||||
uint32_t length;
|
||||
possibleHandlers->GetLength(&length);
|
||||
if (length) {
|
||||
*aHandlerExists = true;
|
||||
return NS_OK;
|
||||
uint32_t length;
|
||||
possibleHandlers->GetLength(&length);
|
||||
if (length) {
|
||||
*aHandlerExists = true;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// if not, fall back on an os-based handler
|
||||
|
@ -120,4 +120,14 @@ interface nsIHandlerService : nsISupports
|
||||
* @returns the MIME type, if any; otherwise returns an empty string ("").
|
||||
*/
|
||||
ACString getTypeFromExtension(in ACString aFileExtension);
|
||||
|
||||
/**
|
||||
* Whether or not there is a handler known to the OS for the
|
||||
* specified protocol type.
|
||||
*
|
||||
* @param aProtocolScheme scheme to check for support
|
||||
*
|
||||
* @returns whether or not a handler exists
|
||||
*/
|
||||
boolean existsForProtocol(in ACString aProtocolScheme);
|
||||
};
|
||||
|
@ -7,11 +7,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(MOZ_ENABLE_CONTENTACTION)
|
||||
#include <contentaction/contentaction.h>
|
||||
#include <QString>
|
||||
#endif
|
||||
|
||||
#include "nsOSHelperAppService.h"
|
||||
#include "nsMIMEInfoUnix.h"
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
@ -32,6 +27,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "ContentHandlerService.h"
|
||||
#include "prenv.h" // for PR_GetEnv()
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -1132,25 +1128,24 @@ nsOSHelperAppService::GetHandlerAndDescriptionFromMailcapFile(const nsAString& a
|
||||
|
||||
nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, bool * aHandlerExists)
|
||||
{
|
||||
LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n",
|
||||
aProtocolScheme));
|
||||
*aHandlerExists = false;
|
||||
|
||||
#if defined(MOZ_ENABLE_CONTENTACTION)
|
||||
// libcontentaction requires character ':' after scheme
|
||||
ContentAction::Action action =
|
||||
ContentAction::Action::defaultActionForScheme(QString(aProtocolScheme) + ':');
|
||||
|
||||
if (action.isValid())
|
||||
*aHandlerExists = true;
|
||||
#endif
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!XRE_IsContentProcess()) {
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
// Check the GNOME registry for a protocol handler
|
||||
*aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
|
||||
// Check the GNOME registry for a protocol handler
|
||||
*aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
|
||||
#else
|
||||
*aHandlerExists = false;
|
||||
#endif
|
||||
} else {
|
||||
*aHandlerExists = false;
|
||||
nsCOMPtr<nsIHandlerService> handlerSvc = do_GetService(NS_HANDLERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && handlerSvc) {
|
||||
rv = handlerSvc->ExistsForProtocol(nsCString(aProtocolScheme), aHandlerExists);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
|
||||
|
Loading…
Reference in New Issue
Block a user