chromeos: dbus: add Bluetooth properties support
[chromium-blink-merge.git] / content / common / pepper_plugin_registry.h
blobc6a664e9a8927cb57613577da6f5e5aecbee3f5f
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_
6 #define CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_
7 #pragma once
9 #include <list>
10 #include <map>
12 #include "content/public/common/pepper_plugin_info.h"
13 #include "webkit/plugins/ppapi/plugin_delegate.h"
15 // Constructs a PepperPluginInfo from a WebPluginInfo. Returns false if
16 // the operation is not possible, in particular the WebPluginInfo::type
17 // must be one of the pepper types.
18 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info,
19 content::PepperPluginInfo* pepper_info);
21 // This class holds references to all of the known pepper plugin modules.
23 // It keeps two lists. One list of preloaded in-process modules, and one list
24 // is a list of all live modules (some of which may be out-of-process and hence
25 // not preloaded).
26 class PepperPluginRegistry
27 : public webkit::ppapi::PluginDelegate::ModuleLifetime {
28 public:
29 ~PepperPluginRegistry();
31 static PepperPluginRegistry* GetInstance();
33 // Computes the list of known pepper plugins.
35 // This method is static so that it can be used by the browser process, which
36 // has no need to load the pepper plugin modules. It will re-compute the
37 // plugin list every time it is called. Generally, code in the registry should
38 // be using the cached plugin_list_ instead.
39 CONTENT_EXPORT static void ComputeList(
40 std::vector<content::PepperPluginInfo>* plugins);
42 // Loads the (native) libraries but does not initialize them (i.e., does not
43 // call PPP_InitializeModule). This is needed by the zygote on Linux to get
44 // access to the plugins before entering the sandbox.
45 static void PreloadModules();
47 // Retrieves the information associated with the given plugin info. The
48 // return value will be NULL if there is no such plugin.
50 // The returned pointer is owned by the PluginRegistry.
51 const content::PepperPluginInfo* GetInfoForPlugin(
52 const webkit::WebPluginInfo& info);
54 // Returns an existing loaded module for the given path. It will search for
55 // both preloaded in-process or currently active (non crashed) out-of-process
56 // plugins matching the given name. Returns NULL if the plugin hasn't been
57 // loaded.
58 webkit::ppapi::PluginModule* GetLiveModule(const FilePath& path);
60 // Notifies the registry that a new non-preloaded module has been created.
61 // This is normally called for out-of-process plugins. Once this is called,
62 // the module is available to be returned by GetModule(). The module will
63 // automatically unregister itself by calling PluginModuleDestroyed().
64 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module);
66 // ModuleLifetime implementation.
67 virtual void PluginModuleDead(
68 webkit::ppapi::PluginModule* dead_module) OVERRIDE;
70 private:
71 PepperPluginRegistry();
73 // All known pepper plugins.
74 std::vector<content::PepperPluginInfo> plugin_list_;
76 // Plugins that have been preloaded so they can be executed in-process in
77 // the renderer (the sandbox prevents on-demand loading).
78 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> >
79 OwningModuleMap;
80 OwningModuleMap preloaded_modules_;
82 // A list of non-owning pointers to all currently-live plugin modules. This
83 // includes both preloaded ones in preloaded_modules_, and out-of-process
84 // modules whose lifetime is managed externally. This will contain only
85 // non-crashed modules. If an out-of-process module crashes, it may
86 // continue as long as there are WebKit references to it, but it will not
87 // appear in this list.
88 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap;
89 NonOwningModuleMap live_modules_;
91 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry);
94 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_