Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: content/common/pepper_plugin_registry.h

Issue 7978009: Split ppapi::PluginList from PepperPluginRegistry so that DRT could load pepper plugins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/content_switches.cc ('k') | content/common/pepper_plugin_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/singleton.h"
10 #include <map>
11 #include <string>
12 #include <vector>
13
14 #include "base/file_path.h"
15 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
16 #include "webkit/plugins/ppapi/plugin_delegate.h" 11 #include "webkit/plugins/ppapi/plugin_delegate.h"
17 #include "webkit/plugins/ppapi/plugin_module.h" 12 #include "webkit/plugins/ppapi/ppapi_plugin_list.h"
18 #include "webkit/plugins/webplugininfo.h"
19 13
20 struct CONTENT_EXPORT PepperPluginInfo { 14 // Static helper class to manage webkit::ppapi::PluginList.
21 PepperPluginInfo();
22 ~PepperPluginInfo();
23
24 webkit::WebPluginInfo ToWebPluginInfo() const;
25
26 // Indicates internal plugins for which there's not actually a library.
27 // These plugins are implemented in the Chrome binary using a separate set
28 // of entry points (see internal_entry_points below).
29 // Defaults to false.
30 bool is_internal;
31
32 // True when this plugin should be run out of process. Defaults to false.
33 bool is_out_of_process;
34
35 FilePath path; // Internal plugins have "internal-[name]" as path.
36 std::string name;
37 std::string description;
38 std::string version;
39 std::vector<webkit::WebPluginMimeType> mime_types;
40
41 // When is_internal is set, this contains the function pointers to the
42 // entry points for the internal plugins.
43 webkit::ppapi::PluginModule::EntryPoints internal_entry_points;
44 };
45
46 // Constructs a PepperPluginInfo from a WebPluginInfo. Returns false if
47 // the operation is not possible, in particular the WebPluginInfo::type
48 // must be one of the pepper types.
49 bool MakePepperPluginInfo(const webkit::WebPluginInfo& webplugin_info,
50 PepperPluginInfo* pepper_info);
51
52 // This class holds references to all of the known pepper plugin modules.
53 //
54 // It keeps two lists. One list of preloaded in-process modules, and one list
55 // is a list of all live modules (some of which may be out-of-process and hence
56 // not preloaded).
57 class PepperPluginRegistry 15 class PepperPluginRegistry
58 : public webkit::ppapi::PluginDelegate::ModuleLifetime { 16 : public webkit::ppapi::PluginDelegate::ModuleLifetime {
59 public: 17 public:
60 ~PepperPluginRegistry();
61
62 static PepperPluginRegistry* GetInstance();
63
64 // Computes the list of known pepper plugins. 18 // Computes the list of known pepper plugins.
65 // 19 //
66 // This method is static so that it can be used by the browser process, which 20 // This method is static so that it can be used by the browser process, which
67 // has no need to load the pepper plugin modules. It will re-compute the 21 // has no need to load the pepper plugin modules. It will re-compute the
68 // plugin list every time it is called. Generally, code in the registry should 22 // plugin list every time it is called. Generally, code in the registry should
69 // be using the cached plugin_list_ instead. 23 // be using the cached plugin_list_ instead.
70 CONTENT_EXPORT static void ComputeList( 24 CONTENT_EXPORT static void ComputeList(
71 std::vector<PepperPluginInfo>* plugins); 25 webkit::ppapi::PluginList* plugin_list);
72 26
73 // Loads the (native) libraries but does not initialize them (i.e., does not 27 // Loads the (native) libraries but does not initialize them (i.e., does not
74 // call PPP_InitializeModule). This is needed by the zygote on Linux to get 28 // call PPP_InitializeModule). This is needed by the zygote on Linux to get
75 // access to the plugins before entering the sandbox. 29 // access to the plugins before entering the sandbox.
76 static void PreloadModules(); 30 static void PreloadModules();
77 31
32 static PepperPluginRegistry* GetInstance();
33
78 // Retrieves the information associated with the given plugin info. The 34 // Retrieves the information associated with the given plugin info. The
79 // return value will be NULL if there is no such plugin. 35 // return value will be NULL if there is no such plugin.
80 // 36 //
81 // The returned pointer is owned by the PluginRegistry. 37 // The returned pointer is owned by the PluginRegistry.
82 const PepperPluginInfo* GetInfoForPlugin( 38 const webkit::ppapi::PluginInfo* GetInfoForPlugin(
83 const webkit::WebPluginInfo& info); 39 const FilePath& plugin_path);
84 40
85 // Returns an existing loaded module for the given path. It will search for 41 // Returns an existing loaded module for the given path. It will search for
86 // both preloaded in-process or currently active (non crashed) out-of-process 42 // both preloaded in-process or currently active (non crashed) out-of-process
87 // plugins matching the given name. Returns NULL if the plugin hasn't been 43 // plugins matching the given name. Returns NULL if the plugin hasn't been
88 // loaded. 44 // loaded.
89 webkit::ppapi::PluginModule* GetLiveModule(const FilePath& path); 45 webkit::ppapi::PluginModule* GetLiveModule(const FilePath& path);
90 46
91 // Notifies the registry that a new non-preloaded module has been created. 47 // Notifies the registry that a new non-preloaded module has been created.
92 // This is normally called for out-of-process plugins. Once this is called, 48 // This is normally called for out-of-process plugins. Once this is called,
93 // the module is available to be returned by GetModule(). The module will 49 // the module is available to be returned by GetModule(). The module will
94 // automatically unregister itself by calling PluginModuleDestroyed(). 50 // automatically unregister itself by calling PluginModuleDestroyed().
95 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module); 51 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module);
96 52
97 // ModuleLifetime implementation. 53 // ModuleLifetime implementation.
98 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module); 54 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module);
99 55
100 private: 56 private:
101 PepperPluginRegistry(); 57 PepperPluginRegistry();
102 58 ~PepperPluginRegistry();
103 // All known pepper plugins. 59 friend struct DefaultSingletonTraits<PepperPluginRegistry>;
104 std::vector<PepperPluginInfo> plugin_list_;
105
106 // Plugins that have been preloaded so they can be executed in-process in
107 // the renderer (the sandbox prevents on-demand loading).
108 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> >
109 OwningModuleMap;
110 OwningModuleMap preloaded_modules_;
111
112 // A list of non-owning pointers to all currently-live plugin modules. This
113 // includes both preloaded ones in preloaded_modules_, and out-of-process
114 // modules whose lifetime is managed externally. This will contain only
115 // non-crashed modules. If an out-of-process module crashes, it may
116 // continue as long as there are WebKit references to it, but it will not
117 // appear in this list.
118 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap;
119 NonOwningModuleMap live_modules_;
120
121 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry);
122 }; 60 };
123 61
124 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_ 62 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_
OLDNEW
« no previous file with comments | « content/common/content_switches.cc ('k') | content/common/pepper_plugin_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698