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

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

Issue 6869051: Move PepperPluginRegistry to content, while leaving the Chrome specific bits (NaCl, registration ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
OLDNEW
(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 CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_
6 #define CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_
7 #pragma once
8
9 #include <list>
10 #include <map>
11 #include <string>
12 #include <vector>
13
14 #include "base/file_path.h"
15 #include "ppapi/proxy/dispatcher.h"
16 #include "webkit/plugins/npapi/webplugininfo.h"
17 #include "webkit/plugins/ppapi/plugin_delegate.h"
18 #include "webkit/plugins/ppapi/plugin_module.h"
19
20 struct PepperPluginInfo {
21 PepperPluginInfo();
22 ~PepperPluginInfo();
23
24 webkit::npapi::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::npapi::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 struct NaClModuleInfo {
47 NaClModuleInfo();
48 ~NaClModuleInfo();
49
50 GURL url;
51 std::string mime_type;
52 };
53
54 // This class holds references to all of the known pepper plugin modules.
55 //
56 // It keeps two lists. One list of preloaded in-process modules, and one list
57 // is a list of all live modules (some of which may be out-of-process and hence
58 // not preloaded).
59 class PepperPluginRegistry
60 : public webkit::ppapi::PluginDelegate::ModuleLifetime,
61 public pp::proxy::Dispatcher::Delegate {
62 public:
63 ~PepperPluginRegistry();
64
65 static const char* kPDFPluginName;
66
67 static PepperPluginRegistry* GetInstance();
68
69 // Computes the list of known pepper plugins.
70 //
71 // This method is static so that it can be used by the browser process, which
72 // has no need to load the pepper plugin modules. It will re-compute the
73 // plugin list every time it is called. Generally, code in the registry should
74 // be using the cached plugin_list_ instead.
75 static void ComputeList(std::vector<PepperPluginInfo>* plugins);
76
77 // Loads the (native) libraries but does not initialize them (i.e., does not
78 // call PPP_InitializeModule). This is needed by the zygote on Linux to get
79 // access to the plugins before entering the sandbox.
80 static void PreloadModules();
81
82 // Retrieves the information associated with the given plugin path. The
83 // return value will be NULL if there is no such plugin.
84 //
85 // The returned pointer is owned by the PluginRegistry.
86 const PepperPluginInfo* GetInfoForPlugin(const FilePath& path) const;
87
88 // Returns an existing loaded module for the given path. It will search for
89 // both preloaded in-process or currently active (non crashed) out-of-process
90 // plugins matching the given name. Returns NULL if the plugin hasn't been
91 // loaded.
92 webkit::ppapi::PluginModule* GetLiveModule(const FilePath& path);
93
94 // Notifies the registry that a new non-preloaded module has been created.
95 // This is normally called for out-of-process plugins. Once this is called,
96 // the module is available to be returned by GetModule(). The module will
97 // automatically unregister itself by calling PluginModuleDestroyed().
98 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module);
99
100 // ModuleLifetime implementation.
101 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module);
102
103 // We implement some Pepper plug-ins using NaCl to take advantage of NaCl's
104 // strong sandbox. Typically, these NaCl modules are stored in extensions
105 // and registered here. Not all NaCl modules need to register for a MIME
106 // type, just the ones that are responsible for rendering a particular MIME
107 // type, like application/pdf. Note: We only register NaCl modules in the
108 // browser process.
109 void RegisterNaClModule(const GURL& url, const std::string& mime_type);
110 void UnregisterNaClModule(const GURL& url);
111
112 // Call UpdatePluginListWithNaClModules() after registering or unregistering
113 // a NaCl module to see those changes reflected in the PluginList.
114 void UpdatePluginListWithNaClModules();
115
116 private:
117 typedef std::list<NaClModuleInfo> NaClModuleInfoList;
118
119 PepperPluginRegistry();
120
121 // Dispatcher::Delegate implementation.
122 virtual MessageLoop* GetIPCMessageLoop();
123 virtual base::WaitableEvent* GetShutdownEvent();
124 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet();
125
126 NaClModuleInfoList::iterator FindNaClModule(const GURL& url);
127
128 // All known pepper plugins.
129 std::vector<PepperPluginInfo> plugin_list_;
130
131 // Plugins that have been preloaded so they can be executed in-process in
132 // the renderer (the sandbox prevents on-demand loading).
133 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> >
134 OwningModuleMap;
135 OwningModuleMap preloaded_modules_;
136
137 // A list of non-owning pointers to all currently-live plugin modules. This
138 // includes both preloaded ones in preloaded_modules_, and out-of-process
139 // modules whose lifetime is managed externally. This will contain only
140 // non-crashed modules. If an out-of-process module crashes, it may
141 // continue as long as there are WebKit references to it, but it will not
142 // appear in this list.
143 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap;
144 NonOwningModuleMap live_modules_;
145
146 NaClModuleInfoList nacl_module_list_;
147
148 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry);
149 };
150
151 #endif // CHROME_COMMON_PEPPER_PLUGIN_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698