Bug 668639 - Work around Apple's latest Java update for OS X 10.5 breaking Java in FF 4 and up. r=bgirard

This commit is contained in:
Steven Michaud 2011-07-07 14:24:28 -05:00
Родитель 1620a4aeda
Коммит 53e35e6fe8
2 изменённых файлов: 35 добавлений и 7 удалений

Просмотреть файл

@ -214,8 +214,8 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
else if (nsCRT::strcmp(prop, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0) else if (nsCRT::strcmp(prop, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0)
{ {
static const char *const java2PluginDirPath = static const char *const java2PluginDirPath =
"/System/Library/Frameworks/JavaVM.framework/Versions/Current/Resources/"; "/System/Library/Java/Support/Deploy.bundle/Contents/Resources/";
NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), PR_TRUE, getter_AddRefs(localFile)); rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), PR_TRUE, getter_AddRefs(localFile));
} }
#else #else
else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0) else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0)
@ -326,7 +326,7 @@ NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFi
#if defined(XP_MACOSX) #if defined(XP_MACOSX)
FSRef fsRef; FSRef fsRef;
OSType folderType = aLocal ? kCachedDataFolderType : kDomainLibraryFolderType; OSType folderType = aLocal ? (OSType) kCachedDataFolderType : (OSType) kDomainLibraryFolderType;
OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef); OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
if (err) return NS_ERROR_FAILURE; if (err) return NS_ERROR_FAILURE;
NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(localDir)); 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)) if (!nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR_LIST))
{ {
#ifdef XP_MACOSX #ifdef XP_MACOSX
// We are temporarily looking for JavaPlugin2 in the Java framework because Apple did not want // As of Java for Mac OS X 10.5 Update 10, Apple has (in effect) deprecated Java Plugin2 on
// to enable it for Safari by including it in the normal search directories. This situation // on OS X 10.5, and removed the soft link to it from /Library/Internet Plug-Ins/. Java
// should be resolved soon and then we should stop looking for JavaPlugin2 explicitly. // 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, 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); *_retval = new nsAppDirectoryEnumerator(this, keys);
#else #else
#ifdef XP_UNIX #ifdef XP_UNIX
@ -587,3 +592,22 @@ nsAppFileLocationProvider::GetFiles(const char *prop, nsISimpleEnumerator **_ret
} }
return rv; 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

Просмотреть файл

@ -72,5 +72,9 @@ protected:
NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile, NS_METHOD GetDefaultUserProfileRoot(nsILocalFile **aLocalFile,
PRBool aLocal = PR_FALSE); PRBool aLocal = PR_FALSE);
#if defined(XP_MACOSX)
static PRBool IsOSXLeopard();
#endif
nsCOMPtr<nsILocalFile> mMozBinDirectory; nsCOMPtr<nsILocalFile> mMozBinDirectory;
}; };