Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions
nsSecurityNameSet Class Reference
Inheritance diagram for nsSecurityNameSet:
Inheritance graph
[legend]
Collaboration diagram for nsSecurityNameSet:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsSecurityNameSet ()
virtual ~nsSecurityNameSet ()
NS_DECL_ISUPPORTS NS_IMETHOD InitializeNameSet (nsIScriptContext *aScriptContext)
 Called to tell the name set to do any initialization it needs to.
 NS_DEFINE_STATIC_IID_ACCESSOR (NS_ISCRIPTEXTERNALNAMESET_IID)

Detailed Description

Definition at line 66 of file nsSecurityManagerFactory.cpp.


Constructor & Destructor Documentation

Definition at line 77 of file nsSecurityManagerFactory.cpp.

{
}

Definition at line 81 of file nsSecurityManagerFactory.cpp.

{
}

Member Function Documentation

Called to tell the name set to do any initialization it needs to.

Implements nsIScriptExternalNameSet.

Definition at line 286 of file nsSecurityManagerFactory.cpp.

{
    JSContext *cx = (JSContext *) aScriptContext->GetNativeContext();
    JSObject *global = JS_GetGlobalObject(cx);

    /*
     * Find Object.prototype's class by walking up the global object's
     * prototype chain.
     */
    JSObject *obj = global;
    JSObject *proto;
    while ((proto = JS_GetPrototype(cx, obj)) != nsnull)
        obj = proto;
    JSClass *objectClass = JS_GetClass(cx, obj);

    jsval v;
    if (!JS_GetProperty(cx, global, "netscape", &v))
        return NS_ERROR_FAILURE;
    JSObject *securityObj;
    if (JSVAL_IS_OBJECT(v)) {
        /*
         * "netscape" property of window object exists; must be LiveConnect
         * package. Get the "security" property.
         */
        obj = JSVAL_TO_OBJECT(v);
        if (!JS_GetProperty(cx, obj, "security", &v) || !JSVAL_IS_OBJECT(v))
            return NS_ERROR_FAILURE;
        securityObj = JSVAL_TO_OBJECT(v);
    } else {
        /* define netscape.security object */
        obj = JS_DefineObject(cx, global, "netscape", objectClass, nsnull, 0);
        if (obj == nsnull)
            return NS_ERROR_FAILURE;
        securityObj = JS_DefineObject(cx, obj, "security", objectClass,
                                      nsnull, 0);
        if (securityObj == nsnull)
            return NS_ERROR_FAILURE;
    }

    /* Define PrivilegeManager object with the necessary "static" methods. */
    obj = JS_DefineObject(cx, securityObj, "PrivilegeManager", objectClass,
                          nsnull, 0);
    if (obj == nsnull)
        return NS_ERROR_FAILURE;

    return JS_DefineFunctions(cx, obj, PrivilegeManager_static_methods)
           ? NS_OK
           : NS_ERROR_FAILURE;
}

Here is the call graph for this function:


The documentation for this class was generated from the following file: