Index: chrome/common/pepper_plugin_registry.cc |
diff --git a/chrome/common/pepper_plugin_registry.cc b/chrome/common/pepper_plugin_registry.cc |
index 0a23ecaaa91346d5149f335922d6e178d2fc39b7..e7771c4b719861fa408ef1fb81a4d94af98380d7 100644 |
--- a/chrome/common/pepper_plugin_registry.cc |
+++ b/chrome/common/pepper_plugin_registry.cc |
@@ -7,6 +7,7 @@ |
#include "base/command_line.h" |
#include "base/string_util.h" |
#include "chrome/common/chrome_switches.h" |
+#include "remoting/client/plugin/pepper_entrypoints.h" |
// static |
PepperPluginRegistry* PepperPluginRegistry::GetInstance() { |
@@ -16,6 +17,21 @@ PepperPluginRegistry* PepperPluginRegistry::GetInstance() { |
// static |
void PepperPluginRegistry::GetList(std::vector<PepperPluginInfo>* plugins) { |
+ InternalPluginInfoList internal_plugin_info; |
+ GetInternalPluginInfo(&internal_plugin_info); |
+ for (InternalPluginInfoList::const_iterator it = |
+ internal_plugin_info.begin(); |
+ it != internal_plugin_info.end(); |
+ ++it) { |
+ plugins->push_back(*it); |
+ } |
+ |
+ GetPluginInfoFromSwitch(plugins); |
+} |
+ |
+// static |
+void PepperPluginRegistry::GetPluginInfoFromSwitch( |
+ std::vector<PepperPluginInfo>* plugins) { |
const std::wstring& value = CommandLine::ForCurrentProcess()->GetSwitchValue( |
switches::kRegisterPepperPlugins); |
if (value.empty()) |
@@ -44,6 +60,35 @@ void PepperPluginRegistry::GetList(std::vector<PepperPluginInfo>* plugins) { |
} |
} |
+// static |
+void PepperPluginRegistry::GetInternalPluginInfo( |
+ InternalPluginInfoList* plugin_info) { |
+ // Currently, to centralize the internal plugin registration logic, we |
+ // hardcode the list of plugins, mimetypes, and registration information |
+ // in this function. This is gross, but because the GetList() function is |
+ // called from both the renderer and browser the other option is to force a |
+ // special register function for each plugin to be called by both |
+ // RendererMain() and BrowserMain(). This seemed like the better tradeoff. |
+ // |
+ // TODO(ajwong): Think up a better way to maintain the plugin registration |
+ // information. Pehraps by construction of a singly linked list of |
+ // plugin initializers that is built with static initializers? |
+ |
+#if defined(ENABLE_REMOTING) |
+ InternalPluginInfo info; |
+ // Add the chromoting plugin. |
+ info.path = |
+ FilePath(FILE_PATH_LITERAL("internal-chromoting")); |
+ info.mime_types.push_back("pepper-application/x-chromoting"); |
+ info.entry_points.get_interface = remoting::PPP_GetInterface; |
+ info.entry_points.initialize_module = remoting::PPP_InitializeModule; |
+ info.entry_points.shutdown_module = remoting::PPP_ShutdownModule; |
+ |
+ plugin_info->push_back(info); |
+#endif |
+ |
+} |
+ |
pepper::PluginModule* PepperPluginRegistry::GetModule( |
const FilePath& path) const { |
ModuleMap::const_iterator it = modules_.find(path); |
@@ -53,8 +98,27 @@ pepper::PluginModule* PepperPluginRegistry::GetModule( |
} |
PepperPluginRegistry::PepperPluginRegistry() { |
+ InternalPluginInfoList internal_plugin_info; |
+ GetInternalPluginInfo(&internal_plugin_info); |
+ // Register modules for these suckers. |
+ for (InternalPluginInfoList::const_iterator it = |
+ internal_plugin_info.begin(); |
+ it != internal_plugin_info.end(); |
+ ++it) { |
+ const FilePath& path = it->path; |
+ ModuleHandle module = |
+ pepper::PluginModule::CreateInternalModule(it->entry_points); |
+ if (!module) { |
+ DLOG(ERROR) << "Failed to load pepper module: " << path.value(); |
+ continue; |
+ } |
+ modules_[path] = module; |
+ } |
+ |
+ // Add the modules specified on the command line last so that they can |
+ // override the internal plugins. |
std::vector<PepperPluginInfo> plugins; |
- GetList(&plugins); |
+ GetPluginInfoFromSwitch(&plugins); |
for (size_t i = 0; i < plugins.size(); ++i) { |
const FilePath& path = plugins[i].path; |
ModuleHandle module = pepper::PluginModule::CreateModule(path); |