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_RENDERER_PEPPER_PEPPER_PLUGIN_REGISTRY_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_REGISTRY_H_
11 #include "base/memory/ref_counted.h"
12 #include "content/public/common/pepper_plugin_info.h"
17 // This class holds references to all of the known pepper plugin modules.
19 // It keeps two lists. One list of preloaded in-process modules, and one list
20 // is a list of all live modules (some of which may be out-of-process and hence
22 class PepperPluginRegistry
{
24 ~PepperPluginRegistry();
26 static PepperPluginRegistry
* GetInstance();
28 // Retrieves the information associated with the given plugin info. The
29 // return value will be NULL if there is no such plugin.
31 // The returned pointer is owned by the PluginRegistry.
32 const PepperPluginInfo
* GetInfoForPlugin(const WebPluginInfo
& info
);
34 // Returns an existing loaded module for the given path. It will search for
35 // both preloaded in-process or currently active (non crashed) out-of-process
36 // plugins matching the given name. Returns NULL if the plugin hasn't been
38 PluginModule
* GetLiveModule(const base::FilePath
& path
);
40 // Notifies the registry that a new non-preloaded module has been created.
41 // This is normally called for out-of-process plugins. Once this is called,
42 // the module is available to be returned by GetModule(). The module will
43 // automatically unregister itself by calling PluginModuleDestroyed().
44 void AddLiveModule(const base::FilePath
& path
, PluginModule
* module
);
46 void PluginModuleDead(PluginModule
* dead_module
);
49 PepperPluginRegistry();
52 // All known pepper plugins.
53 std::vector
<PepperPluginInfo
> plugin_list_
;
55 // Plugins that have been preloaded so they can be executed in-process in
56 // the renderer (the sandbox prevents on-demand loading).
57 typedef std::map
<base::FilePath
, scoped_refptr
<PluginModule
> >
59 OwningModuleMap preloaded_modules_
;
61 // A list of non-owning pointers to all currently-live plugin modules. This
62 // includes both preloaded ones in preloaded_modules_, and out-of-process
63 // modules whose lifetime is managed externally. This will contain only
64 // non-crashed modules. If an out-of-process module crashes, it may
65 // continue as long as there are WebKit references to it, but it will not
66 // appear in this list.
67 typedef std::map
<base::FilePath
, PluginModule
*> NonOwningModuleMap
;
68 NonOwningModuleMap live_modules_
;
70 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry
);
73 } // namespace content
75 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLUGIN_REGISTRY_H_