mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1773947 - Correctly set returned MIME type in GetMIMEInfoFromOS. r=haik,nika
Differential Revision: https://phabricator.services.mozilla.com/D149043
This commit is contained in:
parent
23b3bd73b9
commit
059cd7d495
@ -11,6 +11,8 @@
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsIStringEnumerator.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsMIMEInfoImpl.h"
|
||||
#include "nsMIMEInfoChild.h"
|
||||
|
||||
using mozilla::dom::ContentChild;
|
||||
using mozilla::dom::HandlerInfo;
|
||||
@ -168,12 +170,12 @@ NS_IMETHODIMP ContentHandlerService::FillHandlerInfo(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP ContentHandlerService::GetMIMEInfoFromOS(
|
||||
nsIHandlerInfo* aHandlerInfo, const nsACString& aMIMEType,
|
||||
const nsACString& aExtension, bool* aFound) {
|
||||
const nsACString& aMIMEType, const nsACString& aFileExt, bool* aFound,
|
||||
nsIMIMEInfo** aMIMEInfo) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
HandlerInfo returnedInfo;
|
||||
if (!mHandlerServiceChild->SendGetMIMEInfoFromOS(nsCString(aMIMEType),
|
||||
nsCString(aExtension), &rv,
|
||||
nsCString(aFileExt), &rv,
|
||||
&returnedInfo, aFound)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -182,7 +184,10 @@ NS_IMETHODIMP ContentHandlerService::GetMIMEInfoFromOS(
|
||||
return rv;
|
||||
}
|
||||
|
||||
CopyHandlerInfoTonsIHandlerInfo(returnedInfo, aHandlerInfo);
|
||||
RefPtr<nsChildProcessMIMEInfo> mimeInfo =
|
||||
new nsChildProcessMIMEInfo(returnedInfo.type());
|
||||
CopyHandlerInfoTonsIHandlerInfo(returnedInfo, mimeInfo);
|
||||
mimeInfo.forget(aMIMEInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
interface nsIHandlerInfo;
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIMIMEInfo;
|
||||
|
||||
[scriptable, uuid(53f0ad17-ec62-46a1-adbc-efccc06babcd)]
|
||||
interface nsIHandlerService : nsISupports
|
||||
@ -143,16 +144,32 @@ interface nsIHandlerService : nsISupports
|
||||
boolean existsForProtocol(in ACString aProtocolScheme);
|
||||
|
||||
/*
|
||||
* Fill in a handler info object using information from the OS, taking into
|
||||
* account the MIME type and file extension. When the OS handler
|
||||
* for the MIME type and extension match, |aFound| is returned as true. If
|
||||
* either the MIME type or extension is the empty string and a handler is
|
||||
* found, |aFound| is returned as true.
|
||||
* This method only exists for nsOSHelperAppServiceChild using
|
||||
* the ContentHandlerService implementation.
|
||||
*
|
||||
* Returns an nsIMIMEInfo for the provided MIME type and extension
|
||||
* obtained from an OS lookup. If no handler is found for the type and
|
||||
* extension, returns a generic nsIMIMEInfo object. The MIME type and
|
||||
* extension can be the empty string. When the type and extension don't
|
||||
* map to the same handler, the semantics/resolution are platform
|
||||
* specific. See the platform implementations for details.
|
||||
*
|
||||
* @param aType The MIME type to get handler information for.
|
||||
* @param aFileExtension The filename extension to use either alone
|
||||
* or with the MIME type to get handler information
|
||||
* for. UTF-8 encoded.
|
||||
* @param [out] aFound Out param indicating whether a MIMEInfo could
|
||||
* be found for the provided type and/or extension.
|
||||
* Set to false when neither extension nor the MIME
|
||||
* type are mapped to a handler.
|
||||
* @return A nsIMIMEInfo object. This function must return
|
||||
* a MIMEInfo object if it can allocate one. The
|
||||
* only justifiable reason for not returning one is
|
||||
* an out-of-memory error.
|
||||
*/
|
||||
void getMIMEInfoFromOS(in nsIHandlerInfo aHandlerInfo,
|
||||
in ACString aMIMEType,
|
||||
in ACString aExtension,
|
||||
out bool aFound);
|
||||
[noscript] nsIMIMEInfo getMIMEInfoFromOS(in ACString aType,
|
||||
in ACString aFileExtension,
|
||||
out boolean aFound);
|
||||
|
||||
/*
|
||||
* Get a description for the application responsible for handling
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
#include "nsOSHelperAppServiceChild.h"
|
||||
#include "nsMIMEInfoChild.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
@ -85,30 +84,22 @@ nsOSHelperAppServiceChild::GetMIMEInfoFromOS(const nsACString& aMIMEType,
|
||||
const nsACString& aFileExt,
|
||||
bool* aFound,
|
||||
nsIMIMEInfo** aMIMEInfo) {
|
||||
RefPtr<nsChildProcessMIMEInfo> mimeInfo =
|
||||
new nsChildProcessMIMEInfo(aMIMEType);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIHandlerService> handlerSvc =
|
||||
do_GetService(NS_HANDLERSERVICE_CONTRACTID);
|
||||
if (handlerSvc) {
|
||||
nsresult rv =
|
||||
handlerSvc->GetMIMEInfoFromOS(mimeInfo, aMIMEType, aFileExt, aFound);
|
||||
LOG(
|
||||
("nsOSHelperAppServiceChild::GetMIMEInfoFromOS(): "
|
||||
"MIME type: %s, extension: %s, result: %" PRId32,
|
||||
PromiseFlatCString(aMIMEType).get(),
|
||||
PromiseFlatCString(aFileExt).get(), static_cast<uint32_t>(rv)));
|
||||
mozilla::Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
do_GetService(NS_HANDLERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
LOG_ERR(("nsOSHelperAppServiceChild error: no handler service"));
|
||||
*aFound = false;
|
||||
return rv;
|
||||
}
|
||||
|
||||
mimeInfo.forget(aMIMEInfo);
|
||||
return NS_OK;
|
||||
rv = handlerSvc->GetMIMEInfoFromOS(aMIMEType, aFileExt, aFound, aMIMEInfo);
|
||||
LOG(
|
||||
("nsOSHelperAppServiceChild::GetMIMEInfoFromOS(): "
|
||||
"MIME type: %s, extension: %s, result: %" PRId32,
|
||||
PromiseFlatCString(aMIMEType).get(), PromiseFlatCString(aFileExt).get(),
|
||||
static_cast<uint32_t>(rv)));
|
||||
mozilla::Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
Reference in New Issue
Block a user