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

Side by Side Diff: content/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
Property Changes:
Added: svn:eol-style
+ LF
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 CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_
6 #define CONTENT_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 // Whether the plugin is enabled. Defaults to true.
36 bool enabled;
37
38 FilePath path; // Internal plugins have "internal-[name]" as path.
39 std::string name;
40 std::string description;
41 std::string version;
42 std::vector<webkit::npapi::WebPluginMimeType> mime_types;
43
44 // When is_internal is set, this contains the function pointers to the
45 // entry points for the internal plugins.
46 webkit::ppapi::PluginModule::EntryPoints internal_entry_points;
47 };
48
49 // This class holds references to all of the known pepper plugin modules.
50 //
51 // It keeps two lists. One list of preloaded in-process modules, and one list
52 // is a list of all live modules (some of which may be out-of-process and hence
53 // not preloaded).
54 class PepperPluginRegistry
55 : public webkit::ppapi::PluginDelegate::ModuleLifetime,
56 public pp::proxy::Dispatcher::Delegate {
57 public:
58 ~PepperPluginRegistry();
59
60 static PepperPluginRegistry* GetInstance();
61
62 // Computes the list of known pepper plugins.
63 //
64 // This method is static so that it can be used by the browser process, which
65 // has no need to load the pepper plugin modules. It will re-compute the
66 // plugin list every time it is called. Generally, code in the registry should
67 // be using the cached plugin_list_ instead.
68 static void ComputeList(std::vector<PepperPluginInfo>* plugins);
69
70 // Loads the (native) libraries but does not initialize them (i.e., does not
71 // call PPP_InitializeModule). This is needed by the zygote on Linux to get
72 // access to the plugins before entering the sandbox.
73 static void PreloadModules();
74
75 // Retrieves the information associated with the given plugin path. The
76 // return value will be NULL if there is no such plugin.
77 //
78 // The returned pointer is owned by the PluginRegistry.
79 const PepperPluginInfo* GetInfoForPlugin(const FilePath& path) const;
80
81 // Returns an existing loaded module for the given path. It will search for
82 // both preloaded in-process or currently active (non crashed) out-of-process
83 // plugins matching the given name. Returns NULL if the plugin hasn't been
84 // loaded.
85 webkit::ppapi::PluginModule* GetLiveModule(const FilePath& path);
86
87 // Notifies the registry that a new non-preloaded module has been created.
88 // This is normally called for out-of-process plugins. Once this is called,
89 // the module is available to be returned by GetModule(). The module will
90 // automatically unregister itself by calling PluginModuleDestroyed().
91 void AddLiveModule(const FilePath& path, webkit::ppapi::PluginModule* module);
92
93 // ModuleLifetime implementation.
94 virtual void PluginModuleDead(webkit::ppapi::PluginModule* dead_module);
95
96 private:
97 PepperPluginRegistry();
98
99 // Dispatcher::Delegate implementation.
100 virtual MessageLoop* GetIPCMessageLoop();
101 virtual base::WaitableEvent* GetShutdownEvent();
102 virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet();
103
104 // All known pepper plugins.
105 std::vector<PepperPluginInfo> plugin_list_;
106
107 // Plugins that have been preloaded so they can be executed in-process in
108 // the renderer (the sandbox prevents on-demand loading).
109 typedef std::map<FilePath, scoped_refptr<webkit::ppapi::PluginModule> >
110 OwningModuleMap;
111 OwningModuleMap preloaded_modules_;
112
113 // A list of non-owning pointers to all currently-live plugin modules. This
114 // includes both preloaded ones in preloaded_modules_, and out-of-process
115 // modules whose lifetime is managed externally. This will contain only
116 // non-crashed modules. If an out-of-process module crashes, it may
117 // continue as long as there are WebKit references to it, but it will not
118 // appear in this list.
119 typedef std::map<FilePath, webkit::ppapi::PluginModule*> NonOwningModuleMap;
120 NonOwningModuleMap live_modules_;
121
122 DISALLOW_COPY_AND_ASSIGN(PepperPluginRegistry);
123 };
124
125 #endif // CONTENT_COMMON_PEPPER_PLUGIN_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698