summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/plugin_lib_linux.cc50
1 files changed, 45 insertions, 5 deletions
diff --git a/webkit/glue/plugins/plugin_lib_linux.cc b/webkit/glue/plugins/plugin_lib_linux.cc
index 47d6ebf..8ee5178 100644
--- a/webkit/glue/plugins/plugin_lib_linux.cc
+++ b/webkit/glue/plugins/plugin_lib_linux.cc
@@ -6,6 +6,10 @@
#include "webkit/glue/plugins/plugin_lib.h"
+#include <dlfcn.h>
+#include <errno.h>
+#include <string.h>
+
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "webkit/glue/plugins/plugin_list.h"
@@ -15,21 +19,25 @@ namespace NPAPI {
// static
PluginLib::NativeLibrary PluginLib::LoadNativeLibrary(
const FilePath& library_path) {
- NOTIMPLEMENTED();
- return NULL;
+ void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY);
+ if (!dl)
+ NOTREACHED() << "dlopen failed: " << strerror(errno);
+
+ return dl;
}
// static
void PluginLib::UnloadNativeLibrary(NativeLibrary library) {
- NOTIMPLEMENTED();
+ int ret = dlclose(library);
+ if (ret < 0)
+ NOTREACHED() << "dlclose failed: " << strerror(errno);
}
// static
void* PluginLib::GetFunctionPointerFromNativeLibrary(
NativeLibrary library,
NativeLibraryFunctionNameType name) {
- NOTIMPLEMENTED();
- return NULL;
+ return dlsym(library, name);
}
bool PluginLib::ReadWebPluginInfo(const FilePath& filename,
@@ -37,10 +45,42 @@ bool PluginLib::ReadWebPluginInfo(const FilePath& filename,
NP_GetEntryPointsFunc* np_getentrypoints,
NP_InitializeFunc* np_initialize,
NP_ShutdownFunc* np_shutdown) {
+ // The file to reference is:
+ // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginsDirUnix.cpp
+
*np_getentrypoints = NULL;
*np_initialize = NULL;
*np_shutdown = NULL;
+ void* dl = LoadNativeLibrary(filename);
+ if (!dl)
+ return false;
+
+ void* ns_get_factory = GetFunctionPointerFromNativeLibrary(dl,
+ "NSGetFactory");
+
+ if (ns_get_factory) {
+ // Mozilla calls this an "almost-new-style plugin", then proceeds to
+ // poke at it via XPCOM. Our testing plugin doesn't use it.
+ NOTIMPLEMENTED() << ": " << filename.value()
+ << " is an \"almost-new-style plugin\".";
+ UnloadNativeLibrary(dl);
+ return false;
+ }
+
+ // See comments in plugin_lib_mac regarding this symbol.
+ typedef const char* (*GetMimeDescriptionType)();
+ GetMimeDescriptionType ns_get_mime_description =
+ reinterpret_cast<GetMimeDescriptionType>(
+ GetFunctionPointerFromNativeLibrary(dl, "NP_GetMIMEDescription"));
+ const char* description = "";
+ if (ns_get_mime_description)
+ description = ns_get_mime_description();
+
+ // TODO(port): pick up from here.
+ LOG(INFO) << description;
+ NOTIMPLEMENTED();
+ UnloadNativeLibrary(dl);
return false;
}