// // FUNCTION: StartupProfile() // // PURPOSE: // nsresult StartupProfile() { nsCOMPtr<nsIFile> appDataDir; nsresult rv = NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR, getter_AddRefs(appDataDir)); if (NS_FAILED(rv)) return rv; appDataDir->AppendNative(nsCString("winembed")); nsCOMPtr<nsProfileDirServiceProvider> locProvider; NS_NewProfileDirServiceProvider(true, getter_AddRefs(locProvider)); if (!locProvider) return NS_ERROR_FAILURE; rv = locProvider->Register(); if (NS_FAILED(rv)) return rv; return locProvider->SetProfileDir(appDataDir); }
// // FUNCTION: StartupProfile() // // PURPOSE: // nsresult StartupProfile() { nsCOMPtr<nsIFile> appDataDir; nsresult rv = NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_DIR, getter_AddRefs(appDataDir)); if (NS_FAILED(rv)) return rv; appDataDir->Append(NS_LITERAL_STRING("winembed")); nsCOMPtr<nsILocalFile> localAppDataDir(do_QueryInterface(appDataDir)); nsCOMPtr<nsProfileDirServiceProvider> locProvider; NS_NewProfileDirServiceProvider(PR_TRUE, getter_AddRefs(locProvider)); if (!locProvider) return NS_ERROR_FAILURE; rv = locProvider->Register(); if (NS_FAILED(rv)) return rv; return locProvider->SetProfileDir(localAppDataDir); }
bool LLEmbeddedBrowser::init( std::string applicationDir, std::string componentDir, std::string profileDir, void* nativeWindowHandleIn ) { mNativeWindowHandle = nativeWindowHandleIn; NS_ConvertUTF8toUTF16 applicationDirUTF16(applicationDir.c_str()); NS_ConvertUTF8toUTF16 componentDirUTF16(componentDir.c_str()); NS_ConvertUTF8toUTF16 profileDirUTF16(profileDir.c_str()); nsCOMPtr< nsILocalFile > applicationDirNative; nsresult result = NS_NewLocalFile( applicationDirUTF16, PR_FALSE, getter_AddRefs( applicationDirNative ) ); if ( NS_FAILED( result ) ) { setLastError( 0x1000 ); return false; }; nsCOMPtr< nsILocalFile > componentDirNative; result = NS_NewLocalFile( componentDirUTF16 , PR_FALSE, getter_AddRefs( componentDirNative ) ); if ( NS_FAILED( result ) ) { setLastError( 0x1001 ); return false; }; result = XRE_InitEmbedding( componentDirNative, applicationDirNative, nsnull, nsnull, 0 ); if ( NS_FAILED( result ) ) { setLastError( 0x1002 ); return false; }; nsCOMPtr< nsILocalFile > profileDirNative; result = NS_NewLocalFile( profileDirUTF16 , PR_TRUE, getter_AddRefs( profileDirNative ) ); if ( NS_FAILED( result ) ) { setLastError( 0x1007 ); return false; }; nsCOMPtr< nsProfileDirServiceProvider > locProvider; NS_NewProfileDirServiceProvider( PR_TRUE, getter_AddRefs( locProvider ) ); if ( ! locProvider ) { setLastError( 0x1003 ); XRE_TermEmbedding(); return PR_FALSE; }; result = locProvider->Register(); if ( NS_FAILED( result ) ) { setLastError( 0x1004 ); XRE_TermEmbedding(); return PR_FALSE; }; result = locProvider->SetProfileDir( profileDirNative ); if ( NS_FAILED( result ) ) { setLastError( 0x1005 ); XRE_TermEmbedding(); return PR_FALSE; }; nsCOMPtr<nsIPref> pref = do_CreateInstance( NS_PREF_CONTRACTID ); if ( pref ) { pref->SetBoolPref( "security.warn_entering_secure", PR_FALSE ); pref->SetBoolPref( "security.warn_entering_weak", PR_FALSE ); pref->SetBoolPref( "security.warn_leaving_secure", PR_FALSE ); pref->SetBoolPref( "security.warn_submit_insecure", PR_FALSE ); pref->SetBoolPref( "network.protocol-handler.warn-external-default", PR_FALSE ); } else { setLastError( 0x1006 ); }; // disable proxy by default enableProxy( false, "", 0 ); // Originally from Linux version but seems to help other platforms too nsresult rv; nsCOMPtr<nsIAppShell> appShell; NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID); appShell = do_CreateInstance(kAppShellCID, &rv); if (!appShell) { setLastError( 0x1008 ); return PR_FALSE; } sAppShell = appShell.get(); NS_ADDREF(sAppShell); sAppShell->Create(0, nsnull); sAppShell->Spinup(); clearLastError(); return true; }