| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/npapi/plugin_group.h" | 5 #include "webkit/plugins/npapi/plugin_group.h" |
| 6 | 6 |
| 7 #include "base/linked_ptr.h" | 7 #include "base/linked_ptr.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 if (plugin.name.find(name_matcher_) == string16::npos) { | 179 if (plugin.name.find(name_matcher_) == string16::npos) { |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 | 182 |
| 183 if (version_ranges_.empty()) { | 183 if (version_ranges_.empty()) { |
| 184 return true; | 184 return true; |
| 185 } | 185 } |
| 186 | 186 |
| 187 // There's at least one version range, the plugin's version must be in it. | 187 // There's at least one version range, the plugin's version must be in it. |
| 188 scoped_ptr<Version> plugin_version( | 188 scoped_ptr<Version> plugin_version( |
| 189 Version::GetVersionFromString(UTF16ToWide(plugin.version))); | 189 Version::GetVersionFromString(UTF16ToASCII(plugin.version))); |
| 190 if (plugin_version.get() == NULL) { | 190 if (plugin_version.get() == NULL) { |
| 191 // No version could be extracted, assume we don't match the range. | 191 // No version could be extracted, assume we don't match the range. |
| 192 return false; | 192 return false; |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Match if the plugin is contained in any of the defined VersionRanges. | 195 // Match if the plugin is contained in any of the defined VersionRanges. |
| 196 for (size_t i = 0; i < version_ranges_.size(); ++i) { | 196 for (size_t i = 0; i < version_ranges_.size(); ++i) { |
| 197 if (IsVersionInRange(*plugin_version, version_ranges_[i])) { | 197 if (IsVersionInRange(*plugin_version, version_ranges_[i])) { |
| 198 return true; | 198 return true; |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 // None of the VersionRanges matched. | 201 // None of the VersionRanges matched. |
| 202 return false; | 202 return false; |
| 203 } | 203 } |
| 204 | 204 |
| 205 /* static */ | 205 /* static */ |
| 206 Version* PluginGroup::CreateVersionFromString(const string16& version_string) { | 206 Version* PluginGroup::CreateVersionFromString(const string16& version_string) { |
| 207 // Remove spaces and ')' from the version string, | 207 // Remove spaces and ')' from the version string, |
| 208 // Replace any instances of 'r', ',' or '(' with a dot. | 208 // Replace any instances of 'r', ',' or '(' with a dot. |
| 209 std::wstring version = UTF16ToWide(version_string); | 209 std::wstring version = UTF16ToWide(version_string); |
| 210 RemoveChars(version, L") ", &version); | 210 RemoveChars(version, L") ", &version); |
| 211 std::replace(version.begin(), version.end(), 'r', '.'); | 211 std::replace(version.begin(), version.end(), 'r', '.'); |
| 212 std::replace(version.begin(), version.end(), ',', '.'); | 212 std::replace(version.begin(), version.end(), ',', '.'); |
| 213 std::replace(version.begin(), version.end(), '(', '.'); | 213 std::replace(version.begin(), version.end(), '(', '.'); |
| 214 | 214 |
| 215 return Version::GetVersionFromString(version); | 215 return Version::GetVersionFromString(WideToASCII(version)); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) { | 218 void PluginGroup::UpdateActivePlugin(const WebPluginInfo& plugin) { |
| 219 // A group is enabled if any of the files are enabled. | 219 // A group is enabled if any of the files are enabled. |
| 220 if (plugin.enabled) { | 220 if (plugin.enabled) { |
| 221 if (!enabled_) { | 221 if (!enabled_) { |
| 222 // If this is the first enabled plugin, use its description. | 222 // If this is the first enabled plugin, use its description. |
| 223 enabled_ = true; | 223 enabled_ = true; |
| 224 UpdateDescriptionAndVersion(plugin); | 224 UpdateDescriptionAndVersion(plugin); |
| 225 } | 225 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 } else { | 404 } else { |
| 405 it->enabled = false; | 405 it->enabled = false; |
| 406 PluginList::Singleton()->DisablePlugin(it->path); | 406 PluginList::Singleton()->DisablePlugin(it->path); |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 enabled_ = enabled_plugin_exists; | 409 enabled_ = enabled_plugin_exists; |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace npapi | 412 } // namespace npapi |
| 413 } // namespace webkit | 413 } // namespace webkit |
| OLD | NEW |