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

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

Issue 5783005: PluginList: Unit tests and bugfixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a few details Created 10 years 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_GLUE_PLUGINS_PLUGIN_LIST_H_ 5 #ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_
6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_
7 7
8 #include <map>
8 #include <set> 9 #include <set>
9 #include <string> 10 #include <string>
11 #include <utility>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/basictypes.h" 14 #include "base/basictypes.h"
13 #include "base/file_path.h" 15 #include "base/file_path.h"
14 #include "base/linked_ptr.h" 16 #include "base/linked_ptr.h"
15 #include "base/lock.h" 17 #include "base/lock.h"
16 #include "third_party/npapi/bindings/nphostapi.h" 18 #include "third_party/npapi/bindings/nphostapi.h"
17 #include "webkit/glue/plugins/plugin_group.h" 19 #include "webkit/glue/plugins/plugin_group.h"
18 #include "webkit/glue/plugins/webplugininfo.h" 20 #include "webkit/glue/plugins/webplugininfo.h"
19 21
20 class GURL; 22 class GURL;
21 23
22 namespace base { 24 namespace base {
23 25
24 template <typename T> 26 template <typename T>
25 struct DefaultLazyInstanceTraits; 27 struct DefaultLazyInstanceTraits;
26 28
27 } // namespace base 29 } // namespace base
28 30
31 namespace plugin_test_internal {
32 class TestablePluginList;
33 }
34
29 namespace NPAPI { 35 namespace NPAPI {
30 36
31 #define kDefaultPluginLibraryName FILE_PATH_LITERAL("default_plugin") 37 #define kDefaultPluginLibraryName FILE_PATH_LITERAL("default_plugin")
32 #define kGearsPluginLibraryName FILE_PATH_LITERAL("gears") 38 #define kGearsPluginLibraryName FILE_PATH_LITERAL("gears")
33 39
34 class PluginInstance; 40 class PluginInstance;
35 41
36 // This struct holds entry points into a plugin. The entry points are 42 // This struct holds entry points into a plugin. The entry points are
37 // slightly different between Win/Mac and Unixes. 43 // slightly different between Win/Mac and Unixes.
38 struct PluginEntryPoints { 44 struct PluginEntryPoints {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // Disable all plugins groups that are known to be outdated, according to 220 // Disable all plugins groups that are known to be outdated, according to
215 // the information hardcoded in PluginGroup, to make sure that they can't 221 // the information hardcoded in PluginGroup, to make sure that they can't
216 // be loaded on a web page and instead show a UI to update to the latest 222 // be loaded on a web page and instead show a UI to update to the latest
217 // version. 223 // version.
218 void DisableOutdatedPluginGroups(); 224 void DisableOutdatedPluginGroups();
219 225
220 const DisabledPlugins& GetDisabledPlugins() const; 226 const DisabledPlugins& GetDisabledPlugins() const;
221 227
222 const DisabledGroups& GetDisabledGroups() const; 228 const DisabledGroups& GetDisabledGroups() const;
223 229
224 ~PluginList(); 230 virtual ~PluginList();
225 231
226 private: 232 private:
227 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); 233 friend class plugin_test_internal::TestablePluginList;
Bernhard Bauer 2010/12/14 20:18:34 Couldn't you make the necessary methods protected?
Jakob Kummerow 2010/12/15 18:03:27 Done. I have to say, though, that I find it ugly t
jam 2010/12/15 19:43:39 I agree that it's not as nice. We shouldn't break
228 234
229 // Constructors are private for singletons 235 // Constructors are private for singletons
230 PluginList(); 236 PluginList();
231 237
232 // Creates PluginGroups for the static group definitions, and adds them to 238 // Creates PluginGroups for the static group definitions, and adds them to
233 // the PluginGroup cache of this PluginList. 239 // the PluginGroup cache of this PluginList.
234 void AddHardcodedPluginGroups(); 240 void AddHardcodedPluginGroups();
235 241
236 // Adds the given WebPluginInfo to its corresponding group, creating it if 242 // Adds the given WebPluginInfo to its corresponding group, creating it if
237 // necessary, and returns the group. 243 // necessary, and returns the group.
238 // Callers need to protect calls to this method by a lock themselves. 244 // Callers need to protect calls to this method by a lock themselves.
239 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); 245 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info);
240 246
241 // Load all plugins from the default plugins directory 247 // Load all plugins from the default plugins directory.
242 void LoadPlugins(bool refresh); 248 // Declared virtual so that it can be overridden for tests.
249 virtual void LoadPlugins(bool refresh);
250
251 // Allows tests to perform custom post-initialization tasks on newly created
252 // PluginGroups.
253 virtual void PostInitPluginGroup(PluginGroup* group) { }
Bernhard Bauer 2010/12/14 20:18:34 Nit: Maybe name it DidInitPluginGroup?
danno 2010/12/15 10:42:12 How about ProcessGroupAfterInitialize On 2010/12/1
Jakob Kummerow 2010/12/15 18:03:27 Done.
243 254
244 // Load all plugins from a specific directory. 255 // Load all plugins from a specific directory.
245 // |plugins| is updated with loaded plugin information. 256 // |plugins| is updated with loaded plugin information.
246 // |visited_plugins| is updated with paths to all plugins that were considered 257 // |visited_plugins| is updated with paths to all plugins that were considered
247 // (including those we didn't load) 258 // (including those we didn't load)
248 void LoadPluginsFromDir(const FilePath& path, 259 void LoadPluginsFromDir(const FilePath& path,
249 std::set<FilePath>* visited_plugins); 260 std::set<FilePath>* visited_plugins);
250 261
251 // Returns true if we should load the given plugin, or false otherwise. 262 // Returns true if we should load the given plugin, or false otherwise.
252 // plugins is the list of plugins we have crawled in the current plugin 263 // plugins is the list of plugins we have crawled in the current plugin
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 mutable Lock lock_; 352 mutable Lock lock_;
342 353
343 friend struct base::DefaultLazyInstanceTraits<PluginList>; 354 friend struct base::DefaultLazyInstanceTraits<PluginList>;
344 355
345 DISALLOW_COPY_AND_ASSIGN(PluginList); 356 DISALLOW_COPY_AND_ASSIGN(PluginList);
346 }; 357 };
347 358
348 } // namespace NPAPI 359 } // namespace NPAPI
349 360
350 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ 361 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698