[content shell] hook up testRunner.dumpEditingCallbacks
[chromium-blink-merge.git] / content / common / pepper_plugin_registry.h
blobf0a5ebf5d2a1511643337deb49603e41ae8fac61
1 // Copyright (c) 2012 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_
8 #include <list>
9 #include <map>
11 #include "content/public/common/pepper_plugin_info.h"
12 #include "webkit/plugins/ppapi/plugin_delegate.h"
14 namespace content {
16 // Constructs a PepperPluginInfo from a WebPluginInfo. Returns false if
17 // the operation is not possible, in particular the WebPluginInfo::type
18 // must be one of the pepper types.
19 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info,
20 PepperPluginInfo* pepper_info);
22 // This class holds references to all of the known pepper plugin modules.
24 // It keeps two lists. One list of preloaded in-process modules, and one list
25 // is a list of all live modules (some of which may be out-of-process and hence
26 // not preloaded).
27 class PepperPluginRegistry
28 : public webkit::ppapi::PluginDelegate::ModuleLifetime {
29 public:
30 ~PepperPluginRegistry();
32 static PepperPluginRegistry* GetInstance();
34 // Computes the list of known pepper plugins.
36 // This method is static so that it can be used by the browser process, which
37 // has no need to load the pepper plugin modules. It will re-compute the
38 // plugin list every time it is called. Generally, code in the registry should
39 // be using the cached plugin_list_ instead.
40 CONTENT_EXPORT static void ComputeList(
41 std::vector<PepperPluginInfo>* plugins);
43 // Loads the (native) libraries but does not initialize them (i.e., does not
44 // call PPP_InitializeModule). This is needed by the zygote on Linux to get
45 // access to the plugins before entering the sandbox.
46 static void PreloadModules();
48 // Retrieves the information associated with the given plugin info. The
49 // return value will be NULL if there is no such plugin.
51 // The returned pointer is owned by the PluginRegistry.
52 const PepperPluginInfo* GetInfoForPlugin(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<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 } // namespace content
96 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_