summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/Plugins')
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp30
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h3
-rw-r--r--Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp7
-rw-r--r--Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm6
-rw-r--r--Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp6
-rw-r--r--Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp6
6 files changed, 49 insertions, 9 deletions
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
index 97775c626..37ff06030 100644
--- a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
+++ b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
@@ -69,6 +69,16 @@ typedef ListHashSet<String, 32, CaseFoldingHash> PathHashSet;
typedef ListHashSet<String, 32> PathHashSet;
#endif
+static inline Vector<PluginModuleInfo> deepIsolatedCopyPluginInfoVector(const Vector<PluginModuleInfo>& vector)
+{
+ // Let the copy begin!
+ Vector<PluginModuleInfo> copy;
+ copy.reserveCapacity(vector.size());
+ for (unsigned i = 0; i < vector.size(); ++i)
+ copy.append(vector[i].isolatedCopy());
+ return copy;
+}
+
void PluginInfoStore::loadPluginsIfNecessary()
{
if (m_pluginListIsUpToDate)
@@ -94,7 +104,8 @@ void PluginInfoStore::loadPluginsIfNecessary()
for (PathHashSet::const_iterator it = uniquePluginPaths.begin(); it != end; ++it)
loadPlugin(plugins, *it);
- m_plugins.swap(plugins);
+ m_plugins = deepIsolatedCopyPluginInfoVector(plugins);
+
m_pluginListIsUpToDate = true;
}
@@ -113,15 +124,15 @@ void PluginInfoStore::loadPlugin(Vector<PluginModuleInfo>& plugins, const String
Vector<PluginModuleInfo> PluginInfoStore::plugins()
{
+ MutexLocker locker(m_pluginsLock);
loadPluginsIfNecessary();
-
- Vector<PluginModuleInfo> plugins(m_plugins);
-
- return plugins;
+ return deepIsolatedCopyPluginInfoVector(m_plugins);
}
PluginModuleInfo PluginInfoStore::findPluginForMIMEType(const String& mimeType) const
{
+ MutexLocker locker(m_pluginsLock);
+
ASSERT(!mimeType.isNull());
for (size_t i = 0; i < m_plugins.size(); ++i) {
@@ -139,6 +150,8 @@ PluginModuleInfo PluginInfoStore::findPluginForMIMEType(const String& mimeType)
PluginModuleInfo PluginInfoStore::findPluginForExtension(const String& extension, String& mimeType) const
{
+ MutexLocker locker(m_pluginsLock);
+
ASSERT(!extension.isNull());
for (size_t i = 0; i < m_plugins.size(); ++i) {
@@ -187,7 +200,10 @@ String PluginInfoStore::getMIMETypeForExtension(const String& extension)
PluginModuleInfo PluginInfoStore::findPlugin(String& mimeType, const KURL& url)
{
- loadPluginsIfNecessary();
+ {
+ MutexLocker locker(m_pluginsLock);
+ loadPluginsIfNecessary();
+ }
// First, check if we can get the plug-in based on its MIME type.
if (!mimeType.isNull()) {
@@ -219,6 +235,8 @@ PluginModuleInfo PluginInfoStore::findPlugin(String& mimeType, const KURL& url)
PluginModuleInfo PluginInfoStore::infoForPluginWithPath(const String& pluginPath) const
{
+ MutexLocker locker(m_pluginsLock);
+
for (size_t i = 0; i < m_plugins.size(); ++i) {
if (m_plugins[i].path == pluginPath)
return m_plugins[i];
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
index f30303c83..42df69b09 100644
--- a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
+++ b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
@@ -27,6 +27,7 @@
#define PluginInfoStore_h
#include "PluginModuleInfo.h"
+#include <wtf/ThreadingPrimitives.h>
namespace WebCore {
class KURL;
@@ -87,6 +88,8 @@ private:
Vector<String> m_additionalPluginsDirectories;
Vector<PluginModuleInfo> m_plugins;
bool m_pluginListIsUpToDate;
+
+ mutable Mutex m_pluginsLock;
};
} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp b/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp
index 653c72965..fa9339d09 100644
--- a/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp
+++ b/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp
@@ -31,6 +31,7 @@
#include "PluginProcessCreationParameters.h"
#include "ProcessExecutablePath.h"
#include <WebCore/FileSystem.h>
+#include <WebCore/GOwnPtrGtk.h>
#include <glib.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
@@ -54,8 +55,8 @@ bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData&
argv[3] = 0;
gint status;
- gchar* stdOut;
- if (!g_spawn_sync(0, argv, 0, G_SPAWN_STDERR_TO_DEV_NULL, 0, 0, &stdOut, 0, &status, 0))
+ GOwnPtr<gchar> stdOut;
+ if (!g_spawn_sync(0, argv, 0, G_SPAWN_STDERR_TO_DEV_NULL, 0, 0, &stdOut.outPtr(), 0, &status, 0))
return false;
if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS)
return false;
@@ -63,7 +64,7 @@ bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData&
const unsigned kNumLinesExpected = 3;
String lines[kNumLinesExpected];
unsigned lineIndex = 0;
- const UChar* current = reinterpret_cast<const UChar*>(stdOut);
+ const UChar* current = reinterpret_cast<const UChar*>(stdOut.get());
while (lineIndex < kNumLinesExpected) {
const UChar* start = current;
while (*current++ != UChar('\n')) { }
diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
index 7a04b5355..8688cfa79 100644
--- a/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
+++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
@@ -73,7 +73,13 @@ Vector<String> PluginInfoStore::individualPluginPaths()
bool PluginInfoStore::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
{
+#if ENABLE(NETSCAPE_PLUGIN_API)
return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+#else
+ UNUSED_PARAM(pluginPath);
+ UNUSED_PARAM(plugin);
+ return false;
+#endif
}
bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
diff --git a/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp b/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp
index caecf7942..aa44998d1 100644
--- a/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp
+++ b/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp
@@ -95,7 +95,13 @@ Vector<String> PluginInfoStore::individualPluginPaths()
bool PluginInfoStore::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
{
+#if ENABLE(NETSCAPE_PLUGIN_API)
return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+#else
+ UNUSED_PARAM(pluginPath);
+ UNUSED_PARAM(plugin);
+ return false;
+#endif
}
bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
diff --git a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp
index 78d0562d9..634225eaf 100644
--- a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp
+++ b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp
@@ -325,7 +325,13 @@ static uint64_t fileVersion(DWORD leastSignificant, DWORD mostSignificant)
bool PluginInfoStore::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
{
+#if ENABLE(NETSCAPE_PLUGIN_API)
return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+#else
+ UNUSED_PARAM(pluginPath);
+ UNUSED_PARAM(plugin);
+ return false;
+#endif
}
static bool isOldWindowsMediaPlayerPlugin(const PluginModuleInfo& plugin)