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

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

Issue 10828279: Preprocessing version number for plugins to ignore leading zeros during comparisons. This eliminate… (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 4 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
===================================================================
--- webkit/plugins/npapi/plugin_group.cc (revision 151240)
+++ webkit/plugins/npapi/plugin_group.cc (working copy)
@@ -7,6 +7,7 @@
#include "webkit/plugins/npapi/plugin_group.h"
#include "base/memory/linked_ptr.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
@@ -100,6 +101,27 @@
}
/* static */
+std::string PluginGroup::RemoveLeadingZerosFromVersionComponents(
+ const std::string& version) {
+ std::string no_leading_zeros_version;
+ std::vector<std::string> numbers;
+ base::SplitString(version, '.', &numbers);
+ for (size_t i = 0; i < numbers.size(); ++i) {
+ size_t n = numbers[i].size();
+ size_t j = 0;
+ while (j < n && numbers[i][j] == '0') {
+ ++j;
+ }
+ no_leading_zeros_version += (j < n) ? numbers[i].substr(j) : "0";
+ if (i != numbers.size() - 1) {
+ no_leading_zeros_version += ".";
+ }
+ }
+
+ return no_leading_zeros_version;
+}
+
+/* static */
void PluginGroup::CreateVersionFromString(const string16& version_string,
Version* parsed_version) {
// Remove spaces and ')' from the version string,
@@ -112,6 +134,9 @@
std::replace(version.begin(), version.end(), '(', '.');
std::replace(version.begin(), version.end(), '_', '.');
+ // Remove leading zeros from each of the version components.
+ version = RemoveLeadingZerosFromVersionComponents(version);
+
*parsed_version = Version(version);
}
« 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