зеркало из https://github.com/mozilla/gecko-dev.git
Bug 468678: Remove support for resource (.rsrc) files in Mac OS X plugins. r=smichaud
This commit is contained in:
Родитель
9a488f5a7e
Коммит
ee97d7ac20
|
@ -237,10 +237,6 @@ NS_IMPL_ISUPPORTS1(nsNPAPIPlugin, nsIPlugin)
|
||||||
|
|
||||||
nsNPAPIPlugin::nsNPAPIPlugin()
|
nsNPAPIPlugin::nsNPAPIPlugin()
|
||||||
{
|
{
|
||||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
|
||||||
mPluginRefNum = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memset((void*)&mPluginFuncs, 0, sizeof(mPluginFuncs));
|
memset((void*)&mPluginFuncs, 0, sizeof(mPluginFuncs));
|
||||||
mPluginFuncs.size = sizeof(mPluginFuncs);
|
mPluginFuncs.size = sizeof(mPluginFuncs);
|
||||||
mPluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
mPluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
||||||
|
@ -254,14 +250,6 @@ nsNPAPIPlugin::~nsNPAPIPlugin()
|
||||||
mLibrary = nsnull;
|
mLibrary = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
|
||||||
void
|
|
||||||
nsNPAPIPlugin::SetPluginRefNum(short aRefNum)
|
|
||||||
{
|
|
||||||
mPluginRefNum = aRefNum;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID,
|
nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID,
|
||||||
const nsAString& browserDumpID)
|
const nsAString& browserDumpID)
|
||||||
|
@ -571,10 +559,7 @@ nsNPAPIPlugin::Shutdown()
|
||||||
|
|
||||||
NPError shutdownError;
|
NPError shutdownError;
|
||||||
mLibrary->NP_Shutdown(&shutdownError);
|
mLibrary->NP_Shutdown(&shutdownError);
|
||||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
|
||||||
if (shutdownError == NS_OK && mPluginRefNum > 0)
|
|
||||||
::CloseResFile(mPluginRefNum);
|
|
||||||
#endif
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,11 +106,6 @@ public:
|
||||||
static PRBool RunPluginOOP(const nsPluginTag *aPluginTag);
|
static PRBool RunPluginOOP(const nsPluginTag *aPluginTag);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
|
||||||
short mPluginRefNum;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NPPluginFuncs mPluginFuncs;
|
NPPluginFuncs mPluginFuncs;
|
||||||
PluginLibrary* mLibrary;
|
PluginLibrary* mLibrary;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1769,25 +1769,8 @@ static nsresult CreateNPAPIPlugin(nsPluginTag *aPluginTag,
|
||||||
fullPath = aPluginTag->mFullPath;
|
fullPath = aPluginTag->mFullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
|
||||||
short appRefNum = ::CurResFile();
|
|
||||||
nsCOMPtr<nsILocalFile> pluginPath;
|
|
||||||
NS_NewNativeLocalFile(nsDependentCString(fullPath.get()), PR_TRUE,
|
|
||||||
getter_AddRefs(pluginPath));
|
|
||||||
nsPluginFile pluginFile(pluginPath);
|
|
||||||
short pluginRefNum = pluginFile.OpenPluginResource();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rv = nsNPAPIPlugin::CreatePlugin(aPluginTag, aOutNPAPIPlugin);
|
rv = nsNPAPIPlugin::CreatePlugin(aPluginTag, aOutNPAPIPlugin);
|
||||||
|
|
||||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
|
||||||
if (NS_SUCCEEDED(rv))
|
|
||||||
(*aOutNPAPIPlugin)->SetPluginRefNum(pluginRefNum);
|
|
||||||
else if (pluginRefNum > 0)
|
|
||||||
::CloseResFile(pluginRefNum);
|
|
||||||
::UseResFile(appRefNum);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ mMimeTypeArray(nsnull),
|
||||||
mExtensionsArray(nsnull),
|
mExtensionsArray(nsnull),
|
||||||
mLibrary(nsnull),
|
mLibrary(nsnull),
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
mCanUnloadLibrary(!aPluginInfo->fBundle),
|
mCanUnloadLibrary(PR_FALSE),
|
||||||
#else
|
#else
|
||||||
mCanUnloadLibrary(PR_TRUE),
|
mCanUnloadLibrary(PR_TRUE),
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -66,9 +66,6 @@ struct nsPluginInfo {
|
||||||
char* fFileName;
|
char* fFileName;
|
||||||
char* fFullPath;
|
char* fFullPath;
|
||||||
char* fVersion;
|
char* fVersion;
|
||||||
#ifdef XP_MACOSX
|
|
||||||
PRBool fBundle;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -105,9 +102,6 @@ public:
|
||||||
* Should be called after GetPluginInfo to free all allocated stuff
|
* Should be called after GetPluginInfo to free all allocated stuff
|
||||||
*/
|
*/
|
||||||
nsresult FreePluginInfo(nsPluginInfo &PluginInfo);
|
nsresult FreePluginInfo(nsPluginInfo &PluginInfo);
|
||||||
|
|
||||||
// Open the resource fork for the plugin
|
|
||||||
short OpenPluginResource(void);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* nsPluginsDir_h_ */
|
#endif /* nsPluginsDir_h_ */
|
||||||
|
|
|
@ -388,63 +388,6 @@ static char* GetNextPluginStringFromHandle(Handle h, short *index)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __LP64__
|
|
||||||
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;
|
|
||||||
nsCOMPtr<nsILocalFileMac> lfm = do_QueryInterface(pluginFile);
|
|
||||||
if (!lfm || NS_FAILED(lfm->GetFSSpec(&spec)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
Boolean targetIsFolder, wasAliased;
|
|
||||||
::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;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static PRBool IsCompatibleArch(nsIFile *file)
|
static PRBool IsCompatibleArch(nsIFile *file)
|
||||||
{
|
{
|
||||||
CFURLRef pluginURL = NULL;
|
CFURLRef pluginURL = NULL;
|
||||||
|
@ -499,12 +442,6 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||||
// clear out the info, except for the first field.
|
// clear out the info, except for the first field.
|
||||||
memset(&info, 0, sizeof(info));
|
memset(&info, 0, sizeof(info));
|
||||||
|
|
||||||
#ifndef __LP64__
|
|
||||||
// Try to open a resource fork in case we have to use it.
|
|
||||||
nsAutoCloseResourceObject resourceObject(mPlugin);
|
|
||||||
bool resourceOpened = resourceObject.ResourceOpened();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Try to get a bundle reference.
|
// Try to get a bundle reference.
|
||||||
nsCAutoString path;
|
nsCAutoString path;
|
||||||
if (NS_FAILED(rv = mPlugin->GetNativePath(path)))
|
if (NS_FAILED(rv = mPlugin->GetNativePath(path)))
|
||||||
|
@ -520,22 +457,12 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||||
return rv;
|
return rv;
|
||||||
info.fFileName = PL_strdup(fileName.get());
|
info.fFileName = PL_strdup(fileName.get());
|
||||||
|
|
||||||
// Get fBundle
|
|
||||||
if (bundle)
|
|
||||||
info.fBundle = PR_TRUE;
|
|
||||||
|
|
||||||
// Get fName
|
// Get fName
|
||||||
if (bundle) {
|
if (bundle) {
|
||||||
CFTypeRef name = ::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginName"));
|
CFTypeRef name = ::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginName"));
|
||||||
if (name && ::CFGetTypeID(name) == ::CFStringGetTypeID())
|
if (name && ::CFGetTypeID(name) == ::CFStringGetTypeID())
|
||||||
info.fName = CFStringRefToUTF8Buffer(static_cast<CFStringRef>(name));
|
info.fName = CFStringRefToUTF8Buffer(static_cast<CFStringRef>(name));
|
||||||
}
|
}
|
||||||
#ifndef __LP64__
|
|
||||||
if (!info.fName && resourceOpened) {
|
|
||||||
// 'STR#', 126, 2 => plugin name.
|
|
||||||
info.fName = GetPluginString(126, 2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get fDescription
|
// Get fDescription
|
||||||
if (bundle) {
|
if (bundle) {
|
||||||
|
@ -543,12 +470,6 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||||
if (description && ::CFGetTypeID(description) == ::CFStringGetTypeID())
|
if (description && ::CFGetTypeID(description) == ::CFStringGetTypeID())
|
||||||
info.fDescription = CFStringRefToUTF8Buffer(static_cast<CFStringRef>(description));
|
info.fDescription = CFStringRefToUTF8Buffer(static_cast<CFStringRef>(description));
|
||||||
}
|
}
|
||||||
#ifndef __LP64__
|
|
||||||
if (!info.fDescription && resourceOpened) {
|
|
||||||
// 'STR#', 126, 1 => plugin description.
|
|
||||||
info.fDescription = GetPluginString(126, 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get fVersion
|
// Get fVersion
|
||||||
if (bundle) {
|
if (bundle) {
|
||||||
|
@ -604,27 +525,6 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __LP64__
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Fill in the info struct based on the data in the BPSupportedMIMETypes struct
|
// Fill in the info struct based on the data in the BPSupportedMIMETypes struct
|
||||||
int variantCount = info.fVariantCount;
|
int variantCount = info.fVariantCount;
|
||||||
info.fMimeTypeArray = static_cast<char**>(NS_Alloc(variantCount * sizeof(char*)));
|
info.fMimeTypeArray = static_cast<char**>(NS_Alloc(variantCount * sizeof(char*)));
|
||||||
|
|
Загрузка…
Ссылка в новой задаче