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

Unified Diff: webkit/plugins/webplugininfo.cc

Issue 10823434: [6] Moves CreateVersionFromString to plugin_utils and updates the callers. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 2nd CL in series to delete PluginGroup. 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
Index: webkit/plugins/webplugininfo.cc
diff --git a/webkit/plugins/webplugininfo.cc b/webkit/plugins/webplugininfo.cc
index 27c65149d463ae301a1ae4be61c760a3ae87d862..c168c0e400c1d64376d37f60d1b6c92815d1bebd 100644
--- a/webkit/plugins/webplugininfo.cc
+++ b/webkit/plugins/webplugininfo.cc
@@ -5,6 +5,8 @@
#include "webkit/plugins/webplugininfo.h"
#include "base/logging.h"
+#include "base/string_split.h"
+#include "base/string_util.h"
#include "base/utf_string_conversions.h"
namespace webkit {
@@ -63,6 +65,38 @@ WebPluginInfo::WebPluginInfo(const string16& fake_name,
pepper_permissions(0) {
}
+/* static */
+void WebPluginInfo::CreateVersionFromString(const string16& version_string,
+ Version* parsed_version) {
+ // Remove spaces and ')' from the version string,
+ // Replace any instances of 'r', ',' or '(' with a dot.
+ std::string version = UTF16ToASCII(version_string);
+ RemoveChars(version, ") ", &version);
+ std::replace(version.begin(), version.end(), 'd', '.');
+ std::replace(version.begin(), version.end(), 'r', '.');
+ std::replace(version.begin(), version.end(), ',', '.');
+ std::replace(version.begin(), version.end(), '(', '.');
+ std::replace(version.begin(), version.end(), '_', '.');
+
+ // Remove leading zeros from each of the version components.
+ 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 += ".";
+ }
+ }
+
+ *parsed_version = Version(no_leading_zeros_version);
+}
+
bool IsPepperPlugin(const WebPluginInfo& plugin) {
return ((plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS ) ||
(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) ||
« chrome/renderer/chrome_content_renderer_client.cc ('K') | « webkit/plugins/webplugininfo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698