michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef BackstagePass_h__ michael@0: #define BackstagePass_h__ michael@0: michael@0: #include "nsISupports.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsIGlobalObject.h" michael@0: #include "nsIScriptObjectPrincipal.h" michael@0: #include "nsIXPCScriptable.h" michael@0: michael@0: #include "js/HeapAPI.h" michael@0: michael@0: class BackstagePass : public nsIGlobalObject, michael@0: public nsIScriptObjectPrincipal, michael@0: public nsIXPCScriptable, michael@0: public nsIClassInfo, michael@0: public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIXPCSCRIPTABLE michael@0: NS_DECL_NSICLASSINFO michael@0: michael@0: virtual nsIPrincipal* GetPrincipal() { michael@0: return mPrincipal; michael@0: } michael@0: michael@0: virtual JSObject* GetGlobalJSObject() { michael@0: return mGlobal; michael@0: } michael@0: michael@0: virtual void ForgetGlobalObject() { michael@0: mGlobal = nullptr; michael@0: } michael@0: michael@0: virtual void SetGlobalObject(JSObject* global) { michael@0: mGlobal = global; michael@0: } michael@0: michael@0: BackstagePass(nsIPrincipal *prin) : michael@0: mPrincipal(prin) michael@0: { michael@0: } michael@0: michael@0: virtual ~BackstagePass() { } michael@0: michael@0: private: michael@0: nsCOMPtr mPrincipal; michael@0: JS::TenuredHeap mGlobal; michael@0: }; michael@0: michael@0: nsresult michael@0: NS_NewBackstagePass(BackstagePass** ret); michael@0: michael@0: #endif // BackstagePass_h__