summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/plugin_lib.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-30 01:32:46 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-30 01:32:46 +0000
commit8674cdb422a69d1ab2b61ff88e61479a8430bec1 (patch)
treed4eba04aea00d9b8d6b24fe4eb086b280823ef3e /webkit/glue/plugins/plugin_lib.cc
parent0e6860191f3dd4b4bf00ef71336b72c63d319180 (diff)
downloadchromium_src-8674cdb422a69d1ab2b61ff88e61479a8430bec1.zip
chromium_src-8674cdb422a69d1ab2b61ff88e61479a8430bec1.tar.gz
chromium_src-8674cdb422a69d1ab2b61ff88e61479a8430bec1.tar.bz2
Rearrange plugin entry points code to abstract out Linux.
Review URL: http://codereview.chromium.org/19488 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins/plugin_lib.cc')
-rw-r--r--webkit/glue/plugins/plugin_lib.cc63
1 files changed, 35 insertions, 28 deletions
diff --git a/webkit/glue/plugins/plugin_lib.cc b/webkit/glue/plugins/plugin_lib.cc
index cae72ce..4298e65 100644
--- a/webkit/glue/plugins/plugin_lib.cc
+++ b/webkit/glue/plugins/plugin_lib.cc
@@ -37,15 +37,11 @@ PluginLib* PluginLib::CreatePluginLib(const FilePath& filename) {
}
WebPluginInfo info;
- NP_GetEntryPointsFunc np_getentrypoints;
- NP_InitializeFunc np_initialize;
- NP_ShutdownFunc np_shutdown;
- if (!PluginList::ReadPluginInfo(filename, &info, &np_getentrypoints,
- &np_initialize, &np_shutdown)) {
+ const PluginEntryPoints* entry_points = NULL;
+ if (!PluginList::ReadPluginInfo(filename, &info, &entry_points))
return NULL;
- }
- return new PluginLib(info, np_getentrypoints, np_initialize, np_shutdown);
+ return new PluginLib(info, entry_points);
}
void PluginLib::UnloadAllPlugins() {
@@ -66,9 +62,7 @@ void PluginLib::ShutdownAllPlugins() {
}
PluginLib::PluginLib(const WebPluginInfo& info,
- NP_GetEntryPointsFunc np_getentrypoints,
- NP_InitializeFunc np_initialize,
- NP_ShutdownFunc np_shutdown)
+ const PluginEntryPoints* entry_points)
: web_plugin_info_(info),
library_(0),
initialized_(false),
@@ -78,13 +72,13 @@ PluginLib::PluginLib(const WebPluginInfo& info,
memset((void*)&plugin_funcs_, 0, sizeof(plugin_funcs_));
g_loaded_libs->push_back(this);
- if (np_getentrypoints && np_initialize && np_shutdown) {
+ if (entry_points) {
internal_ = true;
- NP_GetEntryPoints_ = np_getentrypoints;
- NP_Initialize_ = np_initialize;
- NP_Shutdown_ = np_shutdown;
+ entry_points_ = *entry_points;
} else {
internal_ = false;
+ // We will read the entry points from the plugin directly.
+ memset(&entry_points_, 0, sizeof(entry_points_));
}
}
@@ -110,14 +104,19 @@ NPError PluginLib::NP_Initialize() {
if (host == 0)
return NPERR_GENERIC_ERROR;
- NPError rv = NP_Initialize_(host->host_functions());
+#if defined(OS_LINUX)
+ NPError rv = entry_points_.np_initialize(host->host_functions(),
+ &plugin_funcs_);
+#else
+ NPError rv = entry_points_.np_initialize(host->host_functions());
+#endif
initialized_ = (rv == NPERR_NO_ERROR);
return rv;
}
void PluginLib::NP_Shutdown(void) {
DCHECK(initialized_);
- NP_Shutdown_();
+ entry_points_.np_shutdown();
}
PluginInstance* PluginLib::CreateInstance(const std::string& mime_type) {
@@ -163,20 +162,24 @@ bool PluginLib::Load() {
rv = true; // assume success now
- NP_Initialize_ = (NP_InitializeFunc)GetFunctionPointerFromNativeLibrary(
- library, FUNCTION_NAME("NP_Initialize"));
- if (NP_Initialize_ == 0)
+ entry_points_.np_initialize =
+ (NP_InitializeFunc)GetFunctionPointerFromNativeLibrary(library,
+ FUNCTION_NAME("NP_Initialize"));
+ if (entry_points_.np_initialize == 0)
rv = false;
- NP_GetEntryPoints_ =
- (NP_GetEntryPointsFunc)GetFunctionPointerFromNativeLibrary(
- library, FUNCTION_NAME("NP_GetEntryPoints"));
- if (NP_GetEntryPoints_ == 0)
+#if !defined(OS_LINUX)
+ entry_points_.np_getentrypoints =
+ (NP_GetEntryPointsFunc)GetFunctionPointerFromNativeLibrary(library,
+ FUNCTION_NAME("NP_GetEntryPoints"));
+ if (entry_points_.np_getentrypoints == 0)
rv = false;
+#endif
- NP_Shutdown_ = (NP_ShutdownFunc)GetFunctionPointerFromNativeLibrary(
- library, FUNCTION_NAME("NP_Shutdown"));
- if (NP_Shutdown_ == 0)
+ entry_points_.np_shutdown =
+ (NP_ShutdownFunc)GetFunctionPointerFromNativeLibrary(library,
+ FUNCTION_NAME("NP_Shutdown"));
+ if (entry_points_.np_shutdown == 0)
rv = false;
} else {
rv = true;
@@ -185,8 +188,12 @@ bool PluginLib::Load() {
if (rv) {
plugin_funcs_.size = sizeof(plugin_funcs_);
plugin_funcs_.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
- if (NP_GetEntryPoints_(&plugin_funcs_) != NPERR_NO_ERROR)
+#if !defined(OS_LINUX)
+ if (entry_points_.np_getentrypoints(&plugin_funcs_) != NPERR_NO_ERROR)
rv = false;
+#else
+ // On Linux, we get the plugin entry points during NP_Initialize.
+#endif
}
if (!internal_) {
@@ -242,7 +249,7 @@ void PluginLib::Unload() {
if (defer_unload) {
FreePluginLibraryTask* free_library_task =
- new FreePluginLibraryTask(library_, NP_Shutdown_);
+ new FreePluginLibraryTask(library_, entry_points_.np_shutdown);
MessageLoop::current()->PostTask(FROM_HERE, free_library_task);
} else {
Shutdown();