Go to the documentation of this file.
27 #ifndef __SB_REMOTE_API_H__
28 #define __SB_REMOTE_API_H__
30 #include <sbISecurityAggregator.h>
31 #include <sbISecurityMixin.h>
32 #include <nsAutoPtr.h>
34 #include <nsPIDOMWindow.h>
35 #include <nsIDOMDocument.h>
42 #define SB_DECL_SECURITYCHECKEDCOMP_INIT virtual nsresult Init();
44 #define SB_IMPL_SECURITYCHECKEDCOMP_INIT_TAIL() \
48 #define SB_IMPL_SECURITYCHECKEDCOMP_INIT_MIXIN_MID( _class, _mixin, _mixinArgs ) \
52 LOG(( "%s::Init()", #_class )); \
54 nsRefPtr<_mixin> mixin = new _mixin _mixinArgs; \
55 NS_ENSURE_TRUE( mixin, NS_ERROR_OUT_OF_MEMORY ); \
59 GetInterfaces( &iidCount, &iids ); \
61 rv = mixin->Init( (sbISecurityAggregator*)this, \
62 ( const nsIID** )iids, iidCount, \
63 sPublicMethods, NS_ARRAY_LENGTH(sPublicMethods), \
64 sPublicRProperties, NS_ARRAY_LENGTH(sPublicRProperties), \
65 sPublicWProperties, NS_ARRAY_LENGTH(sPublicWProperties), \
66 mRemotePlayer->IsPrivileged() ); \
67 NS_ENSURE_SUCCESS( rv, rv ); \
68 NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(iidCount, iids); \
69 mSecurityMixin = do_QueryInterface( \
70 NS_ISUPPORTS_CAST( sbISecurityMixin*, mixin ), &rv ); \
71 NS_ENSURE_SUCCESS( rv, rv ); \
73 nsCOMPtr<nsPIDOMWindow> privWindow = mRemotePlayer->GetWindow(); \
75 nsCOMPtr<nsIDOMDocument> domDoc; \
76 privWindow->GetDocument( getter_AddRefs(domDoc) ); \
77 NS_ENSURE_STATE(domDoc); \
78 rv = mixin->SetNotificationDocument( domDoc ); \
79 NS_ENSURE_SUCCESS( rv, rv ); \
82 #define SB_IMPL_SECURITYCHECKEDCOMP_INIT(_class) \
83 SB_IMPL_SECURITYCHECKEDCOMP_INIT_MIXIN_MID( _class, sbSecurityMixin, () ) \
84 SB_IMPL_SECURITYCHECKEDCOMP_INIT_TAIL()
86 #define SB_IMPL_SECURITYCHECKEDCOMP_INIT_MIXIN_LIBRES( _class, \
88 _libres, _libresArgs ) \
89 SB_IMPL_SECURITYCHECKEDCOMP_INIT_MIXIN_MID( _class, _mixin, _mixinArgs ) \
90 mRemLibraryResource = new _libres _libresArgs; \
91 NS_ENSURE_TRUE( mRemLibraryResource, NS_ERROR_OUT_OF_MEMORY ); \
92 SB_IMPL_SECURITYCHECKEDCOMP_INIT_TAIL()
94 #define SB_IMPL_SECURITYCHECKEDCOMP_INIT_LIBRES(_class, _libres, _libresArgs) \
95 SB_IMPL_SECURITYCHECKEDCOMP_INIT_MIXIN_LIBRES( _class, \
96 sbSecurityMixin, (), \
97 _libres, _libresArgs ) \
100 #define SB_IMPL_SECURITYCHECKEDCOMP_INIT_NOPLAYER_MIXIN( _class, _mixin, _mixinArgs ) \
104 LOG(( "%s::Init()", #_class )); \
106 nsRefPtr<_mixin> mixin = new _mixin _mixinArgs; \
107 NS_ENSURE_TRUE( mixin, NS_ERROR_OUT_OF_MEMORY ); \
111 GetInterfaces( &iidCount, &iids ); \
113 rv = mixin->Init( (sbISecurityAggregator*)this, \
114 ( const nsIID** )iids, iidCount, \
115 sPublicMethods, NS_ARRAY_LENGTH(sPublicMethods), \
116 sPublicRProperties, NS_ARRAY_LENGTH(sPublicRProperties), \
117 sPublicWProperties, NS_ARRAY_LENGTH(sPublicWProperties), \
119 NS_ENSURE_SUCCESS( rv, rv ); \
120 NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(iidCount, iids); \
121 mSecurityMixin = do_QueryInterface( \
122 NS_ISUPPORTS_CAST( sbISecurityMixin*, mixin ), &rv ); \
123 NS_ENSURE_SUCCESS( rv, rv ); \
127 #define SB_IMPL_SECURITYCHECKEDCOMP_INIT_NOPLAYER(_class) \
128 SB_IMPL_SECURITYCHECKEDCOMP_INIT_NOPLAYER_MIXIN( _class, sbSecurityMixin, () )
130 #endif // __SB_REMOTE_API_H__