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
|
|
|
|
|
|
|
#ifndef nsPluginArray_h___
|
|
|
|
#define nsPluginArray_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"
|
2013-08-27 09:05:29 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2016-12-17 08:25:52 +03:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
class nsPluginElement;
|
2014-07-27 19:52:52 +04:00
|
|
|
class nsMimeType;
|
2015-05-20 16:30:05 +03:00
|
|
|
class nsIInternalPluginTag;
|
2011-11-02 17:44:16 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsPluginArray final : public nsIObserver,
|
2015-03-27 21:52:19 +03:00
|
|
|
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
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
explicit nsPluginArray(nsPIDOMWindowInner* aWindow);
|
|
|
|
nsPIDOMWindowInner* GetParentObject() const;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-07-09 17:58:21 +04:00
|
|
|
|
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
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
void GetMimeTypes(nsTArray<RefPtr<nsMimeType>>& aMimeTypes);
|
2016-07-28 00:45:48 +03:00
|
|
|
void GetCTPMimeTypes(nsTArray<RefPtr<nsMimeType>>& aMimeTypes);
|
|
|
|
|
|
|
|
static void NotifyHiddenPluginTouched(nsPluginElement* aElement);
|
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
|
|
|
|
2016-12-17 08:25:52 +03:00
|
|
|
nsPluginElement* Item(uint32_t aIndex, mozilla::dom::CallerType aCallerType);
|
|
|
|
nsPluginElement* NamedItem(const nsAString& aName,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
2013-07-09 17:58:21 +04:00
|
|
|
void Refresh(bool aReloadDocuments);
|
2016-12-17 08:25:52 +03:00
|
|
|
nsPluginElement* IndexedGetter(uint32_t aIndex, bool &aFound,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
|
|
|
nsPluginElement* NamedGetter(const nsAString& aName, bool &aFound,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
|
|
|
uint32_t Length(mozilla::dom::CallerType aCallerType);
|
2016-12-17 08:25:52 +03:00
|
|
|
void GetSupportedNames(nsTArray<nsString>& aRetval,
|
|
|
|
mozilla::dom::CallerType aCallerType);
|
2008-10-22 18:31:14 +04:00
|
|
|
|
1999-04-20 23:18:51 +04:00
|
|
|
private:
|
2014-06-23 23:56:07 +04:00
|
|
|
virtual ~nsPluginArray();
|
|
|
|
|
2013-07-09 17:58:21 +04:00
|
|
|
bool AllowPlugins() const;
|
|
|
|
void EnsurePlugins();
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsPluginElement> > mPlugins;
|
2015-08-04 02:24:35 +03:00
|
|
|
/* A separate list of click-to-play plugins that we don't tell content
|
|
|
|
* about but keep track of so we can still prompt the user to click to play.
|
|
|
|
*/
|
|
|
|
nsTArray<RefPtr<nsPluginElement> > mCTPPlugins;
|
1999-04-20 23:18:51 +04:00
|
|
|
};
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsPluginElement final : public nsISupports,
|
2015-03-27 21:52:19 +03:00
|
|
|
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
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPluginElement(nsPIDOMWindowInner* aWindow,
|
|
|
|
nsIInternalPluginTag* aPluginTag);
|
1999-04-20 23:18:51 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* GetParentObject() const;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2008-10-22 18:31:14 +04:00
|
|
|
|
2015-05-20 16:30:05 +03:00
|
|
|
nsIInternalPluginTag* 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();
|
2016-05-10 05:25:40 +03:00
|
|
|
void GetSupportedNames(nsTArray<nsString>& retval);
|
2013-07-09 17:58:21 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsMimeType> >& MimeTypes();
|
1999-04-20 23:18:51 +04:00
|
|
|
|
|
|
|
protected:
|
2014-07-01 03:00:30 +04:00
|
|
|
~nsPluginElement();
|
2014-06-23 23:56:07 +04:00
|
|
|
|
2013-10-20 11:05:05 +04:00
|
|
|
void EnsurePluginMimeTypes();
|
2013-07-09 17:58:21 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
2015-05-20 16:30:05 +03:00
|
|
|
nsCOMPtr<nsIInternalPluginTag> mPluginTag;
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<nsMimeType> > mMimeTypes;
|
1999-04-20 23:18:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsPluginArray_h___ */
|