js/xpconnect/idl/nsIXPCScriptable.idl

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  *
     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/. */
     7 #include "nsISupports.idl"
     8 #include "nsIClassInfo.idl"
    10 %{C++
    11 #ifdef XP_WIN
    12 #undef GetClassName
    13 #endif
    15 #include "js/TypeDecls.h"
    17 struct JSFreeOp;
    18 %}
    20 interface nsIXPConnectWrappedNative;
    22 [ptr] native JSContextPtr(JSContext);
    23 [ptr] native JSObjectPtr(JSObject);
    24 [ptr] native JSValPtr(JS::Value);
    25 [ptr] native JSFreeOpPtr(JSFreeOp);
    26 [ref] native JSCallArgsRef(const JS::CallArgs);
    28 /**
    29  * Note: This is not really an XPCOM interface.  For example, callers must
    30  * guarantee that they set the *_retval of the various methods that return a
    31  * boolean to PR_TRUE before making the call.  Implementations may skip writing
    32  * to *_retval unless they want to return PR_FALSE.
    33  */
    34 [uuid(9bae4ff5-5618-4ccd-b106-8e21e3fb64d3)]
    35 interface nsIXPCScriptable : nsISupports
    36 {
    37     /* bitflags used for 'flags' (only 32 bits available!) */
    39     const uint32_t WANT_PRECREATE                   = 1 <<  0;
    40     const uint32_t WANT_CREATE                      = 1 <<  1;
    41     const uint32_t WANT_POSTCREATE                  = 1 <<  2;
    42     const uint32_t WANT_ADDPROPERTY                 = 1 <<  3;
    43     const uint32_t WANT_DELPROPERTY                 = 1 <<  4;
    44     const uint32_t WANT_GETPROPERTY                 = 1 <<  5;
    45     const uint32_t WANT_SETPROPERTY                 = 1 <<  6;
    46     const uint32_t WANT_ENUMERATE                   = 1 <<  7;
    47     const uint32_t WANT_NEWENUMERATE                = 1 <<  8;
    48     const uint32_t WANT_NEWRESOLVE                  = 1 <<  9;
    49     const uint32_t WANT_CONVERT                     = 1 << 10;
    50     const uint32_t WANT_FINALIZE                    = 1 << 11;
    51     // unused bit here!
    52     const uint32_t WANT_CALL                        = 1 << 13;
    53     const uint32_t WANT_CONSTRUCT                   = 1 << 14;
    54     const uint32_t WANT_HASINSTANCE                 = 1 << 15;
    55     // Unused bit here!
    56     const uint32_t USE_JSSTUB_FOR_ADDPROPERTY       = 1 << 17;
    57     const uint32_t USE_JSSTUB_FOR_DELPROPERTY       = 1 << 18;
    58     const uint32_t USE_JSSTUB_FOR_SETPROPERTY       = 1 << 19;
    59     const uint32_t DONT_ENUM_STATIC_PROPS           = 1 << 20;
    60     const uint32_t DONT_ENUM_QUERY_INTERFACE        = 1 << 21;
    61     const uint32_t DONT_ASK_INSTANCE_FOR_SCRIPTABLE = 1 << 22;
    62     const uint32_t CLASSINFO_INTERFACES_ONLY        = 1 << 23;
    63     const uint32_t ALLOW_PROP_MODS_DURING_RESOLVE   = 1 << 24;
    64     const uint32_t ALLOW_PROP_MODS_TO_PROTOTYPE     = 1 << 25;
    65     const uint32_t IS_GLOBAL_OBJECT                 = 1 << 26;
    66     const uint32_t DONT_REFLECT_INTERFACE_NAMES     = 1 << 27;
    67     // Unused bit here!
    68     const uint32_t WANT_OUTER_OBJECT                = 1 << 29;
    70     // The high order bit is RESERVED for consumers of these flags. 
    71     // No implementor of this interface should ever return flags 
    72     // with this bit set.
    73     const uint32_t RESERVED                         = 1 << 31;
    75     readonly attribute string   className;
    76     [notxpcom,nostdcall] uint32_t getScriptableFlags();
    78     void   preCreate(in nsISupports nativeObj, in JSContextPtr cx,
    79                      in JSObjectPtr globalObj, out JSObjectPtr parentObj);
    81     void   create(in nsIXPConnectWrappedNative wrapper,
    82                   in JSContextPtr cx, in JSObjectPtr obj);
    84     // Both methods here are protected by WANT_POSTCREATE. If you want to do
    85     // something after a wrapper is created, there's a good chance you also
    86     // want to do something when the wrapper is transplanted to a new
    87     // compartment.
    88     void   postCreate(in nsIXPConnectWrappedNative wrapper,
    89                       in JSContextPtr cx, in JSObjectPtr obj);
    91     void postTransplant(in nsIXPConnectWrappedNative wrapper,
    92                         in JSContextPtr cx, in JSObjectPtr obj);
    94     boolean addProperty(in nsIXPConnectWrappedNative wrapper,
    95                        in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
    96                        in JSValPtr vp);
    98     boolean delProperty(in nsIXPConnectWrappedNative wrapper,
    99                        in JSContextPtr cx, in JSObjectPtr obj, in jsid id);
   101     // The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
   102     // this method does something.
   103     boolean getProperty(in nsIXPConnectWrappedNative wrapper,
   104                        in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
   105                        in JSValPtr vp);
   107     // The returnCode should be set to NS_SUCCESS_I_DID_SOMETHING if
   108     // this method does something.
   109     boolean setProperty(in nsIXPConnectWrappedNative wrapper,
   110                        in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
   111                        in JSValPtr vp);
   113     boolean enumerate(in nsIXPConnectWrappedNative wrapper,
   114                      in JSContextPtr cx, in JSObjectPtr obj);
   116     boolean newEnumerate(in nsIXPConnectWrappedNative wrapper,
   117                         in JSContextPtr cx, in JSObjectPtr obj,
   118                         in uint32_t enum_op, in JSValPtr statep, out jsid idp);
   120     boolean newResolve(in nsIXPConnectWrappedNative wrapper,
   121                       in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
   122                       out JSObjectPtr objp);
   124     boolean convert(in nsIXPConnectWrappedNative wrapper,
   125                    in JSContextPtr cx, in JSObjectPtr obj,
   126                    in uint32_t type, in JSValPtr vp);
   128     void   finalize(in nsIXPConnectWrappedNative wrapper,
   129                     in JSFreeOpPtr fop, in JSObjectPtr obj);
   131     boolean call(in nsIXPConnectWrappedNative wrapper,
   132                 in JSContextPtr cx, in JSObjectPtr obj,
   133                 in JSCallArgsRef args);
   135     boolean construct(in nsIXPConnectWrappedNative wrapper,
   136                      in JSContextPtr cx, in JSObjectPtr obj,
   137                      in JSCallArgsRef args);
   139     boolean hasInstance(in nsIXPConnectWrappedNative wrapper,
   140                        in JSContextPtr cx, in JSObjectPtr obj,
   141                        in jsval val, out boolean bp);
   143     JSObjectPtr outerObject(in nsIXPConnectWrappedNative wrapper,
   144                             in JSContextPtr cx, in JSObjectPtr obj);
   146     void postCreatePrototype(in JSContextPtr cx, in JSObjectPtr proto);
   147 };
   149 %{ C++
   151 #include "nsAutoPtr.h"
   153 #define NS_XPCCLASSINFO_IID \
   154 { 0x9a5b0342, 0x0f70, 0x4d31, \
   155  { 0xb7, 0xd7, 0x29, 0x68, 0xa5, 0x70, 0x4b, 0xd8 } }
   157 class NS_NO_VTABLE nsXPCClassInfo : public nsIClassInfo,
   158                                     public nsIXPCScriptable
   159 {
   160 public:
   161   NS_DECLARE_STATIC_IID_ACCESSOR(NS_XPCCLASSINFO_IID)
   163   NS_IMETHOD_(MozExternalRefCountType) AddRef() = 0;
   164   NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
   166   virtual void PreserveWrapper(nsISupports *aNative) = 0;
   168   virtual uint32_t GetInterfacesBitmap() = 0;
   169 };
   171 NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCClassInfo, NS_XPCCLASSINFO_IID)
   173 inline
   174 nsresult
   175 CallQueryInterface(nsISupports* aSourcePtr,
   176                    nsRefPtrGetterAddRefs<nsXPCClassInfo> aDestPtr)
   177 {
   178   return CallQueryInterface(aSourcePtr,
   179                             static_cast<nsXPCClassInfo**>(aDestPtr));
   180 }
   182 %}

mercurial