ScopedAppData::~ScopedAppData() { SetAllocatedString(this->vendor, nullptr); SetAllocatedString(this->name, nullptr); SetAllocatedString(this->version, nullptr); SetAllocatedString(this->buildID, nullptr); SetAllocatedString(this->ID, nullptr); SetAllocatedString(this->copyright, nullptr); SetAllocatedString(this->profile, nullptr); NS_IF_RELEASE(this->directory); SetStrongPtr(this->xreDirectory, (nsIFile*)nullptr); SetAllocatedString(this->minVersion, nullptr); SetAllocatedString(this->maxVersion, nullptr); SetAllocatedString(this->crashReporterURL, nullptr); SetAllocatedString(this->UAName, nullptr); }
bool GRELoadAndLaunch(const char* firefoxDir, bool silentFail) { char xpcomDllPath[MAXPATHLEN]; snprintf(xpcomDllPath, MAXPATHLEN, "%s/%s", firefoxDir, XPCOM_DLL); if (silentFail && access(xpcomDllPath, F_OK) != 0) return false; if (NS_FAILED(XPCOMGlueStartup(xpcomDllPath))) { ErrorDialog("Couldn't load the XPCOM library"); return false; } if (NS_FAILED(XPCOMGlueLoadXULFunctions(kXULFuncs))) { ErrorDialog("Couldn't load libxul"); return false; } // NOTE: The GRE has successfully loaded, so we can use XPCOM now { // Scope for any XPCOM stuff we create ScopedLogging log; // Get the path to the runtime char rtPath[MAXPATHLEN]; snprintf(rtPath, MAXPATHLEN, "%s/%s", firefoxDir, kWEBAPPRT_PATH); // Get the path to the runtime's INI file char rtIniPath[MAXPATHLEN]; snprintf(rtIniPath, MAXPATHLEN, "%s/%s", rtPath, kWEBAPPRT_INI); // Load the runtime's INI from its path nsCOMPtr<nsIFile> rtINI; if (NS_FAILED(XRE_GetFileFromPath(rtIniPath, getter_AddRefs(rtINI)))) { ErrorDialog("Couldn't load the runtime INI"); return false; } bool exists; nsresult rv = rtINI->Exists(&exists); if (NS_FAILED(rv) || !exists) { ErrorDialog("The runtime INI doesn't exist"); return false; } nsXREAppData *webShellAppData; if (NS_FAILED(XRE_CreateAppData(rtINI, &webShellAppData))) { ErrorDialog("Couldn't read WebappRT application.ini"); return false; } if (!isProfileOverridden) { SetAllocatedString(webShellAppData->profile, profile); // nsXREAppData::name is used for the class name part of the WM_CLASS // property. Set it so that the DE can match our window to the correct // launcher. char programClass[MAXPATHLEN]; snprintf(programClass, MAXPATHLEN, "owa-%s", profile); SetAllocatedString(webShellAppData->name, programClass); } nsCOMPtr<nsIFile> directory; if (NS_FAILED(XRE_GetFileFromPath(rtPath, getter_AddRefs(directory)))) { ErrorDialog("Couldn't open runtime directory"); return false; } nsCOMPtr<nsIFile> xreDir; if (NS_FAILED(XRE_GetFileFromPath(firefoxDir, getter_AddRefs(xreDir)))) { ErrorDialog("Couldn't open XRE directory"); return false; } xreDir.forget(&webShellAppData->xreDirectory); NS_IF_RELEASE(webShellAppData->directory); directory.forget(&webShellAppData->directory); XRE_main(*pargc, *pargv, webShellAppData, 0); XRE_FreeAppData(webShellAppData); } return true; }
ScopedAppData::ScopedAppData(const nsXREAppData* aAppData) { Zero(); this->size = aAppData->size; SetAllocatedString(this->vendor, aAppData->vendor); SetAllocatedString(this->name, aAppData->name); SetAllocatedString(this->version, aAppData->version); SetAllocatedString(this->buildID, aAppData->buildID); SetAllocatedString(this->ID, aAppData->ID); SetAllocatedString(this->copyright, aAppData->copyright); SetAllocatedString(this->profile, aAppData->profile); SetStrongPtr(this->directory, aAppData->directory); this->flags = aAppData->flags; if (aAppData->size > offsetof(nsXREAppData, xreDirectory)) { SetStrongPtr(this->xreDirectory, aAppData->xreDirectory); SetAllocatedString(this->minVersion, aAppData->minVersion); SetAllocatedString(this->maxVersion, aAppData->maxVersion); } if (aAppData->size > offsetof(nsXREAppData, crashReporterURL)) { SetAllocatedString(this->crashReporterURL, aAppData->crashReporterURL); } if (aAppData->size > offsetof(nsXREAppData, UAName)) { SetAllocatedString(this->UAName, aAppData->UAName); } }