|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* vim: set ts=8 sts=4 et sw=4 tw=99: */ |
|
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 __SANDBOXPRIVATE_H__ |
|
8 #define __SANDBOXPRIVATE_H__ |
|
9 |
|
10 #include "nsIGlobalObject.h" |
|
11 #include "nsIScriptObjectPrincipal.h" |
|
12 #include "nsIPrincipal.h" |
|
13 #include "nsWeakReference.h" |
|
14 #include "nsWrapperCache.h" |
|
15 |
|
16 #include "js/RootingAPI.h" |
|
17 |
|
18 // This interface is public only because it is used in jsd. |
|
19 // Once jsd is gone this file should be moved back to xpconnect/src. |
|
20 |
|
21 class SandboxPrivate : public nsIGlobalObject, |
|
22 public nsIScriptObjectPrincipal, |
|
23 public nsSupportsWeakReference, |
|
24 public nsWrapperCache |
|
25 { |
|
26 public: |
|
27 SandboxPrivate(nsIPrincipal *principal, JSObject *global) |
|
28 : mPrincipal(principal) |
|
29 { |
|
30 SetWrapper(global); |
|
31 } |
|
32 virtual ~SandboxPrivate() { } |
|
33 |
|
34 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
35 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(SandboxPrivate, |
|
36 nsIGlobalObject) |
|
37 |
|
38 nsIPrincipal *GetPrincipal() |
|
39 { |
|
40 return mPrincipal; |
|
41 } |
|
42 |
|
43 JSObject *GetGlobalJSObject() |
|
44 { |
|
45 return GetWrapper(); |
|
46 } |
|
47 |
|
48 void ForgetGlobalObject() |
|
49 { |
|
50 ClearWrapper(); |
|
51 } |
|
52 private: |
|
53 nsCOMPtr<nsIPrincipal> mPrincipal; |
|
54 }; |
|
55 |
|
56 #endif // __SANDBOXPRIVATE_H__ |