OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_LIST_H_ |
| 6 #define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_LIST_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <vector> |
| 10 |
| 11 #include "webkit/plugins/ppapi/ppapi_plugin_info.h" |
| 12 |
| 13 namespace webkit { |
| 14 namespace ppapi { |
| 15 |
| 16 // This class holds references to all of the known pepper plugin modules. |
| 17 // |
| 18 // It keeps two lists. One list of preloaded in-process modules, and one list |
| 19 // is a list of all live modules (some of which may be out-of-process and hence |
| 20 // not preloaded). |
| 21 class PluginList { |
| 22 public: |
| 23 PluginList(); |
| 24 ~PluginList(); |
| 25 |
| 26 // The following functions add plugins modules to the list. |
| 27 // They must be called before calling Load/PreloadModules. |
| 28 |
| 29 // Returns the list of all known plugins. |
| 30 const std::vector<PluginInfo>& plugin_list() const { return plugin_list_; } |
| 31 |
| 32 void RegisterAll(); |
| 33 |
| 34 // Loads and initializes all known plugins. |
| 35 void LoadModules(); |
| 36 |
| 37 // Loads the external libraries but does not initialize them (i.e., does not |
| 38 // call PPP_InitializeModule). This is needed by the zygote on Linux to get |
| 39 // access to the plugins before entering the sandbox. |
| 40 void PreloadModules(); |
| 41 |
| 42 // Retrieves the information associated with the given plugin info. The |
| 43 // return value will be NULL if there is no such plugin. |
| 44 // |
| 45 // The returned pointer is owned by PluginList. |
| 46 const PluginInfo* GetInfoForPlugin(const FilePath& plugin_path); |
| 47 |
| 48 // Returns an existing loaded module for the given path. It will search for |
| 49 // both preloaded in-process or currently active (non crashed) out-of-process |
| 50 // plugins matching the given name. Returns NULL if the plugin hasn't been |
| 51 // loaded. |
| 52 PluginModule* GetLiveModule(const FilePath& path); |
| 53 |
| 54 // Notifies the registry that a new non-preloaded module has been created. |
| 55 // This is normally called for out-of-process plugins. Once this is called, |
| 56 // the module is available to be returned by GetModule(). The module will |
| 57 // automatically unregister itself by calling PluginModuleDestroyed(). |
| 58 void AddLiveModule(const FilePath& path, PluginModule* module); |
| 59 |
| 60 // PluginDelegate::ModuleLifetime implementation. |
| 61 virtual void PluginModuleDead(PluginModule* dead_module); |
| 62 |
| 63 private: |
| 64 // Adds plugins specified in the command line. |
| 65 void AddFromCommandLine(); |
| 66 |
| 67 // All known pepper plugins. |
| 68 std::vector<PluginInfo> plugin_list_; |
| 69 |
| 70 // Plugins that have been preloaded so they can be executed in-process in |
| 71 // the renderer (the sandbox prevents on-demand loading). |
| 72 typedef std::map<FilePath, scoped_refptr<PluginModule> > OwningModuleMap; |
| 73 OwningModuleMap preloaded_modules_; |
| 74 |
| 75 // A list of non-owning pointers to all currently-live plugin modules. This |
| 76 // includes both preloaded ones in preloaded_modules_, and out-of-process |
| 77 // modules whose lifetime is managed externally. This will contain only |
| 78 // non-crashed modules. If an out-of-process module crashes, it may |
| 79 // continue as long as there are WebKit references to it, but it will not |
| 80 // appear in this list. |
| 81 typedef std::map<FilePath, PluginModule*> NonOwningModuleMap; |
| 82 NonOwningModuleMap live_modules_; |
| 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(PluginList); |
| 85 }; |
| 86 |
| 87 } // namespace ppapi |
| 88 } // namespace webkit |
| 89 |
| 90 #endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_LIST_H_ |
OLD | NEW |