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

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

Issue 9874001: revert 128949 (and dependent 129252) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/utility/utility_thread_impl.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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_GROUP_H_ 5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_
6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
(...skipping 15 matching lines...) Expand all
27 27
28 // Hard-coded version ranges for plugin groups. 28 // Hard-coded version ranges for plugin groups.
29 struct VersionRangeDefinition { 29 struct VersionRangeDefinition {
30 // Matcher for lowest version matched by this range (inclusive). May be empty 30 // Matcher for lowest version matched by this range (inclusive). May be empty
31 // to match everything iff |version_matcher_high| is also empty. 31 // to match everything iff |version_matcher_high| is also empty.
32 const char* version_matcher_low; 32 const char* version_matcher_low;
33 // Matcher for highest version matched by this range (exclusive). May be empty 33 // Matcher for highest version matched by this range (exclusive). May be empty
34 // to match anything higher than |version_matcher_low|. 34 // to match anything higher than |version_matcher_low|.
35 const char* version_matcher_high; 35 const char* version_matcher_high;
36 const char* min_version; // Minimum secure version. 36 const char* min_version; // Minimum secure version.
37 bool requires_authorization; // If this range needs user permission to run.
37 }; 38 };
38 39
39 // Hard-coded definitions of plugin groups. 40 // Hard-coded definitions of plugin groups.
40 struct PluginGroupDefinition { 41 struct PluginGroupDefinition {
41 // Unique identifier for this group. 42 const char* identifier; // Unique identifier for this group.
42 const char* identifier; 43 const char* name; // Name of this group.
43 // Name of this group. 44 const char* name_matcher; // Substring matcher for the plugin name.
44 const char* name; 45 const VersionRangeDefinition* versions; // List of version ranges.
45 // Substring matcher for the plugin name. 46 size_t num_versions; // Size of the array |versions| points to.
46 const char* name_matcher; 47 const char* update_url; // Location of latest secure version.
47 // List of version ranges.
48 const VersionRangeDefinition* versions;
49 // Size of the array |versions| points to.
50 size_t num_versions;
51 }; 48 };
52 49
53 // Run-time structure to hold version range information. 50 // Run-time structure to hold version range information.
54 struct VersionRange { 51 struct VersionRange {
55 public: 52 public:
56 explicit VersionRange(const VersionRangeDefinition& definition); 53 explicit VersionRange(const VersionRangeDefinition& definition);
57 VersionRange(const VersionRange& other); 54 VersionRange(const VersionRange& other);
58 VersionRange& operator=(const VersionRange& other); 55 VersionRange& operator=(const VersionRange& other);
59 ~VersionRange(); 56 ~VersionRange();
60 57
61 std::string low_str; 58 std::string low_str;
62 std::string high_str; 59 std::string high_str;
63 std::string min_str; 60 std::string min_str;
64 scoped_ptr<Version> low; 61 scoped_ptr<Version> low;
65 scoped_ptr<Version> high; 62 scoped_ptr<Version> high;
66 scoped_ptr<Version> min; 63 scoped_ptr<Version> min;
64 bool requires_authorization;
67 private: 65 private:
68 void InitFrom(const VersionRange& other); 66 void InitFrom(const VersionRange& other);
69 }; 67 };
70 68
71 // A PluginGroup can match a range of versions of a specific plugin (as defined 69 // A PluginGroup can match a range of versions of a specific plugin (as defined
72 // by matching a substring of its name). 70 // by matching a substring of its name).
73 // It contains all WebPluginInfo structs (at least one) matching its definition. 71 // It contains all WebPluginInfo structs (at least one) matching its definition.
74 // In addition, it knows about a security "baseline", i.e. the minimum version 72 // In addition, it knows about a security "baseline", i.e. the minimum version
75 // of a plugin that is needed in order not to exhibit known security 73 // of a plugin that is needed in order not to exhibit known security
76 // vulnerabilities. 74 // vulnerabilities.
77 75
78 class WEBKIT_PLUGINS_EXPORT PluginGroup { 76 class WEBKIT_PLUGINS_EXPORT PluginGroup {
79 public: 77 public:
80 // Used by about:plugins to disable Reader plugin when internal PDF viewer is 78 // Used by about:plugins to disable Reader plugin when internal PDF viewer is
81 // enabled. 79 // enabled.
82 static const char kAdobeReaderGroupName[]; 80 static const char kAdobeReaderGroupName[];
81 static const char kAdobeReaderUpdateURL[];
83 static const char kJavaGroupName[]; 82 static const char kJavaGroupName[];
84 static const char kQuickTimeGroupName[]; 83 static const char kQuickTimeGroupName[];
85 static const char kShockwaveGroupName[]; 84 static const char kShockwaveGroupName[];
86 static const char kRealPlayerGroupName[]; 85 static const char kRealPlayerGroupName[];
87 static const char kSilverlightGroupName[]; 86 static const char kSilverlightGroupName[];
88 static const char kWindowsMediaPlayerGroupName[]; 87 static const char kWindowsMediaPlayerGroupName[];
89 88
90 PluginGroup(const PluginGroup& other); 89 PluginGroup(const PluginGroup& other);
91 90
92 ~PluginGroup(); 91 ~PluginGroup();
(...skipping 18 matching lines...) Expand all
111 identifier_ = identifier; 110 identifier_ = identifier;
112 } 111 }
113 112
114 // Returns this group's name, or the filename without extension if the name 113 // Returns this group's name, or the filename without extension if the name
115 // is empty. 114 // is empty.
116 string16 GetGroupName() const; 115 string16 GetGroupName() const;
117 116
118 // Checks whether a plugin exists in the group with the given path. 117 // Checks whether a plugin exists in the group with the given path.
119 bool ContainsPlugin(const FilePath& path) const; 118 bool ContainsPlugin(const FilePath& path) const;
120 119
120 // Returns the update URL.
121 std::string GetUpdateURL() const { return update_url_; }
122
123 // Returns true if this plugin group is whitelisted.
124 bool IsWhitelisted() const;
125
121 // Returns true if |plugin| in this group has known security problems. 126 // Returns true if |plugin| in this group has known security problems.
122 bool IsVulnerable(const WebPluginInfo& plugin) const; 127 bool IsVulnerable(const WebPluginInfo& plugin) const;
123 128
129 // Returns true if |plugin| in this plug-in group always requires user
130 // authorization to run.
131 bool RequiresAuthorization(const WebPluginInfo& plugin) const;
132
124 // Check if the group has no plugins. Could happen after a reload if the plug- 133 // Check if the group has no plugins. Could happen after a reload if the plug-
125 // in has disappeared from the pc (or in the process of updating). 134 // in has disappeared from the pc (or in the process of updating).
126 bool IsEmpty() const; 135 bool IsEmpty() const;
127 136
128 // Parse a version string as used by a plug-in. This method is more lenient 137 // Parse a version string as used by a plug-in. This method is more lenient
129 // in accepting weird version strings than Version::GetFromString(). 138 // in accepting weird version strings than Version::GetFromString().
130 static Version* CreateVersionFromString(const string16& version_string); 139 static Version* CreateVersionFromString(const string16& version_string);
131 140
132 const std::vector<webkit::WebPluginInfo>& web_plugin_infos() const { 141 const std::vector<webkit::WebPluginInfo>& web_plugin_infos() const {
133 return web_plugin_infos_; 142 return web_plugin_infos_;
134 } 143 }
135 144
136 private: 145 private:
146 friend class PluginList;
137 friend class MockPluginList; 147 friend class MockPluginList;
138 friend class PluginGroupTest; 148 friend class PluginGroupTest;
139 friend class PluginList;
140 friend class ::PluginExceptionsTableModelTest; 149 friend class ::PluginExceptionsTableModelTest;
141 FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated); 150 FRIEND_TEST_ALL_PREFIXES(PluginListTest, DisableOutdated);
142 151
143 // Generates the (short) identifier string for the given plugin. 152 // Generates the (short) identifier string for the given plugin.
144 static std::string GetIdentifier(const webkit::WebPluginInfo& wpi); 153 static std::string GetIdentifier(const webkit::WebPluginInfo& wpi);
145 154
146 // Generates the long identifier (based on the full file path) for the given 155 // Generates the long identifier (based on the full file path) for the given
147 // plugin, to be called when the short identifier is not unique. 156 // plugin, to be called when the short identifier is not unique.
148 static std::string GetLongIdentifier(const webkit::WebPluginInfo& wpi); 157 static std::string GetLongIdentifier(const webkit::WebPluginInfo& wpi);
149 158
(...skipping 10 matching lines...) Expand all
160 static bool IsVersionInRange(const Version& version, 169 static bool IsVersionInRange(const Version& version,
161 const VersionRange& range); 170 const VersionRange& range);
162 171
163 // Returns |true| iff |plugin_version| is both contained in |version_range| 172 // Returns |true| iff |plugin_version| is both contained in |version_range|
164 // and declared outdated (== vulnerable) by it. 173 // and declared outdated (== vulnerable) by it.
165 static bool IsPluginOutdated(const Version& plugin_version, 174 static bool IsPluginOutdated(const Version& plugin_version,
166 const VersionRange& version_range); 175 const VersionRange& version_range);
167 176
168 PluginGroup(const string16& group_name, 177 PluginGroup(const string16& group_name,
169 const string16& name_matcher, 178 const string16& name_matcher,
179 const std::string& update_url,
170 const std::string& identifier); 180 const std::string& identifier);
171 181
172 void InitFrom(const PluginGroup& other); 182 void InitFrom(const PluginGroup& other);
173 183
174 // Returns a non-const vector of all plugins in the group. This is only used 184 // Returns a non-const vector of all plugins in the group. This is only used
175 // by PluginList. 185 // by PluginList.
176 std::vector<webkit::WebPluginInfo>& GetPluginsContainer() { 186 std::vector<webkit::WebPluginInfo>& GetPluginsContainer() {
177 return web_plugin_infos_; 187 return web_plugin_infos_;
178 } 188 }
179 189
180 std::string identifier_; 190 std::string identifier_;
181 string16 group_name_; 191 string16 group_name_;
182 string16 name_matcher_; 192 string16 name_matcher_;
193 std::string update_url_;
183 std::vector<VersionRange> version_ranges_; 194 std::vector<VersionRange> version_ranges_;
184 std::vector<webkit::WebPluginInfo> web_plugin_infos_; 195 std::vector<webkit::WebPluginInfo> web_plugin_infos_;
185 }; 196 };
186 197
187 } // namespace npapi 198 } // namespace npapi
188 } // namespace webkit 199 } // namespace webkit
189 200
190 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_ 201 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_GROUP_H_
OLDNEW
« no previous file with comments | « content/utility/utility_thread_impl.cc ('k') | webkit/plugins/npapi/plugin_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698