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 mozilla_extensions_{{ webidl_name }}_h 8#define mozilla_extensions_{{ webidl_name }}_h 9 10#include "js/TypeDecls.h" 11#include "mozilla/Attributes.h" 12#include "mozilla/dom/BindingDeclarations.h" 13#include "nsCycleCollectionParticipant.h" 14#include "nsCOMPtr.h" 15#include "nsISupports.h" 16#include "nsWrapperCache.h" 17 18#include "ExtensionAPIBase.h" 19#include "ExtensionBrowser.h" 20 21class nsIGlobalObject; 22 23namespace mozilla { 24 25namespace extensions { 26 27class ExtensionEventManager; 28 29class {{ webidl_name }} final : public nsISupports, 30 public nsWrapperCache, 31 public ExtensionAPINamespace { 32 nsCOMPtr<nsIGlobalObject> mGlobal; 33 RefPtr<ExtensionBrowser> mExtensionBrowser; 34 // TODO: add RefPtr for the ExtensionEventManager instances if any. 35 // RefPtr<ExtensionEventManager> mOnEVENTNAMEEventMgr; 36 37 ~{{ webidl_name }}() = default; 38 39 public: 40 {{ webidl_name }}(nsIGlobalObject* aGlobal, ExtensionBrowser* aExtensionBrowser); 41 42 // ExtensionAPIBase methods 43 nsIGlobalObject* GetGlobalObject() const override { return mGlobal; } 44 45 ExtensionBrowser* GetExtensionBrowser() const override { 46 return mExtensionBrowser; 47 } 48 49 nsString GetAPINamespace() const override { return u"{{ api_namespace }}"_ns; } 50 51 // nsWrapperCache interface methods 52 JSObject* WrapObject(JSContext* aCx, 53 JS::Handle<JSObject*> aGivenProto) override; 54 55 // DOM bindings methods 56 static bool IsAllowed(JSContext* aCx, JSObject* aGlobal); 57 58 nsIGlobalObject* GetParentObject() const; 59 60 // TODO: add method for the event manager objects if any. 61 // ExtensionEventManager* OnEVENTNAME(); 62 63 // TODO: add methods for the property getters if any. 64 // void GetPROP_NAME(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval); 65 66 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 67 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS({{ webidl_name }}) 68}; 69 70} // namespace extensions 71} // namespace mozilla 72 73#endif // mozilla_extensions_{{ webidl_name }}_h 74