Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: webkit/glue/plugins/plugin_lib_linux.cc

Issue 18539: Loads and unloads .so files. (Closed)
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698