Line data Source code
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 BackstagePass_h__
8 : #define BackstagePass_h__
9 :
10 : #include "nsISupports.h"
11 : #include "nsWeakReference.h"
12 : #include "nsIGlobalObject.h"
13 : #include "nsIScriptObjectPrincipal.h"
14 : #include "nsIXPCScriptable.h"
15 :
16 : #include "js/HeapAPI.h"
17 :
18 : class XPCWrappedNative;
19 :
20 : class BackstagePass : public nsIGlobalObject,
21 : public nsIScriptObjectPrincipal,
22 : public nsIXPCScriptable,
23 : public nsIClassInfo,
24 : public nsSupportsWeakReference
25 : {
26 : public:
27 : NS_DECL_ISUPPORTS
28 : NS_DECL_NSIXPCSCRIPTABLE
29 : NS_DECL_NSICLASSINFO
30 :
31 0 : virtual nsIPrincipal* GetPrincipal() override {
32 0 : return mPrincipal;
33 : }
34 :
35 : virtual JSObject* GetGlobalJSObject() override;
36 :
37 0 : void ForgetGlobalObject() {
38 0 : mWrapper = nullptr;
39 0 : }
40 :
41 : void SetGlobalObject(JSObject* global);
42 :
43 255 : explicit BackstagePass(nsIPrincipal* prin) :
44 255 : mPrincipal(prin)
45 : {
46 255 : }
47 :
48 : private:
49 0 : virtual ~BackstagePass() { }
50 :
51 : nsCOMPtr<nsIPrincipal> mPrincipal;
52 : XPCWrappedNative* mWrapper;
53 : };
54 :
55 : nsresult
56 : NS_NewBackstagePass(BackstagePass** ret);
57 :
58 : #endif // BackstagePass_h__
|