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

Side by Side Diff: webkit/plugins/npapi/plugin_group.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/mock_plugin_list.cc ('k') | webkit/plugins/npapi/plugin_group.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/string16.h"
14 #include "webkit/plugins/webkit_plugins_export.h"
15 #include "webkit/plugins/webplugininfo.h"
16
17 class FilePath;
18 class PluginExceptionsTableModelTest;
19 class Version;
20
21 namespace webkit {
22 namespace npapi {
23
24 class PluginList;
25 class MockPluginList;
26
27 // Hard-coded definitions of plugin groups.
28 struct PluginGroupDefinition {
29 // Unique identifier for this group.
30 const char* identifier;
31 // Name of this group.
32 const char* name;
33 // Substring matcher for the plugin name.
34 const char* name_matcher;
35 };
36
37 // A PluginGroup can match a range of versions of a specific plugin (as defined
38 // by matching a substring of its name).
39 // It contains all WebPluginInfo structs (at least one) matching its definition.
40
41 class WEBKIT_PLUGINS_EXPORT PluginGroup {
42 public:
43 // Used by about:plugins to disable Reader plugin when internal PDF viewer is
44 // enabled.
45 static const char kAdobeReaderGroupName[];
46 static const char kJavaGroupName[];
47 static const char kQuickTimeGroupName[];
48 static const char kShockwaveGroupName[];
49 static const char kRealPlayerGroupName[];
50 static const char kSilverlightGroupName[];
51 static const char kWindowsMediaPlayerGroupName[];
52
53 PluginGroup(const PluginGroup& other);
54
55 ~PluginGroup();
56
57 PluginGroup& operator=(const PluginGroup& other);
58
59 // Returns true if the given plugin matches this group.
60 bool Match(const webkit::WebPluginInfo& plugin) const;
61
62 // Adds the given plugin to this group.
63 void AddPlugin(const webkit::WebPluginInfo& plugin);
64
65 // Removes a plugin from the group by its path.
66 bool RemovePlugin(const FilePath& filename);
67
68 // Returns a unique identifier for this group, if one is defined, or the empty
69 // string otherwise.
70 const std::string& identifier() const { return identifier_; }
71
72 // Sets a unique identifier for this group or if none is set an empty string.
73 void set_identifier(const std::string& identifier) {
74 identifier_ = identifier;
75 }
76
77 // Returns this group's name, or the filename without extension if the name
78 // is empty.
79 string16 GetGroupName() const;
80
81 // Checks whether a plugin exists in the group with the given path.
82 bool ContainsPlugin(const FilePath& path) const;
83
84 // Check if the group has no plugins. Could happen after a reload if the plug-
85 // in has disappeared from the pc (or in the process of updating).
86 bool IsEmpty() const;
87
88 const std::vector<webkit::WebPluginInfo>& web_plugin_infos() const {
89 return web_plugin_infos_;
90 }
91
92 private:
93 friend class MockPluginList;
94 friend class PluginGroupTest;
95 friend class PluginList;
96 friend class ::PluginExceptionsTableModelTest;
97 FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated);
98
99 // Generates the (short) identifier string for the given plugin.
100 static std::string GetIdentifier(const webkit::WebPluginInfo& wpi);
101
102 // Generates the long identifier (based on the full file path) for the given
103 // plugin, to be called when the short identifier is not unique.
104 static std::string GetLongIdentifier(const webkit::WebPluginInfo& wpi);
105
106 // Creates a PluginGroup from a PluginGroupDefinition. The caller takes
107 // ownership of the created PluginGroup.
108 static PluginGroup* FromPluginGroupDefinition(
109 const PluginGroupDefinition& definition);
110
111 // Creates a PluginGroup from a WebPluginInfo. The caller takes ownership of
112 // the created PluginGroup.
113 static PluginGroup* FromWebPluginInfo(const webkit::WebPluginInfo& wpi);
114
115 PluginGroup(const string16& group_name,
116 const string16& name_matcher,
117 const std::string& identifier);
118
119 void InitFrom(const PluginGroup& other);
120
121 // Returns a non-const vector of all plugins in the group. This is only used
122 // by PluginList.
123 std::vector<webkit::WebPluginInfo>& GetPluginsContainer() {
124 return web_plugin_infos_;
125 }
126
127 std::string identifier_;
128 string16 group_name_;
129 string16 name_matcher_;
130 std::vector<webkit::WebPluginInfo> web_plugin_infos_;
131 };
132
133 } // namespace npapi
134 } // namespace webkit
135
136 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/mock_plugin_list.cc ('k') | webkit/plugins/npapi/plugin_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698