Add scanning of Mac System Folder Internet Plug-ins bug 78751 r=ccarlen/sdagley sr=attinasi a=asa

This commit is contained in:
peterlubczynski%netscape.com 2001-06-22 00:59:19 +00:00
parent 99d35b7061
commit 2ae99c2e49
8 changed files with 154 additions and 62 deletions

View File

@ -327,12 +327,13 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
memset((void*) &callbacks, 0, sizeof(callbacks));
callbacks.size = sizeof(callbacks);
nsPluginsDir pluginsDir(PLUGINS_DIR_LOCATION_MAC_OLD);
nsPluginsDir pluginsDir(PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER);
if(!pluginsDir.Valid())
return NS_ERROR_FAILURE;
short appRefNum = ::CurResFile();
short pluginRefNum;
Boolean found = false;
for(nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++)
{
const nsFileSpec& file = iter;
@ -344,9 +345,34 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
Boolean targetIsFolder, wasAliased;
OSErr err = ::ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
pluginRefNum = ::FSpOpenResFile(&spec, fsRdPerm);
found = true;
}
}
}
// if we didn't find it, try locally
if (!found)
{
nsPluginsDir pluginsDir(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
appRefNum = ::CurResFile();
for(nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++)
{
const nsFileSpec& file = iter;
if (pluginsDir.IsPluginFile(file))
{
FSSpec spec = file;
if (!nsCRT::memcmp(spec.name + 1, aFileName, spec.name[0]))
{
Boolean targetIsFolder, wasAliased;
OSErr err = ::ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
pluginRefNum = ::FSpOpenResFile(&spec, fsRdPerm);
found = PR_TRUE;
}
}
}
}
// call into the entry point
NPError error;

View File

@ -3920,9 +3920,11 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
rv = LoadXPCOMPlugins(compManager, path);
}
nsCOMPtr<nsIPref> theprefs = do_GetService(NS_PREF_CONTRACTID);
// scan the 4x plugins directory for eligible legacy plugin libraries
#ifndef XP_WIN // old plugin finding logic
#if !defined(XP_WIN) && !defined (XP_MAC) // old plugin finding logic
// scan Mozilla plugins dir
nsPluginsDir pluginsDir;
@ -3935,26 +3937,50 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
ScanPluginsDirectory(pluginsDir, compManager, lpath);
}
#endif
#ifdef XP_MAC
// try to scan old-spelled plugins dir ("Plug-ins") for Mac
#if defined (XP_MAC)
// try to scan plugins dir ("Plug-ins") for Mac
// should we check for duplicate plugins here? We probably should.
nsPluginsDir pluginsDirMacOld(PLUGINS_DIR_LOCATION_MAC_OLD);
nsPluginsDir pluginsDirMac(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
// on Mac there is a common folder for storing plugins. Go and look there next
nsPluginsDir pluginsDirMacSystem(PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER);
if (pluginsDirMacSystem.Valid())
{
PRBool skipSystem = PR_FALSE;
if (theprefs)
theprefs->GetBoolPref("browser.plugins.skipSystemInternetFolder",&skipSystem);
// now do the "Internet plug-ins"
if (!skipSystem)
{
nsCOMPtr<nsIFile> lpath = nsnull;
if(isLayoutPath)
lpath = path;
if (pluginsDirMacOld.Valid())
ScanPluginsDirectory(pluginsDirMacSystem,
compManager,
lpath,
PR_FALSE); // don't check for specific plugins
}
}
if (pluginsDirMac.Valid())
{
nsCOMPtr<nsIFile> lpath = nsnull;
if(isLayoutPath)
lpath = path;
ScanPluginsDirectory(pluginsDirMacOld,
ScanPluginsDirectory(pluginsDirMac,
compManager,
lpath,
PR_FALSE); // don't check for specific plugins
}
#endif // XP_MAC
#else // XP_WIN go for new plugin finding logic on Windows
#if defined (XP_WIN) // XP_WIN go for new plugin finding logic on Windows
// currently we decided to look in both local plugins dir and
// that of the previous 4.x installation combining plugins from both places.
@ -4000,7 +4026,6 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
#ifdef XP_WIN
// Checks the installation path of Sun's JRE in scanning for plugins if the prefs are enabled
nsCOMPtr<nsIPref> theprefs = do_GetService(NS_PREF_CONTRACTID);
if (theprefs) // we got the pref service
{
PRBool javaEnabled = PR_FALSE; // don't bother the scan if java is OFF

View File

@ -37,7 +37,7 @@
#define PLUGINS_DIR_LOCATION_AUTO 0
#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1
#define PLUGINS_DIR_LOCATION_4DOTX 2
#define PLUGINS_DIR_LOCATION_MAC_OLD 3
#define PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER 3
#define PLUGINS_DIR_LOCATION_JAVA_JRE 4
class nsPluginsDir : public nsFileSpec {

View File

@ -30,6 +30,7 @@
#include "nsPluginsDir.h"
#include "prlink.h"
#include "nsSpecialSystemDirectory.h"
#include <Processes.h>
#include <Folders.h>
@ -38,34 +39,28 @@
#include <Aliases.h>
#include <string.h>
static nsresult getApplicationSpec(FSSpec& outAppSpec)
{
// Use the process manager to get the application's FSSpec,
// then construct an nsFileSpec that encapsulates it.
ProcessInfoRec info;
info.processInfoLength = sizeof(info);
info.processName = NULL;
info.processAppSpec = &outAppSpec;
ProcessSerialNumber psn = { 0, kCurrentProcess };
OSErr result = GetProcessInformation(&psn, &info);
return (result == noErr ? NS_OK : NS_ERROR_FAILURE);
}
nsPluginsDir::nsPluginsDir(PRUint16 location)
{
PRBool wasAliased;
// The "Plugins" folder in the application's directory is where plugins are loaded from.
mError = getApplicationSpec(mSpec);
if (NS_SUCCEEDED(mError))
switch (location)
{
if (location == PLUGINS_DIR_LOCATION_MAC_OLD)
SetLeafName("Plug-ins");
else
SetLeafName("Plugins");
case PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER:
// The system's shared "Plugin-ins" folder
mError = ::FindFolder(kOnAppropriateDisk, kInternetPlugInFolderType, kDontCreateFolder, & mSpec.vRefNum, &mSpec.parID);
if (mError)
mError = ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, "\p", &mSpec);
break;
case PLUGINS_DIR_LOCATION_MOZ_LOCAL:
default:
// The "Plug-ins" folder in the application's directory is where plugins are loaded from.
// Use the Moz_BinDirectory
nsSpecialSystemDirectory plugDir(nsSpecialSystemDirectory::Moz_BinDirectory);
*(nsFileSpec*)this = plugDir + "Plug-ins";
break;
}
if (IsSymlink())
ResolveSymlink(wasAliased);
}
}
nsPluginsDir::~nsPluginsDir() {}

View File

@ -327,12 +327,13 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
memset((void*) &callbacks, 0, sizeof(callbacks));
callbacks.size = sizeof(callbacks);
nsPluginsDir pluginsDir(PLUGINS_DIR_LOCATION_MAC_OLD);
nsPluginsDir pluginsDir(PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER);
if(!pluginsDir.Valid())
return NS_ERROR_FAILURE;
short appRefNum = ::CurResFile();
short pluginRefNum;
Boolean found = false;
for(nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++)
{
const nsFileSpec& file = iter;
@ -344,9 +345,34 @@ ns4xPlugin::CreatePlugin(nsIServiceManager* aServiceMgr,
Boolean targetIsFolder, wasAliased;
OSErr err = ::ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
pluginRefNum = ::FSpOpenResFile(&spec, fsRdPerm);
found = true;
}
}
}
// if we didn't find it, try locally
if (!found)
{
nsPluginsDir pluginsDir(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
appRefNum = ::CurResFile();
for(nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++)
{
const nsFileSpec& file = iter;
if (pluginsDir.IsPluginFile(file))
{
FSSpec spec = file;
if (!nsCRT::memcmp(spec.name + 1, aFileName, spec.name[0]))
{
Boolean targetIsFolder, wasAliased;
OSErr err = ::ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
pluginRefNum = ::FSpOpenResFile(&spec, fsRdPerm);
found = PR_TRUE;
}
}
}
}
// call into the entry point
NPError error;

View File

@ -3920,9 +3920,11 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
rv = LoadXPCOMPlugins(compManager, path);
}
nsCOMPtr<nsIPref> theprefs = do_GetService(NS_PREF_CONTRACTID);
// scan the 4x plugins directory for eligible legacy plugin libraries
#ifndef XP_WIN // old plugin finding logic
#if !defined(XP_WIN) && !defined (XP_MAC) // old plugin finding logic
// scan Mozilla plugins dir
nsPluginsDir pluginsDir;
@ -3935,26 +3937,50 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
ScanPluginsDirectory(pluginsDir, compManager, lpath);
}
#endif
#ifdef XP_MAC
// try to scan old-spelled plugins dir ("Plug-ins") for Mac
#if defined (XP_MAC)
// try to scan plugins dir ("Plug-ins") for Mac
// should we check for duplicate plugins here? We probably should.
nsPluginsDir pluginsDirMacOld(PLUGINS_DIR_LOCATION_MAC_OLD);
nsPluginsDir pluginsDirMac(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
// on Mac there is a common folder for storing plugins. Go and look there next
nsPluginsDir pluginsDirMacSystem(PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER);
if (pluginsDirMacSystem.Valid())
{
PRBool skipSystem = PR_FALSE;
if (theprefs)
theprefs->GetBoolPref("browser.plugins.skipSystemInternetFolder",&skipSystem);
// now do the "Internet plug-ins"
if (!skipSystem)
{
nsCOMPtr<nsIFile> lpath = nsnull;
if(isLayoutPath)
lpath = path;
if (pluginsDirMacOld.Valid())
ScanPluginsDirectory(pluginsDirMacSystem,
compManager,
lpath,
PR_FALSE); // don't check for specific plugins
}
}
if (pluginsDirMac.Valid())
{
nsCOMPtr<nsIFile> lpath = nsnull;
if(isLayoutPath)
lpath = path;
ScanPluginsDirectory(pluginsDirMacOld,
ScanPluginsDirectory(pluginsDirMac,
compManager,
lpath,
PR_FALSE); // don't check for specific plugins
}
#endif // XP_MAC
#else // XP_WIN go for new plugin finding logic on Windows
#if defined (XP_WIN) // XP_WIN go for new plugin finding logic on Windows
// currently we decided to look in both local plugins dir and
// that of the previous 4.x installation combining plugins from both places.
@ -4000,7 +4026,6 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
#ifdef XP_WIN
// Checks the installation path of Sun's JRE in scanning for plugins if the prefs are enabled
nsCOMPtr<nsIPref> theprefs = do_GetService(NS_PREF_CONTRACTID);
if (theprefs) // we got the pref service
{
PRBool javaEnabled = PR_FALSE; // don't bother the scan if java is OFF

View File

@ -37,7 +37,7 @@
#define PLUGINS_DIR_LOCATION_AUTO 0
#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1
#define PLUGINS_DIR_LOCATION_4DOTX 2
#define PLUGINS_DIR_LOCATION_MAC_OLD 3
#define PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER 3
#define PLUGINS_DIR_LOCATION_JAVA_JRE 4
class nsPluginsDir : public nsFileSpec {

View File

@ -30,6 +30,7 @@
#include "nsPluginsDir.h"
#include "prlink.h"
#include "nsSpecialSystemDirectory.h"
#include <Processes.h>
#include <Folders.h>
@ -38,34 +39,28 @@
#include <Aliases.h>
#include <string.h>
static nsresult getApplicationSpec(FSSpec& outAppSpec)
{
// Use the process manager to get the application's FSSpec,
// then construct an nsFileSpec that encapsulates it.
ProcessInfoRec info;
info.processInfoLength = sizeof(info);
info.processName = NULL;
info.processAppSpec = &outAppSpec;
ProcessSerialNumber psn = { 0, kCurrentProcess };
OSErr result = GetProcessInformation(&psn, &info);
return (result == noErr ? NS_OK : NS_ERROR_FAILURE);
}
nsPluginsDir::nsPluginsDir(PRUint16 location)
{
PRBool wasAliased;
// The "Plugins" folder in the application's directory is where plugins are loaded from.
mError = getApplicationSpec(mSpec);
if (NS_SUCCEEDED(mError))
switch (location)
{
if (location == PLUGINS_DIR_LOCATION_MAC_OLD)
SetLeafName("Plug-ins");
else
SetLeafName("Plugins");
case PLUGINS_DIR_LOCATION_MAC_SYSTEM_PLUGINS_FOLDER:
// The system's shared "Plugin-ins" folder
mError = ::FindFolder(kOnAppropriateDisk, kInternetPlugInFolderType, kDontCreateFolder, & mSpec.vRefNum, &mSpec.parID);
if (mError)
mError = ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, "\p", &mSpec);
break;
case PLUGINS_DIR_LOCATION_MOZ_LOCAL:
default:
// The "Plug-ins" folder in the application's directory is where plugins are loaded from.
// Use the Moz_BinDirectory
nsSpecialSystemDirectory plugDir(nsSpecialSystemDirectory::Moz_BinDirectory);
*(nsFileSpec*)this = plugDir + "Plug-ins";
break;
}
if (IsSymlink())
ResolveSymlink(wasAliased);
}
}
nsPluginsDir::~nsPluginsDir() {}