remove support for resource (.rsrc) files in Mac OS X plugins. b=468678 r=smichaud sr=roc

This commit is contained in:
Josh Aas 2008-12-11 16:52:42 -05:00
Родитель d42f6f7fd8
Коммит d93e9205d2
5 изменённых файлов: 11 добавлений и 125 удалений

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

@ -344,15 +344,6 @@ nsNPAPIPlugin::~nsNPAPIPlugin(void)
memset((void*) &fCallbacks, 0, sizeof(fCallbacks));
}
#if defined(XP_MACOSX)
void
nsNPAPIPlugin::SetPluginRefNum(short aRefNum)
{
fPluginRefNum = aRefNum;
}
#endif
// Creates the nsNPAPIPlugin object. One nsNPAPIPlugin object exists per plugin (not instance).
nsresult
nsNPAPIPlugin::CreatePlugin(const char* aFileName, const char* aFullPath,
@ -511,18 +502,13 @@ nsNPAPIPlugin::CreatePlugin(const char* aFileName, const char* aFullPath,
#endif
#if defined(XP_MACOSX)
short appRefNum = ::CurResFile();
short pluginRefNum;
nsCOMPtr<nsILocalFile> pluginPath;
NS_NewNativeLocalFile(nsDependentCString(aFullPath), PR_TRUE,
getter_AddRefs(pluginPath));
nsPluginFile pluginFile(pluginPath);
pluginRefNum = pluginFile.OpenPluginResource();
nsNPAPIPlugin* plugin = new nsNPAPIPlugin(nsnull, aLibrary, nsnull);
::UseResFile(appRefNum);
if (!plugin)
return NS_ERROR_OUT_OF_MEMORY;
@ -533,8 +519,6 @@ nsNPAPIPlugin::CreatePlugin(const char* aFileName, const char* aFullPath,
NS_RELEASE(*aResult);
return NS_ERROR_FAILURE;
}
plugin->SetPluginRefNum(pluginRefNum);
#endif
#ifdef XP_BEOS
@ -629,8 +613,6 @@ nsNPAPIPlugin::Shutdown(void)
if (fShutdownEntry) {
#if defined(XP_MACOSX)
(*fShutdownEntry)();
if (fPluginRefNum > 0)
::CloseResFile(fPluginRefNum);
#else
NS_TRY_SAFE_CALL_VOID(fShutdownEntry(), fLibrary, nsnull);
#endif

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

@ -97,10 +97,6 @@ protected:
// Ensures that the static CALLBACKS is properly initialized
static void CheckClassInitialized(void);
#ifdef XP_MACOSX
short fPluginRefNum;
#endif
// The plugin-side callbacks that the browser calls. One set of
// plugin callbacks for each plugin.
NPPluginFuncs fCallbacks;

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

@ -718,7 +718,7 @@ nsPluginTag::nsPluginTag(nsPluginInfo* aPluginInfo)
mLibrary(nsnull),
mEntryPoint(nsnull),
#ifdef XP_MACOSX
mCanUnloadLibrary(!aPluginInfo->fBundle),
mCanUnloadLibrary(PR_FALSE),
#else
mCanUnloadLibrary(PR_TRUE),
#endif

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

@ -35,8 +35,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPluginsDir_h___
#define nsPluginsDir_h___
#ifndef nsPluginsDir_h_
#define nsPluginsDir_h_
#include "nsError.h"
#include "nsIFile.h"
@ -66,9 +66,6 @@ struct nsPluginInfo {
char* fFileName;
char* fFullPath;
char* fVersion;
#ifdef XP_MACOSX
PRBool fBundle;
#endif
};
/**
@ -104,9 +101,6 @@ public:
* Should be called after GetPluginInfo to free all allocated stuff
*/
nsresult FreePluginInfo(nsPluginInfo &PluginInfo);
// Open the resource fork for the plugin
short OpenPluginResource(void);
};
#endif /* nsPluginsDir_h___ */
#endif /* nsPluginsDir_h_ */

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

@ -60,7 +60,6 @@
#include <unistd.h>
#include <fcntl.h>
#include <Carbon/Carbon.h>
#include <CoreServices/CoreServices.h>
#include <mach-o/loader.h>
#include <mach-o/fat.h>
@ -158,12 +157,12 @@ PRBool nsPluginsDir::IsPluginFile(nsIFile* file)
PRBool isPluginFile = PR_FALSE;
CFBundleRef pluginBundle = CFBundleCreate(kCFAllocatorDefault, pluginURL);
CFBundleRef pluginBundle = ::CFBundleCreate(kCFAllocatorDefault, pluginURL);
if (pluginBundle) {
UInt32 packageType, packageCreator;
CFBundleGetPackageInfo(pluginBundle, &packageType, &packageCreator);
if (packageType == 'BRPL' || packageType == 'IEPL' || packageType == 'NSPL') {
CFURLRef executableURL = CFBundleCopyExecutableURL(pluginBundle);
CFURLRef executableURL = ::CFBundleCopyExecutableURL(pluginBundle);
if (executableURL) {
isPluginFile = IsLoadablePlugin(executableURL);
::CFRelease(executableURL);
@ -317,79 +316,18 @@ static char* GetNextPluginStringFromHandle(Handle h, short *index)
return ret;
}
static char* GetPluginString(short id, short index)
{
Str255 str;
::GetIndString(str, id, index);
return p2cstrdup(str);
}
// Opens the resource fork for the plugin
// Also checks if the plugin is a CFBundle and opens gets the correct resource
static short OpenPluginResourceFork(nsIFile *pluginFile)
{
FSSpec spec;
OSErr err = toFSSpec(pluginFile, spec);
Boolean targetIsFolder, wasAliased;
err = ::ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
short refNum = ::FSpOpenResFile(&spec, fsRdPerm);
if (refNum < 0) {
nsCString path;
pluginFile->GetNativePath(path);
CFBundleRef bundle = getPluginBundle(path.get());
if (bundle) {
refNum = CFBundleOpenBundleResourceMap(bundle);
::CFRelease(bundle);
}
}
return refNum;
}
short nsPluginFile::OpenPluginResource()
{
return OpenPluginResourceFork(mPlugin);
}
class nsAutoCloseResourceObject {
public:
nsAutoCloseResourceObject(nsIFile *pluginFile)
{
mRefNum = OpenPluginResourceFork(pluginFile);
}
~nsAutoCloseResourceObject()
{
if (mRefNum > 0)
::CloseResFile(mRefNum);
}
PRBool ResourceOpened()
{
return (mRefNum > 0);
}
private:
short mRefNum;
};
/**
* Obtains all of the information currently available for this plugin.
*/
// Obtains all of the information currently available for this plugin.
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
// clear out the info, except for the first field.
memset(&info, 0, sizeof(info));
// First open up resource we can use to get plugin info.
// Try to open a resource fork.
nsAutoCloseResourceObject resourceObject(mPlugin);
bool resourceOpened = resourceObject.ResourceOpened();
// Try to get a bundle reference.
nsCString path;
mPlugin->GetNativePath(path);
CFBundleRef bundle = getPluginBundle(path.get());
// Get fBundle
if (bundle)
info.fBundle = PR_TRUE;
if (!bundle)
return NS_ERROR_FAILURE;
// Get fName
if (bundle) {
@ -397,10 +335,6 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
if (name && ::CFGetTypeID(name) == ::CFStringGetTypeID())
info.fName = CFStringRefToUTF8Buffer(static_cast<CFStringRef>(name));
}
if (!info.fName && resourceOpened) {
// 'STR#', 126, 2 => plugin name.
info.fName = GetPluginString(126, 2);
}
// Get fDescription
if (bundle) {
@ -408,10 +342,6 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
if (description && ::CFGetTypeID(description) == ::CFStringGetTypeID())
info.fDescription = CFStringRefToUTF8Buffer(static_cast<CFStringRef>(description));
}
if (!info.fDescription && resourceOpened) {
// 'STR#', 126, 1 => plugin description.
info.fDescription = GetPluginString(126, 1);
}
// Get fFileName
FSSpec spec;
@ -470,24 +400,8 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
}
}
// Try to get data from the resource fork
if (!info.fVariantCount && resourceObject.ResourceOpened()) {
mi.typeStrings = ::Get1Resource('STR#', 128);
if (mi.typeStrings) {
info.fVariantCount = (**(short**)mi.typeStrings) / 2;
::DetachResource(mi.typeStrings);
::HLock(mi.typeStrings);
} else {
// Don't add this plugin because no mime types could be found
return NS_ERROR_FAILURE;
}
mi.infoStrings = ::Get1Resource('STR#', 127);
if (mi.infoStrings) {
::DetachResource(mi.infoStrings);
::HLock(mi.infoStrings);
}
}
if (!info.fVariantCount)
return NS_ERROR_FAILURE;
// Fill in the info struct based on the data in the BPSupportedMIMETypes struct
int variantCount = info.fVariantCount;