mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 23:13:18 +00:00
5c3e1ed7ef
- Bug 1255818. Switch from JS_ClearPendingException to AutoJSAPI::ClearException for cases when we have an AutoJSAPI around. r=bholley (e1e0413493) - Bug 1253591. HTMLAllCollection should be rooted at the document, not the root element, so it can find the root element. r=peterv (c5f2f253a9) - Bug 1257270 - Use std::nullptr_t instead of nullptr_t in WMFUtils.h. r=cpearce (539e705876) - Bug 1251881 - use UniquePtr instead of ScopedDeletePtr in mozglue/linker/; r=glandium (2fe329e32c) - Bug 1219068 - Compute size correctly when a character consists entirely of glue. r=karlt (80f2e23268) - Bug 1246132 - Improve register allocation speed on large functions, r=sunfish. (6e023c252b) - Bug 1150354: Make nsPluginDirServiceProvider build with MSVC 2015 CTP 6, r=jmathies (0113760730) - Bug 1197311 - Remove PR_snprintf calls in dom/ r=froydnj (6268400ef0) - Bug 1255099 - XHR CTOR doesn't need to use implicitJSContext, r=bz (72f08fbc36) - Bug 1255597 - Part 1: Remove redundent trailing spaces. r=khuey (7f2240cb05) - Bug 1255597 - Part 2: Follow spec to modify the content-type check conditions which determine parsing XHR body or not. r=khuey (ba6f7fc536) - Bug 1255597 - Part 3: Synchronize content-type hint of HttpChannelChild to HttpChannelParent. r=jduell (bb97478b01) - Bug 1255597 - Part 4: Remove 'expected fail' settings and expect test cases in responsexml-media-type.htm should be passed. r=khuey (772884b4fb) - Bug 1201170 - During message diversion must be possible to suspend them. r=jduell (abb2361b7f) - Bug 1201174 - For FTP - in case of divertToParent, it myst be possible to delay delivering of OnDataAv./OnStopR. r=jduell (9299ef81be) - Bug 1247393 - use arrays of UniquePtr in ChannelEventQueue; r=mcmanus (7621205b53) - Bug 1254730 - ChannelEventQueue must be thread-safe, r=michal (b8e01204e9) - Bug 1254859 part 2. Switch the AutoEntryScript in nsXULTemplateBuilder::InitHTMLTemplateRoot to take ownership of error reporting. r=bholley (f183ec692c) - Bug 1254859 part 1. Switch the AutoEntryScript in nsGlobalWindow::FireOnNewGlobalObject to take ownership of error reporting. r=bholley (b0cd891917) - Bug 1254860. Switch the AutoEntryScript TestShellCommandParent::RunCallback to taking ownership of error reporting. r=bholley (0c9697e60f) - Bug 1254857. Switch the AutoEntryScript in xpc::EvalInSandbox to take ownership of error reporting. r=bholley (93b6bfc87c) - Bug 1254847 part 3. Make AutoEntryScript always take ownership of error reporting. r=bholley (3c2929462f) - Bug 1256688 - Continue using getPropertyDescriptor for has in Sandbox창. r=peterv (be7e50b715) - Bug 1254730 - patch 2 - Better comments and a better management of lifetime of ChannelEvents, r=michal (8348911e35) - Bug 1163198 - Remove instances of #ifdef PR_LOGGING in dom/plugins. r=froydnj (ba13039dfa) - Bug 1253216 - clean up the atomic ops ifdef nest. r=jorendorff (6ca747d3cf) - Bug 1257055 - Use jit/arm64/Architecture-arm64.h on non-JIT aarch64. r=lth (4f3949cd19) - Bug 1253379 - Cache timings not send to HttpChannelChild r=mayhemer (395172278f) - align SetAllowStaleCacheContent to FF52, possible misspatch (9d29d27011)
449 lines
14 KiB
C++
449 lines
14 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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/. */
|
|
|
|
#include "nsPluginDirServiceProvider.h"
|
|
|
|
#include "nsCRT.h"
|
|
#include "nsIFile.h"
|
|
#include "nsDependentString.h"
|
|
#include "nsArrayEnumerator.h"
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include <windows.h>
|
|
#include "nsIWindowsRegKey.h"
|
|
|
|
using namespace mozilla;
|
|
|
|
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
|
|
FileExists(LPCWSTR szFile)
|
|
{
|
|
return GetFileAttributesW(szFile) != 0xFFFFFFFF;
|
|
}
|
|
|
|
// Get file version information from a file
|
|
static BOOL
|
|
GetFileVersion(LPCWSTR szFile, verBlock *vbVersion)
|
|
{
|
|
UINT uLen;
|
|
UINT dwLen;
|
|
BOOL bRv;
|
|
DWORD dwHandle;
|
|
LPVOID lpData;
|
|
LPVOID lpBuffer;
|
|
VS_FIXEDFILEINFO *lpBuffer2;
|
|
|
|
ClearVersion(vbVersion);
|
|
if (FileExists(szFile)) {
|
|
bRv = TRUE;
|
|
LPCWSTR lpFilepath = szFile;
|
|
dwLen = GetFileVersionInfoSizeW(lpFilepath, &dwHandle);
|
|
lpData = (LPVOID)moz_xmalloc(dwLen);
|
|
uLen = 0;
|
|
|
|
if (lpData && GetFileVersionInfoW(lpFilepath, dwHandle, dwLen, lpData) != 0) {
|
|
if (VerQueryValueW(lpData, L"\\", &lpBuffer, &uLen) != 0) {
|
|
lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer;
|
|
|
|
vbVersion->wMajor = HIWORD(lpBuffer2->dwFileVersionMS);
|
|
vbVersion->wMinor = LOWORD(lpBuffer2->dwFileVersionMS);
|
|
vbVersion->wRelease = HIWORD(lpBuffer2->dwFileVersionLS);
|
|
vbVersion->wBuild = LOWORD(lpBuffer2->dwFileVersionLS);
|
|
}
|
|
}
|
|
|
|
moz_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
|
|
TranslateVersionStr(const WCHAR* szVersion, verBlock *vbVersion)
|
|
{
|
|
WCHAR* szNum1 = nullptr;
|
|
WCHAR* szNum2 = nullptr;
|
|
WCHAR* szNum3 = nullptr;
|
|
WCHAR* szNum4 = nullptr;
|
|
WCHAR* szJavaBuild = nullptr;
|
|
|
|
WCHAR *strVer = nullptr;
|
|
if (szVersion) {
|
|
strVer = wcsdup(szVersion);
|
|
}
|
|
|
|
if (!strVer) {
|
|
// Out of memory
|
|
ClearVersion(vbVersion);
|
|
return;
|
|
}
|
|
|
|
// Java may be using an underscore instead of a dot for the build ID
|
|
szJavaBuild = wcschr(strVer, '_');
|
|
if (szJavaBuild) {
|
|
szJavaBuild[0] = '.';
|
|
}
|
|
|
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
|
// MSVC 2013 and earlier provided only a non-standard two-argument variant of
|
|
// wcstok that is generally not thread-safe. For our purposes here, it works
|
|
// fine, though.
|
|
auto wcstok = [](wchar_t* strToken, const wchar_t* strDelimit,
|
|
wchar_t** /*ctx*/) {
|
|
return ::std::wcstok(strToken, strDelimit);
|
|
};
|
|
#endif
|
|
wchar_t* ctx = nullptr;
|
|
szNum1 = wcstok(strVer, L".", &ctx);
|
|
szNum2 = wcstok(nullptr, L".", &ctx);
|
|
szNum3 = wcstok(nullptr, L".", &ctx);
|
|
szNum4 = wcstok(nullptr, L".", &ctx);
|
|
|
|
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;
|
|
|
|
free(strVer);
|
|
}
|
|
|
|
// 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_ISUPPORTS(nsPluginDirServiceProvider,
|
|
nsIDirectoryServiceProvider)
|
|
|
|
//*****************************************************************************
|
|
// nsPluginDirServiceProvider::nsIDirectoryServiceProvider
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP
|
|
nsPluginDirServiceProvider::GetFile(const char *charProp, bool *persistant,
|
|
nsIFile **_retval)
|
|
{
|
|
nsCOMPtr<nsIFile> localFile;
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
NS_ENSURE_ARG(charProp);
|
|
|
|
*_retval = nullptr;
|
|
*persistant = false;
|
|
|
|
nsCOMPtr<nsIWindowsRegKey> regKey =
|
|
do_CreateInstance("@mozilla.org/windows-registry-key;1");
|
|
NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE);
|
|
|
|
if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) {
|
|
nsAdoptingCString strVer = Preferences::GetCString(charProp);
|
|
if (!strVer) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
verBlock minVer;
|
|
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
|
|
|
|
// 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
|
|
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)) {
|
|
GetFileVersion(path.get(), &qtVer);
|
|
}
|
|
regKey->Close();
|
|
}
|
|
if (CompareVersion(qtVer, minVer) < 0)
|
|
return rv;
|
|
|
|
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");
|
|
rv = NS_NewLocalFile(path, true,
|
|
getter_AddRefs(localFile));
|
|
}
|
|
}
|
|
} else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) {
|
|
nsAdoptingCString strVer = Preferences::GetCString(charProp);
|
|
if (!strVer) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
verBlock minVer;
|
|
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
|
|
|
|
// Look for Windows Media Player system installation plugins directory
|
|
verBlock wmpVer;
|
|
ClearVersion(&wmpVer);
|
|
|
|
// First we need to check the version of WMP
|
|
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)) {
|
|
GetFileVersion(path.get(), &wmpVer);
|
|
}
|
|
regKey->Close();
|
|
}
|
|
if (CompareVersion(wmpVer, minVer) < 0)
|
|
return rv;
|
|
|
|
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)) {
|
|
rv = NS_NewLocalFile(path, true,
|
|
getter_AddRefs(localFile));
|
|
}
|
|
}
|
|
} else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) {
|
|
nsAdoptingCString strVer = Preferences::GetCString(charProp);
|
|
if (!strVer) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
verBlock minVer;
|
|
TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer);
|
|
|
|
// Look for Adobe Acrobat system installation plugins directory
|
|
verBlock maxVer;
|
|
ClearVersion(&maxVer);
|
|
|
|
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,
|
|
NS_LITERAL_STRING("software\\Adobe\\Adobe Acrobat"),
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
if (NS_FAILED(rv)) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
}
|
|
|
|
// We must enumerate through the keys because what if there is
|
|
// more than one version?
|
|
uint32_t childCount = 0;
|
|
regKey->GetChildCount(&childCount);
|
|
|
|
for (uint32_t index = 0; index < childCount; ++index) {
|
|
nsAutoString childName;
|
|
rv = regKey->GetChildName(index, childName);
|
|
if (NS_SUCCEEDED(rv)) {
|
|
verBlock curVer;
|
|
TranslateVersionStr(childName.get(), &curVer);
|
|
|
|
childName += NS_LITERAL_STRING("\\InstallPath");
|
|
|
|
nsCOMPtr<nsIWindowsRegKey> childKey;
|
|
rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE,
|
|
getter_AddRefs(childKey));
|
|
if (NS_SUCCEEDED(rv)) {
|
|
// We have a sub key
|
|
nsAutoString path;
|
|
rv = childKey->ReadStringValue(NS_LITERAL_STRING(""), path);
|
|
if (NS_SUCCEEDED(rv)) {
|
|
if (CompareVersion(curVer, maxVer) >= 0 &&
|
|
CompareVersion(curVer, minVer) >= 0) {
|
|
newestPath = path;
|
|
CopyVersion(&maxVer, &curVer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!newestPath.IsEmpty()) {
|
|
newestPath += NS_LITERAL_STRING("\\browser");
|
|
rv = NS_NewLocalFile(newestPath, true,
|
|
getter_AddRefs(localFile));
|
|
}
|
|
}
|
|
|
|
if (NS_FAILED(rv)) {
|
|
return rv;
|
|
}
|
|
|
|
localFile.forget(_retval);
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aEnumerator);
|
|
*aEnumerator = nullptr;
|
|
|
|
nsCOMArray<nsIFile> dirs;
|
|
|
|
GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER, dirs);
|
|
GetPLIDDirectoriesWithRootKey(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, dirs);
|
|
|
|
return NS_NewArrayEnumerator(aEnumerator, dirs);
|
|
}
|
|
|
|
nsresult
|
|
nsPluginDirServiceProvider::GetPLIDDirectoriesWithRootKey(uint32_t aKey, nsCOMArray<nsIFile> &aDirs)
|
|
{
|
|
nsCOMPtr<nsIWindowsRegKey> regKey =
|
|
do_CreateInstance("@mozilla.org/windows-registry-key;1");
|
|
NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE);
|
|
|
|
nsresult rv = regKey->Open(aKey,
|
|
NS_LITERAL_STRING("Software\\MozillaPlugins"),
|
|
nsIWindowsRegKey::ACCESS_READ);
|
|
if (NS_FAILED(rv)) {
|
|
return rv;
|
|
}
|
|
|
|
uint32_t childCount = 0;
|
|
regKey->GetChildCount(&childCount);
|
|
|
|
for (uint32_t index = 0; index < childCount; ++index) {
|
|
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)) {
|
|
nsCOMPtr<nsIFile> localFile;
|
|
if (NS_SUCCEEDED(NS_NewLocalFile(path, true,
|
|
getter_AddRefs(localFile))) &&
|
|
localFile) {
|
|
// Some vendors use a path directly to the DLL so chop off
|
|
// the filename
|
|
bool isDir = false;
|
|
if (NS_SUCCEEDED(localFile->IsDirectory(&isDir)) && !isDir) {
|
|
nsCOMPtr<nsIFile> temp;
|
|
localFile->GetParent(getter_AddRefs(temp));
|
|
if (temp)
|
|
localFile = temp;
|
|
}
|
|
|
|
// Now we check to make sure it's actually on disk and
|
|
// To see if we already have this directory in the array
|
|
bool isFileThere = false;
|
|
bool isDupEntry = false;
|
|
if (NS_SUCCEEDED(localFile->Exists(&isFileThere)) && isFileThere) {
|
|
int32_t c = aDirs.Count();
|
|
for (int32_t i = 0; i < c; i++) {
|
|
nsIFile *dup = static_cast<nsIFile*>(aDirs[i]);
|
|
if (dup &&
|
|
NS_SUCCEEDED(dup->Equals(localFile, &isDupEntry)) &&
|
|
isDupEntry) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!isDupEntry) {
|
|
aDirs.AppendObject(localFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|