Chromium Code Reviews| 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 = ""; |
|
Bernhard Bauer
2012/08/13 11:25:43
Nit: The default constructor for std::string alrea
ibraaaa
2012/08/13 12:26:45
Done.
|
| + 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"; |
|
Bernhard Bauer
2012/08/13 11:25:43
I think this slightly changes the behavior for emp
ibraaaa
2012/08/13 12:26:45
Done.
|
| + 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); |
| } |