2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-07-09 06:58:21 -07:00
|
|
|
/* vim: set ts=2 sw=2 et tw=79: */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsPluginArray_h___
|
|
|
|
#define nsPluginArray_h___
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
#include "nsTArray.h"
|
2011-12-01 00:28:16 -08:00
|
|
|
#include "nsWeakReference.h"
|
2013-04-10 13:59:45 -07:00
|
|
|
#include "nsIObserver.h"
|
2013-07-09 06:58:21 -07:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsPluginTags.h"
|
2013-08-26 22:05:29 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
class nsPluginElement;
|
2014-07-27 08:52:52 -07:00
|
|
|
class nsMimeType;
|
2011-11-02 06:44:16 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class nsPluginArray final : public nsIObserver,
|
2015-03-27 11:52:19 -07:00
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsWrapperCache
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-07-09 06:58:21 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsPluginArray,
|
|
|
|
nsIObserver)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-10 13:59:45 -07:00
|
|
|
// nsIObserver
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit nsPluginArray(nsPIDOMWindow* aWindow);
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPIDOMWindow* GetParentObject() const;
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-07-09 06:58:21 -07:00
|
|
|
|
2013-04-10 13:59:45 -07:00
|
|
|
// nsPluginArray registers itself as an observer with a weak reference.
|
|
|
|
// This can't be done in the constructor, because at that point its
|
|
|
|
// refcount is 0 (and it gets destroyed upon registration). So, Init()
|
|
|
|
// must be called after construction.
|
|
|
|
void Init();
|
2013-07-09 06:58:21 -07:00
|
|
|
void Invalidate();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-10-31 22:19:09 -07:00
|
|
|
void GetMimeTypes(nsTArray<nsRefPtr<nsMimeType> >& aMimeTypes,
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> >& aHiddenMimeTypes);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
// PluginArray WebIDL methods
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPluginElement* Item(uint32_t aIndex);
|
|
|
|
nsPluginElement* NamedItem(const nsAString& aName);
|
|
|
|
void Refresh(bool aReloadDocuments);
|
|
|
|
nsPluginElement* IndexedGetter(uint32_t aIndex, bool &aFound);
|
|
|
|
nsPluginElement* NamedGetter(const nsAString& aName, bool &aFound);
|
2014-04-15 19:58:44 -07:00
|
|
|
bool NameIsEnumerable(const nsAString& aName);
|
2013-07-09 06:58:21 -07:00
|
|
|
uint32_t Length();
|
2014-04-15 19:58:44 -07:00
|
|
|
void GetSupportedNames(unsigned, nsTArray<nsString>& aRetval);
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~nsPluginArray();
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
bool AllowPlugins() const;
|
|
|
|
void EnsurePlugins();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
2013-10-31 22:19:09 -07:00
|
|
|
|
|
|
|
// Many sites check whether a particular plugin is installed by enumerating
|
|
|
|
// all navigator.plugins, checking each plugin's name. These sites should
|
|
|
|
// just check navigator.plugins["Popular Plugin Name"] instead. mPlugins
|
|
|
|
// contains those popular plugins that must be exposed in navigator.plugins
|
|
|
|
// enumeration to avoid breaking web content.
|
2013-07-09 06:58:21 -07:00
|
|
|
nsTArray<nsRefPtr<nsPluginElement> > mPlugins;
|
2013-10-31 22:19:09 -07:00
|
|
|
|
|
|
|
// mHiddenPlugins contains plugins that can be queried by
|
|
|
|
// navigator.plugins["Hidden Plugin Name"] but do not need to be exposed in
|
|
|
|
// navigator.plugins enumeration.
|
|
|
|
nsTArray<nsRefPtr<nsPluginElement> > mHiddenPlugins;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class nsPluginElement final : public nsISupports,
|
2015-03-27 11:52:19 -07:00
|
|
|
public nsWrapperCache
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2013-07-09 06:58:21 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPluginElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
nsPluginElement(nsPIDOMWindow* aWindow, nsPluginTag* aPluginTag);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPIDOMWindow* GetParentObject() const;
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
nsPluginTag* PluginTag() const
|
2008-10-22 07:31:14 -07:00
|
|
|
{
|
2013-07-09 06:58:21 -07:00
|
|
|
return mPluginTag;
|
2008-10-22 07:31:14 -07:00
|
|
|
}
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
// Plugin WebIDL methods
|
|
|
|
|
|
|
|
void GetDescription(nsString& retval) const;
|
|
|
|
void GetFilename(nsString& retval) const;
|
|
|
|
void GetVersion(nsString& retval) const;
|
|
|
|
void GetName(nsString& retval) const;
|
|
|
|
nsMimeType* Item(uint32_t index);
|
|
|
|
nsMimeType* NamedItem(const nsAString& name);
|
|
|
|
nsMimeType* IndexedGetter(uint32_t index, bool &found);
|
|
|
|
nsMimeType* NamedGetter(const nsAString& name, bool &found);
|
2014-04-15 19:58:44 -07:00
|
|
|
bool NameIsEnumerable(const nsAString& aName);
|
2013-07-09 06:58:21 -07:00
|
|
|
uint32_t Length();
|
2014-04-15 19:58:44 -07:00
|
|
|
void GetSupportedNames(unsigned, nsTArray<nsString>& retval);
|
2013-07-09 06:58:21 -07:00
|
|
|
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> >& MimeTypes();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
2014-06-30 16:00:30 -07:00
|
|
|
~nsPluginElement();
|
2014-06-23 12:56:07 -07:00
|
|
|
|
2013-10-20 00:05:05 -07:00
|
|
|
void EnsurePluginMimeTypes();
|
2013-07-09 06:58:21 -07:00
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
2013-07-09 06:58:21 -07:00
|
|
|
nsRefPtr<nsPluginTag> mPluginTag;
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> > mMimeTypes;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsPluginArray_h___ */
|