diff options
-rw-r--r-- | webkit/glue/plugins/plugin_lib_linux.cc | 84 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_list_linux.cc | 7 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_gtk.cc | 5 |
3 files changed, 64 insertions, 32 deletions
diff --git a/webkit/glue/plugins/plugin_lib_linux.cc b/webkit/glue/plugins/plugin_lib_linux.cc index 8ee5178..6217a82 100644 --- a/webkit/glue/plugins/plugin_lib_linux.cc +++ b/webkit/glue/plugins/plugin_lib_linux.cc @@ -7,13 +7,16 @@ #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" +// These headers must be included in this order to make the declaration gods +// happy. +#include "base/third_party/nspr/prcpucfg_linux.h" +#include "third_party/mozilla/include/nsplugindefs.h" + namespace NPAPI { // static @@ -21,7 +24,7 @@ PluginLib::NativeLibrary PluginLib::LoadNativeLibrary( const FilePath& library_path) { void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY); if (!dl) - NOTREACHED() << "dlopen failed: " << strerror(errno); + NOTREACHED() << "dlopen failed: " << dlerror(); return dl; } @@ -30,7 +33,7 @@ PluginLib::NativeLibrary PluginLib::LoadNativeLibrary( void PluginLib::UnloadNativeLibrary(NativeLibrary library) { int ret = dlclose(library); if (ret < 0) - NOTREACHED() << "dlclose failed: " << strerror(errno); + NOTREACHED() << "dlclose failed: " << dlerror(); } // static @@ -56,32 +59,59 @@ bool PluginLib::ReadWebPluginInfo(const FilePath& filename, if (!dl) return false; - void* ns_get_factory = GetFunctionPointerFromNativeLibrary(dl, - "NSGetFactory"); + info->path = filename; - 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* (*NP_GetMimeDescriptionType)(); + NP_GetMimeDescriptionType NP_GetMIMEDescription = + reinterpret_cast<NP_GetMimeDescriptionType>( + dlsym(dl, "NP_GetMIMEDescription")); + const char* mime_description = NULL; + if (NP_GetMIMEDescription) + mime_description = NP_GetMIMEDescription(); + + if (mime_description) { + // We parse the description here into WebPluginMimeType structures. + // Description for Flash 10 looks like (all as one string): + // "application/x-shockwave-flash:swf:Shockwave Flash;" + // "application/futuresplash:spl:FutureSplash Player" + std::vector<std::string> descriptions; + SplitString(mime_description, ';', &descriptions); + for (size_t i = 0; i < descriptions.size(); ++i) { + std::vector<std::string> fields; + SplitString(descriptions[i], ':', &fields); + if (fields.size() != 3) { + LOG(WARNING) << "Couldn't parse plugin info: " << descriptions[i]; + continue; + } + + WebPluginMimeType mime_type; + mime_type.mime_type = fields[0]; + SplitString(fields[1], ',', &mime_type.file_extensions); + mime_type.description = ASCIIToWide(fields[2]); + info->mime_types.push_back(mime_type); + } } - // 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; + // The plugin name and description live behind NP_GetValue calls. + typedef NPError (*NP_GetValueType)(void* unused, + nsPluginVariable variable, + void* value_out); + NP_GetValueType NP_GetValue = + reinterpret_cast<NP_GetValueType>(dlsym(dl, "NP_GetValue")); + if (NP_GetValue) { + const char* name = NULL; + NP_GetValue(NULL, nsPluginVariable_NameString, &name); + if (name) + info->name = ASCIIToWide(name); + + const char* description = NULL; + NP_GetValue(NULL, nsPluginVariable_DescriptionString, &description); + if (description) + info->desc = ASCIIToWide(description); + } + + return true; } } // namespace NPAPI diff --git a/webkit/glue/plugins/plugin_list_linux.cc b/webkit/glue/plugins/plugin_list_linux.cc index 3653a0c..efbd6a6 100644 --- a/webkit/glue/plugins/plugin_list_linux.cc +++ b/webkit/glue/plugins/plugin_list_linux.cc @@ -35,7 +35,12 @@ void PluginList::LoadPluginsFromDir(const FilePath& path) { } bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info) { - NOTIMPLEMENTED(); + // The equivalent Windows code verifies we haven't loaded a newer version + // of the same plugin, and then blacklists some known bad plugins. + // The equivalent Mac code verifies that plugins encountered first in the + // plugin list clobber later entries. + // TODO(evanm): figure out which behavior is appropriate for Linux. + // We don't need either yet as I'm just testing with Flash for now. return true; } diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 4d8b908..d910329 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -657,10 +657,7 @@ std::string GetDataResource(int resource_id) { } bool GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins) { - // TODO(port): Implement plugins someday. Don't let the error message - // of NOTIMPLEMENTED into our layout test diffs. - // NOTIMPLEMENTED(); - return false; + return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); } } // namespace webkit_glue |