nsCOMPtr<nsIScriptSecurityManager> secman( do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID)); if (secman) { nsCOMPtr<nsIURI> uri; nsresult rv = NS_NewURI(getter_AddRefs(uri), sourceURL); if (NS_SUCCEEDED(rv)) { rv = secman->CheckLoadURIFromScript(cx, uri); if (NS_FAILED(rv)) return JS_FALSE; } }
nsresult rv = InstallTriggerCheckLoadURIFromScript(cx, sourceURL); if (NS_FAILED(rv)) return JS_FALSE;
InstallTriggerGlobalInstallChrome(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){  nsIDOMInstallTriggerGlobal *nativeThis = (nsIDOMInstallTriggerGlobal*)    JS_GetInstancePrivate(cx, obj, &InstallTriggerGlobalClass, argv);  if (!nativeThis)    return JS_FALSE;  uint32       chromeType = NOT_CHROME;  nsAutoString sourceURL;  nsAutoString name;  *rval = JSVAL_FALSE;  if (nsnull == nativeThis  &&  (JS_FALSE == CreateNativeObject(cx, obj, &nativeThis)) ) {    return JS_TRUE;  }  // get chromeType first, the update enabled check for skins skips whitelisting  if (argc >=1)      JS_ValueToECMAUint32(cx, argv[0], &chromeType);  // make sure XPInstall is enabled, return if not  nsIScriptGlobalObject *globalObject = nsnull;  nsIScriptContext *scriptContext = GetScriptContextFromJSContext(cx);  if (scriptContext)      globalObject = scriptContext->GetGlobalObject();  PRBool enabled = PR_FALSE;  PRBool useWhitelist = ( chromeType != CHROME_SKIN );  nativeThis->UpdateEnabled(globalObject, useWhitelist, &enabled);  if (!enabled || !globalObject)      return JS_TRUE;  // get window.location to construct relative URLs  nsCOMPtr<nsIURI> baseURL;  JSObject* global = JS_GetGlobalObject(cx);  if (global)  {    jsval v;    if (JS_GetProperty(cx,global,"location",&v))    {      nsAutoString location;      ConvertJSValToStr( location, cx, v );      NS_NewURI(getter_AddRefs(baseURL), location);    }  }  if ( argc >= 3 )  {    ConvertJSValToStr(sourceURL, cx, argv[1]);    ConvertJSValToStr(name, cx, argv[2]);    if (baseURL)    {        nsCAutoString resolvedURL;        baseURL->Resolve(NS_ConvertUTF16toUTF8(sourceURL), resolvedURL);        sourceURL = NS_ConvertUTF8toUTF16(resolvedURL);    }    // Make sure caller is allowed to load this url.    // if we can't create a security manager we might be in the wizard, allow    nsCOMPtr<nsIScriptSecurityManager> secman(        do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));    if (secman)    {        nsCOMPtr<nsIURI> uri;        nsresult rv = NS_NewURI(getter_AddRefs(uri), sourceURL);        if (NS_SUCCEEDED(rv))        {            rv = secman->CheckLoadURIFromScript(cx, uri);            if (NS_FAILED(rv))                return JS_FALSE;        }    }    if ( chromeType & CHROME_ALL )    {        // there's at least one known chrome type        nsXPITriggerItem* item = new nsXPITriggerItem(name.get(),                                                      sourceURL.get(),                                                       nsnull);        PRBool nativeRet = PR_FALSE;        nativeThis->InstallChrome(globalObject, chromeType, item, &nativeRet);        *rval = BOOLEAN_TO_JSVAL(nativeRet);    }  }  return JS_TRUE;}