зеркало из https://github.com/mozilla/pjs.git
Implementing new prefs that will allow for automatic scanning of tier one plugins in their installation locations:
pref("plugin.scan.SunJRE", "1.3"); pref("plugin.scan.Acrobat", "5.0"); pref("plugin.scan.Quicktime", "5.0"); pref("plugin.scan.WindowsMediaPlayer", "7.0"); pref("plugin.scan.4xPluginFolder", false); This also adds a one-off hack to scan for Real Player (nppl3260.dll) in the XPCOM components folder. Bug 133282, r=av sr=waterson
This commit is contained in:
Родитель
3526bb0ccd
Коммит
beadac521e
|
@ -183,3 +183,22 @@ pref("print.print_extra_margin", 90); // twips (90 twips is an eigth of an inch)
|
|||
// This indicates whether it should use the native dialog or the XP Dialog
|
||||
pref("print.use_native_print_dialog", true);
|
||||
|
||||
// Locate Java by scanning the Sun JRE installation directory with a minimum version
|
||||
// Note: Does not scan if security.enable_java is not true
|
||||
pref("plugin.scan.SunJRE", "1.3");
|
||||
|
||||
// Locate plugins by scanning the Adobe Acrobat installation directory with a minimum version
|
||||
pref("plugin.scan.Acrobat", "5.0");
|
||||
|
||||
// Locate plugins by scanning the Quicktime installation directory with a minimum version
|
||||
pref("plugin.scan.Quicktime", "5.0");
|
||||
|
||||
// Locate and scan the Window Media Player installation directory for plugins with a minimum version
|
||||
pref("plugin.scan.WindowsMediaPlayer", "7.0");
|
||||
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -35,24 +35,89 @@
|
|||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#include "nsPluginDirServiceProvider.h"
|
||||
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsDependentString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#if defined (XP_WIN)
|
||||
#include <windows.h>
|
||||
#include <windows.h>
|
||||
|
||||
// little helper function to get version info
|
||||
static char* GetKeyValue(char* verbuf, char* key)
|
||||
{
|
||||
char *buf = NULL;
|
||||
UINT blen;
|
||||
|
||||
long result = ::VerQueryValue(verbuf,
|
||||
TEXT(key),
|
||||
(void **)&buf, &blen);
|
||||
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define RETURN_AND_FREE_STRINGS(ret) \
|
||||
PR_BEGIN_MACRO \
|
||||
PL_strfree(ver1); \
|
||||
PL_strfree(ver2); \
|
||||
return (ret); \
|
||||
PR_END_MACRO
|
||||
|
||||
/*
|
||||
* Compares two string versions
|
||||
* Takes into account special Java versions with trailing underscores like "1.3.1_02"
|
||||
* Returns 0 if identical, 1 if aCharVer1 is newer or -1 if aCharVer2 is newer
|
||||
*/
|
||||
static PRInt32 CompareVersions(const char *aCharVer1, const char *aCharVer2)
|
||||
{
|
||||
char *ver1 = PL_strdup(aCharVer1);
|
||||
char *ver2 = PL_strdup(aCharVer2);
|
||||
|
||||
char *lasts1, *lasts2;
|
||||
char *tmp1 = PL_strtok_r(ver1, ".", &lasts1);
|
||||
char *tmp2 = PL_strtok_r(ver2, ".", &lasts2);
|
||||
while (tmp1 || tmp2) {
|
||||
PRUint32 r1 = tmp1 ? atoi(tmp1) : 0;
|
||||
PRUint32 r2 = tmp2 ? atoi(tmp2) : 0;
|
||||
|
||||
if (r1 > r2)
|
||||
RETURN_AND_FREE_STRINGS(1);
|
||||
else if (r2 > r1)
|
||||
RETURN_AND_FREE_STRINGS(-1);
|
||||
|
||||
tmp1 = PL_strtok_r(nsnull, ".", &lasts1);
|
||||
tmp2 = PL_strtok_r(nsnull, ".", &lasts2);
|
||||
}
|
||||
|
||||
// if we've gotten this far, check the buildID's.
|
||||
tmp1 = PL_strprbrk(aCharVer1, "_");
|
||||
tmp2 = PL_strprbrk(aCharVer2, "_");
|
||||
if (tmp1 || tmp2) {
|
||||
PRUint32 r1 = tmp1 ? atoi(++tmp1) : 0;
|
||||
PRUint32 r2 = tmp2 ? atoi(++tmp2) : 0;
|
||||
|
||||
if (r1 > r2)
|
||||
RETURN_AND_FREE_STRINGS(1);
|
||||
else if (r2 > r1)
|
||||
RETURN_AND_FREE_STRINGS(-1);
|
||||
}
|
||||
|
||||
RETURN_AND_FREE_STRINGS(0); // everything is the same
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsPluginDirServiceProvider::Constructor/Destructor
|
||||
//*****************************************************************************
|
||||
|
||||
nsPluginDirServiceProvider::nsPluginDirServiceProvider()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsPluginDirServiceProvider::~nsPluginDirServiceProvider()
|
||||
|
@ -72,118 +137,243 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsPluginDirServiceProvider, nsIDirectoryServicePro
|
|||
NS_IMETHODIMP
|
||||
nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
NS_ENSURE_ARG(prop);
|
||||
*_retval = nsnull;
|
||||
*persistant = PR_TRUE;
|
||||
|
||||
if (nsCRT::strcmp(prop, "NS_4DOTX_PLUGINS_DIR") == 0)
|
||||
{
|
||||
#if defined(XP_WIN)
|
||||
// look for the plugin folder that the user has in their Communicator 4x install
|
||||
HKEY keyloc;
|
||||
long result;
|
||||
DWORD type;
|
||||
char szKey[512] = "Software\\Netscape\\Netscape Navigator";
|
||||
char path[_MAX_PATH];
|
||||
|
||||
result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
|
||||
NS_ENSURE_ARG(prop);
|
||||
*_retval = nsnull;
|
||||
*persistant = PR_TRUE;
|
||||
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
char current_version[80];
|
||||
DWORD length = sizeof(current_version);
|
||||
#if defined(XP_WIN)
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (!prefs) return rv;
|
||||
|
||||
result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type, (LPBYTE)¤t_version, &length);
|
||||
if (nsCRT::strcmp(prop, NS_WIN_4DOTX_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 rv;
|
||||
|
||||
::RegCloseKey(keyloc);
|
||||
PL_strcat(szKey, "\\");
|
||||
PL_strcat(szKey, current_version);
|
||||
PL_strcat(szKey, "\\Main");
|
||||
result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
|
||||
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
DWORD pathlen = sizeof(path);
|
||||
// look for the plugin folder that the user has in their Communicator 4x install
|
||||
HKEY keyloc;
|
||||
long result;
|
||||
DWORD type;
|
||||
char szKey[_MAX_PATH] = "Software\\Netscape\\Netscape Navigator";
|
||||
char path[_MAX_PATH];
|
||||
|
||||
result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen);
|
||||
if (result == ERROR_SUCCESS)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile));
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
|
||||
|
||||
if (result == ERROR_SUCCESS) {
|
||||
char current_version[80];
|
||||
DWORD length = sizeof(current_version);
|
||||
|
||||
result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type, (LPBYTE)¤t_version, &length);
|
||||
|
||||
::RegCloseKey(keyloc);
|
||||
PL_strcat(szKey, "\\");
|
||||
PL_strcat(szKey, current_version);
|
||||
PL_strcat(szKey, "\\Main");
|
||||
result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc);
|
||||
|
||||
if (result == ERROR_SUCCESS) {
|
||||
DWORD pathlen = sizeof(path);
|
||||
|
||||
result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen);
|
||||
if (result == ERROR_SUCCESS)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile));
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
}
|
||||
else if (nsCRT::strcmp(prop, "NS_WIN_JAVA_JRE_DIR") == 0)
|
||||
{
|
||||
#if defined(XP_WIN)
|
||||
} else if (nsCRT::strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) {
|
||||
PRBool isJavaEnabled;
|
||||
nsXPIDLCString minVer;
|
||||
if ((NS_FAILED(prefs->GetBoolPref("security.enable_java", &isJavaEnabled)) || !isJavaEnabled) ||
|
||||
NS_FAILED(prefs->GetCharPref(prop, getter_Copies(minVer))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Look for the Java OJI plugin via the JRE install path
|
||||
HKEY baseloc;
|
||||
HKEY keyloc;
|
||||
FILETIME modTime = {0,0}; // initilize variables
|
||||
FILETIME curVer = {0,0};
|
||||
DWORD type;
|
||||
DWORD index = 0;
|
||||
DWORD numChars = _MAX_PATH;
|
||||
DWORD pathlen;
|
||||
char curKey[_MAX_PATH] = "Software\\JavaSoft\\Java Plug-in";
|
||||
char path[_MAX_PATH];
|
||||
char newestPath[_MAX_PATH + 4]; // to prevent buffer overrun when adding /bin
|
||||
|
||||
newestPath[0] = 0;
|
||||
LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc);
|
||||
HKEY baseloc;
|
||||
HKEY keyloc;
|
||||
FILETIME modTime;
|
||||
DWORD type;
|
||||
DWORD index = 0;
|
||||
DWORD numChars = _MAX_PATH;
|
||||
DWORD pathlen;
|
||||
char maxVer[_MAX_PATH] = "0";
|
||||
char curKey[_MAX_PATH] = "Software\\JavaSoft\\Java Plug-in";
|
||||
char path[_MAX_PATH];
|
||||
char newestPath[_MAX_PATH + 4]; // to prevent buffer overrun when adding \bin
|
||||
|
||||
// we must enumerate through the keys because what if there is more than one version?
|
||||
while (ERROR_SUCCESS == result)
|
||||
{
|
||||
path[0] = 0;
|
||||
numChars = _MAX_PATH;
|
||||
pathlen = sizeof(path);
|
||||
result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime);
|
||||
index++;
|
||||
if (ERROR_SUCCESS == result)
|
||||
{
|
||||
if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc))
|
||||
{
|
||||
// we have a sub key
|
||||
if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL, &type, (LPBYTE)&path, &pathlen))
|
||||
{
|
||||
// Compare time stamps from registry lookup
|
||||
// Only use the key with the latest time stamp because there could be several
|
||||
//
|
||||
// NOTE: This may not be the highest version revsion number (szKey)
|
||||
// if the user installed an older version AFTER a newer one
|
||||
// This assumes the last version installed is the one the user wants to use
|
||||
// We can also tweak this for checking for a minimum version on szKey
|
||||
// Don't tweek. Stay between compatible versions in 1.3.x. JRE 1.4 is an XPCOM
|
||||
// component and needs to be installed explicitly!
|
||||
if (::CompareFileTime(&modTime,&curVer) >= 0 &&
|
||||
(atof(curKey) >= 1.3) && (atof(curKey) < 1.4))
|
||||
{
|
||||
PL_strcpy(newestPath,path);
|
||||
curVer = modTime;
|
||||
}
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
}
|
||||
newestPath[0] = 0;
|
||||
LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc);
|
||||
|
||||
// we must enumerate through the keys because what if there is more than one version?
|
||||
while (ERROR_SUCCESS == result) {
|
||||
path[0] = 0;
|
||||
numChars = _MAX_PATH;
|
||||
pathlen = sizeof(path);
|
||||
result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime);
|
||||
index++;
|
||||
if (ERROR_SUCCESS == result) {
|
||||
if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) {
|
||||
// we have a sub key
|
||||
if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL, &type, (LPBYTE)&path, &pathlen)) {
|
||||
if (CompareVersions(curKey, maxVer) >= 0 && CompareVersions(curKey, minVer.get()) >= 0) {
|
||||
PL_strcpy(newestPath, path);
|
||||
PL_strcpy(maxVer, curKey);
|
||||
}
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
}
|
||||
|
||||
::RegCloseKey(baseloc);
|
||||
|
||||
// if nothing is found, then don't add \bin dir
|
||||
if (newestPath[0] != 0)
|
||||
{
|
||||
PL_strcat(newestPath,"\\bin");
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, getter_AddRefs(localFile));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (localFile && NS_SUCCEEDED(rv))
|
||||
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
|
||||
|
||||
return rv;
|
||||
::RegCloseKey(baseloc);
|
||||
|
||||
// if nothing is found, then don't add \bin dir
|
||||
if (newestPath[0] != 0) {
|
||||
PL_strcat(newestPath,"\\bin");
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, getter_AddRefs(localFile));
|
||||
}
|
||||
} else if (nsCRT::strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
|
||||
nsXPIDLCString minVer;
|
||||
if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(minVer))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// look for the Quicktime system installation plugins directory
|
||||
HKEY keyloc;
|
||||
long result;
|
||||
DWORD type;
|
||||
char qtVer[_MAX_PATH] = "0";
|
||||
char path[_MAX_PATH];
|
||||
DWORD pathlen = sizeof(path);
|
||||
|
||||
// first we need to check the version of Quicktime via checking the EXE's version table
|
||||
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) {
|
||||
if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) {
|
||||
DWORD zerome, versionsize;
|
||||
char* verbuf = nsnull;
|
||||
versionsize = ::GetFileVersionInfoSize((char*)path, &zerome);
|
||||
if (versionsize > 0)
|
||||
verbuf = (char *)PR_Malloc(versionsize);
|
||||
if (!verbuf) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
else if (::GetFileVersionInfo((char*)path, NULL, versionsize, verbuf))
|
||||
PL_strcpy(qtVer, GetKeyValue(verbuf, "\\StringFileInfo\\040904b0\\FileVersion"));
|
||||
|
||||
if (verbuf) PR_Free(verbuf);
|
||||
}
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
if (CompareVersions(qtVer, minVer.get()) < 0)
|
||||
return rv;
|
||||
|
||||
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) {
|
||||
DWORD pathlen = sizeof(path);
|
||||
|
||||
result = ::RegQueryValueEx(keyloc, "InstallDir", NULL, &type, (LPBYTE)&path, &pathlen);
|
||||
PL_strcat(path, "\\Plugins");
|
||||
if (result == ERROR_SUCCESS)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile));
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
} else if (nsCRT::strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) {
|
||||
nsXPIDLCString minVer;
|
||||
if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(minVer))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// look for Windows Media Player system installation plugins directory
|
||||
HKEY keyloc;
|
||||
DWORD type;
|
||||
char wmpVer[_MAX_PATH] = "0";
|
||||
char path[_MAX_PATH];
|
||||
DWORD pathlen = sizeof(path);
|
||||
|
||||
// first we need to check the version of WMP
|
||||
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) {
|
||||
if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) {
|
||||
DWORD zerome, versionsize;
|
||||
char* verbuf = nsnull;
|
||||
versionsize = ::GetFileVersionInfoSize((char*)path, &zerome);
|
||||
if (versionsize > 0)
|
||||
verbuf = (char *)PR_Malloc(versionsize);
|
||||
if (!verbuf) rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
else if (::GetFileVersionInfo((char*)path, NULL, versionsize, verbuf))
|
||||
PL_strcpy(wmpVer, GetKeyValue(verbuf, "\\StringFileInfo\\040904E4\\FileVersion"));
|
||||
|
||||
if (verbuf) PR_Free(verbuf);
|
||||
}
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
if (CompareVersions(wmpVer, minVer.get()) < 0)
|
||||
return rv;
|
||||
|
||||
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\MediaPlayer", 0, KEY_READ, &keyloc)) {
|
||||
if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Installation Directory", NULL, &type, (LPBYTE)&path, &pathlen))
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile));
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
} else if (nsCRT::strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
|
||||
nsXPIDLCString minVer;
|
||||
if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(minVer))))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// look for Adobe Acrobat system installation plugins directory
|
||||
HKEY baseloc;
|
||||
HKEY keyloc;
|
||||
FILETIME modTime;
|
||||
DWORD type;
|
||||
DWORD index = 0;
|
||||
DWORD numChars = _MAX_PATH;
|
||||
DWORD pathlen;
|
||||
char maxVer[_MAX_PATH] = "0";
|
||||
char curKey[_MAX_PATH] = "software\\Adobe\\Acrobat Reader";
|
||||
char path[_MAX_PATH];
|
||||
char newestPath[_MAX_PATH + 8]; // to prevent buffer overrun when adding \browser
|
||||
|
||||
newestPath[0] = 0;
|
||||
if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) {
|
||||
PL_strcpy(curKey, "software\\Adobe\\Adobe Acrobat");
|
||||
if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// we must enumerate through the keys because what if there is more than one version?
|
||||
LONG result = ERROR_SUCCESS;
|
||||
while (ERROR_SUCCESS == result) {
|
||||
path[0] = 0;
|
||||
numChars = _MAX_PATH;
|
||||
pathlen = sizeof(path);
|
||||
result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime);
|
||||
index++;
|
||||
if (ERROR_SUCCESS == result) {
|
||||
PL_strcat(curKey, "\\InstallPath");
|
||||
if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) {
|
||||
// we have a sub key
|
||||
if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) {
|
||||
if (CompareVersions(curKey, maxVer) >= 0 && CompareVersions(curKey, minVer.get()) >= 0) {
|
||||
PL_strcpy(newestPath, path);
|
||||
PL_strcpy(maxVer, curKey);
|
||||
}
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
::RegCloseKey(baseloc);
|
||||
if (newestPath[0] != 0) {
|
||||
PL_strcat(newestPath,"\\browser");
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, getter_AddRefs(localFile));
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
if (localFile && NS_SUCCEEDED(rv))
|
||||
return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,13 @@
|
|||
|
||||
#include "nsIDirectoryService.h"
|
||||
|
||||
// Note: Our directory service provider scan keys are prefs which are check
|
||||
// for minimum versions compatibility
|
||||
#define NS_WIN_JRE_SCAN_KEY "plugin.scan.SunJRE"
|
||||
#define NS_WIN_ACROBAT_SCAN_KEY "plugin.scan.Acrobat"
|
||||
#define NS_WIN_QUICKTIME_SCAN_KEY "plugin.scan.Quicktime"
|
||||
#define NS_WIN_WMP_SCAN_KEY "plugin.scan.WindowsMediaPlayer"
|
||||
#define NS_WIN_4DOTX_SCAN_KEY "plugin.scan.4xPluginFolder"
|
||||
|
||||
//*****************************************************************************
|
||||
// class nsPluginDirServiceProvider
|
||||
|
|
|
@ -4996,53 +4996,50 @@ nsresult nsPluginHostImpl::FindPlugins(PRBool aCreatePluginList, PRBool * aPlugi
|
|||
// the rest is optional
|
||||
|
||||
#if defined (XP_WIN)
|
||||
nsCOMPtr<nsIFile> dirToScan;
|
||||
|
||||
// Scan 4.x plugins location.
|
||||
// Specifying PR_TRUE for the last param to ScanPluginsDirectory, 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
|
||||
rv = dirService->Get("NS_4DOTX_PLUGINS_DIR", NS_GET_IID(nsIFile), getter_AddRefs(dirToScan));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ScanPluginsDirectory(dirToScan, compManager, layoutPath, aCreatePluginList, &pluginschanged, PR_TRUE);
|
||||
|
||||
if (pluginschanged)
|
||||
*aPluginsChanged = PR_TRUE;
|
||||
|
||||
// if we are just looking for possible changes,
|
||||
// no need to proceed if changes are detected
|
||||
if (!aCreatePluginList && *aPluginsChanged) {
|
||||
ClearCachedPluginInfoList();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Scan the installation path of Sun's JRE if the prefs are enabled
|
||||
nsCOMPtr<nsIPref> prefService = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (prefService) // we got the pref service
|
||||
{
|
||||
PRBool javaEnabled = PR_FALSE; // don't bother the scan if java is OFF
|
||||
PRBool doJREPluginScan = PR_FALSE;
|
||||
// 3. Scan the installation paths of our popular plugins if the prefs are enabled
|
||||
|
||||
if (NS_SUCCEEDED(prefService->GetBoolPref("security.enable_java",&javaEnabled)) &&
|
||||
NS_SUCCEEDED(prefService->GetBoolPref("plugin.do_JRE_Plugin_Scan",&doJREPluginScan)) &&
|
||||
javaEnabled && doJREPluginScan)
|
||||
{
|
||||
rv = dirService->Get("NS_WIN_JAVA_JRE_DIR", NS_GET_IID(nsIFile), getter_AddRefs(dirToScan));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
ScanPluginsDirectory(dirToScan, compManager, layoutPath, aCreatePluginList, &pluginschanged);
|
||||
// This table controls the order of scanning
|
||||
const char *prefs[] = {NS_WIN_JRE_SCAN_KEY, nsnull,
|
||||
NS_WIN_ACROBAT_SCAN_KEY, nsnull,
|
||||
NS_WIN_QUICKTIME_SCAN_KEY, nsnull,
|
||||
NS_WIN_WMP_SCAN_KEY, nsnull,
|
||||
NS_WIN_4DOTX_SCAN_KEY, "1" /* second column is flag for 4.x folder */ };
|
||||
|
||||
if (pluginschanged)
|
||||
*aPluginsChanged = PR_TRUE;
|
||||
PRUint32 size = sizeof(prefs) / sizeof(prefs[0]);
|
||||
|
||||
// if we are just looking for possible changes,
|
||||
// no need to proceed if changes are detected
|
||||
if (!aCreatePluginList && *aPluginsChanged) {
|
||||
ClearCachedPluginInfoList();
|
||||
return NS_OK;
|
||||
}
|
||||
for (PRUint32 i = 0; i < size; i+=2) {
|
||||
nsCOMPtr<nsIFile> dirToScan;
|
||||
PRBool bExists;
|
||||
if (NS_SUCCEEDED(dirService->Get(prefs[i], NS_GET_IID(nsIFile), getter_AddRefs(dirToScan))) &&
|
||||
dirToScan &&
|
||||
NS_SUCCEEDED(dirToScan->Exists(&bExists)) &&
|
||||
bExists) {
|
||||
|
||||
PRBool bFilterUnwanted = PR_FALSE;
|
||||
|
||||
// 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
|
||||
nsCOMPtr<nsIPref> prefService = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (prefService &&
|
||||
NS_SUCCEEDED(prefService->GetBoolPref(prefs[i], &bScanEverything)) &&
|
||||
bScanEverything)
|
||||
bFilterUnwanted = PR_FALSE;
|
||||
|
||||
}
|
||||
ScanPluginsDirectory(dirToScan, compManager, layoutPath, aCreatePluginList, &pluginschanged, bFilterUnwanted);
|
||||
|
||||
if (pluginschanged)
|
||||
*aPluginsChanged = PR_TRUE;
|
||||
|
||||
// if we are just looking for possible changes,
|
||||
// no need to proceed if changes are detected
|
||||
if (!aCreatePluginList && *aPluginsChanged) {
|
||||
ClearCachedPluginInfoList();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5080,6 +5077,15 @@ nsresult nsPluginHostImpl::FindPlugins(PRBool aCreatePluginList, PRBool * aPlugi
|
|||
// No more need for cached plugins. Clear it up.
|
||||
ClearCachedPluginInfoList();
|
||||
|
||||
/*
|
||||
* XXX Big time hack alert!!!!
|
||||
* Because Real Player 8 installs in the components folder, we must have this one off
|
||||
* scan for nppl3260.dll because XPCOM has shut off nsGetFactory type plugins.
|
||||
* When we stop supporting Real 8 or they fix their installer, this can go away.
|
||||
*/
|
||||
if (aCreatePluginList)
|
||||
ScanForRealInComponentsFolder(compManager, layoutPath);
|
||||
|
||||
// reverse our list of plugins
|
||||
nsPluginTag *next,*prev = nsnull;
|
||||
for (nsPluginTag *cur = mPlugins; cur; cur = next) {
|
||||
|
@ -6449,3 +6455,70 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPluginHostImpl::ScanForRealInComponentsFolder(nsIComponentManager * aCompManager, nsIFile * aLayoutPath)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
||||
// First, lets check if we already have Real. No point in doing this if it's installed correctly
|
||||
if (NS_SUCCEEDED(IsPluginEnabledForType("audio/x-pn-realaudio-plugin")))
|
||||
return rv;
|
||||
|
||||
// Next, maybe the pref wants to override
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
PRBool bSkipRealPlayerHack = PR_FALSE;
|
||||
if (!prefs ||
|
||||
(NS_SUCCEEDED(prefs->GetBoolPref("plugin.skip_real_player_hack", &bSkipRealPlayerHack)) &&
|
||||
bSkipRealPlayerHack))
|
||||
return rv;
|
||||
|
||||
// now we need the XPCOM components folder
|
||||
nsCOMPtr<nsIFile> RealPlugin;
|
||||
if (NS_FAILED(NS_GetSpecialDirectory(NS_XPCOM_COMPONENT_DIR, getter_AddRefs(RealPlugin))) || !RealPlugin)
|
||||
return rv;
|
||||
|
||||
// make sure the file is actually there
|
||||
RealPlugin->Append(nsDependentCString("nppl3260.dll"));
|
||||
PRBool exists;
|
||||
nsCAutoString filePath;
|
||||
RealPlugin->Exists(&exists);
|
||||
if (!exists || NS_FAILED(RealPlugin->GetNativePath(filePath)))
|
||||
return rv;
|
||||
|
||||
// now make sure it's a plugin
|
||||
nsFileSpec file(filePath.get());
|
||||
if (!nsPluginsDir::IsPluginFile(file))
|
||||
return rv;
|
||||
|
||||
// try to get the mime info and descriptions out of the plugin
|
||||
nsPluginFile pluginFile(file);
|
||||
nsPluginInfo info = { sizeof(info) };
|
||||
if (NS_FAILED(pluginFile.GetPluginInfo(info)))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIFile> layoutPath;
|
||||
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID, &rv);
|
||||
|
||||
// finally, create our "plugin tag" and add it to the list
|
||||
if (info.fMimeTypeArray) {
|
||||
nsPluginTag *pluginTag = new nsPluginTag(&info);
|
||||
if (pluginTag) {
|
||||
pluginTag->mNext = mPlugins;
|
||||
mPlugins = pluginTag;
|
||||
|
||||
// last thing we need is to register this plugin with layout so it can be used in full-page mode
|
||||
if(aLayoutPath)
|
||||
RegisterPluginMimeTypesWithLayout(pluginTag, aCompManager, aLayoutPath);
|
||||
}
|
||||
}
|
||||
|
||||
// free allocated strings in GetPluginInfo
|
||||
pluginFile.FreePluginInfo(info);
|
||||
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -461,6 +461,9 @@ private:
|
|||
|
||||
nsresult EnsurePrivateDirServiceProvider();
|
||||
|
||||
// one-off hack to include nppl3260.dll from the components folder
|
||||
nsresult ScanForRealInComponentsFolder(nsIComponentManager * aCompManager, nsIFile * aLayoutPath);
|
||||
|
||||
char *mPluginPath;
|
||||
nsPluginTag *mPlugins;
|
||||
nsPluginTag *mCachedPlugins;
|
||||
|
|
Загрузка…
Ссылка в новой задаче