Bug 596078: Remove old 4.x plugin directory scan. Patch by Scott Greenlay and Josh Aas. r=bsmedberg

This commit is contained in:
Scott Greenlay 2011-03-31 14:26:57 -04:00
Родитель 3322fdc600
Коммит 983a63d62b
5 изменённых файлов: 27 добавлений и 134 удалений

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

@ -1770,12 +1770,6 @@ pref("plugin.scan.WindowsMediaPlayer", "7.0");
// Which is currently HKLM\Software\MozillaPlugins\xxxPLIDxxx\Path // Which is currently HKLM\Software\MozillaPlugins\xxxPLIDxxx\Path
pref("plugin.scan.plid.all", true); pref("plugin.scan.plid.all", true);
// Controls the scanning of the Navigator 4.x directory for plugins
// When pref is missing, the default is to pickup popular plugins such as
// Flash, Shockwave, Acrobat, and Quicktime. If set to true, ALL plugins
// will be picked up and if set to false the scan will not happen at all
//pref("plugin.scan.4xPluginFolder", false);
// Help Windows NT, 2000, and XP dialup a RAS connection // Help Windows NT, 2000, and XP dialup a RAS connection
// when a network address is unreachable. // when a network address is unreachable.
pref("network.autodial-helper.enabled", true); pref("network.autodial-helper.enabled", true);

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

@ -244,44 +244,7 @@ nsPluginDirServiceProvider::GetFile(const char *charProp, PRBool *persistant,
do_CreateInstance("@mozilla.org/windows-registry-key;1"); do_CreateInstance("@mozilla.org/windows-registry-key;1");
NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE); NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE);
if (nsCRT::strcmp(charProp, NS_WIN_4DOTX_SCAN_KEY) == 0) { if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) {
// Check our prefs to see if scanning the 4.x folder has been
// explictly overriden failure to get the pref is okay, we'll do
// what we've been doing -- a filtered scan
PRBool bScan4x;
if (NS_SUCCEEDED(prefs->GetBoolPref(NS_WIN_4DOTX_SCAN_KEY, &bScan4x)) &&
!bScan4x) {
return NS_ERROR_FAILURE;
}
// Look for the plugin folder that the user has in their
// Communicator 4x install
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
NS_LITERAL_STRING("Software\\Netscape\\Netscape Navigator"),
nsIWindowsRegKey::ACCESS_READ);
if (NS_SUCCEEDED(rv)) {
nsAutoString currentVersion;
rv = regKey->ReadStringValue(NS_LITERAL_STRING("CurrentVersion"),
currentVersion);
if (NS_SUCCEEDED(rv)) {
nsAutoString childName = currentVersion;
childName.Append(NS_LITERAL_STRING("\\Main"));
nsCOMPtr<nsIWindowsRegKey> childKey;
rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_READ,
getter_AddRefs(childKey));
if (NS_SUCCEEDED(rv) && childKey) {
nsAutoString pluginsDirectory;
rv = childKey->ReadStringValue(NS_LITERAL_STRING("Plugins Directory"),
pluginsDirectory);
if (NS_SUCCEEDED(rv)) {
rv = NS_NewLocalFile(pluginsDirectory, PR_TRUE,
getter_AddRefs(localFile));
}
}
}
}
} else if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) {
nsXPIDLCString strVer; nsXPIDLCString strVer;
if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer))))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

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

@ -53,7 +53,6 @@ class nsISimpleEnumerator;
#define NS_WIN_ACROBAT_SCAN_KEY "plugin.scan.Acrobat" #define NS_WIN_ACROBAT_SCAN_KEY "plugin.scan.Acrobat"
#define NS_WIN_QUICKTIME_SCAN_KEY "plugin.scan.Quicktime" #define NS_WIN_QUICKTIME_SCAN_KEY "plugin.scan.Quicktime"
#define NS_WIN_WMP_SCAN_KEY "plugin.scan.WindowsMediaPlayer" #define NS_WIN_WMP_SCAN_KEY "plugin.scan.WindowsMediaPlayer"
#define NS_WIN_4DOTX_SCAN_KEY "plugin.scan.4xPluginFolder"
//***************************************************************************** //*****************************************************************************
// class nsPluginDirServiceProvider // class nsPluginDirServiceProvider

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

@ -2059,33 +2059,6 @@ nsPluginHost::SiteHasData(nsIPluginTag* plugin, const nsACString& domain,
return NS_OK; return NS_OK;
} }
// XXX called from ScanPluginsDirectory only when told to filter
// currently 'unwanted' plugins are Java, and all other plugins except
// Acrobat, Flash, Quicktime and Shockwave
static PRBool isUnwantedPlugin(nsPluginTag * tag)
{
if (tag->mFileName.IsEmpty())
return PR_TRUE;
for (PRInt32 i = 0; i < tag->mVariants; ++i) {
if (!PL_strcasecmp(tag->mMimeTypeArray[i], "application/pdf"))
return PR_FALSE;
if (tag->mIsFlashPlugin)
return PR_FALSE;
if (!PL_strcasecmp(tag->mMimeTypeArray[i], "application/x-director"))
return PR_FALSE;
}
// On Windows, we also want to include the Quicktime plugin from the 4.x directory
// But because it spans several DLL's, the best check for now is by filename
if (tag->mFileName.Find("npqtplugin", PR_TRUE, 0, -1) != kNotFound)
return PR_FALSE;
return PR_TRUE;
}
PRBool nsPluginHost::IsJavaMIMEType(const char* aType) PRBool nsPluginHost::IsJavaMIMEType(const char* aType)
{ {
return aType && return aType &&
@ -2183,11 +2156,9 @@ class nsDefaultComparator<pluginFileinDirectory, pluginFileinDirectory>
typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void); typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
nsresult nsPluginHost::ScanPluginsDirectory(nsIFile * pluginsDir, nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
nsIComponentManager * compManager,
PRBool aCreatePluginList, PRBool aCreatePluginList,
PRBool * aPluginsChanged, PRBool *aPluginsChanged)
PRBool checkForUnwantedPlugins)
{ {
NS_ENSURE_ARG_POINTER(aPluginsChanged); NS_ENSURE_ARG_POINTER(aPluginsChanged);
nsresult rv; nsresult rv;
@ -2278,8 +2249,7 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile * pluginsDir,
else { else {
// if it is unwanted plugin we are checking for, get it back to the cache info list // if it is unwanted plugin we are checking for, get it back to the cache info list
// if this is a duplicate plugin, too place it back in the cache info list marking unwantedness // if this is a duplicate plugin, too place it back in the cache info list marking unwantedness
if ((checkForUnwantedPlugins && isUnwantedPlugin(pluginTag)) || if (IsDuplicatePlugin(pluginTag)) {
IsDuplicatePlugin(pluginTag)) {
if (!pluginTag->HasFlag(NS_PLUGIN_FLAG_UNWANTED)) { if (!pluginTag->HasFlag(NS_PLUGIN_FLAG_UNWANTED)) {
// Plugin switched from wanted to unwanted // Plugin switched from wanted to unwanted
*aPluginsChanged = PR_TRUE; *aPluginsChanged = PR_TRUE;
@ -2384,8 +2354,7 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile * pluginsDir,
// when we sync cached plugins to registry // when we sync cached plugins to registry
NS_ASSERTION(!pluginTag->HasFlag(NS_PLUGIN_FLAG_UNWANTED), NS_ASSERTION(!pluginTag->HasFlag(NS_PLUGIN_FLAG_UNWANTED),
"Brand-new tags should not be unwanted"); "Brand-new tags should not be unwanted");
if ((checkForUnwantedPlugins && isUnwantedPlugin(pluginTag)) || if (IsDuplicatePlugin(pluginTag)) {
IsDuplicatePlugin(pluginTag)) {
pluginTag->Mark(NS_PLUGIN_FLAG_UNWANTED); pluginTag->Mark(NS_PLUGIN_FLAG_UNWANTED);
pluginTag->mNext = mCachedPlugins; pluginTag->mNext = mCachedPlugins;
mCachedPlugins = pluginTag; mCachedPlugins = pluginTag;
@ -2402,20 +2371,12 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile * pluginsDir,
// set the flag that we want to add this plugin to the list for now // set the flag that we want to add this plugin to the list for now
// and see if it remains after we check several reasons not to do so // and see if it remains after we check several reasons not to do so
PRBool bAddIt = PR_TRUE; PRBool bAddIt = PR_TRUE;
// check if this is a specific plugin we don't want if (HaveSamePlugin(pluginTag)) {
if (checkForUnwantedPlugins && isUnwantedPlugin(pluginTag)) // we cannot get here if the plugin has just been added
// and thus |pluginTag| is not from cache, because otherwise
// it would not be present in the list;
bAddIt = PR_FALSE; bAddIt = PR_FALSE;
// check if we already have this plugin in the list which
// is possible if we do refresh
if (bAddIt) {
if (HaveSamePlugin(pluginTag)) {
// we cannot get here if the plugin has just been added
// and thus |pluginTag| is not from cache, because otherwise
// it would not be present in the list;
bAddIt = PR_FALSE;
}
} }
// do it if we still want it // do it if we still want it
@ -2446,11 +2407,9 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile * pluginsDir,
return NS_OK; return NS_OK;
} }
nsresult nsPluginHost::ScanPluginsDirectoryList(nsISimpleEnumerator * dirEnum, nsresult nsPluginHost::ScanPluginsDirectoryList(nsISimpleEnumerator *dirEnum,
nsIComponentManager * compManager,
PRBool aCreatePluginList, PRBool aCreatePluginList,
PRBool * aPluginsChanged, PRBool *aPluginsChanged)
PRBool checkForUnwantedPlugins)
{ {
PRBool hasMore; PRBool hasMore;
while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) { while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) {
@ -2464,7 +2423,7 @@ nsresult nsPluginHost::ScanPluginsDirectoryList(nsISimpleEnumerator * dirEnum,
// don't pass aPluginsChanged directly to prevent it from been reset // don't pass aPluginsChanged directly to prevent it from been reset
PRBool pluginschanged = PR_FALSE; PRBool pluginschanged = PR_FALSE;
ScanPluginsDirectory(nextDir, compManager, aCreatePluginList, &pluginschanged, checkForUnwantedPlugins); ScanPluginsDirectory(nextDir, aCreatePluginList, &pluginschanged);
if (pluginschanged) if (pluginschanged)
*aPluginsChanged = PR_TRUE; *aPluginsChanged = PR_TRUE;
@ -2529,9 +2488,6 @@ nsresult nsPluginHost::FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsCh
if (ReadPluginInfo() == NS_ERROR_NOT_AVAILABLE) if (ReadPluginInfo() == NS_ERROR_NOT_AVAILABLE)
return NS_OK; return NS_OK;
nsCOMPtr<nsIComponentManager> compManager;
NS_GetComponentManager(getter_AddRefs(compManager));
#ifdef XP_WIN #ifdef XP_WIN
// Failure here is not a show-stopper so just warn. // Failure here is not a show-stopper so just warn.
rv = EnsurePrivateDirServiceProvider(); rv = EnsurePrivateDirServiceProvider();
@ -2552,7 +2508,7 @@ nsresult nsPluginHost::FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsCh
// Scan the app-defined list of plugin dirs. // Scan the app-defined list of plugin dirs.
rv = dirService->Get(NS_APP_PLUGINS_DIR_LIST, NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dirList)); rv = dirService->Get(NS_APP_PLUGINS_DIR_LIST, NS_GET_IID(nsISimpleEnumerator), getter_AddRefs(dirList));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
ScanPluginsDirectoryList(dirList, compManager, aCreatePluginList, &pluginschanged); ScanPluginsDirectoryList(dirList, aCreatePluginList, &pluginschanged);
if (pluginschanged) if (pluginschanged)
*aPluginsChanged = PR_TRUE; *aPluginsChanged = PR_TRUE;
@ -2579,7 +2535,7 @@ nsresult nsPluginHost::FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsCh
if (bScanPLIDs && mPrivateDirServiceProvider) { if (bScanPLIDs && mPrivateDirServiceProvider) {
rv = mPrivateDirServiceProvider->GetPLIDDirectories(getter_AddRefs(dirList)); rv = mPrivateDirServiceProvider->GetPLIDDirectories(getter_AddRefs(dirList));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
ScanPluginsDirectoryList(dirList, compManager, aCreatePluginList, &pluginschanged); ScanPluginsDirectoryList(dirList, aCreatePluginList, &pluginschanged);
if (pluginschanged) if (pluginschanged)
*aPluginsChanged = PR_TRUE; *aPluginsChanged = PR_TRUE;
@ -2598,37 +2554,22 @@ nsresult nsPluginHost::FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsCh
// Scan the installation paths of our popular plugins if the prefs are enabled // Scan the installation paths of our popular plugins if the prefs are enabled
// This table controls the order of scanning // This table controls the order of scanning
const char* const prefs[] = {NS_WIN_JRE_SCAN_KEY, nsnull, const char* const prefs[] = {NS_WIN_JRE_SCAN_KEY,
NS_WIN_ACROBAT_SCAN_KEY, nsnull, NS_WIN_ACROBAT_SCAN_KEY,
NS_WIN_QUICKTIME_SCAN_KEY, nsnull, NS_WIN_QUICKTIME_SCAN_KEY,
NS_WIN_WMP_SCAN_KEY, nsnull, NS_WIN_WMP_SCAN_KEY};
NS_WIN_4DOTX_SCAN_KEY, "1" /* second column is flag for 4.x folder */ };
PRUint32 size = sizeof(prefs) / sizeof(prefs[0]); PRUint32 size = sizeof(prefs) / sizeof(prefs[0]);
for (PRUint32 i = 0; i < size; i+=2) { for (PRUint32 i = 0; i < size; i+=1) {
nsCOMPtr<nsIFile> dirToScan; nsCOMPtr<nsIFile> dirToScan;
PRBool bExists; PRBool bExists;
if (NS_SUCCEEDED(dirService->Get(prefs[i], NS_GET_IID(nsIFile), getter_AddRefs(dirToScan))) && if (NS_SUCCEEDED(dirService->Get(prefs[i], NS_GET_IID(nsIFile), getter_AddRefs(dirToScan))) &&
dirToScan && dirToScan &&
NS_SUCCEEDED(dirToScan->Exists(&bExists)) && NS_SUCCEEDED(dirToScan->Exists(&bExists)) &&
bExists) { bExists) {
PRBool bFilterUnwanted = PR_FALSE; ScanPluginsDirectory(dirToScan, aCreatePluginList, &pluginschanged);
// 4.x plugins folder stuff:
// Normally we "filter" the 4.x folder through |IsUnwantedPlugin|
// Check for a pref to see if we want to scan the entire 4.x plugins folder
if (prefs[i+1]) {
PRBool bScanEverything;
bFilterUnwanted = PR_TRUE; // default to filter 4.x folder
if (mPrefService &&
NS_SUCCEEDED(mPrefService->GetBoolPref(prefs[i], &bScanEverything)) &&
bScanEverything)
bFilterUnwanted = PR_FALSE;
}
ScanPluginsDirectory(dirToScan, compManager, aCreatePluginList, &pluginschanged, bFilterUnwanted);
if (pluginschanged) if (pluginschanged)
*aPluginsChanged = PR_TRUE; *aPluginsChanged = PR_TRUE;

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

@ -236,18 +236,14 @@ private:
FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsChanged); FindPlugins(PRBool aCreatePluginList, PRBool * aPluginsChanged);
nsresult nsresult
ScanPluginsDirectory(nsIFile * pluginsDir, ScanPluginsDirectory(nsIFile *pluginsDir,
nsIComponentManager * compManager,
PRBool aCreatePluginList, PRBool aCreatePluginList,
PRBool * aPluginsChanged, PRBool *aPluginsChanged);
PRBool checkForUnwantedPlugins = PR_FALSE);
nsresult nsresult
ScanPluginsDirectoryList(nsISimpleEnumerator * dirEnum, ScanPluginsDirectoryList(nsISimpleEnumerator *dirEnum,
nsIComponentManager * compManager,
PRBool aCreatePluginList, PRBool aCreatePluginList,
PRBool * aPluginsChanged, PRBool *aPluginsChanged);
PRBool checkForUnwantedPlugins = PR_FALSE);
nsresult EnsurePluginLoaded(nsPluginTag* plugin); nsresult EnsurePluginLoaded(nsPluginTag* plugin);