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

Unified Diff: content/renderer/pepper/pepper_plugin_registry.cc

Issue 20172004: Split PepperPluginRegistry into the pieces that are needed in each process. content/common only nee… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 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 | « content/renderer/pepper/pepper_plugin_registry.h ('k') | content/renderer/pepper/plugin_module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/pepper_plugin_registry.cc
===================================================================
--- content/renderer/pepper/pepper_plugin_registry.cc (revision 213578)
+++ content/renderer/pepper/pepper_plugin_registry.cc (working copy)
@@ -2,108 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/pepper_plugin_registry.h"
+#include "content/renderer/pepper/pepper_plugin_registry.h"
-#include "base/command_line.h"
-#include "base/native_library.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "content/public/common/content_client.h"
-#include "content/public/common/content_switches.h"
+#include "base/logging.h"
+#include "content/common/pepper_plugin_list.h"
+#include "content/renderer/pepper/plugin_module.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
namespace content {
-namespace {
-// Appends any plugins from the command line to the given vector.
-void ComputePluginsFromCommandLine(std::vector<PepperPluginInfo>* plugins) {
- bool out_of_process = true;
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiInProcess))
- out_of_process = false;
-
- const std::string value =
- CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kRegisterPepperPlugins);
- if (value.empty())
- return;
-
- // FORMAT:
- // command-line = <plugin-entry> + *( LWS + "," + LWS + <plugin-entry> )
- // plugin-entry =
- // <file-path> +
- // ["#" + <name> + ["#" + <description> + ["#" + <version>]]] +
- // *1( LWS + ";" + LWS + <mime-type> )
- std::vector<std::string> modules;
- base::SplitString(value, ',', &modules);
- for (size_t i = 0; i < modules.size(); ++i) {
- std::vector<std::string> parts;
- base::SplitString(modules[i], ';', &parts);
- if (parts.size() < 2) {
- DLOG(ERROR) << "Required mime-type not found";
- continue;
- }
-
- std::vector<std::string> name_parts;
- base::SplitString(parts[0], '#', &name_parts);
-
- PepperPluginInfo plugin;
- plugin.is_out_of_process = out_of_process;
-#if defined(OS_WIN)
- // This means we can't provide plugins from non-ASCII paths, but
- // since this switch is only for development I don't think that's
- // too awful.
- plugin.path = base::FilePath(ASCIIToUTF16(name_parts[0]));
-#else
- plugin.path = base::FilePath(name_parts[0]);
-#endif
- if (name_parts.size() > 1)
- plugin.name = name_parts[1];
- if (name_parts.size() > 2)
- plugin.description = name_parts[2];
- if (name_parts.size() > 3)
- plugin.version = name_parts[3];
- for (size_t j = 1; j < parts.size(); ++j) {
- WebPluginMimeType mime_type(parts[j],
- std::string(),
- plugin.description);
- plugin.mime_types.push_back(mime_type);
- }
-
- // If the plugin name is empty, use the filename.
- if (plugin.name.empty())
- plugin.name = UTF16ToUTF8(plugin.path.BaseName().LossyDisplayName());
-
- // Command-line plugins get full permissions.
- plugin.permissions = ppapi::PERMISSION_ALL_BITS;
-
- plugins->push_back(plugin);
- }
-}
-
-} // namespace
-
-bool MakePepperPluginInfo(const WebPluginInfo& webplugin_info,
- PepperPluginInfo* pepper_info) {
- if (!webplugin_info.is_pepper_plugin())
- return false;
-
- pepper_info->is_out_of_process =
- webplugin_info.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS ||
- webplugin_info.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED;
- pepper_info->is_sandboxed = webplugin_info.type !=
- WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED;
-
- pepper_info->path = base::FilePath(webplugin_info.path);
- pepper_info->name = UTF16ToASCII(webplugin_info.name);
- pepper_info->description = UTF16ToASCII(webplugin_info.desc);
- pepper_info->version = UTF16ToASCII(webplugin_info.version);
- pepper_info->mime_types = webplugin_info.mime_types;
- pepper_info->permissions = webplugin_info.pepper_permissions;
-
- return true;
-}
-
// static
PepperPluginRegistry* PepperPluginRegistry::GetInstance() {
static PepperPluginRegistry* registry = NULL;
@@ -114,29 +21,6 @@
return registry;
}
-// static
-void PepperPluginRegistry::ComputeList(std::vector<PepperPluginInfo>* plugins) {
- GetContentClient()->AddPepperPlugins(plugins);
- ComputePluginsFromCommandLine(plugins);
-}
-
-// static
-void PepperPluginRegistry::PreloadModules() {
- std::vector<PepperPluginInfo> plugins;
- ComputeList(&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.
- }
- }
-}
-
const PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin(
const WebPluginInfo& info) {
for (size_t i = 0; i < plugin_list_.size(); ++i) {
@@ -197,7 +81,7 @@
}
PepperPluginRegistry::PepperPluginRegistry() {
- ComputeList(&plugin_list_);
+ ComputePepperPluginList(&plugin_list_);
// Note that in each case, AddLiveModule must be called before completing
// initialization. If we bail out (in the continue clauses) before saving
« no previous file with comments | « content/renderer/pepper/pepper_plugin_registry.h ('k') | content/renderer/pepper/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698