Bug 1875822 - Remove a bunch of dead JS plugin code. r=nika

Also bonus clean-up.

Differential Revision: https://phabricator.services.mozilla.com/D199272
This commit is contained in:
Emilio Cobos Álvarez
2024-01-25 21:02:21 +00:00
parent 92d2a69249
commit a310b17d3f
20 changed files with 41 additions and 919 deletions

View File

@@ -1179,12 +1179,6 @@ pref("accessibility.typeaheadfind.timeout", 5000);
pref("accessibility.typeaheadfind.linksonly", false);
pref("accessibility.typeaheadfind.flashBar", 1);
#if defined(_ARM64_) && defined(XP_WIN)
pref("plugin.default.state", 0);
#else
pref("plugin.default.state", 1);
#endif
// Toggling Search bar on and off in about:preferences
pref("browser.preferences.search", true);
#if defined(NIGHTLY_BUILD)

View File

@@ -56,6 +56,7 @@
#include "mozAutoDocUpdate.h"
#include "mozIDOMWindow.h"
#include "nsIOService.h"
#include "nsObjectLoadingContent.h"
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/ArrayIterator.h"
#include "mozilla/ArrayUtils.h"
@@ -312,7 +313,6 @@
#include "nsIObserverService.h"
#include "nsIParserUtils.h"
#include "nsIPermissionManager.h"
#include "nsIPluginTag.h"
#include "nsIPrincipal.h"
#include "nsIProperties.h"
#include "nsIProtocolHandler.h"
@@ -357,7 +357,6 @@
#include "nsPIDOMWindowInlines.h"
#include "nsParser.h"
#include "nsParserConstants.h"
#include "nsPluginHost.h"
#include "nsPoint.h"
#include "nsPointerHashKeys.h"
#include "nsPresContext.h"
@@ -10556,9 +10555,7 @@ uint32_t nsContentUtils::HtmlObjectContentTypeForMIMEType(
return nsIObjectLoadingContent::TYPE_DOCUMENT;
}
bool isSpecialPlugin = nsPluginHost::GetSpecialType(aMIMEType) !=
nsPluginHost::eSpecialType_None;
if (isSpecialPlugin) {
if (nsObjectLoadingContent::IsFallbackMimeType(aMIMEType)) {
return nsIObjectLoadingContent::TYPE_FALLBACK;
}

View File

@@ -8,7 +8,6 @@
interface nsIChannel;
interface nsIRequest;
interface nsIFrame;
interface nsIPluginTag;
interface nsIURI;
webidl BrowsingContext;

View File

@@ -19,8 +19,6 @@
#include "mozilla/dom/Document.h"
#include "nsIExternalProtocolHandler.h"
#include "nsIPermissionManager.h"
#include "nsPluginHost.h"
#include "nsPluginTags.h"
#include "nsIHttpChannel.h"
#include "nsINestedURI.h"
#include "nsScriptSecurityManager.h"
@@ -105,14 +103,20 @@ static LogModule* GetObjectLog() {
#define LOG_ENABLED() MOZ_LOG_TEST(GetObjectLog(), mozilla::LogLevel::Debug)
static bool IsFlashMIME(const nsACString& aMIMEType) {
return nsPluginHost::GetSpecialType(aMIMEType) ==
nsPluginHost::eSpecialType_Flash;
return aMIMEType.LowerCaseEqualsASCII("application/x-shockwave-flash") ||
aMIMEType.LowerCaseEqualsASCII("application/futuresplash") ||
aMIMEType.LowerCaseEqualsASCII("application/x-shockwave-flash-test");
}
static bool IsPluginType(nsObjectLoadingContent::ObjectType type) {
return type == nsObjectLoadingContent::eType_Fallback;
}
bool nsObjectLoadingContent::IsFallbackMimeType(const nsACString& aMIMEType) {
return IsFlashMIME(aMIMEType) ||
aMIMEType.LowerCaseEqualsASCII("application/x-test");
}
///
/// Runnables and helper classes
///
@@ -1569,7 +1573,7 @@ nsresult nsObjectLoadingContent::OpenChannel() {
}
uint32_t nsObjectLoadingContent::GetCapabilities() const {
return eSupportImages | eSupportPlugins | eSupportDocuments;
return eSupportImages | eSupportDocuments;
}
void nsObjectLoadingContent::Destroy() {
@@ -1653,9 +1657,9 @@ nsObjectLoadingContent::ObjectType nsObjectLoadingContent::GetTypeOfContent(
Element* el = AsElement();
NS_ASSERTION(el, "must be a content");
// Images, documents and (fake) plugins are always supported.
MOZ_ASSERT(GetCapabilities() &
(eSupportImages | eSupportDocuments | eSupportPlugins));
// Images and documents are always supported.
MOZ_ASSERT((GetCapabilities() & (eSupportImages | eSupportDocuments)) ==
(eSupportImages | eSupportDocuments));
LOG(
("OBJLC [%p]: calling HtmlObjectContentTypeForMIMEType: aMIMEType: %s - "

View File

@@ -73,6 +73,8 @@ class nsObjectLoadingContent : public nsIStreamListener,
mNetworkCreated = aNetworkCreated;
}
static bool IsFallbackMimeType(const nsACString& aMimeType);
// Helper for WebIDL NeedResolve
bool DoResolve(
JSContext* aCx, JS::Handle<JSObject*> aObject, JS::Handle<jsid> aId,
@@ -171,21 +173,20 @@ class nsObjectLoadingContent : public nsIStreamListener,
enum Capabilities {
eSupportImages = 1u << 0, // Images are supported (imgILoader)
eSupportPlugins = 1u << 1, // Plugins are supported (nsIPluginHost)
eSupportDocuments = 1u << 2, // Documents are supported
eSupportDocuments = 1u << 1, // Documents are supported
// (DocumentLoaderFactory)
// This flag always includes SVG
// Node supports class ID as an attribute, and should fallback if it is
// present, as class IDs are not supported.
eFallbackIfClassIDPresent = 1u << 3,
eFallbackIfClassIDPresent = 1u << 2,
// If possible to get a *plugin* type from the type attribute *or* file
// extension, we can use that type and begin loading the plugin before
// opening a channel.
// A side effect of this is if the channel fails, the plugin is still
// running.
eAllowPluginSkipChannel = 1u << 4
eAllowPluginSkipChannel = 1u << 3
};
/**

View File

@@ -223,8 +223,7 @@ void HTMLEmbedElement::StartObjectLoad(bool aNotify, bool aForceLoad) {
}
uint32_t HTMLEmbedElement::GetCapabilities() const {
return eSupportPlugins | eAllowPluginSkipChannel | eSupportImages |
eSupportDocuments;
return eAllowPluginSkipChannel | eSupportImages | eSupportDocuments;
}
void HTMLEmbedElement::DestroyContent() {

View File

@@ -234,7 +234,6 @@
#include "nsMemoryReporterManager.h"
#include "nsOpenURIInFrameParams.h"
#include "nsPIWindowWatcher.h"
#include "nsPluginTags.h"
#include "nsQueryObject.h"
#include "nsReadableUtils.h"
#include "nsSHistory.h"
@@ -595,8 +594,6 @@ ProcessID GetTelemetryProcessID(const nsACString& remoteType) {
} // anonymous namespace
StaticAutoPtr<nsTHashMap<nsUint32HashKey, ContentParent*>>
ContentParent::sJSPluginContentParents;
StaticAutoPtr<LinkedList<ContentParent>> ContentParent::sContentParents;
StaticRefPtr<ContentParent> ContentParent::sRecycledE10SProcess;
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
@@ -809,8 +806,7 @@ void ContentParent::ReleaseCachedProcesses() {
// Ensure the process cannot be claimed between check and MarkAsDead.
RecursiveMutexAutoLock lock(cp->ThreadsafeHandleMutex());
if (cp->ManagedPBrowserParent().Count() == 0 &&
!cp->HasActiveWorkerOrJSPlugin() &&
if (cp->ManagedPBrowserParent().Count() == 0 && !cp->HasActiveWorker() &&
cp->mRemoteType == DEFAULT_REMOTE_TYPE) {
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
(" Shutdown %p (%s)", cp.get(), cp->mRemoteType.get()));
@@ -824,11 +820,10 @@ void ContentParent::ReleaseCachedProcesses() {
// message manager.
cp->ShutDownMessageManager();
} else {
MOZ_LOG(
ContentParent::GetLog(), LogLevel::Debug,
(" Skipping %p (%s), count %d, HasActiveWorkerOrJSPlugin %d",
cp.get(), cp->mRemoteType.get(), cp->ManagedPBrowserParent().Count(),
cp->HasActiveWorkerOrJSPlugin()));
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
(" Skipping %p (%s), count %d, HasActiveWorker %d", cp.get(),
cp->mRemoteType.get(), cp->ManagedPBrowserParent().Count(),
cp->HasActiveWorker()));
}
}
}
@@ -1198,31 +1193,6 @@ bool ContentParent::WaitForLaunchSync(ProcessPriority aPriority) {
return false;
}
/*static*/
already_AddRefed<ContentParent> ContentParent::GetNewOrUsedJSPluginProcess(
uint32_t aPluginID, const hal::ProcessPriority& aPriority) {
RefPtr<ContentParent> p;
if (sJSPluginContentParents) {
p = sJSPluginContentParents->Get(aPluginID);
} else {
sJSPluginContentParents = new nsTHashMap<nsUint32HashKey, ContentParent*>();
}
if (p) {
return p.forget();
}
p = new ContentParent(aPluginID);
if (!p->LaunchSubprocessSync(aPriority)) {
return nullptr;
}
sJSPluginContentParents->InsertOrUpdate(aPluginID, p);
return p.forget();
}
static nsIDocShell* GetOpenerDocShellHelper(Element* aFrameElement) {
// Propagate the private-browsing status of the element's parent
// docshell to the remote docshell, via the chrome flags.
@@ -1471,14 +1441,9 @@ already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser(
"Cannot allocate BrowserParent in content process");
if (aOpenerContentParent && !aOpenerContentParent->IsShuttingDown()) {
constructorSender = aOpenerContentParent;
} else {
if (aContext.IsJSPlugin()) {
constructorSender = GetNewOrUsedJSPluginProcess(
aContext.JSPluginId(), PROCESS_PRIORITY_FOREGROUND);
} else {
constructorSender = GetNewOrUsedBrowserProcess(
remoteType, aBrowsingContext->Group(), PROCESS_PRIORITY_FOREGROUND);
}
if (!constructorSender) {
return nullptr;
}
@@ -1951,12 +1916,7 @@ void ContentParent::AssertNotInPool() {
MOZ_RELEASE_ASSERT(!mIsInPool);
MOZ_RELEASE_ASSERT(sRecycledE10SProcess != this);
if (IsForJSPlugin()) {
MOZ_RELEASE_ASSERT(!sJSPluginContentParents ||
!sJSPluginContentParents->Get(mJSPluginID));
} else {
MOZ_RELEASE_ASSERT(
!sBrowserContentParents ||
MOZ_RELEASE_ASSERT(!sBrowserContentParents ||
!sBrowserContentParents->Contains(mRemoteType) ||
!sBrowserContentParents->Get(mRemoteType)->Contains(this));
@@ -1964,7 +1924,6 @@ void ContentParent::AssertNotInPool() {
MOZ_RELEASE_ASSERT(group->GetHostProcess(mRemoteType) != this,
"still a host process for one of our groups?");
}
}
}
void ContentParent::AssertAlive() {
@@ -1974,16 +1933,6 @@ void ContentParent::AssertAlive() {
}
void ContentParent::RemoveFromList() {
if (IsForJSPlugin()) {
if (sJSPluginContentParents) {
sJSPluginContentParents->Remove(mJSPluginID);
if (!sJSPluginContentParents->Count()) {
sJSPluginContentParents = nullptr;
}
}
return;
}
if (!mIsInPool) {
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
AssertNotInPool();
@@ -2327,11 +2276,7 @@ void ContentParent::StopRecyclingE10SOnly(bool aForeground) {
}
}
bool ContentParent::HasActiveWorkerOrJSPlugin() {
if (IsForJSPlugin()) {
return true;
}
bool ContentParent::HasActiveWorker() {
// If we have active workers, we need to stay alive.
{
// Most of the times we'll get here with the mutex acquired, but still.
@@ -2344,7 +2289,7 @@ bool ContentParent::HasActiveWorkerOrJSPlugin() {
}
bool ContentParent::ShouldKeepProcessAlive() {
if (HasActiveWorkerOrJSPlugin()) {
if (HasActiveWorker()) {
return true;
}
@@ -2869,7 +2814,7 @@ RefPtr<ContentParent::LaunchPromise> ContentParent::LaunchSubprocessAsync(
});
}
ContentParent::ContentParent(const nsACString& aRemoteType, int32_t aJSPluginID)
ContentParent::ContentParent(const nsACString& aRemoteType)
: mSubprocess(nullptr),
mLaunchTS(TimeStamp::Now()),
mLaunchYieldTS(mLaunchTS),
@@ -2878,7 +2823,6 @@ ContentParent::ContentParent(const nsACString& aRemoteType, int32_t aJSPluginID)
mRemoteType(aRemoteType),
mChildID(gContentChildID++),
mGeolocationWatchID(-1),
mJSPluginID(aJSPluginID),
mThreadsafeHandle(
new ThreadsafeContentParentHandle(this, mChildID, mRemoteType)),
mNumDestroyingTabs(0),
@@ -2899,9 +2843,6 @@ ContentParent::ContentParent(const nsACString& aRemoteType, int32_t aJSPluginID)
mBlockShutdownCalled(false),
#endif
mHangMonitorActor(nullptr) {
MOZ_DIAGNOSTIC_ASSERT(!IsForJSPlugin(),
"XXX(nika): How are we creating a JSPlugin?");
mRemoteTypeIsolationPrincipal =
CreateRemoteTypeIsolationPrincipal(aRemoteType);

View File

@@ -38,7 +38,6 @@
#include "nsClassHashtable.h"
#include "nsTHashMap.h"
#include "nsTHashSet.h"
#include "nsPluginTags.h"
#include "nsHashKeys.h"
#include "nsIAsyncShutdown.h"
#include "nsIDOMProcessParent.h"
@@ -218,14 +217,6 @@ class ContentParent final : public PContentParent,
bool WaitForLaunchSync(hal::ProcessPriority aPriority =
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND);
/**
* Get or create a content process for a JS plugin. aPluginID is the id of the
* JS plugin
* (@see nsFakePlugin::mId). There is a maximum of one process per JS plugin.
*/
static already_AddRefed<ContentParent> GetNewOrUsedJSPluginProcess(
uint32_t aPluginID, const hal::ProcessPriority& aPriority);
/**
* Get or create a content process for the given TabContext. aFrameElement
* should be the frame/iframe element with which this process will
@@ -391,9 +382,6 @@ class ContentParent final : public PContentParent,
bool IsDead() const { return mLifecycleState == LifecycleState::DEAD; }
bool IsForBrowser() const { return mIsForBrowser; }
bool IsForJSPlugin() const {
return mJSPluginID != nsFakePluginTag::NOT_JSPLUGIN;
}
GeckoChildProcessHost* Process() const { return mSubprocess; }
@@ -690,8 +678,6 @@ class ContentParent final : public PContentParent,
*/
static nsClassHashtable<nsCStringHashKey, nsTArray<ContentParent*>>*
sBrowserContentParents;
static mozilla::StaticAutoPtr<nsTHashMap<nsUint32HashKey, ContentParent*>>
sJSPluginContentParents;
static mozilla::StaticAutoPtr<LinkedList<ContentParent>> sContentParents;
/**
@@ -728,11 +714,7 @@ class ContentParent final : public PContentParent,
bool aLoadUri, nsIContentSecurityPolicy* aCsp,
const OriginAttributes& aOriginAttributes);
explicit ContentParent(int32_t aPluginID) : ContentParent(""_ns, aPluginID) {}
explicit ContentParent(const nsACString& aRemoteType)
: ContentParent(aRemoteType, nsFakePluginTag::NOT_JSPLUGIN) {}
ContentParent(const nsACString& aRemoteType, int32_t aPluginID);
explicit ContentParent(const nsACString& aRemoteType);
// Launch the subprocess and associated initialization.
// Returns false if the process fails to start.
@@ -795,9 +777,9 @@ class ContentParent final : public PContentParent,
void RemoveFromList();
/**
* Return if the process has an active worker or JSPlugin
* Return if the process has an active worker.
*/
bool HasActiveWorkerOrJSPlugin();
bool HasActiveWorker();
/**
* Decide whether the process should be kept alive even when it would normally
@@ -1466,12 +1448,6 @@ class ContentParent final : public PContentParent,
ContentParentId mChildID;
int32_t mGeolocationWatchID;
// This contains the id for the JS plugin (@see nsFakePluginTag) if this is
// the ContentParent for a process containing iframes for that JS plugin. If
// this is not a ContentParent for a JS plugin then it contains the value
// nsFakePluginTag::NOT_JSPLUGIN.
int32_t mJSPluginID;
// After we destroy the last Browser, we also start a timer to ensure
// that even content processes that are not responding will get a
// second chance and a shutdown message.

View File

@@ -30,11 +30,6 @@ struct FrameIPCTabContext
uint32_t maxTouchPoints;
};
struct JSPluginFrameIPCTabContext
{
uint32_t jsPluginId;
};
// IPCTabContext is an analog to mozilla::dom::TabContext. Both specify an
// iframe/PBrowser's own and containing app-ids and tell you whether the
// iframe/PBrowser is a browser frame. But only IPCTabContext is allowed to
@@ -46,7 +41,6 @@ union IPCTabContext
{
PopupIPCTabContext;
FrameIPCTabContext;
JSPluginFrameIPCTabContext;
};
}

View File

@@ -19,13 +19,8 @@ namespace mozilla::dom {
TabContext::TabContext()
: mInitialized(false),
mChromeOuterWindowID(0),
mJSPluginID(-1),
mMaxTouchPoints(0) {}
bool TabContext::IsJSPlugin() const { return mJSPluginID >= 0; }
int32_t TabContext::JSPluginId() const { return mJSPluginID; }
uint64_t TabContext::ChromeOuterWindowID() const {
return mChromeOuterWindowID;
}
@@ -60,19 +55,7 @@ bool TabContext::SetTabContext(uint64_t aChromeOuterWindowID,
return true;
}
bool TabContext::SetTabContextForJSPluginFrame(int32_t aJSPluginID) {
NS_ENSURE_FALSE(mInitialized, false);
mInitialized = true;
mJSPluginID = aJSPluginID;
return true;
}
IPCTabContext TabContext::AsIPCTabContext() const {
if (IsJSPlugin()) {
return IPCTabContext(JSPluginFrameIPCTabContext(mJSPluginID));
}
return IPCTabContext(
FrameIPCTabContext(mChromeOuterWindowID, mMaxTouchPoints));
}
@@ -80,7 +63,6 @@ IPCTabContext TabContext::AsIPCTabContext() const {
MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
: mInvalidReason(nullptr) {
uint64_t chromeOuterWindowID = 0;
int32_t jsPluginId = -1;
uint32_t maxTouchPoints = 0;
switch (aParams.type()) {
@@ -90,13 +72,6 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
chromeOuterWindowID = ipcContext.chromeOuterWindowID();
break;
}
case IPCTabContext::TJSPluginFrameIPCTabContext: {
const JSPluginFrameIPCTabContext& ipcContext =
aParams.get_JSPluginFrameIPCTabContext();
jsPluginId = ipcContext.jsPluginId();
break;
}
case IPCTabContext::TFrameIPCTabContext: {
const FrameIPCTabContext& ipcContext = aParams.get_FrameIPCTabContext();
@@ -109,13 +84,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
}
}
bool rv;
if (jsPluginId >= 0) {
rv = mTabContext.SetTabContextForJSPluginFrame(jsPluginId);
} else {
rv = mTabContext.SetTabContext(chromeOuterWindowID, maxTouchPoints);
}
if (!rv) {
if (!mTabContext.SetTabContext(chromeOuterWindowID, maxTouchPoints)) {
mInvalidReason = "Couldn't initialize TabContext.";
}
}

View File

@@ -38,9 +38,6 @@ class TabContext {
*/
IPCTabContext AsIPCTabContext() const;
bool IsJSPlugin() const;
int32_t JSPluginId() const;
uint64_t ChromeOuterWindowID() const;
uint32_t MaxTouchPoints() const { return mMaxTouchPoints; }
@@ -75,16 +72,6 @@ class TabContext {
*/
bool UpdateTabContextAfterSwap(const TabContext& aContext);
/**
* Set this TabContext to be for a JS plugin. aPluginID is the id of the JS
* plugin
* (@see nsFakePlugin::mId).
* As with the other protected mutator methods, this lets you modify a
* TabContext once.
* (@see TabContext::SetTabContext above for more details).
*/
bool SetTabContextForJSPluginFrame(int32_t aJSPluginID);
void SetMaxTouchPoints(uint32_t aMaxTouchPoints) {
mMaxTouchPoints = aMaxTouchPoints;
}
@@ -100,8 +87,6 @@ class TabContext {
*/
uint64_t mChromeOuterWindowID;
int32_t mJSPluginID;
/**
* Maximum number of touch points.
*/
@@ -122,10 +107,6 @@ class MutableTabContext : public TabContext {
bool SetTabContext(uint64_t aChromeOuterWindowID, uint32_t aMaxTouchPoints) {
return TabContext::SetTabContext(aChromeOuterWindowID, aMaxTouchPoints);
}
bool SetTabContextForJSPluginFrame(uint32_t aJSPluginID) {
return TabContext::SetTabContextForJSPluginFrame(aJSPluginID);
}
};
/**

View File

@@ -68,7 +68,6 @@ DIRS += [
"locks",
"network",
"permission",
"plugins/base",
"prototype",
"indexedDB",
"system",

View File

@@ -1,44 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPIDL_SOURCES += [
"nsIPluginTag.idl",
]
XPIDL_MODULE = "plugin"
EXPORTS += [
"nsPluginHost.h",
"nsPluginTags.h",
]
UNIFIED_SOURCES += [
"nsPluginHost.cpp",
"nsPluginTags.cpp",
]
LOCAL_INCLUDES += [
"/dom/base",
"/gfx/cairo/cairo/src",
"/layout/generic",
"/layout/xul",
"/netwerk/base",
"/widget",
"/widget/cocoa",
"/xpcom/base",
]
if CONFIG["OS_ARCH"] == "WINNT":
LOCAL_INCLUDES += [
"/xpcom/base",
]
include("/ipc/chromium/chromium-config.mozbuild")
FINAL_LIBRARY = "xul"
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]

View File

@@ -1,97 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIURI;
[builtinclass, scriptable, uuid(5daa99d5-265a-4397-b429-c943803e2619)]
interface nsIPluginTag : nsISupports
{
// enabledState is stored as one of the following as an integer in prefs,
// so if new states are added, they must not renumber the existing states.
const unsigned long STATE_DISABLED = 0;
const unsigned long STATE_CLICKTOPLAY = 1;
const unsigned long STATE_ENABLED = 2;
readonly attribute AUTF8String description;
readonly attribute AUTF8String filename;
readonly attribute AUTF8String fullpath;
readonly attribute AUTF8String version;
readonly attribute AUTF8String name;
// The 'nice' name of this plugin, e.g. 'flash' 'java'
readonly attribute AUTF8String niceName;
/**
* true only if this plugin is "hardblocked" and cannot be enabled.
*/
// FIXME-jsplugins QI to fakePluginTag possible
// FIXME-jsplugins implement missing + tests (whatever that means)
[infallible]
readonly attribute boolean blocklisted;
/**
* true if the state is non-default and locked, false otherwise.
*/
[infallible]
readonly attribute boolean isEnabledStateLocked;
// If this plugin is capable of being used (not disabled, blocklisted, etc)
[infallible]
readonly attribute boolean active;
// Get a specific nsIBlocklistService::STATE_*
[infallible]
readonly attribute unsigned long blocklistState;
[infallible]
readonly attribute boolean disabled;
[infallible]
readonly attribute boolean clicktoplay;
[infallible]
readonly attribute boolean loaded;
// See the STATE_* values above.
attribute unsigned long enabledState;
readonly attribute PRTime lastModifiedTime;
readonly attribute boolean isFlashPlugin;
Array<AUTF8String> getMimeTypes();
Array<AUTF8String> getMimeDescriptions();
Array<AUTF8String> getExtensions();
/**
* An id for this plugin. 0 is a valid id.
*/
readonly attribute unsigned long id;
};
/**
* An interface representing a "fake" plugin: one implemented in JavaScript, not
* as a NPAPI plug-in. See nsIPluginHost.registerFakePlugin and the
* documentation for the FakePluginTagInit dictionary.
*/
[builtinclass, scriptable, uuid(6d22c968-226d-4156-b230-da6ad6bbf6e8)]
interface nsIFakePluginTag : nsIPluginTag
{
/**
* The URI that should be loaded into the tag (as a frame) to handle the
* plugin. Note that the original data/src value for the plugin is not loaded
* and will need to be requested by the handler via XHR or similar if desired.
*/
readonly attribute nsIURI handlerURI;
/**
* Optional script to run in a sandbox when instantiating a plugin. If this
* value is an empty string then no such script will be run.
* The script runs in a sandbox with system principal in the process that
* contains the element that instantiates the plugin (ie the EMBED or OBJECT
* element). The sandbox global has a 'pluginElement' property that the script
* can use to access the element that instantiates the plugin.
*/
readonly attribute AString sandboxScript;
};

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* nsPluginHost.cpp - top-level plugin management code */
#include "nsPluginHost.h"
#include "nsTString.h"
nsPluginHost::SpecialType nsPluginHost::GetSpecialType(
const nsACString& aMIMEType) {
if (aMIMEType.LowerCaseEqualsASCII("application/x-test")) {
return eSpecialType_Test;
}
if (aMIMEType.LowerCaseEqualsASCII("application/x-shockwave-flash") ||
aMIMEType.LowerCaseEqualsASCII("application/futuresplash") ||
aMIMEType.LowerCaseEqualsASCII("application/x-shockwave-flash-test")) {
return eSpecialType_Flash;
}
return eSpecialType_None;
}

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsPluginHost_h_
#define nsPluginHost_h_
#include "nsStringFwd.h"
namespace nsPluginHost {
// checks whether aType is a type we recognize for potential special handling
enum SpecialType {
eSpecialType_None,
// Needed to whitelist for async init support
eSpecialType_Test,
// Informs some decisions about OOP and quirks
eSpecialType_Flash
};
SpecialType GetSpecialType(const nsACString& aMIMEType);
} // namespace nsPluginHost
#endif // nsPluginHost_h_

View File

@@ -1,389 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsPluginTags.h"
#include "prlink.h"
#include "prenv.h"
#include "nsIBlocklistService.h"
#include "nsCharSeparatedTokenizer.h"
#include "mozilla/Preferences.h"
#include "mozilla/Unused.h"
#include "nsNetUtil.h"
#include <cctype>
#include "mozilla/Encoding.h"
#include "mozilla/dom/FakePluginTagInitBinding.h"
using mozilla::dom::FakePluginTagInit;
using namespace mozilla;
// check comma delimited extensions
static bool ExtensionInList(const nsCString& aExtensionList,
const nsACString& aExtension) {
for (const nsACString& extension :
nsCCharSeparatedTokenizer(aExtensionList, ',').ToRange()) {
if (extension.Equals(aExtension, nsCaseInsensitiveCStringComparator)) {
return true;
}
}
return false;
}
// Search for an extension in an extensions array, and return its
// matching mime type
static bool SearchExtensions(const nsTArray<nsCString>& aExtensions,
const nsTArray<nsCString>& aMimeTypes,
const nsACString& aFindExtension,
nsACString& aMatchingType) {
uint32_t mimes = aMimeTypes.Length();
MOZ_ASSERT(mimes == aExtensions.Length(),
"These arrays should have matching elements");
aMatchingType.Truncate();
for (uint32_t i = 0; i < mimes; i++) {
if (ExtensionInList(aExtensions[i], aFindExtension)) {
aMatchingType = aMimeTypes[i];
return true;
}
}
return false;
}
static nsCString MakeNiceFileName(const nsCString& aFileName) {
nsCString niceName = aFileName;
int32_t niceNameLength = aFileName.RFind(".");
NS_ASSERTION(niceNameLength != kNotFound, "aFileName doesn't have a '.'?");
while (niceNameLength > 0) {
char chr = aFileName[niceNameLength - 1];
if (!std::isalpha(chr))
niceNameLength--;
else
break;
}
// If it turns out that niceNameLength <= 0, we'll fall back and use the
// entire aFileName (which we've already taken care of, a few lines back).
if (niceNameLength > 0) {
niceName.Truncate(niceNameLength);
}
ToLowerCase(niceName);
return niceName;
}
static nsCString MakePrefNameForPlugin(const char* const subname,
nsIInternalPluginTag* aTag) {
nsCString pref;
nsAutoCString pluginName(aTag->GetNiceFileName());
if (pluginName.IsEmpty()) {
// Use filename if nice name fails
pluginName = aTag->FileName();
if (pluginName.IsEmpty()) {
MOZ_ASSERT_UNREACHABLE("Plugin with no filename or nice name in list");
pluginName.AssignLiteral("unknown-plugin-name");
}
}
pref.AssignLiteral("plugin.");
pref.Append(subname);
pref.Append('.');
pref.Append(pluginName);
return pref;
}
static nsCString GetStatePrefNameForPlugin(nsIInternalPluginTag* aTag) {
return MakePrefNameForPlugin("state", aTag);
}
static nsresult IsEnabledStateLockedForPlugin(nsIInternalPluginTag* aTag,
bool* aIsEnabledStateLocked) {
*aIsEnabledStateLocked = false;
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (NS_WARN_IF(!prefs)) {
return NS_ERROR_FAILURE;
}
Unused << prefs->PrefIsLocked(GetStatePrefNameForPlugin(aTag).get(),
aIsEnabledStateLocked);
return NS_OK;
}
/* nsIInternalPluginTag */
uint32_t nsIInternalPluginTag::sNextId;
nsIInternalPluginTag::nsIInternalPluginTag() = default;
nsIInternalPluginTag::nsIInternalPluginTag(const char* aName,
const char* aDescription,
const char* aFileName,
const char* aVersion)
: mName(aName),
mDescription(aDescription),
mFileName(aFileName),
mVersion(aVersion) {}
nsIInternalPluginTag::nsIInternalPluginTag(
const char* aName, const char* aDescription, const char* aFileName,
const char* aVersion, const nsTArray<nsCString>& aMimeTypes,
const nsTArray<nsCString>& aMimeDescriptions,
const nsTArray<nsCString>& aExtensions)
: mName(aName),
mDescription(aDescription),
mFileName(aFileName),
mVersion(aVersion),
mMimeTypes(aMimeTypes.Clone()),
mMimeDescriptions(aMimeDescriptions.Clone()),
mExtensions(aExtensions.Clone()) {}
nsIInternalPluginTag::~nsIInternalPluginTag() = default;
bool nsIInternalPluginTag::HasExtension(const nsACString& aExtension,
nsACString& aMatchingType) const {
return SearchExtensions(mExtensions, mMimeTypes, aExtension, aMatchingType);
}
bool nsIInternalPluginTag::HasMimeType(const nsACString& aMimeType) const {
return mMimeTypes.Contains(aMimeType,
nsCaseInsensitiveCStringArrayComparator());
}
/* nsFakePluginTag */
nsFakePluginTag::nsFakePluginTag()
: mId(sNextId++), mState(ePluginState_Disabled) {}
nsFakePluginTag::nsFakePluginTag(uint32_t aId,
already_AddRefed<nsIURI>&& aHandlerURI,
const char* aName, const char* aDescription,
const nsTArray<nsCString>& aMimeTypes,
const nsTArray<nsCString>& aMimeDescriptions,
const nsTArray<nsCString>& aExtensions,
const nsCString& aNiceName,
const nsString& aSandboxScript)
: nsIInternalPluginTag(aName, aDescription, nullptr, nullptr, aMimeTypes,
aMimeDescriptions, aExtensions),
mId(aId),
mHandlerURI(aHandlerURI),
mNiceName(aNiceName),
mSandboxScript(aSandboxScript),
mState(ePluginState_Enabled) {}
nsFakePluginTag::~nsFakePluginTag() = default;
NS_IMPL_ADDREF(nsFakePluginTag)
NS_IMPL_RELEASE(nsFakePluginTag)
NS_INTERFACE_TABLE_HEAD(nsFakePluginTag)
NS_INTERFACE_TABLE_BEGIN
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(nsFakePluginTag, nsIPluginTag,
nsIInternalPluginTag)
NS_INTERFACE_TABLE_ENTRY(nsFakePluginTag, nsIInternalPluginTag)
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(nsFakePluginTag, nsISupports,
nsIInternalPluginTag)
NS_INTERFACE_TABLE_ENTRY(nsFakePluginTag, nsIFakePluginTag)
NS_INTERFACE_TABLE_END
NS_INTERFACE_TABLE_TAIL
/* static */
nsresult nsFakePluginTag::Create(const FakePluginTagInit& aInitDictionary,
nsFakePluginTag** aPluginTag) {
NS_ENSURE_TRUE(sNextId <= PR_INT32_MAX, NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(!aInitDictionary.mMimeEntries.IsEmpty(), NS_ERROR_INVALID_ARG);
RefPtr<nsFakePluginTag> tag = new nsFakePluginTag();
nsresult rv =
NS_NewURI(getter_AddRefs(tag->mHandlerURI), aInitDictionary.mHandlerURI);
NS_ENSURE_SUCCESS(rv, rv);
CopyUTF16toUTF8(aInitDictionary.mNiceName, tag->mNiceName);
CopyUTF16toUTF8(aInitDictionary.mFullPath, tag->mFullPath);
CopyUTF16toUTF8(aInitDictionary.mName, tag->mName);
CopyUTF16toUTF8(aInitDictionary.mDescription, tag->mDescription);
CopyUTF16toUTF8(aInitDictionary.mFileName, tag->mFileName);
CopyUTF16toUTF8(aInitDictionary.mVersion, tag->mVersion);
tag->mSandboxScript = aInitDictionary.mSandboxScript;
for (const mozilla::dom::FakePluginMimeEntry& mimeEntry :
aInitDictionary.mMimeEntries) {
CopyUTF16toUTF8(mimeEntry.mType, *tag->mMimeTypes.AppendElement());
CopyUTF16toUTF8(mimeEntry.mDescription,
*tag->mMimeDescriptions.AppendElement());
CopyUTF16toUTF8(mimeEntry.mExtension, *tag->mExtensions.AppendElement());
}
tag.forget(aPluginTag);
return NS_OK;
}
bool nsFakePluginTag::HandlerURIMatches(nsIURI* aURI) {
bool equals = false;
return NS_SUCCEEDED(mHandlerURI->Equals(aURI, &equals)) && equals;
}
NS_IMETHODIMP
nsFakePluginTag::GetHandlerURI(nsIURI** aResult) {
NS_IF_ADDREF(*aResult = mHandlerURI);
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetSandboxScript(nsAString& aSandboxScript) {
aSandboxScript = mSandboxScript;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetDescription(/* utf-8 */ nsACString& aResult) {
aResult = mDescription;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetIsFlashPlugin(bool* aIsFlash) {
*aIsFlash = false;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetFilename(/* utf-8 */ nsACString& aResult) {
aResult = mFileName;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetFullpath(/* utf-8 */ nsACString& aResult) {
aResult = mFullPath;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetVersion(/* utf-8 */ nsACString& aResult) {
aResult = mVersion;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetName(/* utf-8 */ nsACString& aResult) {
aResult = mName;
return NS_OK;
}
const nsCString& nsFakePluginTag::GetNiceFileName() {
// We don't try to mimic the special-cased flash/java names if the fake plugin
// claims one of their MIME types, but do allow directly setting niceName if
// emulating those is desired.
if (mNiceName.IsEmpty() && !mFileName.IsEmpty()) {
mNiceName = MakeNiceFileName(mFileName);
}
return mNiceName;
}
NS_IMETHODIMP
nsFakePluginTag::GetNiceName(/* utf-8 */ nsACString& aResult) {
aResult = GetNiceFileName();
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetBlocklistState(uint32_t* aResult) {
// Fake tags don't currently support blocklisting
*aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetBlocklisted(bool* aBlocklisted) {
// Fake tags can't be blocklisted
*aBlocklisted = false;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetIsEnabledStateLocked(bool* aIsEnabledStateLocked) {
return IsEnabledStateLockedForPlugin(this, aIsEnabledStateLocked);
}
bool nsFakePluginTag::IsEnabled() {
return mState == ePluginState_Enabled || mState == ePluginState_Clicktoplay;
}
NS_IMETHODIMP
nsFakePluginTag::GetDisabled(bool* aDisabled) {
*aDisabled = !IsEnabled();
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetClicktoplay(bool* aClicktoplay) {
*aClicktoplay = (mState == ePluginState_Clicktoplay);
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetEnabledState(uint32_t* aEnabledState) {
*aEnabledState = (uint32_t)mState;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::SetEnabledState(uint32_t aEnabledState) {
// There are static asserts above enforcing that this enum matches
mState = (PluginState)aEnabledState;
// FIXME-jsplugins update
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetMimeTypes(nsTArray<nsCString>& aResults) {
aResults = mMimeTypes.Clone();
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetMimeDescriptions(nsTArray<nsCString>& aResults) {
aResults = mMimeDescriptions.Clone();
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetExtensions(nsTArray<nsCString>& aResults) {
aResults = mExtensions.Clone();
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetActive(bool* aResult) {
// Fake plugins can't be blocklisted, so this is just !Disabled
*aResult = IsEnabled();
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetLastModifiedTime(PRTime* aLastModifiedTime) {
// FIXME-jsplugins What should this return, if anything?
MOZ_ASSERT(aLastModifiedTime);
*aLastModifiedTime = 0;
return NS_OK;
}
// We don't load fake plugins out of a library, so they should always be there.
NS_IMETHODIMP
nsFakePluginTag::GetLoaded(bool* ret) {
*ret = true;
return NS_OK;
}
NS_IMETHODIMP
nsFakePluginTag::GetId(uint32_t* aId) {
*aId = mId;
return NS_OK;
}

View File

@@ -1,149 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsPluginTags_h_
#define nsPluginTags_h_
#include "mozilla/Attributes.h"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "nsIPluginTag.h"
#include "nsITimer.h"
#include "nsString.h"
class nsIURI;
namespace mozilla::dom {
struct FakePluginTagInit;
} // namespace mozilla::dom
// An interface representing plugin tags internally.
#define NS_IINTERNALPLUGINTAG_IID \
{ \
0xe8fdd227, 0x27da, 0x46ee, { \
0xbe, 0xf3, 0x1a, 0xef, 0x5a, 0x8f, 0xc5, 0xb4 \
} \
}
class nsIInternalPluginTag : public nsIPluginTag {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IINTERNALPLUGINTAG_IID)
nsIInternalPluginTag();
nsIInternalPluginTag(const char* aName, const char* aDescription,
const char* aFileName, const char* aVersion);
nsIInternalPluginTag(const char* aName, const char* aDescription,
const char* aFileName, const char* aVersion,
const nsTArray<nsCString>& aMimeTypes,
const nsTArray<nsCString>& aMimeDescriptions,
const nsTArray<nsCString>& aExtensions);
virtual bool IsEnabled() = 0;
virtual const nsCString& GetNiceFileName() = 0;
const nsCString& Name() const { return mName; }
const nsCString& Description() const { return mDescription; }
const nsTArray<nsCString>& MimeTypes() const { return mMimeTypes; }
const nsTArray<nsCString>& MimeDescriptions() const {
return mMimeDescriptions;
}
const nsTArray<nsCString>& Extensions() const { return mExtensions; }
const nsCString& FileName() const { return mFileName; }
const nsCString& Version() const { return mVersion; }
// Returns true if this plugin claims it supports this MIME type. The
// comparison is done ASCII-case-insensitively.
bool HasMimeType(const nsACString& aMimeType) const;
// Returns true if this plugin claims it supports the given extension. In
// that case, aMatchingType is set to the MIME type the plugin claims
// corresponds to this extension. The match on aExtension is done
// ASCII-case-insensitively.
bool HasExtension(const nsACString& aExtension,
/* out */ nsACString& aMatchingType) const;
// These must match the STATE_* values in nsIPluginTag.idl
enum PluginState {
ePluginState_Disabled = 0,
ePluginState_Clicktoplay = 1,
ePluginState_Enabled = 2,
ePluginState_MaxValue = 3,
};
protected:
~nsIInternalPluginTag();
nsCString mName; // UTF-8
nsCString mDescription; // UTF-8
nsCString mFileName; // UTF-8
nsCString mVersion; // UTF-8
nsTArray<nsCString> mMimeTypes; // UTF-8
nsTArray<nsCString> mMimeDescriptions; // UTF-8
nsTArray<nsCString> mExtensions; // UTF-8
static uint32_t sNextId;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIInternalPluginTag, NS_IINTERNALPLUGINTAG_IID)
// A class representing "fake" plugin tags for Javascript-based plugins.
// There are currently no other types of supported plugins.
class nsFakePluginTag : public nsIInternalPluginTag, public nsIFakePluginTag {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPLUGINTAG
NS_DECL_NSIFAKEPLUGINTAG
static nsresult Create(const mozilla::dom::FakePluginTagInit& aInitDictionary,
nsFakePluginTag** aPluginTag);
nsFakePluginTag(uint32_t aId, already_AddRefed<nsIURI>&& aHandlerURI,
const char* aName, const char* aDescription,
const nsTArray<nsCString>& aMimeTypes,
const nsTArray<nsCString>& aMimeDescriptions,
const nsTArray<nsCString>& aExtensions,
const nsCString& aNiceName, const nsString& aSandboxScript);
bool IsEnabled() override;
const nsCString& GetNiceFileName() override;
bool HandlerURIMatches(nsIURI* aURI);
nsIURI* HandlerURI() const { return mHandlerURI; }
uint32_t Id() const { return mId; }
const nsString& SandboxScript() const { return mSandboxScript; }
static const int32_t NOT_JSPLUGIN = -1;
private:
nsFakePluginTag();
virtual ~nsFakePluginTag();
// A unique id for this JS-implemented plugin. Registering a plugin through
// nsPluginHost::RegisterFakePlugin assigns a new id. The id is transferred
// through IPC when getting the list of JS-implemented plugins from child
// processes, so it should be consistent across processes.
// 0 is a valid id.
uint32_t mId;
// The URI of the handler for our fake plugin.
// FIXME-jsplugins do we need to sanity check these?
nsCOMPtr<nsIURI> mHandlerURI;
nsCString mFullPath;
nsCString mNiceName;
nsString mSandboxScript;
PluginState mState;
};
#endif // nsPluginTags_h_

View File

@@ -1979,9 +1979,6 @@ pref("dom.global_stop_script", true);
// Support the input event queue on the main thread of content process
pref("input_event_queue.supported", true);
// The default value for nsIPluginTag.enabledState (STATE_ENABLED = 2)
pref("plugin.default.state", 2);
// Enable multi by default.
#if !defined(MOZ_ASAN) && !defined(MOZ_TSAN)
pref("dom.ipc.processCount", 8);

View File

@@ -1321,7 +1321,7 @@ var gBlocklistLevel = DEFAULT_LEVEL;
* disable - can be used by the nsIBlocklistPrompt to allows users to decide
* whether a soft-blocked add-on should be disabled,
* blocked - true if the item is hard-blocked, false otherwise,
* item - the nsIPluginTag or Addon object
* item - the Addon object
*/
// It is not possible to use the one in Services since it will not successfully