Bug 1178963 part 1. Use nsIPluginTagInternal instead of nsPluginTag in cases where it may be nsFakePluginTag. r=peterv

This commit is contained in:
John Schoenick 2015-05-20 15:30:05 +02:00
parent 439268f16c
commit 6601080d53
11 changed files with 189 additions and 112 deletions

View File

@ -9,11 +9,13 @@
#include "mozilla/dom/MimeTypeArrayBinding.h"
#include "mozilla/dom/MimeTypeBinding.h"
#include "nsIDOMNavigator.h"
#include "nsPIDOMWindow.h"
#include "nsPluginArray.h"
#include "nsIMIMEService.h"
#include "nsIMIMEInfo.h"
#include "Navigator.h"
#include "nsServiceManagerUtils.h"
#include "nsPluginTags.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -216,19 +218,22 @@ NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsMimeType, Release)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsMimeType, mWindow, mPluginElement)
nsMimeType::nsMimeType(nsPIDOMWindow* aWindow, nsPluginElement* aPluginElement,
uint32_t aPluginTagMimeIndex, const nsAString& aType)
nsMimeType::nsMimeType(nsPIDOMWindow* aWindow,
nsPluginElement* aPluginElement,
const nsAString& aType,
const nsAString& aDescription,
const nsAString& aExtension)
: mWindow(aWindow),
mPluginElement(aPluginElement),
mPluginTagMimeIndex(aPluginTagMimeIndex),
mType(aType)
mType(aType),
mDescription(aDescription),
mExtension(aExtension)
{
}
nsMimeType::nsMimeType(nsPIDOMWindow* aWindow, const nsAString& aType)
: mWindow(aWindow),
mPluginElement(nullptr),
mPluginTagMimeIndex(0),
mType(aType)
{
}
@ -251,14 +256,9 @@ nsMimeType::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
}
void
nsMimeType::GetDescription(nsString& retval) const
nsMimeType::GetDescription(nsString& aRetval) const
{
retval.Truncate();
if (mPluginElement) {
CopyUTF8toUTF16(mPluginElement->PluginTag()->
mMimeDescriptions[mPluginTagMimeIndex], retval);
}
aRetval = mDescription;
}
nsPluginElement*
@ -269,14 +269,9 @@ nsMimeType::GetEnabledPlugin() const
}
void
nsMimeType::GetSuffixes(nsString& retval) const
nsMimeType::GetSuffixes(nsString& aRetval) const
{
retval.Truncate();
if (mPluginElement) {
CopyUTF8toUTF16(mPluginElement->PluginTag()->
mExtensions[mPluginTagMimeIndex], retval);
}
aRetval = mExtension;
}
void

View File

@ -58,8 +58,11 @@ public:
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsMimeType)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsMimeType)
nsMimeType(nsPIDOMWindow* aWindow, nsPluginElement* aPluginElement,
uint32_t aPluginTagMimeIndex, const nsAString& aMimeType);
nsMimeType(nsPIDOMWindow* aWindow,
nsPluginElement* aPluginElement,
const nsAString& aType,
const nsAString& aDescription,
const nsAString& aExtension);
nsMimeType(nsPIDOMWindow* aWindow, const nsAString& aMimeType);
nsPIDOMWindow* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
@ -85,8 +88,9 @@ protected:
// mimetype array. We rely on the cycle collector to break this
// cycle.
nsRefPtr<nsPluginElement> mPluginElement;
uint32_t mPluginTagMimeIndex;
nsString mType;
nsString mDescription;
nsString mExtension;
};
#endif /* nsMimeTypeArray_h___ */

View File

@ -130,7 +130,7 @@ nsPluginArray::Refresh(bool aReloadDocuments)
// that plugins did not change and was not reloaded
if (pluginHost->ReloadPlugins() ==
NS_ERROR_PLUGINS_PLUGINSNOTCHANGED) {
nsTArray<nsRefPtr<nsPluginTag> > newPluginTags;
nsTArray<nsCOMPtr<nsIInternalPluginTag> > newPluginTags;
pluginHost->GetPlugins(newPluginTags);
// Check if the number of plugins we know about are different from
@ -279,7 +279,7 @@ operator<(const nsRefPtr<nsPluginElement>& lhs,
const nsRefPtr<nsPluginElement>& rhs)
{
// Sort plugins alphabetically by name.
return lhs->PluginTag()->mName < rhs->PluginTag()->mName;
return lhs->PluginTag()->Name() < rhs->PluginTag()->Name();
}
void
@ -296,14 +296,13 @@ nsPluginArray::EnsurePlugins()
return;
}
nsTArray<nsRefPtr<nsPluginTag> > pluginTags;
nsTArray<nsCOMPtr<nsIInternalPluginTag> > pluginTags;
pluginHost->GetPlugins(pluginTags);
// need to wrap each of these with a nsPluginElement, which is
// scriptable.
for (uint32_t i = 0; i < pluginTags.Length(); ++i) {
nsPluginTag* pluginTag = pluginTags[i];
mPlugins.AppendElement(new nsPluginElement(mWindow, pluginTag));
mPlugins.AppendElement(new nsPluginElement(mWindow, pluginTags[i]));
}
// Alphabetize the enumeration order of non-hidden plugins to reduce
@ -323,7 +322,7 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginElement, mWindow, mMimeTypes)
nsPluginElement::nsPluginElement(nsPIDOMWindow* aWindow,
nsPluginTag* aPluginTag)
nsIInternalPluginTag* aPluginTag)
: mWindow(aWindow),
mPluginTag(aPluginTag)
{
@ -349,25 +348,25 @@ nsPluginElement::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
void
nsPluginElement::GetDescription(nsString& retval) const
{
CopyUTF8toUTF16(mPluginTag->mDescription, retval);
CopyUTF8toUTF16(mPluginTag->Description(), retval);
}
void
nsPluginElement::GetFilename(nsString& retval) const
{
CopyUTF8toUTF16(mPluginTag->mFileName, retval);
CopyUTF8toUTF16(mPluginTag->FileName(), retval);
}
void
nsPluginElement::GetVersion(nsString& retval) const
{
CopyUTF8toUTF16(mPluginTag->mVersion, retval);
CopyUTF8toUTF16(mPluginTag->Version(), retval);
}
void
nsPluginElement::GetName(nsString& retval) const
{
CopyUTF8toUTF16(mPluginTag->mName, retval);
CopyUTF8toUTF16(mPluginTag->Name(), retval);
}
nsMimeType*
@ -452,8 +451,18 @@ nsPluginElement::EnsurePluginMimeTypes()
return;
}
for (uint32_t i = 0; i < mPluginTag->mMimeTypes.Length(); ++i) {
NS_ConvertUTF8toUTF16 type(mPluginTag->mMimeTypes[i]);
mMimeTypes.AppendElement(new nsMimeType(mWindow, this, i, type));
if (mPluginTag->MimeTypes().Length() != mPluginTag->MimeDescriptions().Length() ||
mPluginTag->MimeTypes().Length() != mPluginTag->Extensions().Length()) {
MOZ_ASSERT(false, "mime type arrays expected to be the same length");
return;
}
for (uint32_t i = 0; i < mPluginTag->MimeTypes().Length(); ++i) {
NS_ConvertUTF8toUTF16 type(mPluginTag->MimeTypes()[i]);
NS_ConvertUTF8toUTF16 description(mPluginTag->MimeDescriptions()[i]);
NS_ConvertUTF8toUTF16 extension(mPluginTag->Extensions()[i]);
mMimeTypes.AppendElement(new nsMimeType(mWindow, this, type, description,
extension));
}
}

View File

@ -11,11 +11,11 @@
#include "nsWeakReference.h"
#include "nsIObserver.h"
#include "nsWrapperCache.h"
#include "nsPluginTags.h"
#include "nsPIDOMWindow.h"
class nsPluginElement;
class nsMimeType;
class nsIInternalPluginTag;
class nsPluginArray final : public nsIObserver,
public nsSupportsWeakReference,
@ -70,12 +70,12 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPluginElement)
nsPluginElement(nsPIDOMWindow* aWindow, nsPluginTag* aPluginTag);
nsPluginElement(nsPIDOMWindow* aWindow, nsIInternalPluginTag* aPluginTag);
nsPIDOMWindow* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
nsPluginTag* PluginTag() const
nsIInternalPluginTag* PluginTag() const
{
return mPluginTag;
}
@ -102,7 +102,7 @@ protected:
void EnsurePluginMimeTypes();
nsCOMPtr<nsPIDOMWindow> mWindow;
nsRefPtr<nsPluginTag> mPluginTag;
nsCOMPtr<nsIInternalPluginTag> mPluginTag;
nsTArray<nsRefPtr<nsMimeType> > mMimeTypes;
};

View File

@ -750,7 +750,7 @@ HangMonitoredProcess::GetPluginName(nsACString& aPluginName)
return NS_ERROR_UNEXPECTED;
}
aPluginName = tag->mName;
aPluginName = tag->Name();
return NS_OK;
}

View File

@ -1673,8 +1673,8 @@ nsNPAPIPluginInstance::CarbonNPAPIFailure()
static bool
GetJavaVersionFromMimetype(nsPluginTag* pluginTag, nsCString& version)
{
for (uint32_t i = 0; i < pluginTag->mMimeTypes.Length(); ++i) {
nsCString type = pluginTag->mMimeTypes[i];
for (uint32_t i = 0; i < pluginTag->MimeTypes().Length(); ++i) {
nsCString type = pluginTag->MimeTypes()[i];
nsAutoCString jpi("application/x-java-applet;jpi-version=");
int32_t idx = type.Find(jpi, false, 0, -1);

View File

@ -230,7 +230,7 @@ nsInvalidPluginTag::~nsInvalidPluginTag()
// Helper to check for a MIME in a comma-delimited preference
static bool
IsTypeInList(nsCString &aMimeType, nsCString aTypeList)
IsTypeInList(const nsCString& aMimeType, nsCString aTypeList)
{
nsAutoCString searchStr;
searchStr.Assign(',');
@ -998,7 +998,7 @@ nsPluginHost::TrySetUpPluginInstance(const nsACString &aMimeType,
#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_CRASHREPORTER)
if (pluginTag->mIsFlashPlugin) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("FlashVersion"), pluginTag->mVersion);
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("FlashVersion"), pluginTag->Version());
}
#endif
@ -1156,7 +1156,7 @@ nsPluginHost::HavePluginForExtension(const nsACString & aExtension,
}
void
nsPluginHost::GetPlugins(nsTArray<nsRefPtr<nsPluginTag> >& aPluginArray,
nsPluginHost::GetPlugins(nsTArray<nsCOMPtr<nsIInternalPluginTag>>& aPluginArray,
bool aIncludeDisabled)
{
aPluginArray.Clear();
@ -1217,7 +1217,7 @@ nsPluginHost::FindPreferredPlugin(const InfallibleTArray<nsPluginTag*>& matches)
nsPluginTag *preferredPlugin = matches[0];
for (unsigned int i = 1; i < matches.Length(); i++) {
if (mozilla::Version(matches[i]->mVersion.get()) > preferredPlugin->mVersion.get()) {
if (mozilla::Version(matches[i]->Version().get()) > preferredPlugin->Version().get()) {
preferredPlugin = matches[i];
}
}
@ -1411,12 +1411,12 @@ nsresult nsPluginHost::GetPlugin(const nsACString &aMimeType,
rv = NS_OK;
PLUGIN_LOG(PLUGIN_LOG_BASIC,
("nsPluginHost::GetPlugin Begin mime=%s, plugin=%s\n",
PromiseFlatCString(aMimeType).get(), pluginTag->mFileName.get()));
PromiseFlatCString(aMimeType).get(), pluginTag->FileName().get()));
#ifdef DEBUG
if (!pluginTag->mFileName.IsEmpty())
if (!pluginTag->FileName().IsEmpty())
printf("For %s found plugin %s\n",
PromiseFlatCString(aMimeType).get(), pluginTag->mFileName.get());
PromiseFlatCString(aMimeType).get(), pluginTag->FileName().get());
#endif
rv = EnsurePluginLoaded(pluginTag);
@ -1431,7 +1431,7 @@ nsresult nsPluginHost::GetPlugin(const nsACString &aMimeType,
PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("nsPluginHost::GetPlugin End mime=%s, rv=%d, plugin=%p name=%s\n",
PromiseFlatCString(aMimeType).get(), rv, *aPlugin,
(pluginTag ? pluginTag->mFileName.get() : "(not found)")));
(pluginTag ? pluginTag->FileName().get() : "(not found)")));
return rv;
}
@ -1970,7 +1970,7 @@ nsPluginHost::ShouldAddPlugin(nsPluginTag* aPluginTag)
#if defined(XP_WIN) && (defined(__x86_64__) || defined(_M_X64))
// On 64-bit windows, the only plugin we should load is flash. Use library
// filename and MIME type to check.
if (StringBeginsWith(aPluginTag->mFileName, NS_LITERAL_CSTRING("NPSWF"), nsCaseInsensitiveCStringComparator()) &&
if (StringBeginsWith(aPluginTag->FileName(), NS_LITERAL_CSTRING("NPSWF"), nsCaseInsensitiveCStringComparator()) &&
(aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-shockwave-flash")) ||
aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-shockwave-flash-test")))) {
return true;
@ -1983,7 +1983,7 @@ nsPluginHost::ShouldAddPlugin(nsPluginTag* aPluginTag)
}
#ifdef PLUGIN_LOGGING
PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("ShouldAddPlugin : Ignoring non-flash plugin library %s\n", aPluginTag->mFileName.get()));
("ShouldAddPlugin : Ignoring non-flash plugin library %s\n", aPluginTag->FileName().get()));
#endif // PLUGIN_LOGGING
return false;
#else
@ -2003,9 +2003,9 @@ nsPluginHost::AddPluginTag(nsPluginTag* aPluginTag)
if (aPluginTag->IsActive()) {
nsAdoptingCString disableFullPage =
Preferences::GetCString(kPrefDisableFullPage);
for (uint32_t i = 0; i < aPluginTag->mMimeTypes.Length(); i++) {
if (!IsTypeInList(aPluginTag->mMimeTypes[i], disableFullPage)) {
RegisterWithCategoryManager(aPluginTag->mMimeTypes[i],
for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
if (!IsTypeInList(aPluginTag->MimeTypes()[i], disableFullPage)) {
RegisterWithCategoryManager(aPluginTag->MimeTypes()[i],
ePluginRegister);
}
}
@ -2590,11 +2590,15 @@ nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch,
return;
}
nsTArray<nsRefPtr<nsPluginTag>> plugins;
nsTArray<nsCOMPtr<nsIInternalPluginTag>> plugins;
GetPlugins(plugins, true);
for (size_t i = 0; i < plugins.Length(); i++) {
nsRefPtr<nsPluginTag> tag = plugins[i];
nsCOMPtr<nsIInternalPluginTag> basetag = plugins[i];
/// XXX(johns) Bug FIXME-jsplugins - We need to cleanup the various plugintag classes
/// to be more sane and avoid this dance
nsPluginTag *tag = static_cast<nsPluginTag *>(basetag.get());
if (!nsNPAPIPlugin::RunPluginOOP(tag)) {
// Don't expose non-OOP plugins to content processes since we have no way
@ -2603,15 +2607,15 @@ nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch,
}
aPlugins->AppendElement(PluginTag(tag->mId,
tag->mName,
tag->mDescription,
tag->mMimeTypes,
tag->mMimeDescriptions,
tag->mExtensions,
tag->Name(),
tag->Description(),
tag->MimeTypes(),
tag->MimeDescriptions(),
tag->Extensions(),
tag->mIsJavaPlugin,
tag->mIsFlashPlugin,
tag->mFileName,
tag->mVersion,
tag->FileName(),
tag->Version(),
tag->mLastModifiedTime,
tag->IsFromExtension()));
}
@ -2634,18 +2638,18 @@ nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
// Update types with category manager
nsAdoptingCString disableFullPage =
Preferences::GetCString(kPrefDisableFullPage);
for (uint32_t i = 0; i < aPluginTag->mMimeTypes.Length(); i++) {
for (uint32_t i = 0; i < aPluginTag->MimeTypes().Length(); i++) {
nsRegisterType shouldRegister;
if (IsTypeInList(aPluginTag->mMimeTypes[i], disableFullPage)) {
if (IsTypeInList(aPluginTag->MimeTypes()[i], disableFullPage)) {
shouldRegister = ePluginUnregister;
} else {
nsPluginTag *plugin = FindNativePluginForType(aPluginTag->mMimeTypes[i],
nsPluginTag *plugin = FindNativePluginForType(aPluginTag->MimeTypes()[i],
true);
shouldRegister = plugin ? ePluginRegister : ePluginUnregister;
}
RegisterWithCategoryManager(aPluginTag->mMimeTypes[i], shouldRegister);
RegisterWithCategoryManager(aPluginTag->MimeTypes()[i], shouldRegister);
}
nsCOMPtr<nsIObserverService> obsService =
@ -2666,7 +2670,7 @@ nsPluginHost::IsTypeWhitelisted(const char *aMimeType)
}
void
nsPluginHost::RegisterWithCategoryManager(nsCString &aMimeType,
nsPluginHost::RegisterWithCategoryManager(const nsCString& aMimeType,
nsRegisterType aType)
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL,
@ -2768,13 +2772,13 @@ nsPluginHost::WritePluginInfo()
// filename & fullpath are on separate line
// because they can contain field delimiter char
PR_fprintf(fd, "%s%c%c\n%s%c%c\n%s%c%c\n",
(tag->mFileName.get()),
(tag->FileName().get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
(tag->mFullPath.get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
(tag->mVersion.get()),
(tag->Version().get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER);
@ -2792,23 +2796,23 @@ nsPluginHost::WritePluginInfo()
//description, name & mtypecount are on separate line
PR_fprintf(fd, "%s%c%c\n%s%c%c\n%d\n",
(tag->mDescription.get()),
(tag->Description().get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
(tag->mName.get()),
(tag->Name().get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER,
tag->mMimeTypes.Length());
tag->MimeTypes().Length());
// Add in each mimetype this plugin supports
for (uint32_t i = 0; i < tag->mMimeTypes.Length(); i++) {
for (uint32_t i = 0; i < tag->MimeTypes().Length(); i++) {
PR_fprintf(fd, "%d%c%s%c%s%c%s%c%c\n",
i,PLUGIN_REGISTRY_FIELD_DELIMITER,
(tag->mMimeTypes[i].get()),
(tag->MimeTypes()[i].get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
(tag->mMimeDescriptions[i].get()),
(tag->MimeDescriptions()[i].get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
(tag->mExtensions[i].get()),
(tag->Extensions()[i].get()),
PLUGIN_REGISTRY_FIELD_DELIMITER,
PLUGIN_REGISTRY_END_OF_LINE_MARKER);
}
@ -3153,7 +3157,7 @@ nsPluginHost::ReadPluginInfo()
}
MOZ_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_BASIC,
("LoadCachedPluginsInfo : Loading Cached plugininfo for %s\n", tag->mFileName.get()));
("LoadCachedPluginsInfo : Loading Cached plugininfo for %s\n", tag->FileName().get()));
if (!ShouldAddPlugin(tag)) {
continue;
@ -3881,7 +3885,7 @@ nsPluginHost::GetPluginName(nsNPAPIPluginInstance *aPluginInstance,
if (!plugin)
return NS_ERROR_FAILURE;
*aPluginName = TagForPlugin(plugin)->mName.get();
*aPluginName = TagForPlugin(plugin)->Name().get();
return NS_OK;
}

View File

@ -114,7 +114,7 @@ public:
/* out */ nsACString & aMimeType,
PluginFilter aFilter = eExcludeDisabled);
void GetPlugins(nsTArray<nsRefPtr<nsPluginTag> >& aPluginArray,
void GetPlugins(nsTArray<nsCOMPtr<nsIInternalPluginTag>>& aPluginArray,
bool aIncludeDisabled = false);
void FindPluginsForContent(uint32_t aPluginEpoch,
@ -287,7 +287,8 @@ private:
// Registers or unregisters the given mime type with the category manager
// (performs no checks - see UpdateCategoryManager)
enum nsRegisterType { ePluginRegister, ePluginUnregister };
void RegisterWithCategoryManager(nsCString &aMimeType, nsRegisterType aType);
void RegisterWithCategoryManager(const nsCString& aMimeType,
nsRegisterType aType);
void AddPluginTag(nsPluginTag* aPluginTag);

View File

@ -139,6 +139,39 @@ GetStatePrefNameForPlugin(nsPluginTag* aTag)
return MakePrefNameForPlugin("state", aTag);
}
/* nsIInternalPluginTag */
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)
, mMimeDescriptions(aMimeDescriptions)
, mExtensions(aExtensions)
{
}
nsIInternalPluginTag::~nsIInternalPluginTag()
{
}
/* nsPluginTag */
uint32_t nsPluginTag::sNextId;
@ -146,17 +179,15 @@ uint32_t nsPluginTag::sNextId;
nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo,
int64_t aLastModifiedTime,
bool fromExtension)
: mId(sNextId++),
: nsIInternalPluginTag(aPluginInfo->fName, aPluginInfo->fDescription,
aPluginInfo->fFileName, aPluginInfo->fVersion),
mId(sNextId++),
mContentProcessRunningCount(0),
mHadLocalInstance(false),
mName(aPluginInfo->fName),
mDescription(aPluginInfo->fDescription),
mLibrary(nullptr),
mIsJavaPlugin(false),
mIsFlashPlugin(false),
mFileName(aPluginInfo->fFileName),
mFullPath(aPluginInfo->fFullPath),
mVersion(aPluginInfo->fVersion),
mLastModifiedTime(aLastModifiedTime),
mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
mCachedBlocklistStateValid(false),
@ -182,16 +213,13 @@ nsPluginTag::nsPluginTag(const char* aName,
int64_t aLastModifiedTime,
bool fromExtension,
bool aArgsAreUTF8)
: mId(sNextId++),
: nsIInternalPluginTag(aName, aDescription, aFileName, aVersion),
mId(sNextId++),
mContentProcessRunningCount(0),
mName(aName),
mDescription(aDescription),
mLibrary(nullptr),
mIsJavaPlugin(false),
mIsFlashPlugin(false),
mFileName(aFileName),
mFullPath(aFullPath),
mVersion(aVersion),
mLastModifiedTime(aLastModifiedTime),
mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
mCachedBlocklistStateValid(false),
@ -217,18 +245,13 @@ nsPluginTag::nsPluginTag(uint32_t aId,
bool aIsFlashPlugin,
int64_t aLastModifiedTime,
bool aFromExtension)
: mId(aId),
: nsIInternalPluginTag(aName, aDescription, aFileName, aVersion, aMimeTypes,
aMimeDescriptions, aExtensions),
mId(aId),
mContentProcessRunningCount(0),
mName(aName),
mDescription(aDescription),
mMimeTypes(aMimeTypes),
mMimeDescriptions(aMimeDescriptions),
mExtensions(aExtensions),
mLibrary(nullptr),
mIsJavaPlugin(aIsJavaPlugin),
mIsFlashPlugin(aIsFlashPlugin),
mFileName(aFileName),
mVersion(aVersion),
mLastModifiedTime(aLastModifiedTime),
mNiceFileName(),
mCachedBlocklistState(nsIBlocklistService::STATE_NOT_BLOCKED),
@ -242,7 +265,7 @@ nsPluginTag::~nsPluginTag()
NS_ASSERTION(!mNext, "Risk of exhausting the stack space, bug 486349");
}
NS_IMPL_ISUPPORTS(nsPluginTag, nsIPluginTag)
NS_IMPL_ISUPPORTS(nsPluginTag, nsIPluginTag, nsIInternalPluginTag)
void nsPluginTag::InitMime(const char* const* aMimeTypes,
const char* const* aMimeDescriptions,

View File

@ -19,9 +19,57 @@ struct PRLibrary;
struct nsPluginInfo;
class nsNPAPIPlugin;
// 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(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;
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; }
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
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIInternalPluginTag, NS_IINTERNALPLUGINTAG_IID)
// A linked-list of plugin information that is used for instantiating plugins
// and reflecting plugin information into JavaScript.
class nsPluginTag final : public nsIPluginTag
class nsPluginTag final : public nsIInternalPluginTag
{
public:
NS_DECL_ISUPPORTS
@ -69,7 +117,7 @@ public:
// plugin is enabled and not blocklisted
bool IsActive();
bool IsEnabled();
bool IsEnabled() override;
void SetEnabled(bool enabled);
bool IsClicktoplay();
bool IsBlocklisted();
@ -94,18 +142,11 @@ public:
// True if we've ever created an instance of this plugin in the current process.
bool mHadLocalInstance;
nsCString mName; // UTF-8
nsCString mDescription; // UTF-8
nsTArray<nsCString> mMimeTypes; // UTF-8
nsTArray<nsCString> mMimeDescriptions; // UTF-8
nsTArray<nsCString> mExtensions; // UTF-8
PRLibrary *mLibrary;
nsRefPtr<nsNPAPIPlugin> mPlugin;
bool mIsJavaPlugin;
bool mIsFlashPlugin;
nsCString mFileName; // UTF-8
nsCString mFullPath; // UTF-8
nsCString mVersion; // UTF-8
int64_t mLastModifiedTime;
nsCOMPtr<nsITimer> mUnloadTimer;

View File

@ -1341,8 +1341,8 @@ PluginModuleParent::GetPluginDetails()
if (!pluginTag) {
return false;
}
mPluginName = pluginTag->mName;
mPluginVersion = pluginTag->mVersion;
mPluginName = pluginTag->Name();
mPluginVersion = pluginTag->Version();
mIsFlashPlugin = pluginTag->mIsFlashPlugin;
return true;
}