Bug 1729843 - Remove vestigial plugin-related code from nsWebNavigationInfo. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D125026
This commit is contained in:
Benjamin Peterson 2021-09-09 15:03:05 +00:00
parent 9f02eb8a33
commit 9253af4014
10 changed files with 16 additions and 61 deletions

View File

@ -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) {

View File

@ -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);
}

View File

@ -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);
};

View File

@ -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<nsIDocShell> 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);

View File

@ -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() {}

View File

@ -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<nsIWebNavigationInfo> info(
do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID));
if (!info) {
return false;
}
nsCOMPtr<nsIWebNavigation> 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<nsIPluginTag> 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;
}

View File

@ -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<nsISerialEventTarget> GetEventTargetByLoadInfo(
nsILoadInfo* aLoadInfo, mozilla::TaskCategory aCategory);

View File

@ -2037,7 +2037,7 @@ nsObjectLoadingContent::ObjectType nsObjectLoadingContent::GetTypeOfContent(
this, aMIMEType.get(), thisContent.get()));
auto ret =
static_cast<ObjectType>(nsContentUtils::HtmlObjectContentTypeForMIMEType(
aMIMEType, aNoFakePlugin, thisContent));
aMIMEType, aNoFakePlugin));
LOG(("OBJLC[%p]: called HtmlObjectContentTypeForMIMEType\n", this));
return ret;
}

View File

@ -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;
}

View File

@ -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;