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;
|
|
|
|
class nsMimeType;
|
2011-11-02 06:44:16 -07:00
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
class nsPluginArray MOZ_FINAL : public nsIObserver,
|
|
|
|
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
|
|
|
|
|
2013-08-28 13:55:29 -07:00
|
|
|
nsPluginArray(nsPIDOMWindow* aWindow);
|
2013-07-09 06:58:21 -07:00
|
|
|
virtual ~nsPluginArray();
|
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const;
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
|
|
|
|
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-17 00:19:43 -07:00
|
|
|
void GetMimeTypes(nsTArray<nsRefPtr<nsMimeType> >& aMimeTypes);
|
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);
|
|
|
|
uint32_t Length();
|
|
|
|
void GetSupportedNames(nsTArray< nsString >& aRetval);
|
2008-10-22 07:31:14 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
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-07-09 06:58:21 -07:00
|
|
|
nsTArray<nsRefPtr<nsPluginElement> > mPlugins;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2013-07-09 06:58:21 -07:00
|
|
|
class nsPluginElement MOZ_FINAL : public nsISupports,
|
|
|
|
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;
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aScope) MOZ_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);
|
|
|
|
uint32_t Length();
|
|
|
|
void GetSupportedNames(nsTArray< nsString >& retval);
|
|
|
|
|
|
|
|
nsTArray<nsRefPtr<nsMimeType> >& MimeTypes();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
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___ */
|