Mac v2 signing - Bug 1050944 - Get Firefox to launch and run on OSX with the new .app bundle structure, made necessary by Apple's v2 signatures. r=smichaud, r=ted, sr=bsmedberg

This commit is contained in:
Stephen Pohl 2014-09-29 11:51:04 -07:00
parent f5fd544aad
commit dca2016258
6 changed files with 49 additions and 6 deletions

View File

@ -50,6 +50,9 @@
using namespace mozilla;
#ifdef XP_MACOSX
#define kOSXResourcesFolder "Resources"
#endif
#define kDesktopFolder "browser"
#define kMetroFolder "metro"
#define kMetroAppIniFilename "metroapp.ini"
@ -270,7 +273,12 @@ static int do_main(int argc, char* argv[], nsIFile *xreDirectory)
nsCOMPtr<nsIFile> greDir;
exeFile->GetParent(getter_AddRefs(greDir));
#ifdef XP_MACOSX
nsCOMPtr<nsIFile> parent;
greDir->GetParent(getter_AddRefs(parent));
greDir = parent.forget();
greDir->AppendNative(NS_LITERAL_CSTRING(kOSXResourcesFolder));
#endif
nsCOMPtr<nsIFile> appSubdir;
greDir->Clone(getter_AddRefs(appSubdir));
appSubdir->Append(NS_LITERAL_STRING(kDesktopFolder));
@ -564,6 +572,10 @@ InitXPCOMGlue(const char *argv0, nsIFile **xreDirectory)
// chop XPCOM_DLL off exePath
*lastSlash = '\0';
#ifdef XP_MACOSX
lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
strcpy(lastSlash + 1, kOSXResourcesFolder);
#endif
#ifdef XP_WIN
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(exePath), false,
xreDirectory);

View File

@ -135,15 +135,26 @@ GeckoChildProcessHost::GetPathToBinary(FilePath& exePath)
MOZ_ASSERT(gGREPath);
#ifdef OS_WIN
exePath = FilePath(char16ptr_t(gGREPath));
#elif MOZ_WIDGET_COCOA
nsCOMPtr<nsIFile> childProcPath;
NS_NewLocalFile(nsDependentString(gGREPath), false,
getter_AddRefs(childProcPath));
// We need to use an App Bundle on OS X so that we can hide
// the dock icon. See Bug 557225.
nsCOMPtr<nsIFile> tempPath;
childProcPath->GetParent(getter_AddRefs(tempPath));
childProcPath = tempPath.forget();
childProcPath->AppendNative(NS_LITERAL_CSTRING("MacOS"));
childProcPath->AppendNative(NS_LITERAL_CSTRING("plugin-container.app"));
childProcPath->AppendNative(NS_LITERAL_CSTRING("Contents"));
childProcPath->AppendNative(NS_LITERAL_CSTRING("MacOS"));
nsCString tempCPath;
childProcPath->GetNativePath(tempCPath);
exePath = FilePath(tempCPath.get());
#else
nsCString path;
NS_CopyUnicodeToNative(nsDependentString(gGREPath), path);
exePath = FilePath(path.get());
#endif
#ifdef MOZ_WIDGET_COCOA
// We need to use an App Bundle on OS X so that we can hide
// the dock icon. See Bug 557225.
exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_BUNDLE);
#endif
}

View File

@ -1086,6 +1086,10 @@ nsresult SetExceptionHandler(nsIFile* aXREDirectory,
NS_ENSURE_SUCCESS(rv, rv);
#if defined(XP_MACOSX)
nsCOMPtr<nsIFile> parentPath;
exePath->GetParent(getter_AddRefs(parentPath));
exePath = parentPath.forget();
exePath->Append(NS_LITERAL_STRING("MacOS"));
exePath->Append(NS_LITERAL_STRING("crashreporter.app"));
exePath->Append(NS_LITERAL_STRING("Contents"));
exePath->Append(NS_LITERAL_STRING("MacOS"));

View File

@ -4173,6 +4173,8 @@ XREMain::XRE_mainRun()
/*
* XRE_main - A class based main entry point used by most platforms.
* Note that on OSX, aAppData->xreDirectory will point to
* .app/Contents/Resources.
*/
int
XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)

View File

@ -132,7 +132,9 @@ protected:
void Append(nsIFile* aDirectory);
nsCOMPtr<nsIDirectoryServiceProvider> mAppProvider;
// On OSX, mGREDir points to .app/Contents/Resources
nsCOMPtr<nsIFile> mGREDir;
// On OSX, mXULAppDir points to .app/Contents/Resources/browser
nsCOMPtr<nsIFile> mXULAppDir;
nsCOMPtr<nsIFile> mProfileDir;
nsCOMPtr<nsIFile> mProfileLocalDir;

View File

@ -475,6 +475,7 @@ NS_IMPL_ISUPPORTS(NesteggReporter, nsIMemoryReporter)
CountingAllocatorBase<NesteggReporter>::sAmount(0);
#endif /* MOZ_WEBM */
// Note that on OSX, aBinDirectory will point to .app/Contents/Resources/browser
EXPORT_XPCOM_API(nsresult)
NS_InitXPCOM2(nsIServiceManager** aResult,
nsIFile* aBinDirectory,
@ -593,6 +594,17 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
xpcomLib->GetPath(path);
gGREPath = ToNewUnicode(path);
#ifdef XP_MACOSX
nsCOMPtr<nsIFile> parent;
xpcomLib->GetParent(getter_AddRefs(parent));
parent->AppendNative(NS_LITERAL_CSTRING("MacOS"));
bool pathExists = false;
parent->Exists(&pathExists);
if (pathExists) {
xpcomLib = parent.forget();
}
#endif
xpcomLib->AppendNative(nsDependentCString(XPCOM_DLL));
nsDirectoryService::gService->Set(NS_XPCOM_LIBRARY_FILE, xpcomLib);