From 53e35e6fe8e5365db54e42ffeb9913e29fa2d5c7 Mon Sep 17 00:00:00 2001 From: Steven Michaud Date: Thu, 7 Jul 2011 14:24:28 -0500 Subject: [PATCH] Bug 668639 - Work around Apple's latest Java update for OS X 10.5 breaking Java in FF 4 and up. r=bgirard --- xpcom/io/nsAppFileLocationProvider.cpp | 38 +++++++++++++++++++++----- xpcom/io/nsAppFileLocationProvider.h | 4 +++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp index e7e996a8697..e3e191103e4 100644 --- a/xpcom/io/nsAppFileLocationProvider.cpp +++ b/xpcom/io/nsAppFileLocationProvider.cpp @@ -214,8 +214,8 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile else if (nsCRT::strcmp(prop, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0) { static const char *const java2PluginDirPath = - "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Resources/"; - NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), PR_TRUE, getter_AddRefs(localFile)); + "/System/Library/Java/Support/Deploy.bundle/Contents/Resources/"; + rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), PR_TRUE, getter_AddRefs(localFile)); } #else else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0) @@ -326,7 +326,7 @@ NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFi #if defined(XP_MACOSX) FSRef fsRef; - OSType folderType = aLocal ? kCachedDataFolderType : kDomainLibraryFolderType; + OSType folderType = aLocal ? (OSType) kCachedDataFolderType : (OSType) kDomainLibraryFolderType; OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef); if (err) return NS_ERROR_FAILURE; NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(localDir)); @@ -553,11 +553,16 @@ nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_ret if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST)) { #ifdef XP_MACOSX - // We are temporarily looking for JavaPlugin2 in the Java framework because Apple did not want - // to enable it for Safari by including it in the normal search directories. This situation - // should be resolved soon and then we should stop looking for JavaPlugin2 explicitly. + // As of Java for Mac OS X 10.5 Update 10, Apple has (in effect) deprecated Java Plugin2 on + // on OS X 10.5, and removed the soft link to it from /Library/Internet Plug-Ins/. Java + // Plugin2 is still present and usable, but there are no longer any links to it in the + // "normal" locations. So we won't be able to find it unless we look in the "non-normal" + // location where it actually is. Safari can use the WebKit-specific JavaPluginCocoa.bundle, + // which (of course) is still fully supported on OS X 10.5. But we have no alternative to + // using Java Plugin2. For more information see bug 668639. static const char* keys[] = { NS_APP_PLUGINS_DIR, NS_MACOSX_USER_PLUGIN_DIR, - NS_MACOSX_LOCAL_PLUGIN_DIR, NS_MACOSX_JAVA2_PLUGIN_DIR, nsnull }; + NS_MACOSX_LOCAL_PLUGIN_DIR, + IsOSXLeopard() ? NS_MACOSX_JAVA2_PLUGIN_DIR : nsnull, nsnull }; *_retval = new nsAppDirectoryEnumerator(this, keys); #else #ifdef XP_UNIX @@ -587,3 +592,22 @@ nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_ret } return rv; } + +#if defined(XP_MACOSX) +PRBool +nsAppFileLocationProvider::IsOSXLeopard() +{ + static SInt32 version = 0; + + if (!version) { + OSErr err = ::Gestalt(gestaltSystemVersion, &version); + if (err != noErr) { + version = 0; + } else { + version &= 0xFFFF; // The system version is in the low order word + } + } + + return ((version >= 0x1050) && (version < 0x1060)); +} +#endif diff --git a/xpcom/io/nsAppFileLocationProvider.h b/xpcom/io/nsAppFileLocationProvider.h index 1d8dcf01ec2..a06123d32bb 100644 --- a/xpcom/io/nsAppFileLocationProvider.h +++ b/xpcom/io/nsAppFileLocationProvider.h @@ -72,5 +72,9 @@ protected: NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile, PRBool aLocal = PR_FALSE); +#if defined(XP_MACOSX) + static PRBool IsOSXLeopard(); +#endif + nsCOMPtr mMozBinDirectory; };