OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "webkit/plugins/npapi/plugin_group.h" | 7 #include "webkit/plugins/npapi/plugin_group.h" |
8 | 8 |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 // Look for the name matcher anywhere in the plugin name. | 94 // Look for the name matcher anywhere in the plugin name. |
95 if (plugin.name.find(name_matcher_) == string16::npos) { | 95 if (plugin.name.find(name_matcher_) == string16::npos) { |
96 return false; | 96 return false; |
97 } | 97 } |
98 | 98 |
99 return true; | 99 return true; |
100 } | 100 } |
101 | 101 |
102 /* static */ | 102 /* static */ |
103 Version* PluginGroup::CreateVersionFromString(const string16& version_string) { | 103 void PluginGroup::CreateVersionFromString(const string16& version_string, |
| 104 Version* parsed_version) { |
104 // Remove spaces and ')' from the version string, | 105 // Remove spaces and ')' from the version string, |
105 // Replace any instances of 'r', ',' or '(' with a dot. | 106 // Replace any instances of 'r', ',' or '(' with a dot. |
106 std::string version = UTF16ToASCII(version_string); | 107 std::string version = UTF16ToASCII(version_string); |
107 RemoveChars(version, ") ", &version); | 108 RemoveChars(version, ") ", &version); |
108 std::replace(version.begin(), version.end(), 'd', '.'); | 109 std::replace(version.begin(), version.end(), 'd', '.'); |
109 std::replace(version.begin(), version.end(), 'r', '.'); | 110 std::replace(version.begin(), version.end(), 'r', '.'); |
110 std::replace(version.begin(), version.end(), ',', '.'); | 111 std::replace(version.begin(), version.end(), ',', '.'); |
111 std::replace(version.begin(), version.end(), '(', '.'); | 112 std::replace(version.begin(), version.end(), '(', '.'); |
112 std::replace(version.begin(), version.end(), '_', '.'); | 113 std::replace(version.begin(), version.end(), '_', '.'); |
113 | 114 |
114 return Version::GetVersionFromString(version); | 115 *parsed_version = Version(version); |
115 } | 116 } |
116 | 117 |
117 void PluginGroup::AddPlugin(const WebPluginInfo& plugin) { | 118 void PluginGroup::AddPlugin(const WebPluginInfo& plugin) { |
118 // Check if this group already contains this plugin. | 119 // Check if this group already contains this plugin. |
119 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { | 120 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { |
120 if (FilePath::CompareEqualIgnoreCase(web_plugin_infos_[i].path.value(), | 121 if (FilePath::CompareEqualIgnoreCase(web_plugin_infos_[i].path.value(), |
121 plugin.path.value())) { | 122 plugin.path.value())) { |
122 return; | 123 return; |
123 } | 124 } |
124 } | 125 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 159 } |
159 return false; | 160 return false; |
160 } | 161 } |
161 | 162 |
162 bool PluginGroup::IsEmpty() const { | 163 bool PluginGroup::IsEmpty() const { |
163 return web_plugin_infos_.empty(); | 164 return web_plugin_infos_.empty(); |
164 } | 165 } |
165 | 166 |
166 } // namespace npapi | 167 } // namespace npapi |
167 } // namespace webkit | 168 } // namespace webkit |
OLD | NEW |