| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "ppapi/proxy/proxy_channel.h" | |
| 17 #include "webkit/plugins/ppapi/plugin_delegate.h" | 16 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 18 #include "webkit/plugins/ppapi/plugin_module.h" | 17 #include "webkit/plugins/ppapi/plugin_module.h" |
| 19 #include "webkit/plugins/webplugininfo.h" | 18 #include "webkit/plugins/webplugininfo.h" |
| 20 | 19 |
| 21 struct CONTENT_EXPORT PepperPluginInfo { | 20 struct CONTENT_EXPORT PepperPluginInfo { |
| 22 PepperPluginInfo(); | 21 PepperPluginInfo(); |
| 23 ~PepperPluginInfo(); | 22 ~PepperPluginInfo(); |
| 24 | 23 |
| 25 webkit::WebPluginInfo ToWebPluginInfo() const; | 24 webkit::WebPluginInfo ToWebPluginInfo() const; |
| 26 | 25 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 49 // must be one of the pepper types. | 48 // must be one of the pepper types. |
| 50 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info, | 49 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info, |
| 51 PepperPluginInfo* pepper_info); | 50 PepperPluginInfo* pepper_info); |
| 52 | 51 |
| 53 // This class holds references to all of the known pepper plugin modules. | 52 // This class holds references to all of the known pepper plugin modules. |
| 54 // | 53 // |
| 55 // It keeps two lists. One list of preloaded in-process modules, and one list | 54 // It keeps two lists. One list of preloaded in-process modules, and one list |
| 56 // is a list of all live modules (some of which may be out-of-process and hence | 55 // is a list of all live modules (some of which may be out-of-process and hence |
| 57 // not preloaded). | 56 // not preloaded). |
| 58 class PepperPluginRegistry | 57 class PepperPluginRegistry |
| 59 : public webkit::ppapi::PluginDelegate::ModuleLifetime, | 58 : public webkit::ppapi::PluginDelegate::ModuleLifetime { |
| 60 public ppapi::proxy::ProxyChannel::Delegate { | |
| 61 public: | 59 public: |
| 62 ~PepperPluginRegistry(); | 60 ~PepperPluginRegistry(); |
| 63 | 61 |
| 64 static PepperPluginRegistry* GetInstance(); | 62 static PepperPluginRegistry* GetInstance(); |
| 65 | 63 |
| 66 // Computes the list of known pepper plugins. | 64 // Computes the list of known pepper plugins. |
| 67 // | 65 // |
| 68 // This method is static so that it can be used by the browser process, which | 66 // This method is static so that it can be used by the browser process, which |
| 69 // has no need to load the pepper plugin modules. It will re-compute the | 67 // has no need to load the pepper plugin modules. It will re-compute the |
| 70 // plugin list every time it is called. Generally, code in the registry should | 68 // plugin list every time it is called. Generally, code in the registry should |
| (...skipping 24 matching lines...) Expand all Loading... |
| 95 // the module is available to be returned by GetModule(). The module will | 93 // the module is available to be returned by GetModule(). The module will |
| 96 // automatically unregister itself by calling PluginModuleDestroyed(). | 94 // automatically unregister itself by calling PluginModuleDestroyed(). |
| 97 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module); | 95 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module); |
| 98 | 96 |
| 99 // ModuleLifetime implementation. | 97 // ModuleLifetime implementation. |
| 100 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module); | 98 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module); |
| 101 | 99 |
| 102 private: | 100 private: |
| 103 PepperPluginRegistry(); | 101 PepperPluginRegistry(); |
| 104 | 102 |
| 105 // ProxyChannel::Delegate implementation. | |
| 106 virtual base::MessageLoopProxy* GetIPCMessageLoop(); | |
| 107 virtual base::WaitableEvent* GetShutdownEvent(); | |
| 108 | |
| 109 // All known pepper plugins. | 103 // All known pepper plugins. |
| 110 std::vector<PepperPluginInfo> plugin_list_; | 104 std::vector<PepperPluginInfo> plugin_list_; |
| 111 | 105 |
| 112 // Plugins that have been preloaded so they can be executed in-process in | 106 // Plugins that have been preloaded so they can be executed in-process in |
| 113 // the renderer (the sandbox prevents on-demand loading). | 107 // the renderer (the sandbox prevents on-demand loading). |
| 114 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> > | 108 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> > |
| 115 OwningModuleMap; | 109 OwningModuleMap; |
| 116 OwningModuleMap preloaded_modules_; | 110 OwningModuleMap preloaded_modules_; |
| 117 | 111 |
| 118 // A list of non-owning pointers to all currently-live plugin modules. This | 112 // A list of non-owning pointers to all currently-live plugin modules. This |
| 119 // includes both preloaded ones in preloaded_modules_, and out-of-process | 113 // includes both preloaded ones in preloaded_modules_, and out-of-process |
| 120 // modules whose lifetime is managed externally. This will contain only | 114 // modules whose lifetime is managed externally. This will contain only |
| 121 // non-crashed modules. If an out-of-process module crashes, it may | 115 // non-crashed modules. If an out-of-process module crashes, it may |
| 122 // continue as long as there are WebKit references to it, but it will not | 116 // continue as long as there are WebKit references to it, but it will not |
| 123 // appear in this list. | 117 // appear in this list. |
| 124 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap; | 118 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap; |
| 125 NonOwningModuleMap live_modules_; | 119 NonOwningModuleMap live_modules_; |
| 126 | 120 |
| 127 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry); | 121 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry); |
| 128 }; | 122 }; |
| 129 | 123 |
| 130 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ | 124 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ |
| OLD | NEW |