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

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

Issue 6012002: Move the NPAPI files from webkit/glue/plugins to webkit/plugins/npapi and put... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « webkit/glue/plugins/plugin_constants_win.h ('k') | webkit/glue/plugins/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) 2010 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_GLUE_PLUGINS_PLUGIN_GROUP_H_
6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_
7 #pragma once
8
9 #include <map>
10 #include <set>
11 #include <string>
12 #include <vector>
13
14 #include "base/gtest_prod_util.h"
15 #include "base/scoped_ptr.h"
16 #include "base/string16.h"
17
18 class DictionaryValue;
19 class FilePath;
20 class Version;
21 struct WebPluginInfo;
22
23 namespace NPAPI {
24 class PluginList;
25 };
26
27 // Hard-coded version ranges for plugin groups.
28 struct VersionRangeDefinition {
29 // Matcher for lowest version matched by this range (inclusive). May be empty
30 // to match everything iff |version_matcher_high| is also empty.
31 const char* version_matcher_low;
32 // Matcher for highest version matched by this range (exclusive). May be empty
33 // to match anything higher than |version_matcher_low|.
34 const char* version_matcher_high;
35 const char* min_version; // Minimum secure version.
36 };
37
38 // Hard-coded definitions of plugin groups.
39 struct PluginGroupDefinition {
40 const char* identifier; // Unique identifier for this group.
41 const char* name; // Name of this group.
42 const char* name_matcher; // Substring matcher for the plugin name.
43 const VersionRangeDefinition* versions; // List of version ranges.
44 const size_t num_versions; // Size of the array |versions| points to.
45 const char* update_url; // Location of latest secure version.
46 };
47
48 // Run-time structure to hold version range information.
49 struct VersionRange {
50 public:
51 explicit VersionRange(VersionRangeDefinition definition);
52 VersionRange(const VersionRange& other);
53 VersionRange& operator=(const VersionRange& other);
54 ~VersionRange();
55
56 std::string low_str;
57 std::string high_str;
58 std::string min_str;
59 scoped_ptr<Version> low;
60 scoped_ptr<Version> high;
61 scoped_ptr<Version> min;
62 private:
63 void InitFrom(const VersionRange& other);
64 };
65
66 // A PluginGroup can match a range of versions of a specific plugin (as defined
67 // by matching a substring of its name).
68 // It contains all WebPluginInfo structs (at least one) matching its definition.
69 // In addition, it knows about a security "baseline", i.e. the minimum version
70 // of a plugin that is needed in order not to exhibit known security
71 // vulnerabilities.
72
73 class PluginGroup {
74 public:
75 // Used by about:plugins to disable Reader plugin when internal PDF viewer is
76 // enabled.
77 static const char* kAdobeReaderGroupName;
78
79 PluginGroup(const PluginGroup& other);
80
81 ~PluginGroup();
82
83 PluginGroup& operator=(const PluginGroup& other);
84
85 // Configures the set of plugin name patterns for disabling plugins via
86 // enterprise configuration management.
87 static void SetPolicyDisabledPluginPatterns(const std::set<string16>& set);
88
89 // Tests to see if a plugin is on the blacklist using its name as
90 // the lookup key.
91 static bool IsPluginNameDisabledByPolicy(const string16& plugin_name);
92
93 // Tests to see if a plugin is on the blacklist using its path as
94 // the lookup key.
95 static bool IsPluginPathDisabledByPolicy(const FilePath& plugin_path);
96
97 // Returns true if the given plugin matches this group.
98 bool Match(const WebPluginInfo& plugin) const;
99
100 // Adds the given plugin to this group. Provide the position of the
101 // plugin as given by PluginList so we can display its priority.
102 void AddPlugin(const WebPluginInfo& plugin, int position);
103
104 // Enables/disables this group. This enables/disables all plugins in the
105 // group.
106 void Enable(bool enable);
107
108 // Returns whether the plugin group is enabled or not.
109 bool Enabled() const { return enabled_; }
110
111 // Returns a unique identifier for this group, if one is defined, or the empty
112 // string otherwise.
113 const std::string& identifier() const { return identifier_; }
114
115 // Returns this group's name, or the filename without extension if the name
116 // is empty.
117 string16 GetGroupName() const;
118
119 // Returns the description of the highest-priority plug-in in the group.
120 const string16& description() const { return description_; }
121
122 // Returns a DictionaryValue with data to display in the UI.
123 DictionaryValue* GetDataForUI() const;
124
125 // Returns a DictionaryValue with data to save in the preferences.
126 DictionaryValue* GetSummary() const;
127
128 // Returns the update URL.
129 std::string GetUpdateURL() const { return update_url_; }
130
131 // Returns true if the highest-priority plugin in this group has known
132 // security problems.
133 bool IsVulnerable() const;
134
135 // Disables all plugins in this group that are older than the
136 // minimum version.
137 void DisableOutdatedPlugins();
138
139 // Parse a version string as used by a plug-in. This method is more lenient
140 // in accepting weird version strings than Version::GetFromString().
141 static Version* CreateVersionFromString(const string16& version_string);
142
143 private:
144 typedef std::map<std::string, PluginGroup*> PluginMap;
145
146 friend class NPAPI::PluginList;
147 friend class PluginGroupTest;
148 friend class TableModelArrayControllerTest;
149 friend class PluginExceptionsTableModelTest;
150
151 // Generates the (short) identifier string for the given plugin.
152 static std::string GetIdentifier(const WebPluginInfo& wpi);
153
154 // Generates the long identifier (based on the full file path) for the given
155 // plugin, to be called when the short identifier is not unique.
156 static std::string GetLongIdentifier(const WebPluginInfo& wpi);
157
158 // Creates a PluginGroup from a PluginGroupDefinition. The caller takes
159 // ownership of the created PluginGroup.
160 static PluginGroup* FromPluginGroupDefinition(
161 const PluginGroupDefinition& definition);
162
163 // Creates a PluginGroup from a WebPluginInfo. The caller takes ownership of
164 // the created PluginGroup.
165 static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi);
166
167 // Returns |true| if |version| is contained in [low, high) of |range|.
168 static bool IsVersionInRange(const Version& version,
169 const VersionRange& range);
170
171 // Returns |true| iff |plugin_version| is both contained in |version_range|
172 // and declared outdated (== vulnerable) by it.
173 static bool IsPluginOutdated(const Version& plugin_version,
174 const VersionRange& version_range);
175
176 PluginGroup(const string16& group_name,
177 const string16& name_matcher,
178 const std::string& update_url,
179 const std::string& identifier);
180
181 void InitFrom(const PluginGroup& other);
182
183 // Set the description and version for this plugin group from the
184 // given plug-in.
185 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin);
186
187 // Updates the active plugin in the group. The active plugin is the first
188 // enabled one, or if all plugins are disabled, simply the first one.
189 void UpdateActivePlugin(const WebPluginInfo& plugin);
190
191 static std::set<string16>* policy_disabled_plugin_patterns_;
192
193 std::string identifier_;
194 string16 group_name_;
195 string16 name_matcher_;
196 string16 description_;
197 std::string update_url_;
198 bool enabled_;
199 std::vector<VersionRange> version_ranges_;
200 scoped_ptr<Version> version_;
201 std::vector<WebPluginInfo> web_plugin_infos_;
202 std::vector<int> web_plugin_positions_;
203 };
204
205 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_
OLDNEW
« no previous file with comments | « webkit/glue/plugins/plugin_constants_win.h ('k') | webkit/glue/plugins/plugin_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698