diff --git a/browser/components/BrowserContentHandler.jsm b/browser/components/BrowserContentHandler.jsm index 9c51431743a3..27e18c5a4d5c 100644 --- a/browser/components/BrowserContentHandler.jsm +++ b/browser/components/BrowserContentHandler.jsm @@ -824,7 +824,7 @@ nsBrowserContentHandler.prototype = { var webNavInfo = Cc["@mozilla.org/webnavigation-info;1"].getService( Ci.nsIWebNavigationInfo ); - if (!webNavInfo.isTypeSupported(contentType, null)) { + if (!webNavInfo.isTypeSupported(contentType)) { throw NS_ERROR_WONT_HANDLE_CONTENT; } } catch (e) { diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 5dcfe16b2308..048e4d78c2d0 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -256,8 +256,8 @@ nsDSURIContentListener::CanHandleContent(const char* aContentType, *aDesiredContentType = nullptr; if (aContentType) { - uint32_t canHandle = nsWebNavigationInfo::IsTypeSupported( - nsDependentCString(aContentType), mDocShell); + uint32_t canHandle = + nsWebNavigationInfo::IsTypeSupported(nsDependentCString(aContentType)); *aCanHandleContent = (canHandle != nsIWebNavigationInfo::UNSUPPORTED); } diff --git a/docshell/base/nsIWebNavigationInfo.idl b/docshell/base/nsIWebNavigationInfo.idl index 8745425c1ea8..0c3d07a8edeb 100644 --- a/docshell/base/nsIWebNavigationInfo.idl +++ b/docshell/base/nsIWebNavigationInfo.idl @@ -5,8 +5,6 @@ #include "nsISupports.idl" -interface nsIWebNavigation; - /** * The nsIWebNavigationInfo interface exposes a way to get information * on the capabilities of Gecko webnavigation objects. @@ -49,15 +47,9 @@ interface nsIWebNavigationInfo : nsISupports /** * Query whether aType is supported. * @param aType the MIME type in question. - * @param aWebNav the nsIWebNavigation object for which the request - * is being made. This is allowed to be null. If it is non-null, - * the return value of this method may depend on the exact state of - * aWebNav and the values set through nsIWebBrowserSetup; otherwise - * the method will assume that the caller is interested in information - * about nsIWebNavigation objects in their default state. * @return an enum value indicating whether and how aType is supported. * @note This method may rescan plugins to ensure that they're properly * registered for the types they support. */ - unsigned long isTypeSupported(in ACString aType, in nsIWebNavigation aWebNav); + unsigned long isTypeSupported(in ACString aType); }; diff --git a/docshell/base/nsWebNavigationInfo.cpp b/docshell/base/nsWebNavigationInfo.cpp index 0448e1c1d001..03394996970a 100644 --- a/docshell/base/nsWebNavigationInfo.cpp +++ b/docshell/base/nsWebNavigationInfo.cpp @@ -6,48 +6,28 @@ #include "nsWebNavigationInfo.h" -#include "mozilla/dom/BrowsingContext.h" -#include "nsIWebNavigation.h" #include "nsServiceManagerUtils.h" #include "nsIDocumentLoaderFactory.h" -#include "nsIDocShell.h" #include "nsContentUtils.h" #include "imgLoader.h" -#include "nsPluginHost.h" NS_IMPL_ISUPPORTS(nsWebNavigationInfo, nsIWebNavigationInfo) NS_IMETHODIMP nsWebNavigationInfo::IsTypeSupported(const nsACString& aType, - nsIWebNavigation* aWebNav, uint32_t* aIsTypeSupported) { MOZ_ASSERT(aIsTypeSupported, "null out param?"); - *aIsTypeSupported = IsTypeSupported(aType, aWebNav); + *aIsTypeSupported = IsTypeSupported(aType); return NS_OK; } -uint32_t nsWebNavigationInfo::IsTypeSupported(const nsACString& aType, - nsIWebNavigation* aWebNav) { - // Note to self: aWebNav could be an nsWebBrowser or an nsDocShell here (or - // an nsSHistory, but not much we can do with that). So if we start using - // it here, we need to be careful to get to the docshell correctly. - nsCOMPtr docShell(do_QueryInterface(aWebNav)); - auto* browsingContext = docShell ? docShell->GetBrowsingContext() : nullptr; - bool pluginsAllowed = - browsingContext ? browsingContext->GetAllowPlugins() : true; - - return IsTypeSupported(aType, pluginsAllowed); -} - -uint32_t nsWebNavigationInfo::IsTypeSupported(const nsACString& aType, - bool aPluginsAllowed) { +uint32_t nsWebNavigationInfo::IsTypeSupported(const nsACString& aType) { // We want to claim that the type for PDF documents is unsupported, // so that the internal PDF viewer's stream converted will get used. if (aType.LowerCaseEqualsLiteral("application/pdf") && nsContentUtils::IsPDFJSEnabled()) { return nsIWebNavigationInfo::UNSUPPORTED; - ; } const nsCString& flatType = PromiseFlatCString(aType); diff --git a/docshell/base/nsWebNavigationInfo.h b/docshell/base/nsWebNavigationInfo.h index 5abf2e9bab39..97b07c825eaf 100644 --- a/docshell/base/nsWebNavigationInfo.h +++ b/docshell/base/nsWebNavigationInfo.h @@ -21,10 +21,7 @@ class nsWebNavigationInfo final : public nsIWebNavigationInfo { NS_DECL_NSIWEBNAVIGATIONINFO - static uint32_t IsTypeSupported(const nsACString& aType, - nsIWebNavigation* aWebNav); - static uint32_t IsTypeSupported(const nsACString& aType, - bool aPluginsAllowed); + static uint32_t IsTypeSupported(const nsACString& aType); private: ~nsWebNavigationInfo() {} diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 66eaf0f74c1c..5c289ce9a8c9 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -9819,24 +9819,15 @@ bool nsContentUtils::ShouldBlockReservedKeys(WidgetKeyboardEvent* aKeyEvent) { * NOTE Helper method for nsContentUtils::HtmlObjectContentTypeForMIMEType. * NOTE Does not take content policy or capabilities into account */ -static bool HtmlObjectContentSupportsDocument(const nsCString& aMimeType, - nsIContent* aContent) { +static bool HtmlObjectContentSupportsDocument(const nsCString& aMimeType) { nsCOMPtr info( do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID)); if (!info) { return false; } - nsCOMPtr webNav; - if (aContent) { - Document* currentDoc = aContent->GetComposedDoc(); - if (currentDoc) { - webNav = do_GetInterface(currentDoc->GetWindow()); - } - } - uint32_t supported; - nsresult rv = info->IsTypeSupported(aMimeType, webNav, &supported); + nsresult rv = info->IsTypeSupported(aMimeType, &supported); if (NS_FAILED(rv)) { return false; @@ -9878,7 +9869,7 @@ already_AddRefed nsContentUtils::PluginTagForType( /* static */ uint32_t nsContentUtils::HtmlObjectContentTypeForMIMEType( - const nsCString& aMIMEType, bool aNoFakePlugin, nsIContent* aContent) { + const nsCString& aMIMEType, bool aNoFakePlugin) { if (aMIMEType.IsEmpty()) { return nsIObjectLoadingContent::TYPE_NULL; } @@ -9893,7 +9884,7 @@ uint32_t nsContentUtils::HtmlObjectContentTypeForMIMEType( return nsIObjectLoadingContent::TYPE_DOCUMENT; } - if (HtmlObjectContentSupportsDocument(aMIMEType, aContent)) { + if (HtmlObjectContentSupportsDocument(aMIMEType)) { return nsIObjectLoadingContent::TYPE_DOCUMENT; } diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index a7a02bd4a048..cd6b214f4c2f 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -3111,13 +3111,9 @@ class nsContentUtils { * * @param aMIMEType The MIME type of the document being loaded. * @param aNoFakePlugin If false then this method should consider JS plugins. - * @param aContent The nsIContent object which is performing the load. May be - * nullptr in which case the docshell's plugin permissions - * will not be checked. */ static uint32_t HtmlObjectContentTypeForMIMEType(const nsCString& aMIMEType, - bool aNoFakePlugin, - nsIContent* aContent); + bool aNoFakePlugin); static already_AddRefed GetEventTargetByLoadInfo( nsILoadInfo* aLoadInfo, mozilla::TaskCategory aCategory); diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 3b60a17197bc..0c0f0f59c71c 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -2037,7 +2037,7 @@ nsObjectLoadingContent::ObjectType nsObjectLoadingContent::GetTypeOfContent( this, aMIMEType.get(), thisContent.get())); auto ret = static_cast(nsContentUtils::HtmlObjectContentTypeForMIMEType( - aMIMEType, aNoFakePlugin, thisContent)); + aMIMEType, aNoFakePlugin)); LOG(("OBJLC[%p]: called HtmlObjectContentTypeForMIMEType\n", this)); return ret; } diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index 1d53b33e1490..309bfe135cac 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -587,8 +587,8 @@ nsresult NS_GetIsDocumentChannel(nsIChannel* aChannel, bool* aIsDocument) { if (NS_FAILED(rv)) { return rv; } - if (nsContentUtils::HtmlObjectContentTypeForMIMEType( - mimeType, false, nullptr) == nsIObjectLoadingContent::TYPE_DOCUMENT) { + if (nsContentUtils::HtmlObjectContentTypeForMIMEType(mimeType, false) == + nsIObjectLoadingContent::TYPE_DOCUMENT) { *aIsDocument = true; return NS_OK; } diff --git a/netwerk/ipc/DocumentLoadListener.cpp b/netwerk/ipc/DocumentLoadListener.cpp index 4b9affac7819..eb1a9b68990c 100644 --- a/netwerk/ipc/DocumentLoadListener.cpp +++ b/netwerk/ipc/DocumentLoadListener.cpp @@ -217,8 +217,7 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo, // channel listener so that we forward onto DocumentLoadListener. bool TryDefaultContentListener(nsIChannel* aChannel, const nsCString& aContentType) { - uint32_t canHandle = nsWebNavigationInfo::IsTypeSupported( - aContentType, mBrowsingContext->GetAllowPlugins()); + uint32_t canHandle = nsWebNavigationInfo::IsTypeSupported(aContentType); if (canHandle != nsIWebNavigationInfo::UNSUPPORTED) { m_targetStreamListener = mListener; nsLoadFlags loadFlags = 0;