2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsPluginDirServiceProvider.h"
|
|
|
|
|
|
|
|
#include "nsCRT.h"
|
2012-06-05 19:08:30 -07:00
|
|
|
#include "nsIFile.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDependentString.h"
|
|
|
|
#include "prmem.h"
|
|
|
|
#include "nsArrayEnumerator.h"
|
2012-04-03 21:09:20 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
#include <windows.h>
|
|
|
|
#include "nsIWindowsRegKey.h"
|
|
|
|
|
2012-04-03 21:09:20 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
typedef struct structVer
|
|
|
|
{
|
|
|
|
WORD wMajor;
|
|
|
|
WORD wMinor;
|
|
|
|
WORD wRelease;
|
|
|
|
WORD wBuild;
|
|
|
|
} verBlock;
|
|
|
|
|
|
|
|
static void
|
|
|
|
ClearVersion(verBlock *ver)
|
|
|
|
{
|
|
|
|
ver->wMajor = 0;
|
|
|
|
ver->wMinor = 0;
|
|
|
|
ver->wRelease = 0;
|
|
|
|
ver->wBuild = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
2010-02-19 12:31:28 -08:00
|
|
|
FileExists(LPCWSTR szFile)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-02-19 12:31:28 -08:00
|
|
|
return GetFileAttributesW(szFile) != 0xFFFFFFFF;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get file version information from a file
|
|
|
|
static BOOL
|
2010-02-19 12:31:28 -08:00
|
|
|
GetFileVersion(LPCWSTR szFile, verBlock *vbVersion)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
UINT uLen;
|
|
|
|
UINT dwLen;
|
|
|
|
BOOL bRv;
|
|
|
|
DWORD dwHandle;
|
|
|
|
LPVOID lpData;
|
|
|
|
LPVOID lpBuffer;
|
|
|
|
VS_FIXEDFILEINFO *lpBuffer2;
|
|
|
|
|
|
|
|
ClearVersion(vbVersion);
|
|
|
|
if (FileExists(szFile)) {
|
|
|
|
bRv = TRUE;
|
2010-02-19 21:53:38 -08:00
|
|
|
LPCWSTR lpFilepath = szFile;
|
|
|
|
dwLen = GetFileVersionInfoSizeW(lpFilepath, &dwHandle);
|
2007-03-22 10:30:00 -07:00
|
|
|
lpData = (LPVOID)malloc(dwLen);
|
|
|
|
uLen = 0;
|
|
|
|
|
2010-02-19 21:53:38 -08:00
|
|
|
if (lpData && GetFileVersionInfoW(lpFilepath, dwHandle, dwLen, lpData) != 0) {
|
2010-02-13 13:59:39 -08:00
|
|
|
if (VerQueryValueW(lpData, L"\\", &lpBuffer, &uLen) != 0) {
|
2007-03-22 10:30:00 -07:00
|
|
|
lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer;
|
|
|
|
|
|
|
|
vbVersion->wMajor = HIWORD(lpBuffer2->dwFileVersionMS);
|
|
|
|
vbVersion->wMinor = LOWORD(lpBuffer2->dwFileVersionMS);
|
|
|
|
vbVersion->wRelease = HIWORD(lpBuffer2->dwFileVersionLS);
|
|
|
|
vbVersion->wBuild = LOWORD(lpBuffer2->dwFileVersionLS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(lpData);
|
|
|
|
} else {
|
|
|
|
/* File does not exist */
|
|
|
|
bRv = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Will deep copy ver2 into ver1
|
|
|
|
static void
|
|
|
|
CopyVersion(verBlock *ver1, verBlock *ver2)
|
|
|
|
{
|
|
|
|
ver1->wMajor = ver2->wMajor;
|
|
|
|
ver1->wMinor = ver2->wMinor;
|
|
|
|
ver1->wRelease = ver2->wRelease;
|
|
|
|
ver1->wBuild = ver2->wBuild;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert a string version to a version struct
|
|
|
|
static void
|
2010-02-13 13:59:39 -08:00
|
|
|
TranslateVersionStr(const WCHAR* szVersion, verBlock *vbVersion)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-02-19 12:31:28 -08:00
|
|
|
WCHAR* szNum1 = NULL;
|
|
|
|
WCHAR* szNum2 = NULL;
|
|
|
|
WCHAR* szNum3 = NULL;
|
|
|
|
WCHAR* szNum4 = NULL;
|
|
|
|
WCHAR* szJavaBuild = NULL;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
WCHAR *strVer = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (szVersion) {
|
2010-02-13 13:59:39 -08:00
|
|
|
strVer = wcsdup(szVersion);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!strVer) {
|
|
|
|
// Out of memory
|
|
|
|
ClearVersion(vbVersion);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Java may be using an underscore instead of a dot for the build ID
|
2010-02-13 13:59:39 -08:00
|
|
|
szJavaBuild = wcschr(strVer, '_');
|
2007-03-22 10:30:00 -07:00
|
|
|
if (szJavaBuild) {
|
|
|
|
szJavaBuild[0] = '.';
|
|
|
|
}
|
|
|
|
|
2010-02-13 13:59:39 -08:00
|
|
|
szNum1 = wcstok(strVer, L".");
|
|
|
|
szNum2 = wcstok(NULL, L".");
|
|
|
|
szNum3 = wcstok(NULL, L".");
|
|
|
|
szNum4 = wcstok(NULL, L".");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-19 12:31:28 -08:00
|
|
|
vbVersion->wMajor = szNum1 ? (WORD) _wtoi(szNum1) : 0;
|
|
|
|
vbVersion->wMinor = szNum2 ? (WORD) _wtoi(szNum2) : 0;
|
|
|
|
vbVersion->wRelease = szNum3 ? (WORD) _wtoi(szNum3) : 0;
|
|
|
|
vbVersion->wBuild = szNum4 ? (WORD) _wtoi(szNum4) : 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-03-08 22:07:00 -07:00
|
|
|
free(strVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compare two version struct, return zero if the same
|
|
|
|
static int
|
|
|
|
CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew)
|
|
|
|
{
|
|
|
|
if (vbVersionOld.wMajor > vbVersionNew.wMajor) {
|
|
|
|
return 4;
|
|
|
|
} else if (vbVersionOld.wMajor < vbVersionNew.wMajor) {
|
|
|
|
return -4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vbVersionOld.wMinor > vbVersionNew.wMinor) {
|
|
|
|
return 3;
|
|
|
|
} else if (vbVersionOld.wMinor < vbVersionNew.wMinor) {
|
|
|
|
return -3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vbVersionOld.wRelease > vbVersionNew.wRelease) {
|
|
|
|
return 2;
|
|
|
|
} else if (vbVersionOld.wRelease < vbVersionNew.wRelease) {
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vbVersionOld.wBuild > vbVersionNew.wBuild) {
|
|
|
|
return 1;
|
|
|
|
} else if (vbVersionOld.wBuild < vbVersionNew.wBuild) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the versions are all the same */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsPluginDirServiceProvider::Constructor/Destructor
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
nsPluginDirServiceProvider::nsPluginDirServiceProvider()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginDirServiceProvider::~nsPluginDirServiceProvider()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsPluginDirServiceProvider::nsISupports
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS1(nsPluginDirServiceProvider,
|
|
|
|
nsIDirectoryServiceProvider)
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsPluginDirServiceProvider::nsIDirectoryServiceProvider
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFile **_retval)
|
|
|
|
{
|
2012-06-05 19:08:30 -07:00
|
|
|
nsCOMPtr<nsIFile> localFile;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
2009-03-08 22:07:00 -07:00
|
|
|
NS_ENSURE_ARG(charProp);
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
*_retval = nullptr;
|
2011-09-29 23:02:59 -07:00
|
|
|
*persistant = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
nsCOMPtr<nsIWindowsRegKey> regKey =
|
|
|
|
do_CreateInstance("@mozilla.org/windows-registry-key;1");
|
|
|
|
NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE);
|
|
|
|
|
2011-03-31 11:26:57 -07:00
|
|
|
if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) {
|
2012-04-03 21:09:20 -07:00
|
|
|
nsAdoptingCString strVer = Preferences::GetCString(charProp);
|
|
|
|
if (!strVer) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-04-03 21:09:20 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
verBlock minVer;
|
2010-02-13 13:59:39 -08:00
|
|
|
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
|
|
|
NS_LITERAL_STRING("Software\\JavaSoft\\Java Runtime Environment"),
|
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
verBlock maxVer;
|
|
|
|
ClearVersion(&maxVer);
|
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
nsAutoString newestPath;
|
|
|
|
nsAutoString browserJavaVersion;
|
|
|
|
regKey->ReadStringValue(NS_LITERAL_STRING("BrowserJavaVersion"),
|
|
|
|
browserJavaVersion);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = 0;
|
2011-02-17 13:18:53 -08:00
|
|
|
regKey->GetChildCount(&childCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// We must enumerate through the keys because what if there is
|
|
|
|
// more than one version?
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t index = 0; index < childCount; ++index) {
|
2011-02-17 13:18:53 -08:00
|
|
|
nsAutoString childName;
|
|
|
|
rv = regKey->GetChildName(index, childName);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// Skip major.minor as it always points to latest in its family
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t numChars = 0;
|
|
|
|
int32_t offset = 0;
|
2011-02-17 13:18:53 -08:00
|
|
|
while ((offset = childName.FindChar(L'.', offset + 1)) >= 0) {
|
|
|
|
++numChars;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-02-17 13:18:53 -08:00
|
|
|
if (numChars < 2)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWindowsRegKey> childKey;
|
|
|
|
rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE,
|
|
|
|
getter_AddRefs(childKey));
|
|
|
|
if (NS_SUCCEEDED(rv) && childKey) {
|
|
|
|
nsAutoString path;
|
|
|
|
rv = childKey->ReadStringValue(NS_LITERAL_STRING("JavaHome"), path);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
verBlock curVer;
|
2011-06-09 13:17:58 -07:00
|
|
|
TranslateVersionStr(childName.get(), &curVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (CompareVersion(curVer, minVer) >= 0) {
|
2011-02-17 13:18:53 -08:00
|
|
|
if (browserJavaVersion == childName) {
|
|
|
|
newestPath = path;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CompareVersion(curVer, maxVer) >= 0) {
|
2011-02-17 13:18:53 -08:00
|
|
|
newestPath = path;
|
2007-03-22 10:30:00 -07:00
|
|
|
CopyVersion(&maxVer, &curVer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-17 13:18:53 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
if (newestPath.IsEmpty()) {
|
2011-02-17 00:45:20 -08:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We require the newer NPAPI Java plugin.
|
2011-02-17 13:18:53 -08:00
|
|
|
newestPath += NS_LITERAL_STRING("\\bin\\new_plugin");
|
2011-02-17 00:45:20 -08:00
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
rv = NS_NewLocalFile(newestPath,
|
2011-09-29 23:02:59 -07:00
|
|
|
true, getter_AddRefs(localFile));
|
2010-02-13 13:59:39 -08:00
|
|
|
|
2011-02-17 00:45:20 -08:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-02-17 13:18:53 -08:00
|
|
|
nsCOMPtr<nsIWindowsRegKey> newKey =
|
|
|
|
do_CreateInstance("@mozilla.org/windows-registry-key;1");
|
|
|
|
NS_ENSURE_TRUE(newKey, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
rv = newKey->Create(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
|
|
|
NS_LITERAL_STRING("Software\\mozilla.org\\Mozilla"),
|
|
|
|
nsIWindowsRegKey::ACCESS_QUERY_VALUE |
|
|
|
|
nsIWindowsRegKey::ACCESS_SET_VALUE);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool currentVersionExists = false;
|
2011-02-17 13:18:53 -08:00
|
|
|
newKey->HasValue(NS_LITERAL_STRING("CurrentVersion"),
|
|
|
|
¤tVersionExists);
|
|
|
|
if (!currentVersionExists) {
|
|
|
|
newKey->WriteStringValue(NS_LITERAL_STRING("CurrentVersion"),
|
|
|
|
NS_LITERAL_STRING(MOZILLA_VERSION));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-08 22:07:00 -07:00
|
|
|
} else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
|
2012-04-03 21:09:20 -07:00
|
|
|
nsAdoptingCString strVer = Preferences::GetCString(charProp);
|
|
|
|
if (!strVer) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-04-03 21:09:20 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
verBlock minVer;
|
2010-02-13 13:59:39 -08:00
|
|
|
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Look for the Quicktime system installation plugins directory
|
|
|
|
verBlock qtVer;
|
|
|
|
ClearVersion(&qtVer);
|
|
|
|
|
|
|
|
// First we need to check the version of Quicktime via checking
|
|
|
|
// the EXE's version table
|
2011-02-17 13:18:53 -08:00
|
|
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
|
|
|
NS_LITERAL_STRING("software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe"),
|
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAutoString path;
|
|
|
|
rv = regKey->ReadStringValue(NS_LITERAL_STRING(""), path);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-06-09 13:17:58 -07:00
|
|
|
GetFileVersion(path.get(), &qtVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-02-17 13:18:53 -08:00
|
|
|
regKey->Close();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (CompareVersion(qtVer, minVer) < 0)
|
|
|
|
return rv;
|
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
|
|
|
NS_LITERAL_STRING("software\\Apple Computer, Inc.\\QuickTime"),
|
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAutoString path;
|
|
|
|
rv = regKey->ReadStringValue(NS_LITERAL_STRING("InstallDir"), path);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
path += NS_LITERAL_STRING("\\Plugins");
|
2011-09-29 23:02:59 -07:00
|
|
|
rv = NS_NewLocalFile(path, true,
|
2010-02-13 13:59:39 -08:00
|
|
|
getter_AddRefs(localFile));
|
2011-02-17 13:18:53 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-03-08 22:07:00 -07:00
|
|
|
} else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) {
|
2012-04-03 21:09:20 -07:00
|
|
|
nsAdoptingCString strVer = Preferences::GetCString(charProp);
|
|
|
|
if (!strVer) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
2012-04-03 21:09:20 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
verBlock minVer;
|
2010-02-13 13:59:39 -08:00
|
|
|
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Look for Windows Media Player system installation plugins directory
|
|
|
|
verBlock wmpVer;
|
|
|
|
ClearVersion(&wmpVer);
|
|
|
|
|
|
|
|
// First we need to check the version of WMP
|
2011-02-17 13:18:53 -08:00
|
|
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
|
|
|
NS_LITERAL_STRING("software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe"),
|
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAutoString path;
|
|
|
|
rv = regKey->ReadStringValue(NS_LITERAL_STRING(""), path);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-06-09 13:17:58 -07:00
|
|
|
GetFileVersion(path.get(), &wmpVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-02-17 13:18:53 -08:00
|
|
|
regKey->Close();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (CompareVersion(wmpVer, minVer) < 0)
|
|
|
|
return rv;
|
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
|
|
|
NS_LITERAL_STRING("software\\Microsoft\\MediaPlayer"),
|
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsAutoString path;
|
|
|
|
rv = regKey->ReadStringValue(NS_LITERAL_STRING("Installation Directory"),
|
|
|
|
path);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-09-29 23:02:59 -07:00
|
|
|
rv = NS_NewLocalFile(path, true,
|
2010-02-13 13:59:39 -08:00
|
|
|
getter_AddRefs(localFile));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2009-03-08 22:07:00 -07:00
|
|
|
} else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
|
2012-04-03 21:09:20 -07:00
|
|
|
nsAdoptingCString strVer = Preferences::GetCString(charProp);
|
|
|
|
if (!strVer) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
verBlock minVer;
|
2010-02-13 13:59:39 -08:00
|
|
|
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Look for Adobe Acrobat system installation plugins directory
|
|
|
|
verBlock maxVer;
|
|
|
|
ClearVersion(&maxVer);
|
2011-02-17 13:18:53 -08:00
|
|
|
|
|
|
|
nsAutoString newestPath;
|
|
|
|
|
|
|
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
|
|
|
NS_LITERAL_STRING("software\\Adobe\\Acrobat Reader"),
|
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE,
|
2011-04-08 13:57:24 -07:00
|
|
|
NS_LITERAL_STRING("software\\Adobe\\Adobe Acrobat"),
|
2011-02-17 13:18:53 -08:00
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
if (NS_FAILED(rv)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We must enumerate through the keys because what if there is
|
|
|
|
// more than one version?
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = 0;
|
2011-02-17 13:18:53 -08:00
|
|
|
regKey->GetChildCount(&childCount);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t index = 0; index < childCount; ++index) {
|
2011-02-17 13:18:53 -08:00
|
|
|
nsAutoString childName;
|
|
|
|
rv = regKey->GetChildName(index, childName);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
verBlock curVer;
|
2011-06-09 13:17:58 -07:00
|
|
|
TranslateVersionStr(childName.get(), &curVer);
|
2011-02-17 13:18:53 -08:00
|
|
|
|
|
|
|
childName += NS_LITERAL_STRING("\\InstallPath");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWindowsRegKey> childKey;
|
|
|
|
rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE,
|
|
|
|
getter_AddRefs(childKey));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// We have a sub key
|
2011-02-17 13:18:53 -08:00
|
|
|
nsAutoString path;
|
|
|
|
rv = childKey->ReadStringValue(NS_LITERAL_STRING(""), path);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (CompareVersion(curVer, maxVer) >= 0 &&
|
|
|
|
CompareVersion(curVer, minVer) >= 0) {
|
2011-02-17 13:18:53 -08:00
|
|
|
newestPath = path;
|
2007-03-22 10:30:00 -07:00
|
|
|
CopyVersion(&maxVer, &curVer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
if (!newestPath.IsEmpty()) {
|
|
|
|
newestPath += NS_LITERAL_STRING("\\browser");
|
2011-09-29 23:02:59 -07:00
|
|
|
rv = NS_NewLocalFile(newestPath, true,
|
2010-02-13 13:59:39 -08:00
|
|
|
getter_AddRefs(localFile));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (localFile && NS_SUCCEEDED(rv))
|
|
|
|
return CallQueryInterface(localFile, _retval);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aEnumerator);
|
2012-07-30 07:20:58 -07:00
|
|
|
*aEnumerator = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-05 19:08:30 -07:00
|
|
|
nsCOMArray<nsIFile> dirs;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, dirs);
|
|
|
|
GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, dirs);
|
2007-04-03 08:56:31 -07:00
|
|
|
|
|
|
|
return NS_NewArrayEnumerator(aEnumerator, dirs);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsPluginDirServiceProvider::GetPLIDDirectoriesWithRootKey(uint32_t aKey, nsCOMArray<nsIFile> &aDirs)
|
2007-04-03 08:56:31 -07:00
|
|
|
{
|
2011-02-17 13:18:53 -08:00
|
|
|
nsCOMPtr<nsIWindowsRegKey> regKey =
|
|
|
|
do_CreateInstance("@mozilla.org/windows-registry-key;1");
|
|
|
|
NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
nsresult rv = regKey->Open(aKey,
|
|
|
|
NS_LITERAL_STRING("Software\\MozillaPlugins"),
|
|
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t childCount = 0;
|
2011-02-17 13:18:53 -08:00
|
|
|
regKey->GetChildCount(&childCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
for (uint32_t index = 0; index < childCount; ++index) {
|
2011-02-17 13:18:53 -08:00
|
|
|
nsAutoString childName;
|
|
|
|
rv = regKey->GetChildName(index, childName);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
nsCOMPtr<nsIWindowsRegKey> childKey;
|
|
|
|
rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE,
|
|
|
|
getter_AddRefs(childKey));
|
|
|
|
if (NS_SUCCEEDED(rv) && childKey) {
|
|
|
|
nsAutoString path;
|
|
|
|
rv = childKey->ReadStringValue(NS_LITERAL_STRING("Path"), path);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2012-06-05 19:08:30 -07:00
|
|
|
nsCOMPtr<nsIFile> localFile;
|
2011-09-29 23:02:59 -07:00
|
|
|
if (NS_SUCCEEDED(NS_NewLocalFile(path, true,
|
2011-02-17 13:18:53 -08:00
|
|
|
getter_AddRefs(localFile))) &&
|
|
|
|
localFile) {
|
|
|
|
// Some vendors use a path directly to the DLL so chop off
|
|
|
|
// the filename
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isDir = false;
|
2011-02-17 13:18:53 -08:00
|
|
|
if (NS_SUCCEEDED(localFile->IsDirectory(&isDir)) && !isDir) {
|
|
|
|
nsCOMPtr<nsIFile> temp;
|
|
|
|
localFile->GetParent(getter_AddRefs(temp));
|
|
|
|
if (temp)
|
2012-06-05 19:08:30 -07:00
|
|
|
localFile = temp;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-02-17 13:18:53 -08:00
|
|
|
// Now we check to make sure it's actually on disk and
|
|
|
|
// To see if we already have this directory in the array
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isFileThere = false;
|
|
|
|
bool isDupEntry = false;
|
2011-02-17 13:18:53 -08:00
|
|
|
if (NS_SUCCEEDED(localFile->Exists(&isFileThere)) && isFileThere) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t c = aDirs.Count();
|
|
|
|
for (int32_t i = 0; i < c; i++) {
|
2011-02-17 13:18:53 -08:00
|
|
|
nsIFile *dup = static_cast<nsIFile*>(aDirs[i]);
|
|
|
|
if (dup &&
|
|
|
|
NS_SUCCEEDED(dup->Equals(localFile, &isDupEntry)) &&
|
|
|
|
isDupEntry) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isDupEntry) {
|
|
|
|
aDirs.AppendObject(localFile);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-04-03 08:56:31 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|