summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 14:55:53 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-28 14:55:53 +0000
commit4e0616edf0c949858b67859b6f27a0c573425988 (patch)
tree5ca36e9ca74c06a96d0c37fd0957091b9bf10408 /chrome/common
parent0298a21bc8ad80bd7b1cb09ce6d5711e5f698348 (diff)
downloadchromium_src-4e0616edf0c949858b67859b6f27a0c573425988.zip
chromium_src-4e0616edf0c949858b67859b6f27a0c573425988.tar.gz
chromium_src-4e0616edf0c949858b67859b6f27a0c573425988.tar.bz2
Add ppapi plugins to about:plugins
Querying the plugin path and actual mime type is moved from creation of the WebPluginDelegate to creation of the WebPlugin. This cleaned up some code. R=jam BUG=45289 TEST=none Review URL: http://codereview.chromium.org/2262002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/pepper_plugin_registry.cc67
-rw-r--r--chrome/common/pepper_plugin_registry.h38
2 files changed, 105 insertions, 0 deletions
diff --git a/chrome/common/pepper_plugin_registry.cc b/chrome/common/pepper_plugin_registry.cc
new file mode 100644
index 0000000..0a23eca
--- /dev/null
+++ b/chrome/common/pepper_plugin_registry.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/pepper_plugin_registry.h"
+
+#include "base/command_line.h"
+#include "base/string_util.h"
+#include "chrome/common/chrome_switches.h"
+
+// static
+PepperPluginRegistry* PepperPluginRegistry::GetInstance() {
+ static PepperPluginRegistry registry;
+ return &registry;
+}
+
+// static
+void PepperPluginRegistry::GetList(std::vector<PepperPluginInfo>* plugins) {
+ const std::wstring& value = CommandLine::ForCurrentProcess()->GetSwitchValue(
+ switches::kRegisterPepperPlugins);
+ if (value.empty())
+ return;
+
+ // FORMAT:
+ // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> )
+ // plugin-entry = <file-path> + *1( LWS + ";" + LWS + <mime-type> )
+
+ std::vector<std::wstring> modules;
+ SplitString(value, ',', &modules);
+ for (size_t i = 0; i < modules.size(); ++i) {
+ std::vector<std::wstring> parts;
+ SplitString(modules[i], ';', &parts);
+ if (parts.size() < 2) {
+ DLOG(ERROR) << "Required mime-type not found";
+ continue;
+ }
+
+ PepperPluginInfo plugin;
+ plugin.path = FilePath::FromWStringHack(parts[0]);
+ for (size_t j = 1; j < parts.size(); ++j)
+ plugin.mime_types.push_back(WideToASCII(parts[j]));
+
+ plugins->push_back(plugin);
+ }
+}
+
+pepper::PluginModule* PepperPluginRegistry::GetModule(
+ const FilePath& path) const {
+ ModuleMap::const_iterator it = modules_.find(path);
+ if (it == modules_.end())
+ return NULL;
+ return it->second;
+}
+
+PepperPluginRegistry::PepperPluginRegistry() {
+ std::vector<PepperPluginInfo> plugins;
+ GetList(&plugins);
+ for (size_t i = 0; i < plugins.size(); ++i) {
+ const FilePath& path = plugins[i].path;
+ ModuleHandle module = pepper::PluginModule::CreateModule(path);
+ if (!module) {
+ DLOG(ERROR) << "Failed to load pepper module: " << path.value();
+ continue;
+ }
+ modules_[path] = module;
+ }
+}
diff --git a/chrome/common/pepper_plugin_registry.h b/chrome/common/pepper_plugin_registry.h
new file mode 100644
index 0000000..940a1ba
--- /dev/null
+++ b/chrome/common/pepper_plugin_registry.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_
+#define CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_
+
+#include <string>
+#include <map>
+
+#include "webkit/glue/plugins/pepper_plugin_module.h"
+
+struct PepperPluginInfo {
+ FilePath path;
+ std::vector<std::string> mime_types;
+};
+
+// This class holds references to all of the known pepper plugin modules.
+class PepperPluginRegistry {
+ public:
+ static PepperPluginRegistry* GetInstance();
+
+ // Returns the list of known pepper plugins. This method is static so that
+ // it can be used by the browser process, which has no need to load the
+ // pepper plugin modules.
+ static void GetList(std::vector<PepperPluginInfo>* plugins);
+
+ pepper::PluginModule* GetModule(const FilePath& path) const;
+
+ private:
+ PepperPluginRegistry();
+
+ typedef scoped_refptr<pepper::PluginModule> ModuleHandle;
+ typedef std::map<FilePath, ModuleHandle> ModuleMap;
+ ModuleMap modules_;
+};
+
+#endif // CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_