dom/base/nsPluginArray.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 sw=2 et tw=79: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsPluginArray_h___
michael@0 8 #define nsPluginArray_h___
michael@0 9
michael@0 10 #include "nsTArray.h"
michael@0 11 #include "nsWeakReference.h"
michael@0 12 #include "nsIObserver.h"
michael@0 13 #include "nsWrapperCache.h"
michael@0 14 #include "nsPluginTags.h"
michael@0 15 #include "nsPIDOMWindow.h"
michael@0 16
michael@0 17 class nsPluginElement;
michael@0 18 class nsMimeType;
michael@0 19
michael@0 20 class nsPluginArray MOZ_FINAL : public nsIObserver,
michael@0 21 public nsSupportsWeakReference,
michael@0 22 public nsWrapperCache
michael@0 23 {
michael@0 24 public:
michael@0 25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsPluginArray,
michael@0 27 nsIObserver)
michael@0 28
michael@0 29 // nsIObserver
michael@0 30 NS_DECL_NSIOBSERVER
michael@0 31
michael@0 32 nsPluginArray(nsPIDOMWindow* aWindow);
michael@0 33 virtual ~nsPluginArray();
michael@0 34
michael@0 35 nsPIDOMWindow* GetParentObject() const;
michael@0 36 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 37
michael@0 38 // nsPluginArray registers itself as an observer with a weak reference.
michael@0 39 // This can't be done in the constructor, because at that point its
michael@0 40 // refcount is 0 (and it gets destroyed upon registration). So, Init()
michael@0 41 // must be called after construction.
michael@0 42 void Init();
michael@0 43 void Invalidate();
michael@0 44
michael@0 45 void GetMimeTypes(nsTArray<nsRefPtr<nsMimeType> >& aMimeTypes,
michael@0 46 nsTArray<nsRefPtr<nsMimeType> >& aHiddenMimeTypes);
michael@0 47
michael@0 48 // PluginArray WebIDL methods
michael@0 49
michael@0 50 nsPluginElement* Item(uint32_t aIndex);
michael@0 51 nsPluginElement* NamedItem(const nsAString& aName);
michael@0 52 void Refresh(bool aReloadDocuments);
michael@0 53 nsPluginElement* IndexedGetter(uint32_t aIndex, bool &aFound);
michael@0 54 nsPluginElement* NamedGetter(const nsAString& aName, bool &aFound);
michael@0 55 bool NameIsEnumerable(const nsAString& aName);
michael@0 56 uint32_t Length();
michael@0 57 void GetSupportedNames(unsigned, nsTArray<nsString>& aRetval);
michael@0 58
michael@0 59 private:
michael@0 60 bool AllowPlugins() const;
michael@0 61 void EnsurePlugins();
michael@0 62
michael@0 63 nsCOMPtr<nsPIDOMWindow> mWindow;
michael@0 64
michael@0 65 // Many sites check whether a particular plugin is installed by enumerating
michael@0 66 // all navigator.plugins, checking each plugin's name. These sites should
michael@0 67 // just check navigator.plugins["Popular Plugin Name"] instead. mPlugins
michael@0 68 // contains those popular plugins that must be exposed in navigator.plugins
michael@0 69 // enumeration to avoid breaking web content.
michael@0 70 nsTArray<nsRefPtr<nsPluginElement> > mPlugins;
michael@0 71
michael@0 72 // mHiddenPlugins contains plugins that can be queried by
michael@0 73 // navigator.plugins["Hidden Plugin Name"] but do not need to be exposed in
michael@0 74 // navigator.plugins enumeration.
michael@0 75 nsTArray<nsRefPtr<nsPluginElement> > mHiddenPlugins;
michael@0 76 };
michael@0 77
michael@0 78 class nsPluginElement MOZ_FINAL : public nsISupports,
michael@0 79 public nsWrapperCache
michael@0 80 {
michael@0 81 public:
michael@0 82 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 83 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPluginElement)
michael@0 84
michael@0 85 nsPluginElement(nsPIDOMWindow* aWindow, nsPluginTag* aPluginTag);
michael@0 86
michael@0 87 nsPIDOMWindow* GetParentObject() const;
michael@0 88 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 89
michael@0 90 nsPluginTag* PluginTag() const
michael@0 91 {
michael@0 92 return mPluginTag;
michael@0 93 }
michael@0 94
michael@0 95 // Plugin WebIDL methods
michael@0 96
michael@0 97 void GetDescription(nsString& retval) const;
michael@0 98 void GetFilename(nsString& retval) const;
michael@0 99 void GetVersion(nsString& retval) const;
michael@0 100 void GetName(nsString& retval) const;
michael@0 101 nsMimeType* Item(uint32_t index);
michael@0 102 nsMimeType* NamedItem(const nsAString& name);
michael@0 103 nsMimeType* IndexedGetter(uint32_t index, bool &found);
michael@0 104 nsMimeType* NamedGetter(const nsAString& name, bool &found);
michael@0 105 bool NameIsEnumerable(const nsAString& aName);
michael@0 106 uint32_t Length();
michael@0 107 void GetSupportedNames(unsigned, nsTArray<nsString>& retval);
michael@0 108
michael@0 109 nsTArray<nsRefPtr<nsMimeType> >& MimeTypes();
michael@0 110
michael@0 111 protected:
michael@0 112 void EnsurePluginMimeTypes();
michael@0 113
michael@0 114 nsCOMPtr<nsPIDOMWindow> mWindow;
michael@0 115 nsRefPtr<nsPluginTag> mPluginTag;
michael@0 116 nsTArray<nsRefPtr<nsMimeType> > mMimeTypes;
michael@0 117 };
michael@0 118
michael@0 119 #endif /* nsPluginArray_h___ */

mercurial