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

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: custom traits Created 8 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
« 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
29 struct CustomPluginListTraits;
30
36 // This struct holds entry points into a plugin. The entry points are 31 // 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 32 // 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 33 // querying plugins is synchronous and it is preferable to use a higher-level
39 // asynchronous information to query information. 34 // asynchronous information to query information.
40 struct PluginEntryPoints { 35 struct PluginEntryPoints {
41 #if !defined(OS_POSIX) || defined(OS_MACOSX) 36 #if !defined(OS_POSIX) || defined(OS_MACOSX)
42 NP_GetEntryPointsFunc np_getentrypoints; 37 NP_GetEntryPointsFunc np_getentrypoints;
43 #endif 38 #endif
44 NP_InitializeFunc np_initialize; 39 NP_InitializeFunc np_initialize;
45 NP_ShutdownFunc np_shutdown; 40 NP_ShutdownFunc np_shutdown;
(...skipping 95 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. 136 // 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| 137 // 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. 138 // will be true iff the plug-in list was stale.
144 void GetPluginInfoArray(const GURL& url, 139 void GetPluginInfoArray(const GURL& url,
145 const std::string& mime_type, 140 const std::string& mime_type,
146 bool allow_wildcard, 141 bool allow_wildcard,
147 bool* use_stale, 142 bool* use_stale,
148 std::vector<webkit::WebPluginInfo>* info, 143 std::vector<webkit::WebPluginInfo>* info,
149 std::vector<std::string>* actual_mime_types); 144 std::vector<std::string>* actual_mime_types);
150 145
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 146 // Load a specific plugin with full path. Return true iff loading the plug-in
176 // was successful. 147 // was successful.
177 bool LoadPluginIntoPluginList(const FilePath& filename, 148 bool LoadPluginIntoPluginList(const FilePath& filename,
178 std::vector<webkit::WebPluginInfo>* plugins, 149 std::vector<webkit::WebPluginInfo>* plugins,
179 webkit::WebPluginInfo* plugin_info); 150 webkit::WebPluginInfo* plugin_info);
180 151
181 // The following functions are used to support probing for WebPluginInfo 152 // The following functions are used to support probing for WebPluginInfo
182 // using a different instance of this class. 153 // using a different instance of this class.
183 154
184 // Computes a list of all plugins to potentially load from all sources. 155 // Computes a list of all plugins to potentially load from all sources.
185 void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths); 156 void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths);
186 157
187 // TODO(ibraaaa): DELETE. http://crbug.com/124396 158 // 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); 159 void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins);
193 160
194 void set_will_load_plugins_callback(const base::Closure& callback); 161 void set_will_load_plugins_callback(const base::Closure& callback);
195 162
196 virtual ~PluginList(); 163 virtual ~PluginList();
197 164
198 protected: 165 protected:
199 // TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396 166 // Constructors are private for singletons but we expose this one
200 // This constructor is used in unit tests to override the platform-dependent 167 // for subclasses for test purposes.
201 // real-world plugin group definitions with custom ones. 168 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 169
210 private: 170 private:
211 enum LoadingState { 171 enum LoadingState {
212 LOADING_STATE_NEEDS_REFRESH, 172 LOADING_STATE_NEEDS_REFRESH,
213 LOADING_STATE_REFRESHING, 173 LOADING_STATE_REFRESHING,
214 LOADING_STATE_UP_TO_DATE, 174 LOADING_STATE_UP_TO_DATE,
215 }; 175 };
216 176
217 struct InternalPlugin { 177 struct InternalPlugin {
218 webkit::WebPluginInfo info; 178 webkit::WebPluginInfo info;
219 PluginEntryPoints entry_points; 179 PluginEntryPoints entry_points;
220 }; 180 };
221 181
222 friend class PluginListTest; 182 friend class PluginListTest;
223 friend struct base::DefaultLazyInstanceTraits<PluginList>; 183 friend struct base::DefaultLazyInstanceTraits<PluginList>;
224 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); 184 friend struct CustomPluginListTraits;
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 185
242 // Implements all IO dependent operations of the LoadPlugins method so that 186 // Implements all IO dependent operations of the LoadPlugins method so that
243 // test classes can mock these out. 187 // 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( 188 virtual void LoadPluginsIntoPluginListInternal(
249 std::vector<webkit::WebPluginInfo>* plugins); 189 std::vector<webkit::WebPluginInfo>* plugins);
250 190
251 // Load all plugins from the default plugins directory. 191 // Load all plugins from the default plugins directory.
252 void LoadPlugins(); 192 void LoadPlugins();
253 193
254 // Walks a directory and produces a list of all the plugins to potentially 194 // Walks a directory and produces a list of all the plugins to potentially
255 // load in that directory. 195 // load in that directory.
256 void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins); 196 void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins);
257 197
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. 198 // 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 199 // |plugins| is the list of plugins we have crawled in the current plugin
267 // loading run. 200 // loading run.
268 bool ShouldLoadPluginUsingPluginList( 201 bool ShouldLoadPluginUsingPluginList(
269 const webkit::WebPluginInfo& info, 202 const webkit::WebPluginInfo& info,
270 std::vector<webkit::WebPluginInfo>* plugins); 203 std::vector<webkit::WebPluginInfo>* plugins);
271 204
272 // Returns true if the plugin supports |mime_type|. |mime_type| should be all 205 // Returns true if the plugin supports |mime_type|. |mime_type| should be all
273 // lower case. 206 // lower case.
274 bool SupportsType(const webkit::WebPluginInfo& plugin, 207 bool SupportsType(const webkit::WebPluginInfo& plugin,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 251
319 // Extra plugin paths that we want to search when loading. 252 // Extra plugin paths that we want to search when loading.
320 std::vector<FilePath> extra_plugin_paths_; 253 std::vector<FilePath> extra_plugin_paths_;
321 254
322 // Extra plugin directories that we want to search when loading. 255 // Extra plugin directories that we want to search when loading.
323 std::vector<FilePath> extra_plugin_dirs_; 256 std::vector<FilePath> extra_plugin_dirs_;
324 257
325 // Holds information about internal plugins. 258 // Holds information about internal plugins.
326 std::vector<InternalPlugin> internal_plugins_; 259 std::vector<InternalPlugin> internal_plugins_;
327 260
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. 261 // A list holding all plug-ins.
337 std::vector<webkit::WebPluginInfo> plugins_list_; 262 std::vector<webkit::WebPluginInfo> plugins_list_;
338 263
339 // Callback that is invoked whenever the PluginList will reload the plugins. 264 // Callback that is invoked whenever the PluginList will reload the plugins.
340 base::Closure will_load_plugins_callback_; 265 base::Closure will_load_plugins_callback_;
341 266
342 // Need synchronization for the above members since this object can be 267 // Need synchronization for the above members since this object can be
343 // accessed on multiple threads. 268 // accessed on multiple threads.
344 base::Lock lock_; 269 base::Lock lock_;
345 270
346 DISALLOW_COPY_AND_ASSIGN(PluginList); 271 DISALLOW_COPY_AND_ASSIGN(PluginList);
347 }; 272 };
348 273
274 // Custom traits for PlugList that performs platform-dependent initialization
Bernhard Bauer 2012/09/18 11:01:31 Nit: PluginList
ibraaaa 2012/09/18 14:49:01 Done.
275 // when the instance is created.
276 struct CustomPluginListTraits {
ibraaaa 2012/09/18 09:47:13 Is it better to define this inside PluginList?
Bernhard Bauer 2012/09/18 11:01:31 Hm. Yeah, it's probably best to move the declarati
ibraaaa 2012/09/18 14:49:01 Done.
277 static const bool kRegisterOnExit = true;
278 static const bool kAllowedToAccessOnNonjoinableThread = false;
279
280 static PluginList* New(void* instance) {
281 PluginList* plugin_list =
282 base::DefaultLazyInstanceTraits<PluginList>::New(instance);
283 plugin_list->PlatformInit();
284 return plugin_list;
285 }
286
287 static void Delete(PluginList* instance) {
Bernhard Bauer 2012/09/18 11:01:31 If you inherited from base::DefaultLazyInstanceTra
ibraaaa 2012/09/18 14:49:01 Done.
288 base::DefaultLazyInstanceTraits<PluginList>::Delete(instance);
289 }
290 };
291
349 } // namespace npapi 292 } // namespace npapi
350 } // namespace webkit 293 } // namespace webkit
351 294
352 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 295 #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