mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 388701 - nsExternalHelperAppService::GetProtocolHandlerInfo should get OS Specific implementation. r=cbiesinger, sr=dmose
This commit is contained in:
parent
4b82f11407
commit
0b400b90ca
@ -264,3 +264,25 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACS
|
||||
|
||||
return mi;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIHandlerInfo>
|
||||
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
|
||||
{
|
||||
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
|
||||
|
||||
PRBool exists;
|
||||
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
|
||||
&exists);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsMIMEInfoBeOS *handlerInfo = new nsMIMEInfoBeOS();
|
||||
NS_ENSURE_TRUE(handlerInfo, nsnull);
|
||||
NS_ADDREF(handlerInfo);
|
||||
|
||||
nsAutoString desc;
|
||||
GetApplicationDescription(aScheme, desc);
|
||||
handlerInfo->SetDefaultDescription(desc);
|
||||
|
||||
return handlerInfo;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
virtual ~nsOSHelperAppService();
|
||||
|
||||
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, PRBool *aFound);
|
||||
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
|
@ -333,6 +333,27 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
|
||||
return mimeInfo;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIHandlerInfo>
|
||||
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
|
||||
{
|
||||
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
|
||||
|
||||
PRBool exists;
|
||||
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
|
||||
&exists);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsMIMEInfoMac *handlerInfo = new nsMIMEInfoMac();
|
||||
NS_ENSURE_TRUE(handlerInfo, nsnull);
|
||||
NS_ADDREF(handlerInfo);
|
||||
|
||||
nsAutoString desc;
|
||||
GetApplicationDescription(aScheme, desc);
|
||||
handlerInfo->SetDefaultDescription(desc);
|
||||
|
||||
return handlerInfo;
|
||||
}
|
||||
|
||||
// we never want to use a hard coded value for the creator and file type for the mac. always look these values up
|
||||
// from internet config.
|
||||
void nsOSHelperAppService::UpdateCreatorInfo(nsIMIMEInfo * aMIMEInfo)
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
// method overrides --> used to hook the mime service into internet config....
|
||||
NS_IMETHOD GetFromTypeAndExtension(const nsACString& aType, const nsACString& aFileExt, nsIMIMEInfo ** aMIMEInfo);
|
||||
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, PRBool * aFound);
|
||||
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
|
||||
|
||||
// GetFileTokenForPath must be implemented by each platform.
|
||||
// platformAppPath --> a platform specific path to an application that we got out of the
|
||||
|
@ -1476,18 +1476,26 @@ nsExternalHelperAppService::GetProtocolHandlerInfo(const nsACString &aScheme,
|
||||
// and subclasses have lots of good platform specific-knowledge of local
|
||||
// applications which we might need later. For now, just use nsMIMEInfoImpl
|
||||
// instead of implementating a separate nsIHandlerInfo object.
|
||||
nsMIMEInfoImpl *mimeInfo = new nsMIMEInfoImpl;
|
||||
if (!mimeInfo) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aHandlerInfo = GetProtocolInfoFromOS(aScheme).get();
|
||||
if (!aHandlerInfo) {
|
||||
// Either it knows nothing, or we ran out of memory
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ADDREF(*aHandlerInfo = mimeInfo);
|
||||
|
||||
|
||||
nsresult rv = FillProtoInfoForSchemeFromDS(aScheme, *aHandlerInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_ERROR_NOT_AVAILABLE == rv) {
|
||||
// We don't know it, so we always ask the user. By the time we call this
|
||||
// method, we already have checked if we should open this protocol and ask
|
||||
// the user, so these defaults are OK.
|
||||
// XXX this is a bit different than the MIME system, so we may want to look
|
||||
// into this more in the future.
|
||||
(*aHandlerInfo)->SetPreferredAction(nsIHandlerInfo::useSystemDefault);
|
||||
(*aHandlerInfo)->SetAlwaysAskBeforeHandling(PR_TRUE);
|
||||
} else if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(*aHandlerInfo);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -195,6 +195,15 @@ public:
|
||||
const nsACString& aFileExt,
|
||||
PRBool * aFound) = 0;
|
||||
|
||||
/**
|
||||
* Given a scheme, looks up the protocol info from the OS. This should be
|
||||
* overridden by each OS's implementation.
|
||||
*
|
||||
* @param aScheme The protocol scheme we are looking for.
|
||||
* @return An nsIHanderInfo for the protocol.
|
||||
*/
|
||||
virtual already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme) = 0;
|
||||
|
||||
/**
|
||||
* Given a string identifying an application, create an nsIFile representing
|
||||
* it. This function should look in $PATH for the application.
|
||||
|
@ -1673,6 +1673,27 @@ nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aType,
|
||||
return retval;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIHandlerInfo>
|
||||
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
|
||||
{
|
||||
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
|
||||
|
||||
PRBool exists;
|
||||
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
|
||||
&exists);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsMIMEInfoImpl *handlerInfo = new nsMIMEInfoImpl();
|
||||
NS_ENSURE_TRUE(handlerInfo, nsnull);
|
||||
NS_ADDREF(handlerInfo);
|
||||
|
||||
nsAutoString desc;
|
||||
GetApplicationDescription(aScheme, desc);
|
||||
handlerInfo->SetDefaultDescription(desc);
|
||||
|
||||
return handlerInfo;
|
||||
}
|
||||
|
||||
void
|
||||
nsOSHelperAppService::FixFilePermissions(nsILocalFile* aFile)
|
||||
{
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMimeType,
|
||||
const nsACString& aFileExt,
|
||||
PRBool *aFound);
|
||||
already_AddRefed<nsIHanderInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
|
||||
|
||||
// override nsIExternalProtocolService methods
|
||||
nsresult OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists);
|
||||
|
@ -587,3 +587,25 @@ already_AddRefed<nsIMIMEInfo> nsOSHelperAppService::GetMIMEInfoFromOS(const nsAC
|
||||
}
|
||||
return mi;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIHandlerInfo>
|
||||
nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
|
||||
{
|
||||
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
|
||||
|
||||
PRBool exists;
|
||||
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
|
||||
&exists);
|
||||
NS_ENSURE_SUCCESS(rv, nsnull);
|
||||
|
||||
nsMIMEInfoWin *handlerInfo = new nsMIMEInfoWin();
|
||||
NS_ENSURE_TRUE(handlerInfo, nsnull);
|
||||
NS_ADDREF(handlerInfo);
|
||||
|
||||
nsAutoString desc;
|
||||
GetApplicationDescription(aScheme, desc);
|
||||
handlerInfo->SetDefaultDescription(desc);
|
||||
|
||||
return handlerInfo;
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
|
||||
// method overrides for windows registry look up steps....
|
||||
already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMIMEType, const nsACString& aFileExt, PRBool *aFound);
|
||||
already_AddRefed<nsIHandlerInfo> GetProtocolInfoFromOS(const nsACString &aScheme);
|
||||
|
||||
/** Get the string value of a registry value and store it in result.
|
||||
* @return PR_TRUE on success, PR_FALSE on failure
|
||||
|
Loading…
Reference in New Issue
Block a user