2001-09-25 22:43:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2013-07-09 13:58:21 +00:00
|
|
|
/* vim: set ts=2 sw=2 et tw=79: */
|
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
|
|
|
|
|
|
|
#ifndef nsPluginArray_h___
|
|
|
|
#define nsPluginArray_h___
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
#include "nsTArray.h"
|
2011-12-01 08:28:16 +00:00
|
|
|
#include "nsWeakReference.h"
|
2013-04-10 20:59:45 +00:00
|
|
|
#include "nsIObserver.h"
|
2013-07-09 13:58:21 +00:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsPluginTags.h"
|
2013-08-27 05:05:29 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
class nsPluginElement;
|
|
|
|
class nsMimeType;
|
2011-11-02 13:44:16 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
class nsPluginArray MOZ_FINAL : public nsIObserver,
|
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsWrapperCache
|
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
|
|
|
{
|
1999-04-20 19:18:51 +00:00
|
|
|
public:
|
2013-07-09 13:58:21 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsPluginArray,
|
|
|
|
nsIObserver)
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-04-10 20:59:45 +00:00
|
|
|
// nsIObserver
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
2013-08-28 20:55:29 +00:00
|
|
|
nsPluginArray(nsPIDOMWindow* aWindow);
|
2013-07-09 13:58:21 +00:00
|
|
|
virtual ~nsPluginArray();
|
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const;
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
|
|
|
|
2013-04-10 20:59:45 +00: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 13:58:21 +00:00
|
|
|
void Invalidate();
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-11-01 05:19:09 +00:00
|
|
|
void GetMimeTypes(nsTArray<nsRefPtr<nsMimeType> >& aMimeTypes,
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> >& aHiddenMimeTypes);
|
2001-04-04 22:13:04 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
// PluginArray WebIDL methods
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00: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);
|
|
|
|
uint32_t Length();
|
|
|
|
void GetSupportedNames(nsTArray< nsString >& aRetval);
|
2008-10-22 14:31:14 +00:00
|
|
|
|
1999-04-20 19:18:51 +00:00
|
|
|
private:
|
2013-07-09 13:58:21 +00:00
|
|
|
bool AllowPlugins() const;
|
|
|
|
void EnsurePlugins();
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-08-28 20:55:29 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
2013-11-01 05:19:09 +00: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 13:58:21 +00:00
|
|
|
nsTArray<nsRefPtr<nsPluginElement> > mPlugins;
|
2013-11-01 05:19:09 +00: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;
|
1999-04-20 19:18:51 +00:00
|
|
|
};
|
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
class nsPluginElement MOZ_FINAL : public nsISupports,
|
|
|
|
public nsWrapperCache
|
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
|
|
|
{
|
1999-04-20 19:18:51 +00:00
|
|
|
public:
|
2013-07-09 13:58:21 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPluginElement)
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-08-28 20:55:29 +00:00
|
|
|
nsPluginElement(nsPIDOMWindow* aWindow, nsPluginTag* aPluginTag);
|
1999-04-20 19:18:51 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPIDOMWindow* GetParentObject() const;
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
2008-10-22 14:31:14 +00:00
|
|
|
|
2013-07-09 13:58:21 +00:00
|
|
|
nsPluginTag* PluginTag() const
|
2008-10-22 14:31:14 +00:00
|
|
|
{
|
2013-07-09 13:58:21 +00:00
|
|
|
return mPluginTag;
|
2008-10-22 14:31:14 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 13:58:21 +00: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);
|
|
|
|
uint32_t Length();
|
|
|
|
void GetSupportedNames(nsTArray< nsString >& retval);
|
|
|
|
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> >& MimeTypes();
|
1999-04-20 19:18:51 +00:00
|
|
|
|
|
|
|
protected:
|
2013-10-20 07:05:05 +00:00
|
|
|
void EnsurePluginMimeTypes();
|
2013-07-09 13:58:21 +00:00
|
|
|
|
2013-08-28 20:55:29 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
2013-07-09 13:58:21 +00:00
|
|
|
nsRefPtr<nsPluginTag> mPluginTag;
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> > mMimeTypes;
|
1999-04-20 19:18:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsPluginArray_h___ */
|