|
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 BackstagePass : public nsIGlobalObject, |
|
19 public nsIScriptObjectPrincipal, |
|
20 public nsIXPCScriptable, |
|
21 public nsIClassInfo, |
|
22 public nsSupportsWeakReference |
|
23 { |
|
24 public: |
|
25 NS_DECL_ISUPPORTS |
|
26 NS_DECL_NSIXPCSCRIPTABLE |
|
27 NS_DECL_NSICLASSINFO |
|
28 |
|
29 virtual nsIPrincipal* GetPrincipal() { |
|
30 return mPrincipal; |
|
31 } |
|
32 |
|
33 virtual JSObject* GetGlobalJSObject() { |
|
34 return mGlobal; |
|
35 } |
|
36 |
|
37 virtual void ForgetGlobalObject() { |
|
38 mGlobal = nullptr; |
|
39 } |
|
40 |
|
41 virtual void SetGlobalObject(JSObject* global) { |
|
42 mGlobal = global; |
|
43 } |
|
44 |
|
45 BackstagePass(nsIPrincipal *prin) : |
|
46 mPrincipal(prin) |
|
47 { |
|
48 } |
|
49 |
|
50 virtual ~BackstagePass() { } |
|
51 |
|
52 private: |
|
53 nsCOMPtr<nsIPrincipal> mPrincipal; |
|
54 JS::TenuredHeap<JSObject*> mGlobal; |
|
55 }; |
|
56 |
|
57 nsresult |
|
58 NS_NewBackstagePass(BackstagePass** ret); |
|
59 |
|
60 #endif // BackstagePass_h__ |