1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef nsPluginArray_h___ 8 #define nsPluginArray_h___ 9 10 #include "nsWeakReference.h" 11 #include "nsWrapperCache.h" 12 #include "nsCOMPtr.h" 13 #include "nsTArray.h" 14 #include "mozilla/dom/BindingDeclarations.h" 15 16 class nsPIDOMWindowInner; 17 class nsPluginElement; 18 class nsMimeType; 19 20 namespace mozilla::dom { 21 enum class CallerType : uint32_t; 22 } // namespace mozilla::dom 23 24 /** 25 * Array class backing HTML's navigator.plugins. This array is always empty. 26 */ 27 class nsPluginArray final : public nsSupportsWeakReference, 28 public nsWrapperCache { 29 public: 30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 31 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPluginArray) 32 33 explicit nsPluginArray(nsPIDOMWindowInner* aWindow); 34 nsPIDOMWindowInner* GetParentObject() const; 35 virtual JSObject* WrapObject(JSContext* aCx, 36 JS::Handle<JSObject*> aGivenProto) override; 37 38 // PluginArray WebIDL methods Refresh(bool aReloadDocuments)39 void Refresh(bool aReloadDocuments) {} 40 Item(uint32_t aIndex,mozilla::dom::CallerType aCallerType)41 nsPluginElement* Item(uint32_t aIndex, mozilla::dom::CallerType aCallerType) { 42 return nullptr; 43 } 44 NamedItem(const nsAString & aName,mozilla::dom::CallerType aCallerType)45 nsPluginElement* NamedItem(const nsAString& aName, 46 mozilla::dom::CallerType aCallerType) { 47 return nullptr; 48 } 49 Length(mozilla::dom::CallerType aCallerType)50 uint32_t Length(mozilla::dom::CallerType aCallerType) { return 0; } 51 IndexedGetter(uint32_t aIndex,bool & aFound,mozilla::dom::CallerType aCallerType)52 nsPluginElement* IndexedGetter(uint32_t aIndex, bool& aFound, 53 mozilla::dom::CallerType aCallerType) { 54 return nullptr; 55 } 56 NamedGetter(const nsAString & aName,bool & aFound,mozilla::dom::CallerType aCallerType)57 nsPluginElement* NamedGetter(const nsAString& aName, bool& aFound, 58 mozilla::dom::CallerType aCallerType) { 59 return nullptr; 60 } 61 GetSupportedNames(nsTArray<nsString> & aRetval,mozilla::dom::CallerType aCallerType)62 void GetSupportedNames(nsTArray<nsString>& aRetval, 63 mozilla::dom::CallerType aCallerType) {} 64 65 private: 66 virtual ~nsPluginArray(); 67 68 nsCOMPtr<nsPIDOMWindowInner> mWindow; 69 }; 70 71 /** 72 * Plugin class backing entries in HTML's navigator.plugins array. 73 * Currently, these cannot be constructed. 74 */ 75 class nsPluginElement final : public nsISupports, public nsWrapperCache { 76 public: 77 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 78 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPluginElement) 79 80 nsPluginElement() = delete; 81 GetParentObject()82 nsPIDOMWindowInner* GetParentObject() const { 83 MOZ_ASSERT_UNREACHABLE("nsMimeType can not exist"); 84 return nullptr; 85 } 86 WrapObject(JSContext * aCx,JS::Handle<JSObject * > aGivenProto)87 virtual JSObject* WrapObject(JSContext* aCx, 88 JS::Handle<JSObject*> aGivenProto) override { 89 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 90 return nullptr; 91 } 92 93 // Plugin WebIDL methods GetDescription(nsString & retval)94 void GetDescription(nsString& retval) const { 95 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 96 } 97 GetFilename(nsString & retval)98 void GetFilename(nsString& retval) const { 99 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 100 } 101 GetVersion(nsString & retval)102 void GetVersion(nsString& retval) const { 103 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 104 } 105 GetName(nsString & retval)106 void GetName(nsString& retval) const { 107 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 108 } 109 Item(uint32_t index)110 nsMimeType* Item(uint32_t index) { 111 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 112 return nullptr; 113 } 114 NamedItem(const nsAString & name)115 nsMimeType* NamedItem(const nsAString& name) { 116 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 117 return nullptr; 118 } Length()119 uint32_t Length() { 120 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 121 return 0; 122 } 123 IndexedGetter(uint32_t index,bool & found)124 nsMimeType* IndexedGetter(uint32_t index, bool& found) { 125 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 126 return nullptr; 127 } 128 NamedGetter(const nsAString & name,bool & found)129 nsMimeType* NamedGetter(const nsAString& name, bool& found) { 130 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 131 return nullptr; 132 } 133 GetSupportedNames(nsTArray<nsString> & retval)134 void GetSupportedNames(nsTArray<nsString>& retval) { 135 MOZ_ASSERT_UNREACHABLE("nsPluginElement can not exist"); 136 } 137 138 protected: 139 virtual ~nsPluginElement() = default; 140 }; 141 142 #endif /* nsPluginArray_h___ */ 143