| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 5 #ifndef CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| 6 #define CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 6 #define CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "content/public/common/pepper_plugin_info.h" | 11 #include "content/public/common/pepper_plugin_info.h" |
| 12 #include "webkit/plugins/ppapi/plugin_delegate.h" | 12 |
| 13 // TODO(jam): refactor |
| 14 #include "content/renderer/pepper/plugin_module.h" |
| 13 | 15 |
| 14 namespace content { | 16 namespace content { |
| 15 | 17 |
| 16 // Constructs a PepperPluginInfo from a WebPluginInfo. Returns false if | 18 // Constructs a PepperPluginInfo from a WebPluginInfo. Returns false if |
| 17 // the operation is not possible, in particular the WebPluginInfo::type | 19 // the operation is not possible, in particular the WebPluginInfo::type |
| 18 // must be one of the pepper types. | 20 // must be one of the pepper types. |
| 19 bool MakePepperPluginInfo(const WebPluginInfo& webplugin_info, | 21 bool MakePepperPluginInfo(const WebPluginInfo& webplugin_info, |
| 20 PepperPluginInfo* pepper_info); | 22 PepperPluginInfo* pepper_info); |
| 21 | 23 |
| 22 // This class holds references to all of the known pepper plugin modules. | 24 // This class holds references to all of the known pepper plugin modules. |
| 23 // | 25 // |
| 24 // It keeps two lists. One list of preloaded in-process modules, and one list | 26 // 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 | 27 // is a list of all live modules (some of which may be out-of-process and hence |
| 26 // not preloaded). | 28 // not preloaded). |
| 27 class PepperPluginRegistry | 29 class PepperPluginRegistry { |
| 28 : public webkit::ppapi::PluginDelegate::ModuleLifetime { | |
| 29 public: | 30 public: |
| 30 ~PepperPluginRegistry(); | 31 ~PepperPluginRegistry(); |
| 31 | 32 |
| 32 static PepperPluginRegistry* GetInstance(); | 33 static PepperPluginRegistry* GetInstance(); |
| 33 | 34 |
| 34 // Computes the list of known pepper plugins. | 35 // Computes the list of known pepper plugins. |
| 35 // | 36 // |
| 36 // This method is static so that it can be used by the browser process, which | 37 // 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 // 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 // plugin list every time it is called. Generally, code in the registry should |
| (...skipping 18 matching lines...) Expand all Loading... |
| 57 // loaded. | 58 // loaded. |
| 58 webkit::ppapi::PluginModule* GetLiveModule(const base::FilePath& path); | 59 webkit::ppapi::PluginModule* GetLiveModule(const base::FilePath& path); |
| 59 | 60 |
| 60 // Notifies the registry that a new non-preloaded module has been created. | 61 // 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 // 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 // the module is available to be returned by GetModule(). The module will |
| 63 // automatically unregister itself by calling PluginModuleDestroyed(). | 64 // automatically unregister itself by calling PluginModuleDestroyed(). |
| 64 void AddLiveModule(const base::FilePath& path, | 65 void AddLiveModule(const base::FilePath& path, |
| 65 webkit::ppapi::PluginModule* module); | 66 webkit::ppapi::PluginModule* module); |
| 66 | 67 |
| 67 // ModuleLifetime implementation. | 68 void PluginModuleDead(webkit::ppapi::PluginModule* dead_module); |
| 68 virtual void PluginModuleDead( | |
| 69 webkit::ppapi::PluginModule* dead_module) OVERRIDE; | |
| 70 | 69 |
| 71 private: | 70 private: |
| 72 PepperPluginRegistry(); | 71 PepperPluginRegistry(); |
| 73 | 72 |
| 74 // All known pepper plugins. | 73 // All known pepper plugins. |
| 75 std::vector<PepperPluginInfo> plugin_list_; | 74 std::vector<PepperPluginInfo> plugin_list_; |
| 76 | 75 |
| 77 // Plugins that have been preloaded so they can be executed in-process in | 76 // Plugins that have been preloaded so they can be executed in-process in |
| 78 // the renderer (the sandbox prevents on-demand loading). | 77 // the renderer (the sandbox prevents on-demand loading). |
| 79 typedef std::map<base::FilePath, | 78 typedef std::map<base::FilePath, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 90 typedef std::map<base::FilePath, webkit::ppapi::PluginModule*> | 89 typedef std::map<base::FilePath, webkit::ppapi::PluginModule*> |
| 91 NonOwningModuleMap; | 90 NonOwningModuleMap; |
| 92 NonOwningModuleMap live_modules_; | 91 NonOwningModuleMap live_modules_; |
| 93 | 92 |
| 94 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry); | 93 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry); |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 } // namespace content | 96 } // namespace content |
| 98 | 97 |
| 99 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 98 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| OLD | NEW |