2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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-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
|
|
|
|
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;
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsPluginArray::nsPluginArray(nsPIDOMWindowInner* 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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsPIDOMWindowInner*
|
2013-07-09 13:58:21 +00:00
|
|
|
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*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
nsPluginArray::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-07-09 13:58:21 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return PluginArrayBinding::Wrap(aCx, this, aGivenProto);
|
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,
|
2016-06-05 08:03:36 +00:00
|
|
|
mPlugins)
|
2013-11-01 05:19:09 +00:00
|
|
|
|
|
|
|
static void
|
2015-10-18 05:24:48 +00:00
|
|
|
GetPluginMimeTypes(const nsTArray<RefPtr<nsPluginElement> >& aPlugins,
|
|
|
|
nsTArray<RefPtr<nsMimeType> >& aMimeTypes)
|
2013-11-01 05:19:09 +00:00
|
|
|
{
|
|
|
|
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
|
2015-10-18 05:24:48 +00:00
|
|
|
operator<(const RefPtr<nsMimeType>& lhs, const RefPtr<nsMimeType>& rhs)
|
2012-09-18 07:56:14 +00:00
|
|
|
{
|
|
|
|
// Sort MIME types alphabetically by type name.
|
|
|
|
return lhs->Type() < rhs->Type();
|
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
2015-10-18 05:24:48 +00:00
|
|
|
nsPluginArray::GetMimeTypes(nsTArray<RefPtr<nsMimeType>>& aMimeTypes)
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2013-10-17 07:19:43 +00:00
|
|
|
aMimeTypes.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);
|
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
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<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) {
|
2015-05-20 13:30:05 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIInternalPluginTag> > newPluginTags;
|
2013-07-09 13:58:21 +00:00
|
|
|
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).
|
2015-05-30 05:42:23 +00:00
|
|
|
if (newPluginTags.Length() == mPlugins.Length()) {
|
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();
|
2008-10-31 21:40:35 +00:00
|
|
|
|
2015-10-26 21:37:32 +00:00
|
|
|
nsCOMPtr<nsIDOMNavigator> navigator = mWindow->GetNavigator();
|
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
|
|
|
|
2015-08-13 12:22:48 +00:00
|
|
|
if (!aFound) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mPlugins[aIndex];
|
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*
|
2015-10-18 05:24:48 +00:00
|
|
|
FindPlugin(const nsTArray<RefPtr<nsPluginElement> >& aPlugins,
|
2013-11-01 05:19:09 +00:00
|
|
|
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);
|
|
|
|
aFound = (plugin != nullptr);
|
|
|
|
return plugin;
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
2002-05-16 20:41:26 +00:00
|
|
|
|
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
|
2016-05-10 02:25:40 +00:00
|
|
|
nsPluginArray::GetSupportedNames(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
|
|
|
}
|
|
|
|
|
2012-09-18 07:56:14 +00:00
|
|
|
static bool
|
2015-10-18 05:24:48 +00:00
|
|
|
operator<(const RefPtr<nsPluginElement>& lhs,
|
|
|
|
const RefPtr<nsPluginElement>& rhs)
|
2012-09-18 07:56:14 +00:00
|
|
|
{
|
|
|
|
// Sort plugins alphabetically by name.
|
2015-05-20 13:30:05 +00:00
|
|
|
return lhs->PluginTag()->Name() < rhs->PluginTag()->Name();
|
2012-09-18 07:56:14 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginArray::EnsurePlugins()
|
1999-04-20 19:18:51 +00:00
|
|
|
{
|
2016-06-05 08:03:36 +00:00
|
|
|
if (!mPlugins.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
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2013-10-20 07:05:05 +00:00
|
|
|
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
|
|
|
|
2015-05-20 13:30:05 +00:00
|
|
|
nsTArray<nsCOMPtr<nsIInternalPluginTag> > pluginTags;
|
2013-07-09 13:58:21 +00:00
|
|
|
pluginHost->GetPlugins(pluginTags);
|
1999-04-20 19:18:51 +00:00
|
|
|
|
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) {
|
2016-06-05 08:03:36 +00:00
|
|
|
mPlugins.AppendElement(new nsPluginElement(mWindow, pluginTags[i]));
|
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
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsPluginElement::nsPluginElement(nsPIDOMWindowInner* aWindow,
|
2015-05-20 13:30:05 +00:00
|
|
|
nsIInternalPluginTag* aPluginTag)
|
2013-07-09 13:58:21 +00:00
|
|
|
: mWindow(aWindow),
|
|
|
|
mPluginTag(aPluginTag)
|
|
|
|
{
|
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2014-06-30 23:00:30 +00:00
|
|
|
nsPluginElement::~nsPluginElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
nsPIDOMWindowInner*
|
2013-07-09 13:58:21 +00:00
|
|
|
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*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
nsPluginElement::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2009-04-22 19:13:10 +00:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
return PluginBinding::Wrap(aCx, this, aGivenProto);
|
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
|
|
|
{
|
2015-05-20 13:30:05 +00:00
|
|
|
CopyUTF8toUTF16(mPluginTag->Description(), 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
|
|
|
{
|
2015-05-20 13:30:05 +00:00
|
|
|
CopyUTF8toUTF16(mPluginTag->FileName(), 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
|
|
|
{
|
2015-05-20 13:30:05 +00:00
|
|
|
CopyUTF8toUTF16(mPluginTag->Version(), retval);
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
void
|
|
|
|
nsPluginElement::GetName(nsString& retval) const
|
|
|
|
{
|
2015-05-20 13:30:05 +00:00
|
|
|
CopyUTF8toUTF16(mPluginTag->Name(), retval);
|
2013-07-09 13:58:21 +00:00
|
|
|
}
|
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
|
|
|
|
2015-08-13 12:22:48 +00:00
|
|
|
if (!aFound) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mMimeTypes[aIndex];
|
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
|
|
|
}
|
|
|
|
|
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
|
2016-05-10 02:25:40 +00:00
|
|
|
nsPluginElement::GetSupportedNames(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
|
|
|
}
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<nsMimeType> >&
|
2013-07-09 13:58:21 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-05-20 13:30:05 +00:00
|
|
|
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));
|
2000-11-29 02:26:11 +00:00
|
|
|
}
|
1999-04-20 19:18:51 +00:00
|
|
|
}
|