diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-28 15:13:10 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-28 15:13:10 +0000 |
commit | 8cc9dd62ea7a7d60ce5486fbd62baf9266fa0f15 (patch) | |
tree | 2c8b16963720b487ff79da260c4789891df4bd99 /chrome | |
parent | 241a4f1e1c2164ae31b37cec47ffde2e0c71aed8 (diff) | |
download | chromium_src-8cc9dd62ea7a7d60ce5486fbd62baf9266fa0f15.zip chromium_src-8cc9dd62ea7a7d60ce5486fbd62baf9266fa0f15.tar.gz chromium_src-8cc9dd62ea7a7d60ce5486fbd62baf9266fa0f15.tar.bz2 |
Add in support for internal pepper plugins into the PepperPluginRegistry and pepper::PluginModule.
Used Chromoting's plugin as the first attempt at using this interface.
BUG=none
TEST=compiles
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=50667
Review URL: http://codereview.chromium.org/2843018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/chrome_common.gypi | 5 | ||||
-rw-r--r-- | chrome/common/DEPS | 1 | ||||
-rw-r--r-- | chrome/common/pepper_plugin_registry.cc | 66 | ||||
-rw-r--r-- | chrome/common/pepper_plugin_registry.h | 11 |
4 files changed, 81 insertions, 2 deletions
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index 9e5e562..31572eb 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -311,6 +311,11 @@ 'common/sandbox_policy.cc', ], }], + ['remoting==1', { + 'dependencies': [ + '../remoting/remoting.gyp:chromoting_plugin', + ], + }], ], 'export_dependent_settings': [ '../app/app.gyp:app_base', diff --git a/chrome/common/DEPS b/chrome/common/DEPS index c3db484..75629ca 100644 --- a/chrome/common/DEPS +++ b/chrome/common/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+grit", # For generated headers "+libxml", "+media/audio", + "+remoting/client/plugin", "+sandbox/src", "+skia/include", "+webkit/default_plugin", diff --git a/chrome/common/pepper_plugin_registry.cc b/chrome/common/pepper_plugin_registry.cc index 0a23eca..e7771c4 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); diff --git a/chrome/common/pepper_plugin_registry.h b/chrome/common/pepper_plugin_registry.h index 940a1ba..9949ed4 100644 --- a/chrome/common/pepper_plugin_registry.h +++ b/chrome/common/pepper_plugin_registry.h @@ -7,11 +7,12 @@ #include <string> #include <map> +#include <vector> #include "webkit/glue/plugins/pepper_plugin_module.h" struct PepperPluginInfo { - FilePath path; + FilePath path; // Internal plugins are of the form "internal-[name]". std::vector<std::string> mime_types; }; @@ -28,6 +29,14 @@ class PepperPluginRegistry { pepper::PluginModule* GetModule(const FilePath& path) const; private: + static void GetPluginInfoFromSwitch(std::vector<PepperPluginInfo>* plugins); + + struct InternalPluginInfo : public PepperPluginInfo { + pepper::PluginModule::EntryPoints entry_points; + }; + typedef std::vector<InternalPluginInfo> InternalPluginInfoList; + static void GetInternalPluginInfo(InternalPluginInfoList* plugin_info); + PepperPluginRegistry(); typedef scoped_refptr<pepper::PluginModule> ModuleHandle; |