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

Unified Diff: webkit/plugins/npapi/plugin_group.cc

Issue 10263022: Move version metadata from PluginGroup into PluginInstaller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/npapi/plugin_group.h ('k') | webkit/plugins/npapi/plugin_group_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/npapi/plugin_group.cc
diff --git a/webkit/plugins/npapi/plugin_group.cc b/webkit/plugins/npapi/plugin_group.cc
index aa8be2f12aec2e9eb9685d26c846815d590ed252..6f3c6074204eba7eefb3d4ab5ac8585e85542ec4 100644
--- a/webkit/plugins/npapi/plugin_group.cc
+++ b/webkit/plugins/npapi/plugin_group.cc
@@ -27,38 +27,6 @@ const char PluginGroup::kRealPlayerGroupName[] = "RealPlayer";
const char PluginGroup::kSilverlightGroupName[] = "Silverlight";
const char PluginGroup::kWindowsMediaPlayerGroupName[] = "Windows Media Player";
-VersionRange::VersionRange(const VersionRangeDefinition& definition)
- : low_str(definition.version_matcher_low),
- high_str(definition.version_matcher_high),
- min_str(definition.min_version) {
- if (!low_str.empty())
- low.reset(Version::GetVersionFromString(low_str));
- if (!high_str.empty())
- high.reset(Version::GetVersionFromString(high_str));
- if (!min_str.empty())
- min.reset(Version::GetVersionFromString(min_str));
-}
-
-VersionRange::VersionRange(const VersionRange& other) {
- InitFrom(other);
-}
-
-VersionRange& VersionRange::operator=(const VersionRange& other) {
- InitFrom(other);
- return *this;
-}
-
-VersionRange::~VersionRange() {}
-
-void VersionRange::InitFrom(const VersionRange& other) {
- low_str = other.low_str;
- high_str = other.high_str;
- min_str = other.min_str;
- low.reset(Version::GetVersionFromString(other.low_str));
- high.reset(Version::GetVersionFromString(other.high_str));
- min.reset(Version::GetVersionFromString(other.min_str));
-}
-
PluginGroup::PluginGroup(const string16& group_name,
const string16& name_matcher,
const std::string& identifier)
@@ -71,7 +39,6 @@ void PluginGroup::InitFrom(const PluginGroup& other) {
identifier_ = other.identifier_;
group_name_ = other.group_name_;
name_matcher_ = other.name_matcher_;
- version_ranges_ = other.version_ranges_;
web_plugin_infos_ = other.web_plugin_infos_;
}
@@ -87,12 +54,9 @@ PluginGroup& PluginGroup::operator=(const PluginGroup& other) {
/*static*/
PluginGroup* PluginGroup::FromPluginGroupDefinition(
const PluginGroupDefinition& definition) {
- PluginGroup* group = new PluginGroup(ASCIIToUTF16(definition.name),
- ASCIIToUTF16(definition.name_matcher),
- definition.identifier);
- for (size_t i = 0; i < definition.num_versions; ++i)
- group->version_ranges_.push_back(VersionRange(definition.versions[i]));
- return group;
+ return new PluginGroup(ASCIIToUTF16(definition.name),
+ ASCIIToUTF16(definition.name_matcher),
+ definition.identifier);
}
PluginGroup::~PluginGroup() { }
@@ -132,25 +96,7 @@ bool PluginGroup::Match(const WebPluginInfo& plugin) const {
return false;
}
- if (version_ranges_.empty()) {
- return true;
- }
-
- // There's at least one version range, the plugin's version must be in it.
- scoped_ptr<Version> plugin_version(CreateVersionFromString(plugin.version));
- if (plugin_version.get() == NULL) {
- // No version could be extracted, assume we don't match the range.
- return false;
- }
-
- // Match if the plugin is contained in any of the defined VersionRanges.
- for (size_t i = 0; i < version_ranges_.size(); ++i) {
- if (IsVersionInRange(*plugin_version, version_ranges_[i])) {
- return true;
- }
- }
- // None of the VersionRanges matched.
- return false;
+ return true;
}
/* static */
@@ -213,41 +159,6 @@ bool PluginGroup::ContainsPlugin(const FilePath& path) const {
return false;
}
-/*static*/
-bool PluginGroup::IsVersionInRange(const Version& version,
- const VersionRange& range) {
- DCHECK(range.low.get() != NULL || range.high.get() == NULL)
- << "Lower bound of version range must be defined.";
- return (range.low.get() == NULL && range.high.get() == NULL) ||
- (range.low->CompareTo(version) <= 0 &&
- (range.high.get() == NULL || range.high->CompareTo(version) > 0));
-}
-
-/*static*/
-bool PluginGroup::IsPluginOutdated(const Version& plugin_version,
- const VersionRange& version_range) {
- if (IsVersionInRange(plugin_version, version_range)) {
- if (version_range.min.get() &&
- plugin_version.CompareTo(*version_range.min) < 0) {
- return true;
- }
- }
- return false;
-}
-
-// Returns true if the latest version of this plugin group is vulnerable.
-bool PluginGroup::IsVulnerable(const WebPluginInfo& plugin) const {
- scoped_ptr<Version> version(CreateVersionFromString(plugin.version));
- if (!version.get())
- return false;
-
- for (size_t i = 0; i < version_ranges_.size(); ++i) {
- if (IsPluginOutdated(*version, version_ranges_[i]))
- return true;
- }
- return false;
-}
-
bool PluginGroup::IsEmpty() const {
return web_plugin_infos_.empty();
}
« no previous file with comments | « webkit/plugins/npapi/plugin_group.h ('k') | webkit/plugins/npapi/plugin_group_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698