зеркало из 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()
|
||||
{
|
||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
||||
mPluginRefNum = -1;
|
||||
#endif
|
||||
|
||||
memset((void*)&mPluginFuncs, 0, sizeof(mPluginFuncs));
|
||||
mPluginFuncs.size = sizeof(mPluginFuncs);
|
||||
mPluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
||||
|
@ -254,14 +250,6 @@ nsNPAPIPlugin::~nsNPAPIPlugin()
|
|||
mLibrary = nsnull;
|
||||
}
|
||||
|
||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
||||
void
|
||||
nsNPAPIPlugin::SetPluginRefNum(short aRefNum)
|
||||
{
|
||||
mPluginRefNum = aRefNum;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID,
|
||||
const nsAString& browserDumpID)
|
||||
|
@ -571,10 +559,7 @@ nsNPAPIPlugin::Shutdown()
|
|||
|
||||
NPError shutdownError;
|
||||
mLibrary->NP_Shutdown(&shutdownError);
|
||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
||||
if (shutdownError == NS_OK && mPluginRefNum > 0)
|
||||
::CloseResFile(mPluginRefNum);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,11 +106,6 @@ public:
|
|||
static PRBool RunPluginOOP(const nsPluginTag *aPluginTag);
|
||||
|
||||
protected:
|
||||
|
||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
||||
short mPluginRefNum;
|
||||
#endif
|
||||
|
||||
NPPluginFuncs mPluginFuncs;
|
||||
PluginLibrary* mLibrary;
|
||||
};
|
||||
|
|
|
@ -1769,25 +1769,8 @@ static nsresult CreateNPAPIPlugin(nsPluginTag *aPluginTag,
|
|||
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);
|
||||
|
||||
#if defined(XP_MACOSX) && !defined(__LP64__)
|
||||
if (NS_SUCCEEDED(rv))
|
||||
(*aOutNPAPIPlugin)->SetPluginRefNum(pluginRefNum);
|
||||
else if (pluginRefNum > 0)
|
||||
::CloseResFile(pluginRefNum);
|
||||
::UseResFile(appRefNum);
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ mMimeTypeArray(nsnull),
|
|||
mExtensionsArray(nsnull),
|
||||
mLibrary(nsnull),
|
||||
#ifdef XP_MACOSX
|
||||
mCanUnloadLibrary(!aPluginInfo->fBundle),
|
||||
mCanUnloadLibrary(PR_FALSE),
|
||||
#else
|
||||
mCanUnloadLibrary(PR_TRUE),
|
||||
#endif
|
||||
|
|
|
@ -66,9 +66,6 @@ struct nsPluginInfo {
|
|||
char* fFileName;
|
||||
char* fFullPath;
|
||||
char* fVersion;
|
||||
#ifdef XP_MACOSX
|
||||
PRBool fBundle;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -105,9 +102,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_ */
|
||||
|
|
|
@ -388,63 +388,6 @@ static char* GetNextPluginStringFromHandle(Handle h, short *index)
|
|||
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)
|
||||
{
|
||||
CFURLRef pluginURL = NULL;
|
||||
|
@ -499,12 +442,6 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
|||
// clear out the info, except for the first field.
|
||||
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.
|
||||
nsCAutoString path;
|
||||
if (NS_FAILED(rv = mPlugin->GetNativePath(path)))
|
||||
|
@ -520,22 +457,12 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
|||
return rv;
|
||||
info.fFileName = PL_strdup(fileName.get());
|
||||
|
||||
// Get fBundle
|
||||
if (bundle)
|
||||
info.fBundle = PR_TRUE;
|
||||
|
||||
// Get fName
|
||||
if (bundle) {
|
||||
CFTypeRef name = ::CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginName"));
|
||||
if (name && ::CFGetTypeID(name) == ::CFStringGetTypeID())
|
||||
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
|
||||
if (bundle) {
|
||||
|
@ -543,12 +470,6 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
|||
if (description && ::CFGetTypeID(description) == ::CFStringGetTypeID())
|
||||
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
|
||||
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
|
||||
int variantCount = info.fVariantCount;
|
||||
info.fMimeTypeArray = static_cast<char**>(NS_Alloc(variantCount * sizeof(char*)));
|
||||
|
|
Загрузка…
Ссылка в новой задаче