diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 01:45:13 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 01:45:13 +0000 |
commit | 3efc4679d44aa442d4ae35ed95dff3ef0cf5ded6 (patch) | |
tree | 0dbe7d2f261feef9ad6fcc86c807de2290d4b5a1 /webkit/glue/plugins | |
parent | f6ff74fbffed33d0ec390a61458ef6012881078f (diff) | |
download | chromium_src-3efc4679d44aa442d4ae35ed95dff3ef0cf5ded6.zip chromium_src-3efc4679d44aa442d4ae35ed95dff3ef0cf5ded6.tar.gz chromium_src-3efc4679d44aa442d4ae35ed95dff3ef0cf5ded6.tar.bz2 |
Linux plugin loader loads and unloads .so files.
Review URL: http://codereview.chromium.org/18539
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r-- | webkit/glue/plugins/plugin_lib_linux.cc | 50 |
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; } |