mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Fixing #36089. Allowing Mac browse through both 'Plugins' and 'Plug-ins' folders, a=waterson
This commit is contained in:
parent
74af64f5a1
commit
089f65cac9
@ -2822,68 +2822,6 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef XP_WIN // for now keep the old plugin finding logic for non-Windows platforms
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|
||||||
{
|
|
||||||
// do not do anything if it is already done
|
|
||||||
// use nsPluginHostImpl::ReloadPlugins to enforce loading
|
|
||||||
if(mPluginsLoaded)
|
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
// retrieve a path for layout module. Needed for plugin mime types registration
|
|
||||||
nsCOMPtr<nsIFile> path;
|
|
||||||
PRBool isLayoutPath = PR_FALSE;
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID, &rv);
|
|
||||||
if (NS_SUCCEEDED(rv) && compManager) {
|
|
||||||
isLayoutPath = NS_SUCCEEDED(compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(path)));
|
|
||||||
rv = LoadXPCOMPlugins(compManager, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. scan the plugins directory (where is it?) for eligible plugin libraries.
|
|
||||||
nsPluginsDir pluginsDir;
|
|
||||||
if (! pluginsDir.Valid())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
for (nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++) {
|
|
||||||
const nsFileSpec& file = iter;
|
|
||||||
if (pluginsDir.IsPluginFile(file)) {
|
|
||||||
nsPluginFile pluginFile(file);
|
|
||||||
PRLibrary* pluginLibrary = NULL;
|
|
||||||
|
|
||||||
// load the plugin's library so we can ask it some questions
|
|
||||||
if (pluginFile.LoadPlugin(pluginLibrary) != NS_OK || pluginLibrary == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// create a tag describing this plugin.
|
|
||||||
nsPluginInfo info = { sizeof(info) };
|
|
||||||
nsresult res = pluginFile.GetPluginInfo(info);
|
|
||||||
if(NS_FAILED(res))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
|
||||||
pluginFile.FreePluginInfo(info);
|
|
||||||
|
|
||||||
if(pluginTag == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
pluginTag->mNext = mPlugins;
|
|
||||||
mPlugins = pluginTag;
|
|
||||||
|
|
||||||
if(isLayoutPath)
|
|
||||||
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, path);
|
|
||||||
|
|
||||||
pluginTag->mLibrary = pluginLibrary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mPluginsLoaded = PR_TRUE;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // go for new plugin finding logic on Windows
|
|
||||||
|
|
||||||
static PRBool areTheSameFileNames(char * name1, char * name2)
|
static PRBool areTheSameFileNames(char * name1, char * name2)
|
||||||
{
|
{
|
||||||
if((name1 == nsnull) || (name2 == nsnull))
|
if((name1 == nsnull) || (name2 == nsnull))
|
||||||
@ -2945,45 +2883,26 @@ static PRBool isUnwantedPlugin(nsPluginTag * tag)
|
|||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
nsresult nsPluginHostImpl::ScanPluginsDirectory(nsPluginsDir& pluginsDir,
|
||||||
|
nsIComponentManager * compManager,
|
||||||
|
nsIFile * layoutPath,
|
||||||
|
PRBool checkForUnwantedPlugins,
|
||||||
|
PRBool checkForDups)
|
||||||
{
|
{
|
||||||
// do not do anything if it is already done
|
for (nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++)
|
||||||
// use nsPluginHostImpl::ReloadPlugins to enforce loading
|
|
||||||
if(mPluginsLoaded)
|
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
// retrieve a path for layout module. Needed for plugin mime types registration
|
|
||||||
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID);
|
|
||||||
nsCOMPtr<nsIFile> path;
|
|
||||||
nsresult rvIsLayoutPath = compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(path));
|
|
||||||
|
|
||||||
LoadXPCOMPlugins(compManager, path);
|
|
||||||
|
|
||||||
// currently we decided to look in both local plugins dir and
|
|
||||||
// that of the previous 4.x installation combining plugins from both places.
|
|
||||||
// See bug #21938
|
|
||||||
// As of 1.27.00 this selective mechanism is natively supported in Windows
|
|
||||||
// native implementation of nsPluginsDir.
|
|
||||||
|
|
||||||
nsPluginsDir pluginsDir4x(PLUGINS_DIR_LOCATION_4DOTX);
|
|
||||||
nsPluginsDir pluginsDirMoz(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
|
|
||||||
|
|
||||||
if(!pluginsDir4x.Valid() && !pluginsDirMoz.Valid())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
// first, make a list from MOZ_LOCAL installation
|
|
||||||
for (nsDirectoryIterator iter(pluginsDirMoz, PR_TRUE); iter.Exists(); iter++)
|
|
||||||
{
|
{
|
||||||
const nsFileSpec& file = iter;
|
const nsFileSpec& file = iter;
|
||||||
if (pluginsDirMoz.IsPluginFile(file)) {
|
if (pluginsDir.IsPluginFile(file))
|
||||||
nsPluginFile pluginFile(file);
|
|
||||||
PRLibrary* pluginLibrary = NULL;
|
|
||||||
|
|
||||||
#ifndef XP_WIN
|
|
||||||
// load the plugin's library so we can ask it some questions but not for Windows for now
|
|
||||||
if (pluginFile.LoadPlugin(pluginLibrary) == NS_OK && pluginLibrary != NULL)
|
|
||||||
{
|
{
|
||||||
|
nsPluginFile pluginFile(file);
|
||||||
|
PRLibrary* pluginLibrary = nsnull;
|
||||||
|
|
||||||
|
// load the plugin's library so we can ask it some questions, but not for Windows
|
||||||
|
#ifndef XP_WIN
|
||||||
|
if (pluginFile.LoadPlugin(pluginLibrary) != NS_OK || pluginLibrary == nsnull)
|
||||||
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// create a tag describing this plugin.
|
// create a tag describing this plugin.
|
||||||
nsPluginInfo info = { sizeof(info) };
|
nsPluginInfo info = { sizeof(info) };
|
||||||
nsresult res = pluginFile.GetPluginInfo(info);
|
nsresult res = pluginFile.GetPluginInfo(info);
|
||||||
@ -2991,48 +2910,6 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||||
|
|
||||||
pluginFile.FreePluginInfo(info);
|
|
||||||
|
|
||||||
if(pluginTag == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
pluginTag->mNext = mPlugins;
|
|
||||||
mPlugins = pluginTag;
|
|
||||||
|
|
||||||
if(NS_SUCCEEDED(rvIsLayoutPath))
|
|
||||||
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, path);
|
|
||||||
|
|
||||||
pluginTag->mLibrary = pluginLibrary;
|
|
||||||
|
|
||||||
#ifndef XP_WIN
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now check the 4.x plugins dir and add new files
|
|
||||||
for (nsDirectoryIterator iter2(pluginsDir4x, PR_TRUE); iter2.Exists(); iter2++)
|
|
||||||
{
|
|
||||||
const nsFileSpec& file = iter2;
|
|
||||||
if (pluginsDir4x.IsPluginFile(file))
|
|
||||||
{
|
|
||||||
nsPluginFile pluginFile(file);
|
|
||||||
PRLibrary* pluginLibrary = NULL;
|
|
||||||
|
|
||||||
#ifndef XP_WIN
|
|
||||||
// load the plugin's library so we can ask it some questions but not for Windows for now
|
|
||||||
if (pluginFile.LoadPlugin(pluginLibrary) == NS_OK && pluginLibrary != NULL)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
// create a tag describing this plugin.
|
|
||||||
nsPluginInfo info = { sizeof(info) };
|
|
||||||
nsresult res = pluginFile.GetPluginInfo(info);
|
|
||||||
if(NS_FAILED(res))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
|
||||||
|
|
||||||
pluginFile.FreePluginInfo(info);
|
pluginFile.FreePluginInfo(info);
|
||||||
|
|
||||||
if(pluginTag == nsnull)
|
if(pluginTag == nsnull)
|
||||||
@ -3040,14 +2917,15 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||||||
|
|
||||||
pluginTag->mLibrary = pluginLibrary;
|
pluginTag->mLibrary = pluginLibrary;
|
||||||
|
|
||||||
// search for a match in the list of MOZ_LOCAL plugins, ignore if found, add if not
|
|
||||||
PRBool bAddIt = PR_TRUE;
|
PRBool bAddIt = PR_TRUE;
|
||||||
|
|
||||||
// make sure we ignore 4.x Java plugins no matter what
|
if(checkForUnwantedPlugins)
|
||||||
// and other unwanted plugins as per temporary decision described in #23856
|
{
|
||||||
if(isUnwantedPlugin(pluginTag))
|
if(isUnwantedPlugin(pluginTag))
|
||||||
bAddIt = PR_FALSE;
|
bAddIt = PR_FALSE;
|
||||||
else
|
}
|
||||||
|
|
||||||
|
if(bAddIt && checkForDups)
|
||||||
{
|
{
|
||||||
for(nsPluginTag* tag = mPlugins; tag != nsnull; tag = tag->mNext)
|
for(nsPluginTag* tag = mPlugins; tag != nsnull; tag = tag->mNext)
|
||||||
{
|
{
|
||||||
@ -3064,22 +2942,90 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||||||
pluginTag->mNext = mPlugins;
|
pluginTag->mNext = mPlugins;
|
||||||
mPlugins = pluginTag;
|
mPlugins = pluginTag;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(rvIsLayoutPath))
|
if(layoutPath)
|
||||||
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, path);
|
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, layoutPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
delete pluginTag;
|
delete pluginTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef XP_WIN
|
NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
||||||
}
|
{
|
||||||
#endif
|
// do not do anything if it is already done
|
||||||
}
|
// use nsPluginHostImpl::ReloadPlugins to enforce loading
|
||||||
|
if(mPluginsLoaded)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
// retrieve a path for layout module. Needed for plugin mime types registration
|
||||||
|
nsCOMPtr<nsIFile> path;
|
||||||
|
PRBool isLayoutPath = PR_FALSE;
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && compManager)
|
||||||
|
{
|
||||||
|
isLayoutPath = NS_SUCCEEDED(compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(path)));
|
||||||
|
rv = LoadXPCOMPlugins(compManager, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scan the 4x plugins directory for eligible legacy plugin libraries
|
||||||
|
|
||||||
|
#ifndef XP_WIN // old plugin finding logic
|
||||||
|
|
||||||
|
// scan Mozilla plugins dir
|
||||||
|
nsPluginsDir pluginsDir;
|
||||||
|
|
||||||
|
if (pluginsDir.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDir, compManager, isLayoutPath ? path : nsnull);
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
// try to scan old-spelled plugins dir ("Plug-ins") for Mac
|
||||||
|
// should we check for duplicate plugins here? We probably should.
|
||||||
|
nsPluginsDir pluginsDirMacOld(PLUGINS_DIR_LOCATION_MAC_OLD);
|
||||||
|
|
||||||
|
if (pluginsDirMacOld.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDirMacOld,
|
||||||
|
compManager,
|
||||||
|
isLayoutPath ? path : nsnull,
|
||||||
|
PR_FALSE, // don't check for specific plugins
|
||||||
|
PR_TRUE); // check for dups
|
||||||
|
#endif // XP_MAC
|
||||||
|
|
||||||
|
#else // 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.
|
||||||
|
// See bug #21938
|
||||||
|
// As of 1.27.00 this selective mechanism is natively supported in Windows
|
||||||
|
// native implementation of nsPluginsDir.
|
||||||
|
|
||||||
|
// first, make a list from MOZ_LOCAL installation
|
||||||
|
nsPluginsDir pluginsDirMoz(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
|
||||||
|
|
||||||
|
if (pluginsDirMoz.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDirMoz, compManager, isLayoutPath ? path : nsnull);
|
||||||
|
|
||||||
|
// now check the 4.x plugins dir and add new files
|
||||||
|
// Specifying the last two params as PR_TRUE we make sure that:
|
||||||
|
// 1. we search for a match in the list of MOZ_LOCAL plugins, ignore if found,
|
||||||
|
// add if not found (check for dups)
|
||||||
|
// 2. we ignore 4.x Java plugins no matter what and other
|
||||||
|
// unwanted plugins as per temporary decision described in bug #23856
|
||||||
|
nsPluginsDir pluginsDir4x(PLUGINS_DIR_LOCATION_4DOTX);
|
||||||
|
if (pluginsDir4x.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDir4x,
|
||||||
|
compManager,
|
||||||
|
isLayoutPath ? path : nsnull,
|
||||||
|
PR_TRUE, // check for specific plugins
|
||||||
|
PR_TRUE); // check for dups
|
||||||
|
|
||||||
|
#endif // !XP_WIN
|
||||||
|
|
||||||
mPluginsLoaded = PR_TRUE;
|
mPluginsLoaded = PR_TRUE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
#endif // XP_WIN -- end new plugin finding logic
|
|
||||||
|
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
LoadXPCOMPlugin(nsIComponentManager* aComponentManager,
|
LoadXPCOMPlugin(nsIComponentManager* aComponentManager,
|
||||||
|
@ -337,6 +337,13 @@ private:
|
|||||||
nsresult
|
nsresult
|
||||||
RegisterPluginMimeTypesWithLayout(nsPluginTag *pluginTag, nsIComponentManager * compManager, nsIFile * layoutPath);
|
RegisterPluginMimeTypesWithLayout(nsPluginTag *pluginTag, nsIComponentManager * compManager, nsIFile * layoutPath);
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
ScanPluginsDirectory(nsPluginsDir& pluginsDir,
|
||||||
|
nsIComponentManager * compManager,
|
||||||
|
nsIFile * layoutPath,
|
||||||
|
PRBool checkForUnwantedPlugins = PR_FALSE,
|
||||||
|
PRBool checkForDups = PR_FALSE);
|
||||||
|
|
||||||
char *mPluginPath;
|
char *mPluginPath;
|
||||||
nsPluginTag *mPlugins;
|
nsPluginTag *mPlugins;
|
||||||
PRBool mPluginsLoaded;
|
PRBool mPluginsLoaded;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#define PLUGINS_DIR_LOCATION_AUTO 0
|
#define PLUGINS_DIR_LOCATION_AUTO 0
|
||||||
#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1
|
#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1
|
||||||
#define PLUGINS_DIR_LOCATION_4DOTX 2
|
#define PLUGINS_DIR_LOCATION_4DOTX 2
|
||||||
|
#define PLUGINS_DIR_LOCATION_MAC_OLD 3
|
||||||
|
|
||||||
class nsPluginsDir : public nsFileSpec {
|
class nsPluginsDir : public nsFileSpec {
|
||||||
public:
|
public:
|
||||||
|
@ -68,7 +68,11 @@ nsPluginsDir::nsPluginsDir(PRUint16 location)
|
|||||||
#else
|
#else
|
||||||
// The "Plugins" folder in the application's directory is where plugins are loaded from.
|
// The "Plugins" folder in the application's directory is where plugins are loaded from.
|
||||||
mError = getApplicationSpec(mSpec);
|
mError = getApplicationSpec(mSpec);
|
||||||
if (NS_SUCCEEDED(mError)) {
|
if (NS_SUCCEEDED(mError))
|
||||||
|
{
|
||||||
|
if(location == PLUGINS_DIR_LOCATION_MAC_OLD)
|
||||||
|
SetLeafName("Plug-ins");
|
||||||
|
else
|
||||||
SetLeafName("Plugins");
|
SetLeafName("Plugins");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2822,68 +2822,6 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef XP_WIN // for now keep the old plugin finding logic for non-Windows platforms
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|
||||||
{
|
|
||||||
// do not do anything if it is already done
|
|
||||||
// use nsPluginHostImpl::ReloadPlugins to enforce loading
|
|
||||||
if(mPluginsLoaded)
|
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
// retrieve a path for layout module. Needed for plugin mime types registration
|
|
||||||
nsCOMPtr<nsIFile> path;
|
|
||||||
PRBool isLayoutPath = PR_FALSE;
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID, &rv);
|
|
||||||
if (NS_SUCCEEDED(rv) && compManager) {
|
|
||||||
isLayoutPath = NS_SUCCEEDED(compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(path)));
|
|
||||||
rv = LoadXPCOMPlugins(compManager, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. scan the plugins directory (where is it?) for eligible plugin libraries.
|
|
||||||
nsPluginsDir pluginsDir;
|
|
||||||
if (! pluginsDir.Valid())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
for (nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++) {
|
|
||||||
const nsFileSpec& file = iter;
|
|
||||||
if (pluginsDir.IsPluginFile(file)) {
|
|
||||||
nsPluginFile pluginFile(file);
|
|
||||||
PRLibrary* pluginLibrary = NULL;
|
|
||||||
|
|
||||||
// load the plugin's library so we can ask it some questions
|
|
||||||
if (pluginFile.LoadPlugin(pluginLibrary) != NS_OK || pluginLibrary == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// create a tag describing this plugin.
|
|
||||||
nsPluginInfo info = { sizeof(info) };
|
|
||||||
nsresult res = pluginFile.GetPluginInfo(info);
|
|
||||||
if(NS_FAILED(res))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
|
||||||
pluginFile.FreePluginInfo(info);
|
|
||||||
|
|
||||||
if(pluginTag == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
pluginTag->mNext = mPlugins;
|
|
||||||
mPlugins = pluginTag;
|
|
||||||
|
|
||||||
if(isLayoutPath)
|
|
||||||
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, path);
|
|
||||||
|
|
||||||
pluginTag->mLibrary = pluginLibrary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mPluginsLoaded = PR_TRUE;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // go for new plugin finding logic on Windows
|
|
||||||
|
|
||||||
static PRBool areTheSameFileNames(char * name1, char * name2)
|
static PRBool areTheSameFileNames(char * name1, char * name2)
|
||||||
{
|
{
|
||||||
if((name1 == nsnull) || (name2 == nsnull))
|
if((name1 == nsnull) || (name2 == nsnull))
|
||||||
@ -2945,45 +2883,26 @@ static PRBool isUnwantedPlugin(nsPluginTag * tag)
|
|||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
nsresult nsPluginHostImpl::ScanPluginsDirectory(nsPluginsDir& pluginsDir,
|
||||||
|
nsIComponentManager * compManager,
|
||||||
|
nsIFile * layoutPath,
|
||||||
|
PRBool checkForUnwantedPlugins,
|
||||||
|
PRBool checkForDups)
|
||||||
{
|
{
|
||||||
// do not do anything if it is already done
|
for (nsDirectoryIterator iter(pluginsDir, PR_TRUE); iter.Exists(); iter++)
|
||||||
// use nsPluginHostImpl::ReloadPlugins to enforce loading
|
|
||||||
if(mPluginsLoaded)
|
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
// retrieve a path for layout module. Needed for plugin mime types registration
|
|
||||||
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID);
|
|
||||||
nsCOMPtr<nsIFile> path;
|
|
||||||
nsresult rvIsLayoutPath = compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(path));
|
|
||||||
|
|
||||||
LoadXPCOMPlugins(compManager, path);
|
|
||||||
|
|
||||||
// currently we decided to look in both local plugins dir and
|
|
||||||
// that of the previous 4.x installation combining plugins from both places.
|
|
||||||
// See bug #21938
|
|
||||||
// As of 1.27.00 this selective mechanism is natively supported in Windows
|
|
||||||
// native implementation of nsPluginsDir.
|
|
||||||
|
|
||||||
nsPluginsDir pluginsDir4x(PLUGINS_DIR_LOCATION_4DOTX);
|
|
||||||
nsPluginsDir pluginsDirMoz(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
|
|
||||||
|
|
||||||
if(!pluginsDir4x.Valid() && !pluginsDirMoz.Valid())
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
|
||||||
// first, make a list from MOZ_LOCAL installation
|
|
||||||
for (nsDirectoryIterator iter(pluginsDirMoz, PR_TRUE); iter.Exists(); iter++)
|
|
||||||
{
|
{
|
||||||
const nsFileSpec& file = iter;
|
const nsFileSpec& file = iter;
|
||||||
if (pluginsDirMoz.IsPluginFile(file)) {
|
if (pluginsDir.IsPluginFile(file))
|
||||||
nsPluginFile pluginFile(file);
|
|
||||||
PRLibrary* pluginLibrary = NULL;
|
|
||||||
|
|
||||||
#ifndef XP_WIN
|
|
||||||
// load the plugin's library so we can ask it some questions but not for Windows for now
|
|
||||||
if (pluginFile.LoadPlugin(pluginLibrary) == NS_OK && pluginLibrary != NULL)
|
|
||||||
{
|
{
|
||||||
|
nsPluginFile pluginFile(file);
|
||||||
|
PRLibrary* pluginLibrary = nsnull;
|
||||||
|
|
||||||
|
// load the plugin's library so we can ask it some questions, but not for Windows
|
||||||
|
#ifndef XP_WIN
|
||||||
|
if (pluginFile.LoadPlugin(pluginLibrary) != NS_OK || pluginLibrary == nsnull)
|
||||||
|
continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// create a tag describing this plugin.
|
// create a tag describing this plugin.
|
||||||
nsPluginInfo info = { sizeof(info) };
|
nsPluginInfo info = { sizeof(info) };
|
||||||
nsresult res = pluginFile.GetPluginInfo(info);
|
nsresult res = pluginFile.GetPluginInfo(info);
|
||||||
@ -2991,48 +2910,6 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
||||||
|
|
||||||
pluginFile.FreePluginInfo(info);
|
|
||||||
|
|
||||||
if(pluginTag == nsnull)
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
pluginTag->mNext = mPlugins;
|
|
||||||
mPlugins = pluginTag;
|
|
||||||
|
|
||||||
if(NS_SUCCEEDED(rvIsLayoutPath))
|
|
||||||
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, path);
|
|
||||||
|
|
||||||
pluginTag->mLibrary = pluginLibrary;
|
|
||||||
|
|
||||||
#ifndef XP_WIN
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now check the 4.x plugins dir and add new files
|
|
||||||
for (nsDirectoryIterator iter2(pluginsDir4x, PR_TRUE); iter2.Exists(); iter2++)
|
|
||||||
{
|
|
||||||
const nsFileSpec& file = iter2;
|
|
||||||
if (pluginsDir4x.IsPluginFile(file))
|
|
||||||
{
|
|
||||||
nsPluginFile pluginFile(file);
|
|
||||||
PRLibrary* pluginLibrary = NULL;
|
|
||||||
|
|
||||||
#ifndef XP_WIN
|
|
||||||
// load the plugin's library so we can ask it some questions but not for Windows for now
|
|
||||||
if (pluginFile.LoadPlugin(pluginLibrary) == NS_OK && pluginLibrary != NULL)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
// create a tag describing this plugin.
|
|
||||||
nsPluginInfo info = { sizeof(info) };
|
|
||||||
nsresult res = pluginFile.GetPluginInfo(info);
|
|
||||||
if(NS_FAILED(res))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
nsPluginTag* pluginTag = new nsPluginTag(&info);
|
|
||||||
|
|
||||||
pluginFile.FreePluginInfo(info);
|
pluginFile.FreePluginInfo(info);
|
||||||
|
|
||||||
if(pluginTag == nsnull)
|
if(pluginTag == nsnull)
|
||||||
@ -3040,14 +2917,15 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||||||
|
|
||||||
pluginTag->mLibrary = pluginLibrary;
|
pluginTag->mLibrary = pluginLibrary;
|
||||||
|
|
||||||
// search for a match in the list of MOZ_LOCAL plugins, ignore if found, add if not
|
|
||||||
PRBool bAddIt = PR_TRUE;
|
PRBool bAddIt = PR_TRUE;
|
||||||
|
|
||||||
// make sure we ignore 4.x Java plugins no matter what
|
if(checkForUnwantedPlugins)
|
||||||
// and other unwanted plugins as per temporary decision described in #23856
|
{
|
||||||
if(isUnwantedPlugin(pluginTag))
|
if(isUnwantedPlugin(pluginTag))
|
||||||
bAddIt = PR_FALSE;
|
bAddIt = PR_FALSE;
|
||||||
else
|
}
|
||||||
|
|
||||||
|
if(bAddIt && checkForDups)
|
||||||
{
|
{
|
||||||
for(nsPluginTag* tag = mPlugins; tag != nsnull; tag = tag->mNext)
|
for(nsPluginTag* tag = mPlugins; tag != nsnull; tag = tag->mNext)
|
||||||
{
|
{
|
||||||
@ -3064,22 +2942,90 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
|||||||
pluginTag->mNext = mPlugins;
|
pluginTag->mNext = mPlugins;
|
||||||
mPlugins = pluginTag;
|
mPlugins = pluginTag;
|
||||||
|
|
||||||
if(NS_SUCCEEDED(rvIsLayoutPath))
|
if(layoutPath)
|
||||||
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, path);
|
RegisterPluginMimeTypesWithLayout(pluginTag, compManager, layoutPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
delete pluginTag;
|
delete pluginTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef XP_WIN
|
NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
|
||||||
}
|
{
|
||||||
#endif
|
// do not do anything if it is already done
|
||||||
}
|
// use nsPluginHostImpl::ReloadPlugins to enforce loading
|
||||||
|
if(mPluginsLoaded)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
// retrieve a path for layout module. Needed for plugin mime types registration
|
||||||
|
nsCOMPtr<nsIFile> path;
|
||||||
|
PRBool isLayoutPath = PR_FALSE;
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID, &rv);
|
||||||
|
if (NS_SUCCEEDED(rv) && compManager)
|
||||||
|
{
|
||||||
|
isLayoutPath = NS_SUCCEEDED(compManager->SpecForRegistryLocation(REL_PLUGIN_DLL, getter_AddRefs(path)));
|
||||||
|
rv = LoadXPCOMPlugins(compManager, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scan the 4x plugins directory for eligible legacy plugin libraries
|
||||||
|
|
||||||
|
#ifndef XP_WIN // old plugin finding logic
|
||||||
|
|
||||||
|
// scan Mozilla plugins dir
|
||||||
|
nsPluginsDir pluginsDir;
|
||||||
|
|
||||||
|
if (pluginsDir.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDir, compManager, isLayoutPath ? path : nsnull);
|
||||||
|
|
||||||
|
#ifdef XP_MAC
|
||||||
|
// try to scan old-spelled plugins dir ("Plug-ins") for Mac
|
||||||
|
// should we check for duplicate plugins here? We probably should.
|
||||||
|
nsPluginsDir pluginsDirMacOld(PLUGINS_DIR_LOCATION_MAC_OLD);
|
||||||
|
|
||||||
|
if (pluginsDirMacOld.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDirMacOld,
|
||||||
|
compManager,
|
||||||
|
isLayoutPath ? path : nsnull,
|
||||||
|
PR_FALSE, // don't check for specific plugins
|
||||||
|
PR_TRUE); // check for dups
|
||||||
|
#endif // XP_MAC
|
||||||
|
|
||||||
|
#else // 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.
|
||||||
|
// See bug #21938
|
||||||
|
// As of 1.27.00 this selective mechanism is natively supported in Windows
|
||||||
|
// native implementation of nsPluginsDir.
|
||||||
|
|
||||||
|
// first, make a list from MOZ_LOCAL installation
|
||||||
|
nsPluginsDir pluginsDirMoz(PLUGINS_DIR_LOCATION_MOZ_LOCAL);
|
||||||
|
|
||||||
|
if (pluginsDirMoz.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDirMoz, compManager, isLayoutPath ? path : nsnull);
|
||||||
|
|
||||||
|
// now check the 4.x plugins dir and add new files
|
||||||
|
// Specifying the last two params as PR_TRUE we make sure that:
|
||||||
|
// 1. we search for a match in the list of MOZ_LOCAL plugins, ignore if found,
|
||||||
|
// add if not found (check for dups)
|
||||||
|
// 2. we ignore 4.x Java plugins no matter what and other
|
||||||
|
// unwanted plugins as per temporary decision described in bug #23856
|
||||||
|
nsPluginsDir pluginsDir4x(PLUGINS_DIR_LOCATION_4DOTX);
|
||||||
|
if (pluginsDir4x.Valid())
|
||||||
|
ScanPluginsDirectory(pluginsDir4x,
|
||||||
|
compManager,
|
||||||
|
isLayoutPath ? path : nsnull,
|
||||||
|
PR_TRUE, // check for specific plugins
|
||||||
|
PR_TRUE); // check for dups
|
||||||
|
|
||||||
|
#endif // !XP_WIN
|
||||||
|
|
||||||
mPluginsLoaded = PR_TRUE;
|
mPluginsLoaded = PR_TRUE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
#endif // XP_WIN -- end new plugin finding logic
|
|
||||||
|
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
LoadXPCOMPlugin(nsIComponentManager* aComponentManager,
|
LoadXPCOMPlugin(nsIComponentManager* aComponentManager,
|
||||||
|
@ -337,6 +337,13 @@ private:
|
|||||||
nsresult
|
nsresult
|
||||||
RegisterPluginMimeTypesWithLayout(nsPluginTag *pluginTag, nsIComponentManager * compManager, nsIFile * layoutPath);
|
RegisterPluginMimeTypesWithLayout(nsPluginTag *pluginTag, nsIComponentManager * compManager, nsIFile * layoutPath);
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
ScanPluginsDirectory(nsPluginsDir& pluginsDir,
|
||||||
|
nsIComponentManager * compManager,
|
||||||
|
nsIFile * layoutPath,
|
||||||
|
PRBool checkForUnwantedPlugins = PR_FALSE,
|
||||||
|
PRBool checkForDups = PR_FALSE);
|
||||||
|
|
||||||
char *mPluginPath;
|
char *mPluginPath;
|
||||||
nsPluginTag *mPlugins;
|
nsPluginTag *mPlugins;
|
||||||
PRBool mPluginsLoaded;
|
PRBool mPluginsLoaded;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#define PLUGINS_DIR_LOCATION_AUTO 0
|
#define PLUGINS_DIR_LOCATION_AUTO 0
|
||||||
#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1
|
#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1
|
||||||
#define PLUGINS_DIR_LOCATION_4DOTX 2
|
#define PLUGINS_DIR_LOCATION_4DOTX 2
|
||||||
|
#define PLUGINS_DIR_LOCATION_MAC_OLD 3
|
||||||
|
|
||||||
class nsPluginsDir : public nsFileSpec {
|
class nsPluginsDir : public nsFileSpec {
|
||||||
public:
|
public:
|
||||||
|
@ -68,7 +68,11 @@ nsPluginsDir::nsPluginsDir(PRUint16 location)
|
|||||||
#else
|
#else
|
||||||
// The "Plugins" folder in the application's directory is where plugins are loaded from.
|
// The "Plugins" folder in the application's directory is where plugins are loaded from.
|
||||||
mError = getApplicationSpec(mSpec);
|
mError = getApplicationSpec(mSpec);
|
||||||
if (NS_SUCCEEDED(mError)) {
|
if (NS_SUCCEEDED(mError))
|
||||||
|
{
|
||||||
|
if(location == PLUGINS_DIR_LOCATION_MAC_OLD)
|
||||||
|
SetLeafName("Plug-ins");
|
||||||
|
else
|
||||||
SetLeafName("Plugins");
|
SetLeafName("Plugins");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user