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

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

Issue 19625: Add support for dynamically loading internal plugins (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
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 | « webkit/glue/plugins/plugin_lib.h ('k') | webkit/glue/plugins/plugin_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/plugin_lib_win.cc
===================================================================
--- webkit/glue/plugins/plugin_lib_win.cc (revision 8751)
+++ webkit/glue/plugins/plugin_lib_win.cc (working copy)
@@ -7,6 +7,7 @@
#include "webkit/glue/plugins/plugin_lib.h"
#include "base/file_version_info.h"
+#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "webkit/activex_shim/npp_impl.h"
#include "webkit/default_plugin/plugin_main.h"
@@ -23,60 +24,9 @@
namespace NPAPI
{
-static const PluginVersionInfo g_internal_plugins[] = {
- {
- kActiveXShimFileName,
- L"ActiveX Plug-in",
- L"ActiveX Plug-in provides a shim to support ActiveX controls",
- L"1, 0, 0, 1",
- L"application/x-oleobject|application/oleobject",
- L"*|*",
- L"",
- activex_shim::ActiveX_Shim_NP_GetEntryPoints,
- activex_shim::ActiveX_Shim_NP_Initialize,
- activex_shim::ActiveX_Shim_NP_Shutdown
- },
- {
- kActiveXShimFileNameForMediaPlayer,
- kActiveXShimFileNameForMediaPlayer,
- L"Windows Media Player",
- L"1, 0, 0, 1",
- L"application/x-ms-wmp|application/asx|video/x-ms-asf-plugin|"
- L"application/x-mplayer2|video/x-ms-asf|video/x-ms-wm|audio/x-ms-wma|"
- L"audio/x-ms-wax|video/x-ms-wmv|video/x-ms-wvx",
- L"*|*|*|*|asf,asx,*|wm,*|wma,*|wax,*|wmv,*|wvx,*",
- L"",
- activex_shim::ActiveX_Shim_NP_GetEntryPoints,
- activex_shim::ActiveX_Shim_NP_Initialize,
- activex_shim::ActiveX_Shim_NP_Shutdown
- },
- {
- kDefaultPluginLibraryName,
- L"Default Plug-in",
- L"Provides functionality for installing third-party plug-ins",
- L"1, 0, 0, 1",
- L"*",
- L"",
- L"",
- default_plugin::NP_GetEntryPoints,
- default_plugin::NP_Initialize,
- default_plugin::NP_Shutdown
- },
-#ifdef GEARS_STATIC_LIB
- {
- kGearsPluginLibraryName,
- L"Gears",
- L"Statically linked Gears",
- L"1, 0, 0, 1",
- L"application/x-googlegears",
- L"",
- L"",
- Gears_NP_GetEntryPoints,
- Gears_NP_Initialize,
- Gears_NP_Shutdown
- },
-#endif
-};
+// A list of all dynamically loaded internal plugins.
+base::LazyInstance<std::vector<PluginVersionInfo> > g_dynamic_internal_plugins(
+ base::LINKER_INITIALIZED);
/* static */
PluginLib::NativeLibrary PluginLib::LoadNativeLibrary(
@@ -112,16 +62,88 @@
return GetProcAddress(library, name);
}
+void PluginLib::RegisterInternalPlugin(const PluginVersionInfo& info) {
+ g_dynamic_internal_plugins.Pointer()->push_back(info);
+}
+
bool PluginLib::ReadWebPluginInfo(const FilePath &filename,
WebPluginInfo* info,
NP_GetEntryPointsFunc* np_getentrypoints,
NP_InitializeFunc* np_initialize,
NP_ShutdownFunc* np_shutdown) {
- for (int i = 0; i < arraysize(g_internal_plugins); ++i) {
- if (filename.value() == g_internal_plugins[i].path) {
- return CreateWebPluginInfo(g_internal_plugins[i], info, np_getentrypoints,
- np_initialize, np_shutdown);
+ static bool builtin_plugins_loaded = false;
+ if (!builtin_plugins_loaded) {
+ // The builtin plugins only need to be loaded one time
+ const PluginVersionInfo builtin_plugins[] = {
+ {
+ kActiveXShimFileName,
+ L"ActiveX Plug-in",
+ L"ActiveX Plug-in provides a shim to support ActiveX controls",
+ L"1, 0, 0, 1",
+ L"application/x-oleobject|application/oleobject",
+ L"*|*",
+ L"",
+ activex_shim::ActiveX_Shim_NP_GetEntryPoints,
+ activex_shim::ActiveX_Shim_NP_Initialize,
+ activex_shim::ActiveX_Shim_NP_Shutdown
+ },
+ {
+ kActiveXShimFileNameForMediaPlayer,
+ kActiveXShimFileNameForMediaPlayer,
+ L"Windows Media Player",
+ L"1, 0, 0, 1",
+ L"application/x-ms-wmp|application/asx|video/x-ms-asf-plugin|"
+ L"application/x-mplayer2|video/x-ms-asf|video/x-ms-wm|audio/x-ms-wma|"
+ L"audio/x-ms-wax|video/x-ms-wmv|video/x-ms-wvx",
+ L"*|*|*|*|asf,asx,*|wm,*|wma,*|wax,*|wmv,*|wvx,*",
+ L"",
+ activex_shim::ActiveX_Shim_NP_GetEntryPoints,
+ activex_shim::ActiveX_Shim_NP_Initialize,
+ activex_shim::ActiveX_Shim_NP_Shutdown
+ },
+ {
+ kDefaultPluginLibraryName,
+ L"Default Plug-in",
+ L"Provides functionality for installing third-party plug-ins",
+ L"1, 0, 0, 1",
+ L"*",
+ L"",
+ L"",
+ default_plugin::NP_GetEntryPoints,
+ default_plugin::NP_Initialize,
+ default_plugin::NP_Shutdown
+ },
+#ifdef GEARS_STATIC_LIB
+ {
+ kGearsPluginLibraryName,
+ L"Gears",
+ L"Statically linked Gears",
+ L"1, 0, 0, 1",
+ L"application/x-googlegears",
+ L"",
+ L"",
+ Gears_NP_GetEntryPoints,
+ Gears_NP_Initialize,
+ Gears_NP_Shutdown
+ },
+#endif
+ };
+
+ for (int i = 0; i < arraysize(builtin_plugins); ++i) {
+ RegisterInternalPlugin(builtin_plugins[i]);
}
+
+ builtin_plugins_loaded = true;
+ }
+
+ // Check for dynamically loaded internal plugins
+ std::vector<PluginVersionInfo>& internal_plugins =
+ *(g_dynamic_internal_plugins.Pointer());
+ for (size_t i = 0; i < internal_plugins.size(); ++i) {
+ if (filename.value() == internal_plugins[i].path) {
+ return CreateWebPluginInfo(internal_plugins[i], info, np_getentrypoints,
+ np_initialize, np_shutdown);
+ }
}
// On windows, the way we get the mime types for the library is
« no previous file with comments | « webkit/glue/plugins/plugin_lib.h ('k') | webkit/glue/plugins/plugin_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698