Split PepperPluginRegistry into the pieces that are needed in each process. content/common only needed a simple method to get the list of pepper plugins. The zygote specific method moves to content/zygote. The rest moves to content/renderer, as that has dependencies on the pepper implementation which depends on blink.
BUG=263054
[email protected]
Review URL: https://codereview.chromium.org/20172004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213593 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc
index dcea4c0..0df288f 100644
--- a/content/zygote/zygote_main_linux.cc
+++ b/content/zygote/zygote_main_linux.cc
@@ -20,6 +20,7 @@
#include "base/files/file_path.h"
#include "base/linux_util.h"
#include "base/memory/scoped_ptr.h"
+#include "base/native_library.h"
#include "base/pickle.h"
#include "base/posix/eintr_wrapper.h"
#include "base/posix/unix_domain_socket_linux.h"
@@ -28,11 +29,12 @@
#include "base/sys_info.h"
#include "build/build_config.h"
#include "content/common/font_config_ipc_linux.h"
-#include "content/common/pepper_plugin_registry.h"
+#include "content/common/pepper_plugin_list.h"
#include "content/common/sandbox_linux.h"
#include "content/common/zygote_commands_linux.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
+#include "content/public/common/pepper_plugin_info.h"
#include "content/public/common/sandbox_linux.h"
#include "content/public/common/zygote_fork_delegate_linux.h"
#include "content/zygote/zygote_linux.h"
@@ -249,6 +251,27 @@
}
}
+#if defined(ENABLE_PLUGINS)
+// Loads the (native) libraries but does not initialize them (i.e., does not
+// call PPP_InitializeModule). This is needed by the zygote on Linux to get
+// access to the plugins before entering the sandbox.
+void PreloadPepperPlugins() {
+ std::vector<PepperPluginInfo> plugins;
+ ComputePepperPluginList(&plugins);
+ for (size_t i = 0; i < plugins.size(); ++i) {
+ if (!plugins[i].is_internal && plugins[i].is_sandboxed) {
+ std::string error;
+ base::NativeLibrary library = base::LoadNativeLibrary(plugins[i].path,
+ &error);
+ DLOG_IF(WARNING, !library) << "Unable to load plugin "
+ << plugins[i].path.value() << " "
+ << error;
+ (void)library; // Prevent release-mode warning.
+ }
+ }
+}
+#endif
+
// This function triggers the static and lazy construction of objects that need
// to be created before imposing the sandbox.
static void PreSandboxInit() {
@@ -277,7 +300,7 @@
#endif
#if defined(ENABLE_PLUGINS)
// Ensure access to the Pepper plugins before the sandbox is turned on.
- PepperPluginRegistry::PreloadModules();
+ PreloadPepperPlugins();
#endif
#if defined(ENABLE_WEBRTC)
InitializeWebRtcModule();