mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1448374 - Loading a .javascript file from a WebExtension's web_accessible_resources messing with macOS file associations r=jimm
From content processes, on Mac, use ContentHandlerService::GetTypeFromExtension() instead of trying to query the OS directly for MIME information. Trying to get MIME information from the OS is blocked by content process sandboxing on Mac. MozReview-Commit-ID: KGJHDBklxvb --HG-- extra : rebase_source : ae46525eee622d64ffc6e263b19682aec033480a
This commit is contained in:
parent
02b381dff1
commit
58ac4dd796
@ -32,6 +32,10 @@ public:
|
||||
bool *found,
|
||||
nsIHandlerInfo **_retval) override;
|
||||
|
||||
// override so we can have a child process sandbox-friendly implementation
|
||||
bool GetMIMETypeFromOSForExtension(const nsACString& aExtension,
|
||||
nsACString& aMIMEType) override;
|
||||
|
||||
// GetFileTokenForPath must be implemented by each platform.
|
||||
// platformAppPath --> a platform specific path to an application that we got out of the
|
||||
// rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsTArray.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIHandlerService.h"
|
||||
#include "nsILocalFileMac.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIStringBundle.h"
|
||||
@ -573,3 +574,34 @@ nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Override GetMIMETypeFromOSForExtension() so that we can proxy requests for
|
||||
* the MIME type to the parent when we're executing in the child process. If
|
||||
* we're in the parent process, query the OS directly.
|
||||
*/
|
||||
bool
|
||||
nsOSHelperAppService::GetMIMETypeFromOSForExtension(const nsACString& aExtension,
|
||||
nsACString& aMIMEType)
|
||||
{
|
||||
if (XRE_IsParentProcess()) {
|
||||
return nsExternalHelperAppService::GetMIMETypeFromOSForExtension(aExtension,
|
||||
aMIMEType);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHandlerService> handlerSvc =
|
||||
do_GetService(NS_HANDLERSERVICE_CONTRACTID);
|
||||
if (NS_WARN_IF(!handlerSvc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult rv = handlerSvc->GetTypeFromExtension(aExtension, aMIMEType);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aMIMEType.IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user