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

Side by Side Diff: webkit/plugins/npapi/plugin_list.h

Issue 10918174: Remove PluginGroup (Closed) Base URL: http://git.chromium.org/chromium/src.git@remove_async_plugin_finder
Patch Set: fix conflicts Created 8 years, 2 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
« no previous file with comments | « webkit/plugins/npapi/plugin_group.cc ('k') | webkit/plugins/npapi/plugin_list.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) 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 WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/lazy_instance.h"
16 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
17 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
18 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
19 #include "third_party/npapi/bindings/nphostapi.h" 20 #include "third_party/npapi/bindings/nphostapi.h"
20 #include "webkit/plugins/npapi/plugin_group.h"
21 #include "webkit/plugins/webkit_plugins_export.h" 21 #include "webkit/plugins/webkit_plugins_export.h"
22 #include "webkit/plugins/webplugininfo.h" 22 #include "webkit/plugins/webplugininfo.h"
23 23
24 class GURL; 24 class GURL;
25 25
26 namespace base {
27
28 template <typename T>
29 struct DefaultLazyInstanceTraits;
30
31 } // namespace base
32
33 namespace webkit { 26 namespace webkit {
34 namespace npapi { 27 namespace npapi {
35 28
36 // This struct holds entry points into a plugin. The entry points are 29 // This struct holds entry points into a plugin. The entry points are
37 // slightly different between Win/Mac and Unixes. Note that the interface for 30 // slightly different between Win/Mac and Unixes. Note that the interface for
38 // querying plugins is synchronous and it is preferable to use a higher-level 31 // querying plugins is synchronous and it is preferable to use a higher-level
39 // asynchronous information to query information. 32 // asynchronous information to query information.
40 struct PluginEntryPoints { 33 struct PluginEntryPoints {
41 #if !defined(OS_POSIX) || defined(OS_MACOSX) 34 #if !defined(OS_POSIX) || defined(OS_MACOSX)
42 NP_GetEntryPointsFunc np_getentrypoints; 35 NP_GetEntryPointsFunc np_getentrypoints;
43 #endif 36 #endif
44 NP_InitializeFunc np_initialize; 37 NP_InitializeFunc np_initialize;
45 NP_ShutdownFunc np_shutdown; 38 NP_ShutdownFunc np_shutdown;
46 }; 39 };
47 40
48 // The PluginList is responsible for loading our NPAPI based plugins. It does 41 // The PluginList is responsible for loading our NPAPI based plugins. It does
49 // so in whatever manner is appropriate for the platform. On Windows, it loads 42 // so in whatever manner is appropriate for the platform. On Windows, it loads
50 // plugins from a known directory by looking for DLLs which start with "NP", 43 // plugins from a known directory by looking for DLLs which start with "NP",
51 // and checking to see if they are valid NPAPI libraries. On the Mac, it walks 44 // and checking to see if they are valid NPAPI libraries. On the Mac, it walks
52 // the machine-wide and user plugin directories and loads anything that has 45 // the machine-wide and user plugin directories and loads anything that has
53 // the correct types. On Linux, it walks the plugin directories as well 46 // the correct types. On Linux, it walks the plugin directories as well
54 // (e.g. /usr/lib/browser-plugins/). 47 // (e.g. /usr/lib/browser-plugins/).
55 // This object is thread safe. 48 // This object is thread safe.
56 class WEBKIT_PLUGINS_EXPORT PluginList { 49 class WEBKIT_PLUGINS_EXPORT PluginList {
57 public: 50 public:
51 // Custom traits that performs platform-dependent initialization
52 // when the instance is created.
53 struct CustomLazyInstanceTraits;
54
58 // Gets the one instance of the PluginList. 55 // Gets the one instance of the PluginList.
59 static PluginList* Singleton(); 56 static PluginList* Singleton();
60 57
61 // Returns true if we're in debug-plugin-loading mode. This is controlled 58 // Returns true if we're in debug-plugin-loading mode. This is controlled
62 // by a command line switch. 59 // by a command line switch.
63 static bool DebugPluginLoading(); 60 static bool DebugPluginLoading();
64 61
65 // Cause the plugin list to refresh next time they are accessed, regardless 62 // Cause the plugin list to refresh next time they are accessed, regardless
66 // of whether they are already loaded. 63 // of whether they are already loaded.
67 void RefreshPlugins(); 64 void RefreshPlugins();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // If |use_stale| is NULL, this will load the plug-in list if necessary. 138 // If |use_stale| is NULL, this will load the plug-in list if necessary.
142 // If it is not NULL, the plug-in list will not be loaded, and |*use_stale| 139 // If it is not NULL, the plug-in list will not be loaded, and |*use_stale|
143 // will be true iff the plug-in list was stale. 140 // will be true iff the plug-in list was stale.
144 void GetPluginInfoArray(const GURL& url, 141 void GetPluginInfoArray(const GURL& url,
145 const std::string& mime_type, 142 const std::string& mime_type,
146 bool allow_wildcard, 143 bool allow_wildcard,
147 bool* use_stale, 144 bool* use_stale,
148 std::vector<webkit::WebPluginInfo>* info, 145 std::vector<webkit::WebPluginInfo>* info,
149 std::vector<std::string>* actual_mime_types); 146 std::vector<std::string>* actual_mime_types);
150 147
151 // TODO(ibraaaa): DELETE. http://crbug.com/124396
152 // Populates the given vector with all available plugin groups. If
153 // |load_if_necessary| is true, this will potentially load the plugin list
154 // synchronously.
155 void GetPluginGroups(bool load_if_necessary,
156 std::vector<PluginGroup>* plugin_groups);
157
158 // TODO(ibraaaa): DELETE. http://crbug.com/124396
159 // Returns a copy of the PluginGroup corresponding to the given WebPluginInfo.
160 // The caller takes ownership of the returned PluginGroup.
161 PluginGroup* GetPluginGroup(const webkit::WebPluginInfo& web_plugin_info);
162
163 // TODO(ibraaaa): DELETE. http://crbug.com/124396
164 // Returns the name of the PluginGroup with the given identifier.
165 // If no such group exists, an empty string is returned.
166 string16 GetPluginGroupName(const std::string& identifier);
167
168 // TODO(ibraaaa): DELETE. http://crbug.com/124396
169 // Load a specific plugin with full path. Return true iff loading the plug-in
170 // was successful.
171 bool LoadPlugin(const FilePath& filename,
172 ScopedVector<PluginGroup>* plugin_groups,
173 webkit::WebPluginInfo* plugin_info);
174
175 // Load a specific plugin with full path. Return true iff loading the plug-in 148 // Load a specific plugin with full path. Return true iff loading the plug-in
176 // was successful. 149 // was successful.
177 bool LoadPluginIntoPluginList(const FilePath& filename, 150 bool LoadPluginIntoPluginList(const FilePath& filename,
178 std::vector<webkit::WebPluginInfo>* plugins, 151 std::vector<webkit::WebPluginInfo>* plugins,
179 webkit::WebPluginInfo* plugin_info); 152 webkit::WebPluginInfo* plugin_info);
180 153
181 // The following functions are used to support probing for WebPluginInfo 154 // The following functions are used to support probing for WebPluginInfo
182 // using a different instance of this class. 155 // using a different instance of this class.
183 156
184 // Computes a list of all plugins to potentially load from all sources. 157 // Computes a list of all plugins to potentially load from all sources.
185 void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths); 158 void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths);
186 159
187 // TODO(ibraaaa): DELETE. http://crbug.com/124396 160 // Clears the internal list of Plugins and copies them from the vector.
188 // Returns the list of hardcoded plug-in groups for testing.
189 const std::vector<PluginGroup*>& GetHardcodedPluginGroups() const;
190
191 // Clears the internal list of PluginGroups and copies them from the vector.
192 void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins); 161 void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins);
193 162
194 void set_will_load_plugins_callback(const base::Closure& callback); 163 void set_will_load_plugins_callback(const base::Closure& callback);
195 164
196 virtual ~PluginList(); 165 virtual ~PluginList();
197 166
198 protected: 167 protected:
199 // TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396 168 // Constructors are private for singletons but we expose this one
200 // This constructor is used in unit tests to override the platform-dependent 169 // for subclasses for test purposes.
201 // real-world plugin group definitions with custom ones. 170 PluginList();
202 PluginList(const PluginGroupDefinition* definitions, size_t num_definitions);
203
204 // TODO(ibraaaa): DELETE. http://crbug.com/124396
205 // Adds the given WebPluginInfo to its corresponding group, creating it if
206 // necessary, and returns the group.
207 PluginGroup* AddToPluginGroups(const webkit::WebPluginInfo& web_plugin_info,
208 ScopedVector<PluginGroup>* plugin_groups);
209 171
210 private: 172 private:
211 enum LoadingState { 173 enum LoadingState {
212 LOADING_STATE_NEEDS_REFRESH, 174 LOADING_STATE_NEEDS_REFRESH,
213 LOADING_STATE_REFRESHING, 175 LOADING_STATE_REFRESHING,
214 LOADING_STATE_UP_TO_DATE, 176 LOADING_STATE_UP_TO_DATE,
215 }; 177 };
216 178
217 struct InternalPlugin { 179 struct InternalPlugin {
218 webkit::WebPluginInfo info; 180 webkit::WebPluginInfo info;
219 PluginEntryPoints entry_points; 181 PluginEntryPoints entry_points;
220 }; 182 };
221 183
222 friend class PluginListTest; 184 friend class PluginListTest;
223 friend struct base::DefaultLazyInstanceTraits<PluginList>; 185 friend struct base::DefaultLazyInstanceTraits<PluginList>;
224 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition);
225
226 // Constructors are private for singletons.
227 PluginList();
228
229 // TODO(ibraaaa): DELETE. http://crbug.com/124396
230 // Creates PluginGroups for the hardcoded group definitions, and stores them
231 // in |hardcoded_plugin_groups_|.
232 void AddHardcodedPluginGroups(const PluginGroupDefinition* group_definitions,
233 size_t num_group_definitions);
234
235 // TODO(ibraaaa): DELETE. http://crbug.com/124396
236 // Creates a new PluginGroup either from a hardcoded group definition, or from
237 // the plug-in information.
238 // Caller takes ownership of the returned PluginGroup.
239 PluginGroup* CreatePluginGroup(
240 const webkit::WebPluginInfo& web_plugin_info) const;
241 186
242 // Implements all IO dependent operations of the LoadPlugins method so that 187 // Implements all IO dependent operations of the LoadPlugins method so that
243 // test classes can mock these out. 188 // test classes can mock these out.
244 virtual void LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups);
245
246 // Implements all IO dependent operations of the LoadPlugins method so that
247 // test classes can mock these out.
248 virtual void LoadPluginsIntoPluginListInternal( 189 virtual void LoadPluginsIntoPluginListInternal(
249 std::vector<webkit::WebPluginInfo>* plugins); 190 std::vector<webkit::WebPluginInfo>* plugins);
250 191
251 // Load all plugins from the default plugins directory. 192 // Load all plugins from the default plugins directory.
252 void LoadPlugins(); 193 void LoadPlugins();
253 194
254 // Walks a directory and produces a list of all the plugins to potentially 195 // Walks a directory and produces a list of all the plugins to potentially
255 // load in that directory. 196 // load in that directory.
256 void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins); 197 void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins);
257 198
258 // TODO(ibraaaa): DELETE. http://crbug.com/124396
259 // Returns true if we should load the given plugin, or false otherwise.
260 // |plugins| is the list of plugins we have crawled in the current plugin
261 // loading run.
262 bool ShouldLoadPlugin(const webkit::WebPluginInfo& info,
263 ScopedVector<PluginGroup>* plugins);
264
265 // Returns true if we should load the given plugin, or false otherwise. 199 // Returns true if we should load the given plugin, or false otherwise.
266 // |plugins| is the list of plugins we have crawled in the current plugin 200 // |plugins| is the list of plugins we have crawled in the current plugin
267 // loading run. 201 // loading run.
268 bool ShouldLoadPluginUsingPluginList( 202 bool ShouldLoadPluginUsingPluginList(
269 const webkit::WebPluginInfo& info, 203 const webkit::WebPluginInfo& info,
270 std::vector<webkit::WebPluginInfo>* plugins); 204 std::vector<webkit::WebPluginInfo>* plugins);
271 205
272 // Returns true if the plugin supports |mime_type|. |mime_type| should be all 206 // Returns true if the plugin supports |mime_type|. |mime_type| should be all
273 // lower case. 207 // lower case.
274 bool SupportsType(const webkit::WebPluginInfo& plugin, 208 bool SupportsType(const webkit::WebPluginInfo& plugin,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 252
319 // Extra plugin paths that we want to search when loading. 253 // Extra plugin paths that we want to search when loading.
320 std::vector<FilePath> extra_plugin_paths_; 254 std::vector<FilePath> extra_plugin_paths_;
321 255
322 // Extra plugin directories that we want to search when loading. 256 // Extra plugin directories that we want to search when loading.
323 std::vector<FilePath> extra_plugin_dirs_; 257 std::vector<FilePath> extra_plugin_dirs_;
324 258
325 // Holds information about internal plugins. 259 // Holds information about internal plugins.
326 std::vector<InternalPlugin> internal_plugins_; 260 std::vector<InternalPlugin> internal_plugins_;
327 261
328 // TODO(ibraaaa): DELETE. http://crbug.com/124396
329 // Holds the currently available plugin groups.
330 ScopedVector<PluginGroup> plugin_groups_;
331
332 // Holds the hardcoded definitions of well-known plug-ins.
333 // This should only be modified during construction of the PluginList.
334 ScopedVector<PluginGroup> hardcoded_plugin_groups_;
335
336 // A list holding all plug-ins. 262 // A list holding all plug-ins.
337 std::vector<webkit::WebPluginInfo> plugins_list_; 263 std::vector<webkit::WebPluginInfo> plugins_list_;
338 264
339 // Callback that is invoked whenever the PluginList will reload the plugins. 265 // Callback that is invoked whenever the PluginList will reload the plugins.
340 base::Closure will_load_plugins_callback_; 266 base::Closure will_load_plugins_callback_;
341 267
342 // Need synchronization for the above members since this object can be 268 // Need synchronization for the above members since this object can be
343 // accessed on multiple threads. 269 // accessed on multiple threads.
344 base::Lock lock_; 270 base::Lock lock_;
345 271
346 DISALLOW_COPY_AND_ASSIGN(PluginList); 272 DISALLOW_COPY_AND_ASSIGN(PluginList);
347 }; 273 };
348 274
349 } // namespace npapi 275 } // namespace npapi
350 } // namespace webkit 276 } // namespace webkit
351 277
352 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 278 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_group.cc ('k') | webkit/plugins/npapi/plugin_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698