OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "webkit/glue/plugins/plugin_lib.h" | 7 #include "webkit/glue/plugins/plugin_lib.h" |
8 | 8 |
9 #include <dlfcn.h> | |
10 #include <errno.h> | |
11 | |
9 #include "base/string_util.h" | 12 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
11 #include "webkit/glue/plugins/plugin_list.h" | 14 #include "webkit/glue/plugins/plugin_list.h" |
12 | 15 |
13 namespace NPAPI { | 16 namespace NPAPI { |
14 | 17 |
15 // static | 18 // static |
16 PluginLib::NativeLibrary PluginLib::LoadNativeLibrary( | 19 PluginLib::NativeLibrary PluginLib::LoadNativeLibrary( |
17 const FilePath& library_path) { | 20 const FilePath& library_path) { |
18 NOTIMPLEMENTED(); | 21 void* dl = dlopen(library_path.value().c_str(), RTLD_LAZY); |
19 return NULL; | 22 if (!dl) |
23 NOTREACHED() << "dlopen failed: " << strerror(errno); | |
24 | |
25 return dl; | |
20 } | 26 } |
21 | 27 |
22 // static | 28 // static |
23 void PluginLib::UnloadNativeLibrary(NativeLibrary library) { | 29 void PluginLib::UnloadNativeLibrary(NativeLibrary library) { |
24 NOTIMPLEMENTED(); | 30 int ret = dlclose(library); |
31 if (ret < 0) | |
32 NOTREACHED() << "dlclose failed: " << strerror(errno); | |
25 } | 33 } |
26 | 34 |
27 // static | 35 // static |
28 void* PluginLib::GetFunctionPointerFromNativeLibrary( | 36 void* PluginLib::GetFunctionPointerFromNativeLibrary( |
29 NativeLibrary library, | 37 NativeLibrary library, |
30 NativeLibraryFunctionNameType name) { | 38 NativeLibraryFunctionNameType name) { |
31 NOTIMPLEMENTED(); | 39 return dlsym(library, name); |
32 return NULL; | |
33 } | 40 } |
34 | 41 |
35 bool PluginLib::ReadWebPluginInfo(const FilePath& filename, | 42 bool PluginLib::ReadWebPluginInfo(const FilePath& filename, |
36 WebPluginInfo* info, | 43 WebPluginInfo* info, |
37 NP_GetEntryPointsFunc* np_getentrypoints, | 44 NP_GetEntryPointsFunc* np_getentrypoints, |
38 NP_InitializeFunc* np_initialize, | 45 NP_InitializeFunc* np_initialize, |
39 NP_ShutdownFunc* np_shutdown) { | 46 NP_ShutdownFunc* np_shutdown) { |
47 // The file to reference is: | |
48 // http://mxr.mozilla.org/firefox/source/modules/plugin/base/src/nsPluginsDirU nix.cpp | |
49 | |
40 *np_getentrypoints = NULL; | 50 *np_getentrypoints = NULL; |
41 *np_initialize = NULL; | 51 *np_initialize = NULL; |
42 *np_shutdown = NULL; | 52 *np_shutdown = NULL; |
43 | 53 |
54 void* dl = LoadNativeLibrary(filename); | |
55 if (!dl) | |
56 return false; | |
57 | |
58 void* ns_get_factory = GetFunctionPointerFromNativeLibrary(dl, | |
59 "NSGetFactory"); | |
60 | |
61 if (ns_get_factory) { | |
62 // Mozilla calls this an "almost-new-style plugin", then proceeds to | |
63 // poke at it via XPCOM. Our testing plugin doesn't use it. | |
64 NOTIMPLEMENTED() << ": " << filename.value() | |
65 << " is an \"almost-new-style plugin\"."; | |
66 UnloadNativeLibrary(dl); | |
jam
2009/01/23 01:54:10
I'm not sure you want to do this. On Windows at l
| |
67 return false; | |
68 } | |
69 | |
70 // See comments in plugin_lib_mac regarding this symbol. | |
71 typedef const char* (*GetMimeDescriptionType)(); | |
72 GetMimeDescriptionType ns_get_mime_description = | |
73 reinterpret_cast<GetMimeDescriptionType>( | |
74 GetFunctionPointerFromNativeLibrary(dl, "NP_GetMIMEDescription")); | |
75 const char* description = ""; | |
76 if (ns_get_mime_description) | |
77 description = ns_get_mime_description(); | |
78 | |
79 // TODO(port): pick up from here. | |
80 LOG(INFO) << description; | |
81 NOTIMPLEMENTED(); | |
82 UnloadNativeLibrary(dl); | |
44 return false; | 83 return false; |
45 } | 84 } |
46 | 85 |
47 } // namespace NPAPI | 86 } // namespace NPAPI |
OLD | NEW |