PluginInfoStoreUnix.cpp [plain text]
#include "config.h"
#if ENABLE(NETSCAPE_PLUGIN_API)
#include "PluginInfoStore.h"
#include "NetscapePluginModule.h"
#include "PluginSearchPath.h"
#include "ProcessExecutablePath.h"
#include <WebCore/FileSystem.h>
#include <WebCore/PlatformDisplay.h>
#include <limits.h>
#include <stdlib.h>
#if PLATFORM(GTK)
#include "PluginInfoCache.h"
#endif
using namespace WebCore;
namespace WebKit {
Vector<String> PluginInfoStore::pluginsDirectories()
{
return WebKit::pluginsDirectories();
}
Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
{
Vector<String> result;
char normalizedPath[PATH_MAX];
for (const auto& path : listDirectory(directory, String("*.so"))) {
CString filename = fileSystemRepresentation(path);
if (realpath(filename.data(), normalizedPath))
result.append(stringFromFileSystemRepresentation(normalizedPath));
}
return result;
}
Vector<String> PluginInfoStore::individualPluginPaths()
{
return Vector<String>();
}
bool PluginInfoStore::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
{
#if PLATFORM(GTK)
if (PluginInfoCache::singleton().getPluginInfo(pluginPath, plugin)) {
#if ENABLE(PLUGIN_PROCESS_GTK2)
if (plugin.requiresGtk2) {
if (PlatformDisplay::sharedDisplay().type() != PlatformDisplay::Type::X11)
return false;
String pluginProcessPath = executablePathOfPluginProcess();
pluginProcessPath.append('2');
if (!fileExists(pluginProcessPath))
return false;
}
#endif
return true;
}
if (NetscapePluginModule::getPluginInfo(pluginPath, plugin)) {
PluginInfoCache::singleton().updatePluginInfo(pluginPath, plugin);
return true;
}
return false;
#else
return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
#endif
}
bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& , const PluginModuleInfo& )
{
return true;
}
}
#endif // ENABLE(NETSCAPE_PLUGIN_API)