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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 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 #include "webkit/plugins/webplugininfo.h" 5 #include "webkit/plugins/webplugininfo.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_split.h"
9 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
9 11
10 namespace webkit { 12 namespace webkit {
11 13
12 WebPluginMimeType::WebPluginMimeType() {} 14 WebPluginMimeType::WebPluginMimeType() {}
13 15
14 WebPluginMimeType::WebPluginMimeType(const std::string& m, 16 WebPluginMimeType::WebPluginMimeType(const std::string& m,
15 const std::string& f, 17 const std::string& f,
16 const std::string& d) 18 const std::string& d)
17 : mime_type(m), 19 : mime_type(m),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const string16& fake_desc) 58 const string16& fake_desc)
57 : name(fake_name), 59 : name(fake_name),
58 path(fake_path), 60 path(fake_path),
59 version(fake_version), 61 version(fake_version),
60 desc(fake_desc), 62 desc(fake_desc),
61 mime_types(), 63 mime_types(),
62 type(PLUGIN_TYPE_NPAPI), 64 type(PLUGIN_TYPE_NPAPI),
63 pepper_permissions(0) { 65 pepper_permissions(0) {
64 } 66 }
65 67
68 /* static */
69 void WebPluginInfo::CreateVersionFromString(const string16& version_string,
70 Version* parsed_version) {
71 // Remove spaces and ')' from the version string,
72 // Replace any instances of 'r', ',' or '(' with a dot.
73 std::string version = UTF16ToASCII(version_string);
74 RemoveChars(version, ") ", &version);
75 std::replace(version.begin(), version.end(), 'd', '.');
76 std::replace(version.begin(), version.end(), 'r', '.');
77 std::replace(version.begin(), version.end(), ',', '.');
78 std::replace(version.begin(), version.end(), '(', '.');
79 std::replace(version.begin(), version.end(), '_', '.');
80
81 // Remove leading zeros from each of the version components.
82 std::string no_leading_zeros_version;
83 std::vector<std::string> numbers;
84 base::SplitString(version, '.', &numbers);
85 for (size_t i = 0; i < numbers.size(); ++i) {
86 size_t n = numbers[i].size();
87 size_t j = 0;
88 while (j < n && numbers[i][j] == '0') {
89 ++j;
90 }
91 no_leading_zeros_version += (j < n) ? numbers[i].substr(j) : "0";
92 if (i != numbers.size() - 1) {
93 no_leading_zeros_version += ".";
94 }
95 }
96
97 *parsed_version = Version(no_leading_zeros_version);
98 }
99
66 bool IsPepperPlugin(const WebPluginInfo& plugin) { 100 bool IsPepperPlugin(const WebPluginInfo& plugin) {
67 return ((plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS ) || 101 return ((plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS ) ||
68 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) || 102 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) ||
69 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED)); 103 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED));
70 } 104 }
71 105
72 bool IsOutOfProcessPlugin(const WebPluginInfo& plugin) { 106 bool IsOutOfProcessPlugin(const WebPluginInfo& plugin) {
73 return ((plugin.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) || 107 return ((plugin.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) ||
74 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) || 108 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS) ||
75 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED)); 109 (plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_UNSANDBOXED));
76 } 110 }
77 111
78 } // namespace webkit 112 } // namespace webkit
OLDNEW
« 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