Bug 1178963 part 1. Use nsIPluginTagInternal instead of nsPluginTag in cases where it may be nsFakePluginTag. r=peterv
authorJohn Schoenick <jschoenick@mozilla.com>
Wed, 20 May 2015 15:30:05 +0200
changeset 254595 ae321edfafccfe0afa4794b9efe0501815c8f669
parent 254594 78171f294e4485017b7c4cc1f8c94da8227e7dcd
child 254596 a73ee6e0fc92722fbb1256b3eb43d8dc7a2267a1
push id29108
push userryanvm@gmail.com
push dateMon, 27 Jul 2015 14:12:01 +0000
treeherdermozilla-central@27ae736ef960 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1178963
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1178963 part 1. Use nsIPluginTagInternal instead of nsPluginTag in cases where it may be nsFakePluginTag. r=peterv
dom/base/nsMimeTypeArray.cpp
dom/base/nsMimeTypeArray.h
dom/base/nsPluginArray.cpp
dom/base/nsPluginArray.h
dom/ipc/ProcessHangMonitor.cpp
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginHost.h
dom/plugins/base/nsPluginTags.cpp
dom/plugins/base/nsPluginTags.h
dom/plugins/ipc/PluginModuleParent.cpp
--- a/dom/base/nsMimeTypeArray.cpp
+++ b/dom/base/nsMimeTypeArray.cpp
@@ -4,21 +4,23 @@
  * 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 "nsMimeTypeArray.h"
 
 #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;
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsMimeTypeArray)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsMimeTypeArray)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsMimeTypeArray)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@@ -211,29 +213,32 @@ nsMimeTypeArray::EnsurePluginMimeTypes()
   pluginArray->GetMimeTypes(mMimeTypes);
 }
 
 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsMimeType, AddRef)
 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)
 {
 }
 
 nsMimeType::~nsMimeType()
 {
 }
 
@@ -246,41 +251,31 @@ nsMimeType::GetParentObject() const
 
 JSObject*
 nsMimeType::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return MimeTypeBinding::Wrap(aCx, this, 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*
 nsMimeType::GetEnabledPlugin() const
 {
   return (mPluginElement && mPluginElement->PluginTag()->IsEnabled()) ?
     mPluginElement : nullptr;
 }
 
 void
-nsMimeType::GetSuffixes(nsString& retval) const
+nsMimeType::GetSuffixes(nsString& aRetval) const
 {
-  retval.Truncate();
-
-  if (mPluginElement) {
-    CopyUTF8toUTF16(mPluginElement->PluginTag()->
-                    mExtensions[mPluginTagMimeIndex], retval);
-  }
+  aRetval = mExtension;
 }
 
 void
 nsMimeType::GetType(nsString& aRetval) const
 {
   aRetval = mType;
 }
--- a/dom/base/nsMimeTypeArray.h
+++ b/dom/base/nsMimeTypeArray.h
@@ -53,18 +53,21 @@ protected:
 };
 
 class nsMimeType final : public nsWrapperCache
 {
 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;
 
   const nsString& Type() const
   {
     return mType;
   }
@@ -80,13 +83,14 @@ protected:
 
   nsCOMPtr<nsPIDOMWindow> mWindow;
 
   // Strong reference to the active plugin, if any. Note that this
   // creates an explicit reference cycle through the plugin element's
   // 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___ */
--- a/dom/base/nsPluginArray.cpp
+++ b/dom/base/nsPluginArray.cpp
@@ -125,17 +125,17 @@ nsPluginArray::Refresh(bool aReloadDocum
   if(!AllowPlugins() || !pluginHost) {
     return;
   }
 
   // NS_ERROR_PLUGINS_PLUGINSNOTCHANGED on reloading plugins indicates
   // 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
     // the number of plugin tags the plugin host knows about. If the
     // lengths are different, we refresh. This is safe because we're
     // notified for every plugin enabling/disabling event that
     // happens, and therefore the lengths will be in sync only when
     // the both arrays contain the same plugin tags (though as
@@ -274,41 +274,40 @@ nsPluginArray::AllowPlugins() const
   return docShell && docShell->PluginsAllowedInCurrentDoc();
 }
 
 static bool
 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
 nsPluginArray::EnsurePlugins()
 {
   if (!mPlugins.IsEmpty()) {
     // We already have an array of plugin elements.
     return;
   }
 
   nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
   if (!pluginHost) {
     // We have no plugin host.
     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
   // fingerprintable entropy based on plugins' installation file times.
   mPlugins.Sort();
 }
 
 // nsPluginElement implementation.
@@ -318,17 +317,17 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPlugi
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginElement)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginElement, mWindow, mMimeTypes)
 
 nsPluginElement::nsPluginElement(nsPIDOMWindow* aWindow,
-                                 nsPluginTag* aPluginTag)
+                                 nsIInternalPluginTag* aPluginTag)
   : mWindow(aWindow),
     mPluginTag(aPluginTag)
 {
 }
 
 nsPluginElement::~nsPluginElement()
 {
 }
@@ -344,35 +343,35 @@ JSObject*
 nsPluginElement::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return PluginBinding::Wrap(aCx, this, 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*
 nsPluginElement::Item(uint32_t aIndex)
 {
   EnsurePluginMimeTypes();
 
   return mMimeTypes.SafeElementAt(aIndex);
@@ -447,13 +446,23 @@ nsPluginElement::MimeTypes()
 
 void
 nsPluginElement::EnsurePluginMimeTypes()
 {
   if (!mMimeTypes.IsEmpty()) {
     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));
   }
 }
--- a/dom/base/nsPluginArray.h
+++ b/dom/base/nsPluginArray.h
@@ -6,21 +6,21 @@
 
 #ifndef nsPluginArray_h___
 #define nsPluginArray_h___
 
 #include "nsTArray.h"
 #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,
                             public nsWrapperCache
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsPluginArray,
@@ -65,22 +65,22 @@ private:
 
 class nsPluginElement final : public nsISupports,
                               public nsWrapperCache
 {
 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;
   }
 
   // Plugin WebIDL methods
 
   void GetDescription(nsString& retval) const;
   void GetFilename(nsString& retval) const;
@@ -97,13 +97,13 @@ public:
   nsTArray<nsRefPtr<nsMimeType> >& MimeTypes();
 
 protected:
   ~nsPluginElement();
 
   void EnsurePluginMimeTypes();
 
   nsCOMPtr<nsPIDOMWindow> mWindow;
-  nsRefPtr<nsPluginTag> mPluginTag;
+  nsCOMPtr<nsIInternalPluginTag> mPluginTag;
   nsTArray<nsRefPtr<nsMimeType> > mMimeTypes;
 };
 
 #endif /* nsPluginArray_h___ */
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -745,17 +745,17 @@ HangMonitoredProcess::GetPluginName(nsAC
   uint32_t id = mHangData.get_PluginHangData().pluginId();
 
   nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
   nsPluginTag* tag = host->PluginWithId(id);
   if (!tag) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  aPluginName = tag->mName;
+  aPluginName = tag->Name();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HangMonitoredProcess::TerminateScript()
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   if (mHangData.type() != HangData::TSlowScriptData) {
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -1668,18 +1668,18 @@ nsNPAPIPluginInstance::CarbonNPAPIFailur
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch CarbonEventModelFailureEvent.");
   }
 }
 
 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);
     if (idx != 0) {
       continue;
     }
 
     type.Cut(0, jpi.Length());
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -225,17 +225,17 @@ nsInvalidPluginTag::nsInvalidPluginTag(c
   mSeen(false)
 {}
 
 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(',');
   searchStr.Append(aTypeList);
   searchStr.Append(',');
 
   nsACString::const_iterator start, end;
 
@@ -993,17 +993,17 @@ nsPluginHost::TrySetUpPluginInstance(con
   nsPluginTag* pluginTag = FindNativePluginForType(aMimeType, true);
 
   NS_ASSERTION(pluginTag, "Must have plugin tag here!");
 
   plugin->GetLibrary()->SetHasLocalInstance();
 
 #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
 
   nsRefPtr<nsNPAPIPluginInstance> instance = new nsNPAPIPluginInstance();
 
   // This will create the owning reference. The connection must be made between the
   // instance and the instance owner before initialization. Plugins can call into
   // the browser during initialization.
@@ -1151,17 +1151,17 @@ nsPluginHost::HavePluginForExtension(con
                                      /* out */ nsACString & aMimeType,
                                      PluginFilter aFilter)
 {
   bool checkEnabled = aFilter & eExcludeDisabled;
   return FindNativePluginForExtension(aExtension, aMimeType, checkEnabled);
 }
 
 void
-nsPluginHost::GetPlugins(nsTArray<nsRefPtr<nsPluginTag> >& aPluginArray,
+nsPluginHost::GetPlugins(nsTArray<nsCOMPtr<nsIInternalPluginTag>>& aPluginArray,
                          bool aIncludeDisabled)
 {
   aPluginArray.Clear();
 
   LoadPlugins();
 
   nsPluginTag* plugin = mPlugins;
   while (plugin != nullptr) {
@@ -1212,17 +1212,17 @@ nsPluginHost::FindPreferredPlugin(const 
   ///             alphabetically.
 
   if (matches.IsEmpty()) {
     return nullptr;
   }
 
   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];
     }
   }
 
   return preferredPlugin;
 }
 
 nsPluginTag*
@@ -1406,37 +1406,37 @@ nsresult nsPluginHost::GetPlugin(const n
   // If plugins haven't been scanned yet, do so now
   LoadPlugins();
 
   nsPluginTag* pluginTag = FindNativePluginForType(aMimeType, true);
   if (pluginTag) {
     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);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     NS_ADDREF(*aPlugin = pluginTag->mPlugin);
     return NS_OK;
   }
 
   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;
 }
 
 // Normalize 'host' to ACE.
 nsresult
 nsPluginHost::NormalizeHostname(nsCString& host)
 {
@@ -1965,30 +1965,30 @@ struct CompareFilesByTime
 } // namespace
 
 bool
 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;
   }
   // Accept the test plugin MIME types, so mochitests still work.
   if (aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-test")) ||
       aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-Second-Test")) ||
       aPluginTag->HasMimeType(NS_LITERAL_CSTRING("application/x-java-test"))) {
     return true;
   }
 #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
   return true;
 #endif // defined(XP_WIN) && (defined(__x86_64__) || defined(_M_X64))
 }
 
 void
@@ -1998,19 +1998,19 @@ nsPluginHost::AddPluginTag(nsPluginTag* 
     return;
   }
   aPluginTag->mNext = mPlugins;
   mPlugins = 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);
       }
     }
   }
 }
 
 typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
 
@@ -2585,38 +2585,42 @@ nsPluginHost::FindPluginsForContent(uint
   // Load plugins so that the epoch is correct.
   LoadPlugins();
 
   *aNewPluginEpoch = ChromeEpoch();
   if (aPluginEpoch == ChromeEpoch()) {
     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
       // to bridge them over.
       continue;
     }
 
     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()));
   }
 }
 
 void
 nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
 {
@@ -2629,28 +2633,28 @@ nsPluginHost::UpdatePluginInfo(nsPluginT
 
   if (!aPluginTag) {
     return;
   }
 
   // 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 =
     mozilla::services::GetObserverService();
   if (obsService)
     obsService->NotifyObservers(nullptr, "plugin-info-updated", nullptr);
 }
 
@@ -2661,17 +2665,17 @@ nsPluginHost::IsTypeWhitelisted(const ch
   if (!whitelist.Length()) {
     return true;
   }
   nsDependentCString wrap(aMimeType);
   return IsTypeInList(wrap, whitelist);
 }
 
 void
-nsPluginHost::RegisterWithCategoryManager(nsCString &aMimeType,
+nsPluginHost::RegisterWithCategoryManager(const nsCString& aMimeType,
                                           nsRegisterType aType)
 {
   PLUGIN_LOG(PLUGIN_LOG_NORMAL,
              ("nsPluginTag::RegisterWithCategoryManager type = %s, removing = %s\n",
               aMimeType.get(), aType == ePluginUnregister ? "yes" : "no"));
 
   nsCOMPtr<nsICategoryManager> catMan =
     do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
@@ -2763,23 +2767,23 @@ nsPluginHost::WritePluginInfo()
   // Store all plugins in the mPlugins list - all plugins currently in use.
   PR_fprintf(fd, "\n[PLUGINS]\n");
 
   for (nsPluginTag *tag = mPlugins; tag; tag = tag->mNext) {
     // store each plugin info into the registry
     // 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);
 
     // lastModifiedTimeStamp|canUnload|tag->mFlags|fromExtension
     PR_fprintf(fd, "%lld%c%d%c%lu%c%d%c%c\n",
       tag->mLastModifiedTime,
       PLUGIN_REGISTRY_FIELD_DELIMITER,
       false, // did store whether or not to unload in-process plugins
@@ -2787,33 +2791,33 @@ nsPluginHost::WritePluginInfo()
       0, // legacy field for flags
       PLUGIN_REGISTRY_FIELD_DELIMITER,
       tag->IsFromExtension(),
       PLUGIN_REGISTRY_FIELD_DELIMITER,
       PLUGIN_REGISTRY_END_OF_LINE_MARKER);
 
     //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);
     }
   }
 
   PR_fprintf(fd, "\n[INVALID]\n");
 
   nsRefPtr<nsInvalidPluginTag> invalidPlugins = mInvalidPlugins;
@@ -3148,17 +3152,17 @@ nsPluginHost::ReadPluginInfo()
       delete [] heapalloced;
 
     // Import flags from registry into prefs for old registry versions
     if (hasValidFlags && !pluginStateImported) {
       tag->ImportFlagsToPrefs(tagflag);
     }
 
     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;
     }
 
     tag->mNext = mCachedPlugins;
     mCachedPlugins = tag;
   }
@@ -3876,17 +3880,17 @@ nsPluginHost::GetPluginName(nsNPAPIPlugi
   nsNPAPIPluginInstance *instance = static_cast<nsNPAPIPluginInstance*>(aPluginInstance);
   if (!instance)
     return NS_ERROR_FAILURE;
 
   nsNPAPIPlugin* plugin = instance->GetPlugin();
   if (!plugin)
     return NS_ERROR_FAILURE;
 
-  *aPluginName = TagForPlugin(plugin)->mName.get();
+  *aPluginName = TagForPlugin(plugin)->Name().get();
 
   return NS_OK;
 }
 
 nsresult
 nsPluginHost::GetPluginTagForInstance(nsNPAPIPluginInstance *aPluginInstance,
                                       nsIPluginTag **aPluginTag)
 {
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -109,17 +109,17 @@ public:
   bool HavePluginForType(const nsACString & aMimeType,
                          PluginFilter aFilter = eExcludeDisabled);
 
   // FIXME-jsplugins what if fake has different extensions
   bool HavePluginForExtension(const nsACString & aExtension,
                               /* 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,
                              nsTArray<mozilla::plugins::PluginTag>* aPlugins,
                              uint32_t* aNewPluginEpoch);
 
   nsresult GetURL(nsISupports* pluginInst,
                   const char* url,
@@ -282,17 +282,18 @@ private:
 
   nsresult
   FindPlugins(bool aCreatePluginList, bool * aPluginsChanged);
 
   // FIXME revisit, no ns prefix
   // 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);
 
   nsresult
   ScanPluginsDirectory(nsIFile *pluginsDir,
                        bool aCreatePluginList,
                        bool *aPluginsChanged);
 
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -134,34 +134,65 @@ CStringArrayToXPCArray(nsTArray<nsCStrin
 }
 
 static nsCString
 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;
 
 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),
     mIsFromExtension(fromExtension)
 {
   InitMime(aPluginInfo->fMimeTypeArray,
            aPluginInfo->fMimeDescriptionArray,
            aPluginInfo->fExtensionArray,
@@ -177,26 +208,23 @@ nsPluginTag::nsPluginTag(const char* aNa
                          const char* aVersion,
                          const char* const* aMimeTypes,
                          const char* const* aMimeDescriptions,
                          const char* const* aExtensions,
                          int32_t aVariants,
                          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),
     mIsFromExtension(fromExtension)
 {
   InitMime(aMimeTypes, aMimeDescriptions, aExtensions,
            static_cast<uint32_t>(aVariants));
   if (!aArgsAreUTF8)
@@ -212,42 +240,37 @@ nsPluginTag::nsPluginTag(uint32_t aId,
                          const char* aVersion,
                          nsTArray<nsCString> aMimeTypes,
                          nsTArray<nsCString> aMimeDescriptions,
                          nsTArray<nsCString> aExtensions,
                          bool aIsJavaPlugin,
                          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),
     mCachedBlocklistStateValid(false),
     mIsFromExtension(aFromExtension)
 {
 }
 
 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,
                            const char* const* aExtensions,
                            uint32_t aVariantCount)
 {
   if (!aMimeTypes) {
     return;
--- a/dom/plugins/base/nsPluginTags.h
+++ b/dom/plugins/base/nsPluginTags.h
@@ -14,19 +14,67 @@
 #include "nsIPluginTag.h"
 #include "nsITimer.h"
 #include "nsString.h"
 
 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
   NS_DECL_NSIPLUGINTAG
 
   // These must match the STATE_* values in nsIPluginTag.idl
   enum PluginState {
     ePluginState_Disabled = 0,
@@ -64,17 +112,17 @@ public:
               int64_t aLastModifiedTime,
               bool aFromExtension);
 
   void TryUnloadPlugin(bool inShutdown);
 
   // plugin is enabled and not blocklisted
   bool IsActive();
 
-  bool IsEnabled();
+  bool IsEnabled() override;
   void SetEnabled(bool enabled);
   bool IsClicktoplay();
   bool IsBlocklisted();
 
   PluginState GetPluginState();
   void SetPluginState(PluginState state);
 
   // import legacy flags from plugin registry into the preferences
@@ -89,28 +137,21 @@ public:
   uint32_t      mId;
 
   // Number of PluginModuleParents living in all content processes.
   size_t        mContentProcessRunningCount;
 
   // 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;
 
   void          InvalidateBlocklistState();
 
   // Returns true if this plugin claims it supports this MIME type.  The
   // comparison is done ASCII-case-insensitively.
   bool          HasMimeType(const nsACString & aMimeType) const;
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -1336,18 +1336,18 @@ PluginModuleParent::GetPluginDetails()
     nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
     if (!host) {
         return false;
     }
     nsPluginTag* pluginTag = host->TagForPlugin(mPlugin);
     if (!pluginTag) {
         return false;
     }
-    mPluginName = pluginTag->mName;
-    mPluginVersion = pluginTag->mVersion;
+    mPluginName = pluginTag->Name();
+    mPluginVersion = pluginTag->Version();
     mIsFlashPlugin = pluginTag->mIsFlashPlugin;
     return true;
 }
 
 #ifdef XP_WIN
 void
 PluginModuleChromeParent::EvaluateHangUIState(const bool aReset)
 {