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

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: 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
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/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "third_party/npapi/bindings/nphostapi.h" 19 #include "third_party/npapi/bindings/nphostapi.h"
20 #include "webkit/plugins/npapi/plugin_group.h"
21 #include "webkit/plugins/webkit_plugins_export.h" 20 #include "webkit/plugins/webkit_plugins_export.h"
22 #include "webkit/plugins/webplugininfo.h" 21 #include "webkit/plugins/webplugininfo.h"
23 22
24 class GURL; 23 class GURL;
25 24
26 namespace base { 25 namespace base {
27 26
28 template <typename T> 27 template <typename T>
29 struct DefaultLazyInstanceTraits; 28 struct DefaultLazyInstanceTraits;
30 29
(...skipping 110 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. 140 // 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| 141 // 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. 142 // will be true iff the plug-in list was stale.
144 void GetPluginInfoArray(const GURL& url, 143 void GetPluginInfoArray(const GURL& url,
145 const std::string& mime_type, 144 const std::string& mime_type,
146 bool allow_wildcard, 145 bool allow_wildcard,
147 bool* use_stale, 146 bool* use_stale,
148 std::vector<webkit::WebPluginInfo>* info, 147 std::vector<webkit::WebPluginInfo>* info,
149 std::vector<std::string>* actual_mime_types); 148 std::vector<std::string>* actual_mime_types);
150 149
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 150 // Load a specific plugin with full path. Return true iff loading the plug-in
176 // was successful. 151 // was successful.
177 bool LoadPluginIntoPluginList(const FilePath& filename, 152 bool LoadPluginIntoPluginList(const FilePath& filename,
178 std::vector<webkit::WebPluginInfo>* plugins, 153 std::vector<webkit::WebPluginInfo>* plugins,
179 webkit::WebPluginInfo* plugin_info); 154 webkit::WebPluginInfo* plugin_info);
180 155
181 // The following functions are used to support probing for WebPluginInfo 156 // The following functions are used to support probing for WebPluginInfo
182 // using a different instance of this class. 157 // using a different instance of this class.
183 158
184 // Computes a list of all plugins to potentially load from all sources. 159 // Computes a list of all plugins to potentially load from all sources.
185 void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths); 160 void GetPluginPathsToLoad(std::vector<FilePath>* plugin_paths);
186 161
187 // TODO(ibraaaa): DELETE. http://crbug.com/124396 162 // 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); 163 void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins);
193 164
194 void set_will_load_plugins_callback(const base::Closure& callback); 165 void set_will_load_plugins_callback(const base::Closure& callback);
195 166
196 virtual ~PluginList(); 167 virtual ~PluginList();
197 168
198 protected: 169 protected:
199 // TODO(ibraaaa): DELETE and add a different one. http://crbug.com/124396 170 // This constructor is used in tests to skip
200 // This constructor is used in unit tests to override the platform-dependent 171 // platform-dependent initialization.
201 // real-world plugin group definitions with custom ones. 172 explicit PluginList(int skip_platform_init);
Bernhard Bauer 2012/09/17 15:18:01 Ugh. Could you use custom traits on |g_singleton|
ibraaaa 2012/09/17 17:53:09 Done.
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 173
210 private: 174 private:
211 enum LoadingState { 175 enum LoadingState {
212 LOADING_STATE_NEEDS_REFRESH, 176 LOADING_STATE_NEEDS_REFRESH,
213 LOADING_STATE_REFRESHING, 177 LOADING_STATE_REFRESHING,
214 LOADING_STATE_UP_TO_DATE, 178 LOADING_STATE_UP_TO_DATE,
215 }; 179 };
216 180
217 struct InternalPlugin { 181 struct InternalPlugin {
218 webkit::WebPluginInfo info; 182 webkit::WebPluginInfo info;
219 PluginEntryPoints entry_points; 183 PluginEntryPoints entry_points;
220 }; 184 };
221 185
222 friend class PluginListTest; 186 friend class PluginListTest;
223 friend struct base::DefaultLazyInstanceTraits<PluginList>; 187 friend struct base::DefaultLazyInstanceTraits<PluginList>;
224 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition);
225 188
226 // Constructors are private for singletons. 189 // Constructors are private for singletons.
227 PluginList(); 190 PluginList();
228 191
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
242 // Implements all IO dependent operations of the LoadPlugins method so that
243 // 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 192 // Implements all IO dependent operations of the LoadPlugins method so that
247 // test classes can mock these out. 193 // test classes can mock these out.
248 virtual void LoadPluginsIntoPluginListInternal( 194 virtual void LoadPluginsIntoPluginListInternal(
249 std::vector<webkit::WebPluginInfo>* plugins); 195 std::vector<webkit::WebPluginInfo>* plugins);
250 196
251 // Load all plugins from the default plugins directory. 197 // Load all plugins from the default plugins directory.
252 void LoadPlugins(); 198 void LoadPlugins();
253 199
254 // Walks a directory and produces a list of all the plugins to potentially 200 // Walks a directory and produces a list of all the plugins to potentially
255 // load in that directory. 201 // load in that directory.
256 void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins); 202 void GetPluginsInDir(const FilePath& path, std::vector<FilePath>* plugins);
257 203
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. 204 // 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 205 // |plugins| is the list of plugins we have crawled in the current plugin
267 // loading run. 206 // loading run.
268 bool ShouldLoadPluginUsingPluginList( 207 bool ShouldLoadPluginUsingPluginList(
269 const webkit::WebPluginInfo& info, 208 const webkit::WebPluginInfo& info,
270 std::vector<webkit::WebPluginInfo>* plugins); 209 std::vector<webkit::WebPluginInfo>* plugins);
271 210
272 // Returns true if the plugin supports |mime_type|. |mime_type| should be all 211 // Returns true if the plugin supports |mime_type|. |mime_type| should be all
273 // lower case. 212 // lower case.
274 bool SupportsType(const webkit::WebPluginInfo& plugin, 213 bool SupportsType(const webkit::WebPluginInfo& plugin,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 257
319 // Extra plugin paths that we want to search when loading. 258 // Extra plugin paths that we want to search when loading.
320 std::vector<FilePath> extra_plugin_paths_; 259 std::vector<FilePath> extra_plugin_paths_;
321 260
322 // Extra plugin directories that we want to search when loading. 261 // Extra plugin directories that we want to search when loading.
323 std::vector<FilePath> extra_plugin_dirs_; 262 std::vector<FilePath> extra_plugin_dirs_;
324 263
325 // Holds information about internal plugins. 264 // Holds information about internal plugins.
326 std::vector<InternalPlugin> internal_plugins_; 265 std::vector<InternalPlugin> internal_plugins_;
327 266
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. 267 // A list holding all plug-ins.
337 std::vector<webkit::WebPluginInfo> plugins_list_; 268 std::vector<webkit::WebPluginInfo> plugins_list_;
338 269
339 // Callback that is invoked whenever the PluginList will reload the plugins. 270 // Callback that is invoked whenever the PluginList will reload the plugins.
340 base::Closure will_load_plugins_callback_; 271 base::Closure will_load_plugins_callback_;
341 272
342 // Need synchronization for the above members since this object can be 273 // Need synchronization for the above members since this object can be
343 // accessed on multiple threads. 274 // accessed on multiple threads.
344 base::Lock lock_; 275 base::Lock lock_;
345 276
346 DISALLOW_COPY_AND_ASSIGN(PluginList); 277 DISALLOW_COPY_AND_ASSIGN(PluginList);
347 }; 278 };
348 279
349 } // namespace npapi 280 } // namespace npapi
350 } // namespace webkit 281 } // namespace webkit
351 282
352 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ 283 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698