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

Side by Side Diff: webkit/plugins/webplugininfo.cc

Issue 19844003: Remove webkit/plugins/npapi. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove GetDefaultWindowParent Created 7 years, 5 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 | Annotate | Revision Log
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 <algorithm>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/version.h"
9 14
10 namespace webkit { 15 namespace webkit {
11 16
12 WebPluginMimeType::WebPluginMimeType() {} 17 WebPluginMimeType::WebPluginMimeType() {}
13 18
14 WebPluginMimeType::WebPluginMimeType(const std::string& m, 19 WebPluginMimeType::WebPluginMimeType(const std::string& m,
15 const std::string& f, 20 const std::string& f,
16 const std::string& d) 21 const std::string& d)
17 : mime_type(m), 22 : mime_type(m),
18 file_extensions(), 23 file_extensions(),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const base::string16& fake_desc) 61 const base::string16& fake_desc)
57 : name(fake_name), 62 : name(fake_name),
58 path(fake_path), 63 path(fake_path),
59 version(fake_version), 64 version(fake_version),
60 desc(fake_desc), 65 desc(fake_desc),
61 mime_types(), 66 mime_types(),
62 type(PLUGIN_TYPE_NPAPI), 67 type(PLUGIN_TYPE_NPAPI),
63 pepper_permissions(0) { 68 pepper_permissions(0) {
64 } 69 }
65 70
71 void WebPluginInfo::CreateVersionFromString(
72 const base::string16& version_string,
73 base::Version* parsed_version) {
74 // Remove spaces and ')' from the version string,
75 // Replace any instances of 'r', ',' or '(' with a dot.
76 std::string version = UTF16ToASCII(version_string);
77 RemoveChars(version, ") ", &version);
78 std::replace(version.begin(), version.end(), 'd', '.');
79 std::replace(version.begin(), version.end(), 'r', '.');
80 std::replace(version.begin(), version.end(), ',', '.');
81 std::replace(version.begin(), version.end(), '(', '.');
82 std::replace(version.begin(), version.end(), '_', '.');
83
84 // Remove leading zeros from each of the version components.
85 std::string no_leading_zeros_version;
86 std::vector<std::string> numbers;
87 base::SplitString(version, '.', &numbers);
88 for (size_t i = 0; i < numbers.size(); ++i) {
89 size_t n = numbers[i].size();
90 size_t j = 0;
91 while (j < n && numbers[i][j] == '0') {
92 ++j;
93 }
94 no_leading_zeros_version += (j < n) ? numbers[i].substr(j) : "0";
95 if (i != numbers.size() - 1) {
96 no_leading_zeros_version += ".";
97 }
98 }
99
100 *parsed_version = Version(no_leading_zeros_version);
101 }
102
66 } // namespace webkit 103 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698