Bug 1602308: Allow MOZ_PLUGIN_PATH to prepend search paths for Flash r=Gijs,froydnj

MOZ_PLUGIN_PATH is a ':'-separated list of folders (';' on Windows) that we search for when launching Flash -- the only supported browser plugin.

Differential Revision: https://phabricator.services.mozilla.com/D68601

--HG--
extra : moz-landing-system : lando
This commit is contained in:
David Parks 2020-03-30 21:57:28 +00:00
Родитель 7f7aa73508
Коммит c3c148c25d
1 изменённых файлов: 28 добавлений и 0 удалений

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

@ -26,6 +26,7 @@
#include "prio.h" #include "prio.h"
#include "nsAppDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsPluginDirServiceProvider.h" #include "nsPluginDirServiceProvider.h"
@ -922,6 +923,33 @@ nsresult PluginFinder::DeterminePluginDirs() {
NS_GET_IID(nsISimpleEnumerator), NS_GET_IID(nsISimpleEnumerator),
getter_AddRefs(dirEnum))); getter_AddRefs(dirEnum)));
// Add any paths from MOZ_PLUGIN_PATH first.
#if defined(XP_WIN) || defined(XP_LINUX)
# ifdef XP_WIN
# define PATH_SEPARATOR ';'
# else
# define PATH_SEPARATOR ':'
# endif
const char* pathsenv = PR_GetEnv("MOZ_PLUGIN_PATH");
if (pathsenv) {
const nsDependentCString pathsStr(pathsenv);
nsCCharSeparatedTokenizer paths(pathsStr, PATH_SEPARATOR);
while (paths.hasMoreTokens()) {
auto pathStr = paths.nextToken();
nsCOMPtr<nsIFile> pathFile;
rv = NS_NewNativeLocalFile(pathStr, true, getter_AddRefs(pathFile));
if (NS_WARN_IF(NS_FAILED(rv))) {
continue;
}
bool exists;
if (pathFile && NS_SUCCEEDED(pathFile->Exists(&exists)) && exists) {
mPluginDirs.AppendElement(pathFile);
}
}
}
#endif // defined(XP_WIN) || defined(XP_LINUX)
bool hasMore = false; bool hasMore = false;
while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) { while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> supports; nsCOMPtr<nsISupports> supports;