InitializeWindowCreator(initContext);
void DoMozInitialization(WebShellInitContext * initContext){        if (gFirstTime) {        // PENDING(edburns): We need this for rdf_getChildCount        PR_SetEnv("XPCOM_CHECK_THREADSAFE=0");                nsILocalFile * pathFile = nsnull;        nsresult rv = nsnull;        JNIEnv *   env = initContext->env;        nsAutoString BinDir;        BinDir.AssignWithConversion(gBinDir);        rv = NS_NewLocalFile(BinDir, PR_TRUE, &pathFile);        if (NS_FAILED(rv)) {            ::util_ThrowExceptionToJava(env, "call to NS_NewLocalFile failed.");            return;        }                // It is vitally important to call NS_InitEmbedding before calling        // anything else.        NS_InitEmbedding(pathFile, nsnull);        rv = NS_GetGlobalComponentManager(&gComponentManager);        if (NS_FAILED(rv)) {            ::util_ThrowExceptionToJava(env, "NS_GetGlobalComponentManager() failed.");            return;        }        const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE");        if (nsnull != webclientLogFile) {            PR_SetLogFile(webclientLogFile);            // If this fails, it just goes to stdout/stderr        }                // handle the profile manager nonsense        nsCOMPtr<nsICmdLineService> cmdLine =do_GetService(kCmdLineServiceCID);        nsCOMPtr<nsIProfile> profile = do_GetService(NS_PROFILE_CONTRACTID);        if (!cmdLine || !profile) {            ::util_ThrowExceptionToJava(env, "Can't get the profile manager.");            return;        }        PRInt32 numProfiles=0;        rv = profile->GetProfileCount(&numProfiles);        char *argv[3];        int i, argc = 0;        argv[0] = strdup(gBinDir);        if (numProfiles > 1) {            PRUnichar **Names;            PRUint32 NamesLen = 0;            rv = profile->GetProfileList(&NamesLen, &Names);            argv[1] = strdup("-p");            if (NS_SUCCEEDED(rv)) {                PR_ASSERT(NamesLen >= 1);                // PENDING(edburns): fix for 70656.  Really we should have a way                // for the embedding app to specify which profile to use.                  // For now we just get the name of the first profile.                char * temp = new char[100]; // de-allocated in following for loop                for (i = 0; Names[0][i] != '\0'; i++) {                    temp[i] = (char) Names[0][i];                }                nsMemory::Free(Names);                temp[i] = '\0';                argv[2] = temp;                argc = 3;            }            else {                argv[2] = strdup("default");            }                printf("debug: edburns: argv[1]: %s argv[2]: %s\n", argv[1],                   argv[2]);        }        else {            argc = 1;        }        rv = cmdLine->Initialize(argc, argv);        for (i = 0; i < argc; i++) {            nsCRT::free(argv[i]);        }        if (NS_FAILED(rv)) {            ::util_ThrowExceptionToJava(env, "Can't initialize nsICmdLineService.");            return;        }        nsCOMPtr<nsIProfileInternal> profileInt = do_QueryInterface(profile);        if (profileInt) {            rv = profileInt->StartupWithArgs(cmdLine, PR_FALSE);            if (NS_FAILED(rv)) {                ::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");                return;            }        }        else {            ::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service.");            return;        }    }} 