Chromium Code Reviews| Index: webkit/glue/plugins/plugin_lib_linux.cc |
| diff --git a/webkit/glue/plugins/plugin_lib_linux.cc b/webkit/glue/plugins/plugin_lib_linux.cc |
| index 47d6ebf2896d789813595a443f4caa5dcbb00870..e3a5c07b2497932fdba0242e1b7c14dcd71b453f 100644 |
| --- a/webkit/glue/plugins/plugin_lib_linux.cc |
| +++ b/webkit/glue/plugins/plugin_lib_linux.cc |
| @@ -6,6 +6,9 @@ |
| #include "webkit/glue/plugins/plugin_lib.h" |
| +#include <dlfcn.h> |
| +#include <errno.h> |
| + |
| #include "base/string_util.h" |
| #include "base/sys_string_conversions.h" |
| #include "webkit/glue/plugins/plugin_list.h" |
| @@ -15,21 +18,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 +44,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); |
|
jam
2009/01/23 01:54:10
I'm not sure you want to do this. On Windows at l
|
| + 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; |
| } |