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