2015-05-03 22:32:37 +03: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 15:12:37 +04: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 23:18:51 +04:00
|
|
|
|
|
|
|
#include "nsPluginArray.h"
|
2013-08-14 10:56:21 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
#include "mozilla/dom/PluginArrayBinding.h"
|
|
|
|
#include "mozilla/dom/PluginBinding.h"
|
2013-11-01 09:19:09 +04:00
|
|
|
|
1999-04-20 23:18:51 +04:00
|
|
|
#include "nsMimeTypeArray.h"
|
2011-11-02 17:44:16 +04:00
|
|
|
#include "Navigator.h"
|
2001-01-24 01:29:41 +03:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIWebNavigation.h"
|
2011-05-21 17:28:54 +04:00
|
|
|
#include "nsPluginHost.h"
|
2013-07-09 17:58:21 +04:00
|
|
|
#include "nsPluginTags.h"
|
2013-04-11 00:59:45 +04:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIWeakReference.h"
|
|
|
|
#include "mozilla/Services.h"
|
2013-07-09 17:58:21 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2011-11-02 17:44:16 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPluginArray::nsPluginArray(nsPIDOMWindowInner* aWindow)
|
2013-07-09 17:58:21 +04:00
|
|
|
: mWindow(aWindow)
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-11 00:59:45 +04:00
|
|
|
void
|
|
|
|
nsPluginArray::Init()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> obsService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (obsService) {
|
|
|
|
obsService->AddObserver(this, "plugin-info-updated", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-10 22:48:22 +03:00
|
|
|
nsPluginArray::~nsPluginArray()
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner*
|
2013-07-09 17:58:21 +04:00
|
|
|
nsPluginArray::GetParentObject() const
|
|
|
|
{
|
2013-08-29 00:55:29 +04:00
|
|
|
MOZ_ASSERT(mWindow);
|
|
|
|
return mWindow;
|
2013-07-09 17:58:21 +04: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 17:13:33 +03:00
|
|
|
nsPluginArray::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-07-09 17:58:21 +04: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 17:13:33 +03:00
|
|
|
return PluginArrayBinding::Wrap(aCx, this, aGivenProto);
|
2013-07-09 17:58:21 +04:00
|
|
|
}
|
2010-01-12 16:08:43 +03:00
|
|
|
|
2013-07-09 17:58:21 +04: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-11 00:59:45 +04: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 21:42:36 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsPluginArray,
|
|
|
|
mWindow,
|
2015-05-30 08:42:23 +03:00
|
|
|
mPlugins)
|
2013-11-01 09:19:09 +04:00
|
|
|
|
|
|
|
static void
|
2015-10-18 08:24:48 +03:00
|
|
|
GetPluginMimeTypes(const nsTArray<RefPtr<nsPluginElement> >& aPlugins,
|
|
|
|
nsTArray<RefPtr<nsMimeType> >& aMimeTypes)
|
2013-11-01 09:19:09 +04:00
|
|
|
{
|
|
|
|
for (uint32_t i = 0; i < aPlugins.Length(); ++i) {
|
|
|
|
nsPluginElement *plugin = aPlugins[i];
|
|
|
|
aMimeTypes.AppendElements(plugin->MimeTypes());
|
|
|
|
}
|
|
|
|
}
|
2000-11-29 05:26:11 +03:00
|
|
|
|
2012-09-18 11:56:14 +04:00
|
|
|
static bool
|
2015-10-18 08:24:48 +03:00
|
|
|
operator<(const RefPtr<nsMimeType>& lhs, const RefPtr<nsMimeType>& rhs)
|
2012-09-18 11:56:14 +04:00
|
|
|
{
|
|
|
|
// Sort MIME types alphabetically by type name.
|
|
|
|
return lhs->Type() < rhs->Type();
|
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
2015-10-18 08:24:48 +03:00
|
|
|
nsPluginArray::GetMimeTypes(nsTArray<RefPtr<nsMimeType>>& aMimeTypes)
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2013-10-17 11:19:43 +04:00
|
|
|
aMimeTypes.Clear();
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-12-01 12:28:16 +04:00
|
|
|
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePlugins();
|
2006-03-21 08:31:59 +03:00
|
|
|
|
2013-11-01 09:19:09 +04:00
|
|
|
GetPluginMimeTypes(mPlugins, aMimeTypes);
|
2012-09-18 11:56:14 +04: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 08:31:59 +03:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::Item(uint32_t aIndex)
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2013-07-09 17:58:21 +04:00
|
|
|
bool unused;
|
|
|
|
return IndexedGetter(aIndex, unused);
|
2008-10-22 18:31:14 +04:00
|
|
|
}
|
2000-11-29 05:26:11 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::NamedItem(const nsAString& aName)
|
2008-10-22 18:31:14 +04:00
|
|
|
{
|
2013-07-09 17:58:21 +04:00
|
|
|
bool unused;
|
|
|
|
return NamedGetter(aName, unused);
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
|
|
|
nsPluginArray::Refresh(bool aReloadDocuments)
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2000-11-29 05:26:11 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
if(!AllowPlugins() || !pluginHost) {
|
|
|
|
return;
|
2000-11-29 05:26:11 +03:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04: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 16:30:05 +03:00
|
|
|
nsTArray<nsCOMPtr<nsIInternalPluginTag> > newPluginTags;
|
2013-07-09 17:58:21 +04: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 08:42:23 +03:00
|
|
|
if (newPluginTags.Length() == mPlugins.Length()) {
|
2013-07-09 17:58:21 +04:00
|
|
|
return;
|
2000-11-29 05:26:11 +03:00
|
|
|
}
|
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
mPlugins.Clear();
|
2008-11-01 00:40:35 +03:00
|
|
|
|
2015-10-27 00:37:32 +03:00
|
|
|
nsCOMPtr<nsIDOMNavigator> navigator = mWindow->GetNavigator();
|
2008-11-01 00:40:35 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
if (!navigator) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static_cast<mozilla::dom::Navigator*>(navigator.get())->RefreshMIMEArray();
|
2008-11-01 00:40:35 +03:00
|
|
|
|
2013-08-29 00:55:29 +04:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(mWindow);
|
2013-07-09 17:58:21 +04:00
|
|
|
if (aReloadDocuments && webNav) {
|
|
|
|
webNav->Reload(nsIWebNavigation::LOAD_FLAGS_NONE);
|
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::IndexedGetter(uint32_t aIndex, bool &aFound)
|
2001-04-05 02:12:26 +04:00
|
|
|
{
|
2013-07-09 17:58:21 +04:00
|
|
|
aFound = false;
|
2001-04-05 02:12:26 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2001-04-05 02:12:26 +04:00
|
|
|
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePlugins();
|
2001-04-05 02:12:26 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
aFound = aIndex < mPlugins.Length();
|
2001-04-05 02:12:26 +04:00
|
|
|
|
2015-08-13 15:22:48 +03:00
|
|
|
if (!aFound) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mPlugins[aIndex];
|
2001-04-05 02:12:26 +04:00
|
|
|
}
|
|
|
|
|
2010-08-13 08:05:05 +04:00
|
|
|
void
|
|
|
|
nsPluginArray::Invalidate()
|
|
|
|
{
|
2013-04-11 00:59:45 +04:00
|
|
|
nsCOMPtr<nsIObserverService> obsService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (obsService) {
|
|
|
|
obsService->RemoveObserver(this, "plugin-info-updated");
|
|
|
|
}
|
2010-08-13 08:05:05 +04:00
|
|
|
}
|
|
|
|
|
2013-11-01 09:19:09 +04:00
|
|
|
static nsPluginElement*
|
2015-10-18 08:24:48 +03:00
|
|
|
FindPlugin(const nsTArray<RefPtr<nsPluginElement> >& aPlugins,
|
2013-11-01 09:19:09 +04: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 17:58:21 +04:00
|
|
|
nsPluginElement*
|
|
|
|
nsPluginArray::NamedGetter(const nsAString& aName, bool &aFound)
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2013-07-09 17:58:21 +04:00
|
|
|
aFound = false;
|
2000-12-22 03:08:31 +03:00
|
|
|
|
2013-07-09 17:58:21 +04: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 21:42:36 +04:00
|
|
|
}
|
|
|
|
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePlugins();
|
2000-12-22 03:08:31 +03:00
|
|
|
|
2013-11-01 09:19:09 +04:00
|
|
|
nsPluginElement* plugin = FindPlugin(mPlugins, aName);
|
|
|
|
aFound = (plugin != nullptr);
|
|
|
|
return plugin;
|
2013-07-09 17:58:21 +04:00
|
|
|
}
|
2002-05-17 00:41:26 +04:00
|
|
|
|
2014-04-16 06:58:44 +04:00
|
|
|
bool
|
|
|
|
nsPluginArray::NameIsEnumerable(const nsAString& aName)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
uint32_t
|
|
|
|
nsPluginArray::Length()
|
|
|
|
{
|
|
|
|
if (!AllowPlugins()) {
|
|
|
|
return 0;
|
2002-05-17 00:41:26 +04:00
|
|
|
}
|
|
|
|
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePlugins();
|
2002-05-17 00:41:26 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
return mPlugins.Length();
|
|
|
|
}
|
2001-01-24 01:29:41 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
2014-04-16 06:58:44 +04:00
|
|
|
nsPluginArray::GetSupportedNames(unsigned, nsTArray<nsString>& aRetval)
|
2013-07-09 17:58:21 +04: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 05:26:11 +03:00
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2013-04-11 00:59:45 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginArray::Observe(nsISupports *aSubject, const char *aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aData) {
|
2013-04-11 00:59:45 +04:00
|
|
|
if (!nsCRT::strcmp(aTopic, "plugin-info-updated")) {
|
|
|
|
Refresh(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
bool
|
|
|
|
nsPluginArray::AllowPlugins() const
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2014-01-10 06:03:47 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = mWindow ? mWindow->GetDocShell() : nullptr;
|
2013-07-09 17:58:21 +04:00
|
|
|
|
|
|
|
return docShell && docShell->PluginsAllowedInCurrentDoc();
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2012-09-18 11:56:14 +04:00
|
|
|
static bool
|
2015-10-18 08:24:48 +03:00
|
|
|
operator<(const RefPtr<nsPluginElement>& lhs,
|
|
|
|
const RefPtr<nsPluginElement>& rhs)
|
2012-09-18 11:56:14 +04:00
|
|
|
{
|
|
|
|
// Sort plugins alphabetically by name.
|
2015-05-20 16:30:05 +03:00
|
|
|
return lhs->PluginTag()->Name() < rhs->PluginTag()->Name();
|
2012-09-18 11:56:14 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
|
|
|
nsPluginArray::EnsurePlugins()
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2015-05-30 08:42:23 +03:00
|
|
|
if (!mPlugins.IsEmpty()) {
|
2013-10-20 11:05:05 +04:00
|
|
|
// We already have an array of plugin elements.
|
|
|
|
return;
|
|
|
|
}
|
2013-07-09 17:58:21 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
2013-10-20 11:05:05 +04:00
|
|
|
if (!pluginHost) {
|
|
|
|
// We have no plugin host.
|
2013-07-09 17:58:21 +04:00
|
|
|
return;
|
2000-11-29 05:26:11 +03:00
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
nsTArray<nsCOMPtr<nsIInternalPluginTag> > pluginTags;
|
2013-07-09 17:58:21 +04:00
|
|
|
pluginHost->GetPlugins(pluginTags);
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
// need to wrap each of these with a nsPluginElement, which is
|
|
|
|
// scriptable.
|
|
|
|
for (uint32_t i = 0; i < pluginTags.Length(); ++i) {
|
2015-05-20 16:30:05 +03:00
|
|
|
mPlugins.AppendElement(new nsPluginElement(mWindow, pluginTags[i]));
|
2013-07-09 17:58:21 +04:00
|
|
|
}
|
2012-09-18 11:56:14 +04:00
|
|
|
|
|
|
|
// Alphabetize the enumeration order of non-hidden plugins to reduce
|
|
|
|
// fingerprintable entropy based on plugins' installation file times.
|
|
|
|
mPlugins.Sort();
|
2013-07-09 17:58:21 +04:00
|
|
|
}
|
2010-01-12 16:08:43 +03:00
|
|
|
|
2013-07-09 17:58:21 +04: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 21:42:36 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-29 12:57:00 +04: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 21:42:36 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPluginElement::nsPluginElement(nsPIDOMWindowInner* aWindow,
|
2015-05-20 16:30:05 +03:00
|
|
|
nsIInternalPluginTag* aPluginTag)
|
2013-07-09 17:58:21 +04:00
|
|
|
: mWindow(aWindow),
|
|
|
|
mPluginTag(aPluginTag)
|
|
|
|
{
|
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2014-07-01 03:00:30 +04:00
|
|
|
nsPluginElement::~nsPluginElement()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner*
|
2013-07-09 17:58:21 +04:00
|
|
|
nsPluginElement::GetParentObject() const
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2013-08-29 00:55:29 +04:00
|
|
|
MOZ_ASSERT(mWindow);
|
|
|
|
return mWindow;
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04: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 17:13:33 +03:00
|
|
|
nsPluginElement::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2009-04-22 23:13:10 +04: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 17:13:33 +03:00
|
|
|
return PluginBinding::Wrap(aCx, this, aGivenProto);
|
2009-04-22 23:13:10 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
|
|
|
nsPluginElement::GetDescription(nsString& retval) const
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2015-05-20 16:30:05 +03:00
|
|
|
CopyUTF8toUTF16(mPluginTag->Description(), retval);
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
|
|
|
nsPluginElement::GetFilename(nsString& retval) const
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2015-05-20 16:30:05 +03:00
|
|
|
CopyUTF8toUTF16(mPluginTag->FileName(), retval);
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
|
|
|
nsPluginElement::GetVersion(nsString& retval) const
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2015-05-20 16:30:05 +03:00
|
|
|
CopyUTF8toUTF16(mPluginTag->Version(), retval);
|
2013-07-09 17:58:21 +04:00
|
|
|
}
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
|
|
|
nsPluginElement::GetName(nsString& retval) const
|
|
|
|
{
|
2015-05-20 16:30:05 +03:00
|
|
|
CopyUTF8toUTF16(mPluginTag->Name(), retval);
|
2013-07-09 17:58:21 +04:00
|
|
|
}
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::Item(uint32_t aIndex)
|
|
|
|
{
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePluginMimeTypes();
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
return mMimeTypes.SafeElementAt(aIndex);
|
|
|
|
}
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::NamedItem(const nsAString& aName)
|
|
|
|
{
|
|
|
|
bool unused;
|
|
|
|
return NamedGetter(aName, unused);
|
2008-10-22 18:31:14 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::IndexedGetter(uint32_t aIndex, bool &aFound)
|
2008-10-22 18:31:14 +04:00
|
|
|
{
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePluginMimeTypes();
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
aFound = aIndex < mMimeTypes.Length();
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2015-08-13 15:22:48 +03:00
|
|
|
if (!aFound) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mMimeTypes[aIndex];
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
nsMimeType*
|
|
|
|
nsPluginElement::NamedGetter(const nsAString& aName, bool &aFound)
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePluginMimeTypes();
|
2013-07-09 17:58:21 +04:00
|
|
|
|
|
|
|
aFound = false;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mMimeTypes.Length(); ++i) {
|
|
|
|
if (mMimeTypes[i]->Type().Equals(aName)) {
|
|
|
|
aFound = true;
|
2000-11-29 05:26:11 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
return mMimeTypes[i];
|
2000-11-29 05:26:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-11-01 00:40:35 +03:00
|
|
|
}
|
|
|
|
|
2014-04-16 06:58:44 +04:00
|
|
|
bool
|
|
|
|
nsPluginElement::NameIsEnumerable(const nsAString& aName)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
uint32_t
|
|
|
|
nsPluginElement::Length()
|
2008-11-01 00:40:35 +03:00
|
|
|
{
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePluginMimeTypes();
|
2008-11-01 00:40:35 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
return mMimeTypes.Length();
|
|
|
|
}
|
2008-11-01 00:40:35 +03:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
void
|
2014-04-16 06:58:44 +04:00
|
|
|
nsPluginElement::GetSupportedNames(unsigned, nsTArray<nsString>& retval)
|
2013-07-09 17:58:21 +04:00
|
|
|
{
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePluginMimeTypes();
|
2013-07-09 17:58:21 +04:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < mMimeTypes.Length(); ++i) {
|
|
|
|
retval.AppendElement(mMimeTypes[i]->Type());
|
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsMimeType> >&
|
2013-07-09 17:58:21 +04:00
|
|
|
nsPluginElement::MimeTypes()
|
1999-04-20 23:18:51 +04:00
|
|
|
{
|
2013-10-20 11:05:05 +04:00
|
|
|
EnsurePluginMimeTypes();
|
2013-07-09 17:58:21 +04:00
|
|
|
|
|
|
|
return mMimeTypes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-10-20 11:05:05 +04:00
|
|
|
nsPluginElement::EnsurePluginMimeTypes()
|
2013-07-09 17:58:21 +04:00
|
|
|
{
|
|
|
|
if (!mMimeTypes.IsEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-20 16:30:05 +03: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 05:26:11 +03:00
|
|
|
}
|
1999-04-20 23:18:51 +04:00
|
|
|
}
|