2001-09-25 22:43:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
1999-04-20 19:18:51 +00:00
|
|
|
|
|
|
|
#include "nsPluginArray.h"
|
2013-08-14 06:56:21 +00:00
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-07-09 13:58:21 +00:00
|
|
|
#include "mozilla/dom/PluginArrayBinding.h"
|
|
|
|
#include "mozilla/dom/PluginBinding.h"
|
2013-11-01 05:19:09 +00:00
|
|
|
|
|
|
|
#include "nsCharSeparatedTokenizer.h"
|
1999-04-20 19:18:51 +00:00
|
|
|
#include "nsMimeTypeArray.h"
|
2011-11-02 13:44:16 +00:00
|
|
|
#include "Navigator.h"
|
2001-01-23 22:29:41 +00:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIWebNavigation.h"
|
2011-05-21 13:28:54 +00:00
|
|
|
#include "nsPluginHost.h"
|
2013-07-09 13:58:21 +00:00
|
|
|
#include "nsPluginTags.h"
|
2013-04-10 20:59:45 +00:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIWeakReference.h"
|
|
|
|
#include "mozilla/Services.h"
|
2013-07-09 13:58:21 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2011-11-02 13:44:16 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2013-08-28 20:55:29 +00:00
|
|
|
nsPluginArray::nsPluginArray(nsPIDOMWindow* aWindow)
|
2013-07-09 13:58:21 +00:00
|
|
|
: mWindow(aWindow)
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-10 20:59:45 +00:00
|
|
|
void
|
|
|
|
nsPluginArray::Init()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obsService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (obsService) {
|
|
|
|
obsService->AddObserver(this, "plugin-info-updated", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-10 19:48:22 +00:00
|
|
|
nsPluginArray::~nsPluginArray()
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPIDOMWindow*
|
|
|
|
nsPluginArray::GetParentObject() const
|
|
|
|
{
|
2013-08-28 20:55:29 +00:00
|
|
|
MOZ_ASSERT(mWindow);
|
|
|
|
return mWindow;
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-08 22:27:18 +00:00
|
|
|
nsPluginArray::WrapObject(JSContext* aCx)
|
2013-07-09 13:58:21 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return PluginArrayBinding::Wrap(aCx, this);
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
2010-01-12 13:08:43 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPluginArray)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPluginArray)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginArray)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
2013-04-10 20:59:45 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-29 08:57:00 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginArray,
|
|
|
|
mWindow,
|
|
|
|
mPlugins,
|
|
|
|
mHiddenPlugins)
|
2013-11-01 05:19:09 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
GetPluginMimeTypes(const nsTArray<nsRefPtr<nsPluginElement> >& aPlugins,
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> >& aMimeTypes)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < aPlugins.Length(); ++i) {
|
|
|
|
nsPluginElement *plugin = aPlugins[i];
|
|
|
|
aMimeTypes.AppendElements(plugin->MimeTypes());
|
|
|
|
}
|
|
|
|
}
|
2000-11-29 02:26:11 +00:00
|
|
|
|
2012-09-18 07:56:14 +00:00
|
|
|
static bool
|
|
|
|
operator<(const nsRefPtr<nsMimeType>& lhs, const nsRefPtr<nsMimeType>& rhs)
|
|
|
|
{
|
|
|
|
// Sort MIME types alphabetically by type name.
|
|
|
|
return lhs->Type() < rhs->Type();
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
2013-11-01 05:19:09 +00:00
|
|
|
nsPluginArray::GetMimeTypes(nsTArray<nsRefPtr<nsMimeType> >& aMimeTypes,
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> >& aHiddenMimeTypes)
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-10-17 07:19:43 +00:00
|
|
|
aMimeTypes.Clear();
|
2013-11-01 05:19:09 +00:00
|
|
|
aHiddenMimeTypes.Clear();
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-12-01 08:28:16 +00:00
|
|
|
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePlugins();
|
2006-03-21 05:31:59 +00:00
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
GetPluginMimeTypes(mPlugins, aMimeTypes);
|
|
|
|
GetPluginMimeTypes(mHiddenPlugins, aHiddenMimeTypes);
|
2012-09-18 07:56:14 +00:00
|
|
|
|
|
|
|
// Alphabetize the enumeration order of non-hidden MIME types to reduce
|
|
|
|
// fingerprintable entropy based on plugins' installation file times.
|
|
|
|
aMimeTypes.Sort();
|
2006-03-21 05:31:59 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::Item(uint32_t aIndex)
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
bool unused;
|
|
|
|
return IndexedGetter(aIndex, unused);
|
2008-10-22 14:31:14 +00:00
|
|
|
}
|
2000-11-29 02:26:11 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::NamedItem(const nsAString& aName)
|
2008-10-22 14:31:14 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
bool unused;
|
|
|
|
return NamedGetter(aName, unused);
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginArray::Refresh(bool aReloadDocuments)
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2000-11-29 02:26:11 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
if(!AllowPlugins() || !pluginHost) {
|
|
|
|
return;
|
2000-11-29 02:26:11 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
// 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;
|
|
|
|
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
|
|
|
|
// different types).
|
2013-11-01 05:19:09 +00:00
|
|
|
uint32_t pluginCount = mPlugins.Length() + mHiddenPlugins.Length();
|
|
|
|
if (newPluginTags.Length() == pluginCount) {
|
2013-07-09 13:58:21 +00:00
|
|
|
return;
|
2000-11-29 02:26:11 +00:00
|
|
|
}
|
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
mPlugins.Clear();
|
2013-11-01 05:19:09 +00:00
|
|
|
mHiddenPlugins.Clear();
|
2008-10-31 21:40:35 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsCOMPtr<nsIDOMNavigator> navigator;
|
2013-08-28 20:55:29 +00:00
|
|
|
mWindow->GetNavigator(getter_AddRefs(navigator));
|
2008-10-31 21:40:35 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
if (!navigator) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static_cast<mozilla::dom::Navigator*>(navigator.get())->RefreshMIMEArray();
|
2008-10-31 21:40:35 +00:00
|
|
|
|
2013-08-28 20:55:29 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mWindow);
|
2013-07-09 13:58:21 +00:00
|
|
|
if (aReloadDocuments && webNav) {
|
|
|
|
webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
|
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::IndexedGetter(uint32_t aIndex, bool &aFound)
|
2001-04-04 22:12:26 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
aFound = false;
|
2001-04-04 22:12:26 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2001-04-04 22:12:26 +00:00
|
|
|
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePlugins();
|
2001-04-04 22:12:26 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
aFound = aIndex < mPlugins.Length();
|
2001-04-04 22:12:26 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
return aFound ? mPlugins[aIndex] : nullptr;
|
2001-04-04 22:12:26 +00:00
|
|
|
}
|
|
|
|
|
2010-08-13 04:05:05 +00:00
|
|
|
void
|
|
|
|
nsPluginArray::Invalidate()
|
|
|
|
{
|
2013-04-10 20:59:45 +00:00
|
|
|
nsCOMPtr<nsIObserverService> obsService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (obsService) {
|
|
|
|
obsService->RemoveObserver(this, "plugin-info-updated");
|
|
|
|
}
|
2010-08-13 04:05:05 +00:00
|
|
|
}
|
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
static nsPluginElement*
|
|
|
|
FindPlugin(const nsTArray<nsRefPtr<nsPluginElement> >& aPlugins,
|
|
|
|
const nsAString& aName)
|
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < aPlugins.Length(); ++i) {
|
|
|
|
nsAutoString pluginName;
|
|
|
|
nsPluginElement* plugin = aPlugins[i];
|
|
|
|
plugin->GetName(pluginName);
|
|
|
|
|
|
|
|
if (pluginName.Equals(aName)) {
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::NamedGetter(const nsAString& aName, bool &aFound)
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
aFound = false;
|
2000-12-22 00:08:31 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return nullptr;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
}
|
|
|
|
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePlugins();
|
2000-12-22 00:08:31 +00:00
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
nsPluginElement* plugin = FindPlugin(mPlugins, aName);
|
|
|
|
if (!plugin) {
|
|
|
|
plugin = FindPlugin(mHiddenPlugins, aName);
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
2002-05-16 20:41:26 +00:00
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
aFound = (plugin != nullptr);
|
|
|
|
return plugin;
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
2002-05-16 20:41:26 +00:00
|
|
|
|
2014-04-16 02:58:44 +00:00
|
|
|
bool
|
|
|
|
nsPluginArray::NameIsEnumerable(const nsAString& aName)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
uint32_t
|
|
|
|
nsPluginArray::Length()
|
|
|
|
{
|
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return 0;
|
2002-05-16 20:41:26 +00:00
|
|
|
}
|
|
|
|
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePlugins();
|
2002-05-16 20:41:26 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
return mPlugins.Length();
|
|
|
|
}
|
2001-01-23 22:29:41 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
2014-04-16 02:58:44 +00:00
|
|
|
nsPluginArray::GetSupportedNames(unsigned, nsTArray<nsString>& aRetval)
|
2013-07-09 13:58:21 +00:00
|
|
|
{
|
|
|
|
aRetval.Clear();
|
|
|
|
|
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mPlugins.Length(); ++i) {
|
|
|
|
nsAutoString pluginName;
|
|
|
|
mPlugins[i]->GetName(pluginName);
|
|
|
|
|
|
|
|
aRetval.AppendElement(pluginName);
|
2000-11-29 02:26:11 +00:00
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-04-10 20:59:45 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginArray::Observe(nsISupports *aSubject, const char *aTopic,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t *aData) {
|
2013-04-10 20:59:45 +00:00
|
|
|
if (!nsCRT::strcmp(aTopic, "plugin-info-updated")) {
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
bool
|
|
|
|
nsPluginArray::AllowPlugins() const
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2014-01-10 02:03:47 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = mWindow ? mWindow->GetDocShell() : nullptr;
|
2013-07-09 13:58:21 +00:00
|
|
|
|
|
|
|
return docShell && docShell->PluginsAllowedInCurrentDoc();
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
static bool
|
|
|
|
HasStringPrefix(const nsCString& str, const nsACString& prefix) {
|
|
|
|
return str.Compare(prefix.BeginReading(), false, prefix.Length()) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
IsPluginEnumerable(const nsTArray<nsCString>& enumerableNames,
|
|
|
|
const nsPluginTag* pluginTag)
|
|
|
|
{
|
|
|
|
const nsCString& pluginName = pluginTag->mName;
|
|
|
|
|
|
|
|
const uint32_t length = enumerableNames.Length();
|
|
|
|
for (uint32_t i = 0; i < length; i++) {
|
|
|
|
const nsCString& name = enumerableNames[i];
|
|
|
|
if (HasStringPrefix(pluginName, name)) {
|
|
|
|
return true; // don't hide plugin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // hide plugin!
|
|
|
|
}
|
|
|
|
|
2012-09-18 07:56:14 +00:00
|
|
|
static bool
|
|
|
|
operator<(const nsRefPtr<nsPluginElement>& lhs,
|
|
|
|
const nsRefPtr<nsPluginElement>& rhs)
|
|
|
|
{
|
|
|
|
// Sort plugins alphabetically by name.
|
|
|
|
return lhs->PluginTag()->mName < rhs->PluginTag()->mName;
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginArray::EnsurePlugins()
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-11-01 05:19:09 +00:00
|
|
|
if (!mPlugins.IsEmpty() || !mHiddenPlugins.IsEmpty()) {
|
2013-10-20 07:05:05 +00:00
|
|
|
// We already have an array of plugin elements.
|
|
|
|
return;
|
|
|
|
}
|
2013-07-09 13:58:21 +00:00
|
|
|
|
2013-10-20 07:05:05 +00:00
|
|
|
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
|
|
|
if (!pluginHost) {
|
|
|
|
// We have no plugin host.
|
2013-07-09 13:58:21 +00:00
|
|
|
return;
|
2000-11-29 02:26:11 +00:00
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsTArray<nsRefPtr<nsPluginTag> > pluginTags;
|
|
|
|
pluginHost->GetPlugins(pluginTags);
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
nsTArray<nsCString> enumerableNames;
|
|
|
|
|
|
|
|
const nsAdoptingCString& enumerableNamesPref =
|
|
|
|
Preferences::GetCString("plugins.enumerable_names");
|
|
|
|
|
|
|
|
bool disablePluginHiding = !enumerableNamesPref ||
|
|
|
|
enumerableNamesPref.EqualsLiteral("*");
|
|
|
|
|
|
|
|
if (!disablePluginHiding) {
|
|
|
|
nsCCharSeparatedTokenizer tokens(enumerableNamesPref, ',');
|
|
|
|
while (tokens.hasMoreTokens()) {
|
|
|
|
const nsCSubstring& token = tokens.nextToken();
|
|
|
|
if (!token.IsEmpty()) {
|
|
|
|
enumerableNames.AppendElement(token);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
// need to wrap each of these with a nsPluginElement, which is
|
|
|
|
// scriptable.
|
|
|
|
for (uint32_t i = 0; i < pluginTags.Length(); ++i) {
|
2013-11-01 05:19:09 +00:00
|
|
|
nsPluginTag* pluginTag = pluginTags[i];
|
|
|
|
|
|
|
|
// Add the plugin to the list of hidden plugins or non-hidden plugins?
|
|
|
|
nsTArray<nsRefPtr<nsPluginElement> >& pluginArray =
|
|
|
|
(disablePluginHiding || IsPluginEnumerable(enumerableNames, pluginTag))
|
|
|
|
? mPlugins
|
|
|
|
: mHiddenPlugins;
|
|
|
|
|
|
|
|
pluginArray.AppendElement(new nsPluginElement(mWindow, pluginTag));
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
2012-09-18 07:56:14 +00:00
|
|
|
|
|
|
|
// Alphabetize the enumeration order of non-hidden plugins to reduce
|
|
|
|
// fingerprintable entropy based on plugins' installation file times.
|
|
|
|
mPlugins.Sort();
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
2010-01-12 13:08:43 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
// nsPluginElement implementation.
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPluginElement)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPluginElement)
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPluginElement)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-29 08:57:00 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginElement, mWindow, mMimeTypes)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
|
2013-08-28 20:55:29 +00:00
|
|
|
nsPluginElement::nsPluginElement(nsPIDOMWindow* aWindow,
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPluginTag* aPluginTag)
|
|
|
|
: mWindow(aWindow),
|
|
|
|
mPluginTag(aPluginTag)
|
|
|
|
{
|
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2014-06-30 23:00:30 +00:00
|
|
|
nsPluginElement::~nsPluginElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPIDOMWindow*
|
|
|
|
nsPluginElement::GetParentObject() const
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-08-28 20:55:29 +00:00
|
|
|
MOZ_ASSERT(mWindow);
|
|
|
|
return mWindow;
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:18 +00:00
|
|
|
nsPluginElement::WrapObject(JSContext* aCx)
|
2009-04-22 19:13:10 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return PluginBinding::Wrap(aCx, this);
|
2009-04-22 19:13:10 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginElement::GetDescription(nsString& retval) const
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
CopyUTF8toUTF16(mPluginTag->mDescription, retval);
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginElement::GetFilename(nsString& retval) const
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
CopyUTF8toUTF16(mPluginTag->mFileName, retval);
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginElement::GetVersion(nsString& retval) const
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
CopyUTF8toUTF16(mPluginTag->mVersion, retval);
|
|
|
|
}
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginElement::GetName(nsString& retval) const
|
|
|
|
{
|
|
|
|
CopyUTF8toUTF16(mPluginTag->mName, retval);
|
|
|
|
}
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::Item(uint32_t aIndex)
|
|
|
|
{
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePluginMimeTypes();
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
return mMimeTypes.SafeElementAt(aIndex);
|
|
|
|
}
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::NamedItem(const nsAString& aName)
|
|
|
|
{
|
|
|
|
bool unused;
|
|
|
|
return NamedGetter(aName, unused);
|
2008-10-22 14:31:14 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::IndexedGetter(uint32_t aIndex, bool &aFound)
|
2008-10-22 14:31:14 +00:00
|
|
|
{
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePluginMimeTypes();
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
aFound = aIndex < mMimeTypes.Length();
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
return aFound ? mMimeTypes[aIndex] : nullptr;
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::NamedGetter(const nsAString& aName, bool &aFound)
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePluginMimeTypes();
|
2013-07-09 13:58:21 +00:00
|
|
|
|
|
|
|
aFound = false;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mMimeTypes.Length(); ++i) {
|
|
|
|
if (mMimeTypes[i]->Type().Equals(aName)) {
|
|
|
|
aFound = true;
|
2000-11-29 02:26:11 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
return mMimeTypes[i];
|
2000-11-29 02:26:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2008-10-31 21:40:35 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 02:58:44 +00:00
|
|
|
bool
|
|
|
|
nsPluginElement::NameIsEnumerable(const nsAString& aName)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
uint32_t
|
|
|
|
nsPluginElement::Length()
|
2008-10-31 21:40:35 +00:00
|
|
|
{
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePluginMimeTypes();
|
2008-10-31 21:40:35 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
return mMimeTypes.Length();
|
|
|
|
}
|
2008-10-31 21:40:35 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
2014-04-16 02:58:44 +00:00
|
|
|
nsPluginElement::GetSupportedNames(unsigned, nsTArray<nsString>& retval)
|
2013-07-09 13:58:21 +00:00
|
|
|
{
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePluginMimeTypes();
|
2013-07-09 13:58:21 +00:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mMimeTypes.Length(); ++i) {
|
|
|
|
retval.AppendElement(mMimeTypes[i]->Type());
|
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsTArray<nsRefPtr<nsMimeType> >&
|
|
|
|
nsPluginElement::MimeTypes()
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-10-20 07:05:05 +00:00
|
|
|
EnsurePluginMimeTypes();
|
2013-07-09 13:58:21 +00:00
|
|
|
|
|
|
|
return mMimeTypes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-10-20 07:05:05 +00:00
|
|
|
nsPluginElement::EnsurePluginMimeTypes()
|
2013-07-09 13:58:21 +00:00
|
|
|
{
|
|
|
|
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));
|
2000-11-29 02:26:11 +00:00
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|