diff options
author | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-10 23:43:57 +0000 |
---|---|---|
committer | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-10 23:43:57 +0000 |
commit | 6aaed7a2a41bcca966daa63b7edad16b3159ee1e (patch) | |
tree | 37cc276d211c7bd47133f299d341b020fcb5394f /webkit/plugins/npapi/plugin_lib_posix.cc | |
parent | d9b10feee212c63938d0b39904ea61fcea5f611e (diff) | |
download | chromium_src-6aaed7a2a41bcca966daa63b7edad16b3159ee1e.zip chromium_src-6aaed7a2a41bcca966daa63b7edad16b3159ee1e.tar.gz chromium_src-6aaed7a2a41bcca966daa63b7edad16b3159ee1e.tar.bz2 |
Support out-of-date plugin blocking on Linux.
BUG=NONE
TEST=plugin_group_unittest.cc,plugin_lib_unittest.cc
Review URL: http://codereview.chromium.org/5981010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70963 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins/npapi/plugin_lib_posix.cc')
-rw-r--r-- | webkit/plugins/npapi/plugin_lib_posix.cc | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/webkit/plugins/npapi/plugin_lib_posix.cc b/webkit/plugins/npapi/plugin_lib_posix.cc index 19fa141..27f87de 100644 --- a/webkit/plugins/npapi/plugin_lib_posix.cc +++ b/webkit/plugins/npapi/plugin_lib_posix.cc @@ -185,18 +185,25 @@ bool PluginLib::ReadWebPluginInfo(const FilePath& filename, if (NP_GetValue) { const char* name = NULL; NP_GetValue(NULL, nsPluginVariable_NameString, &name); - if (name) + if (name) { info->name = UTF8ToUTF16(name); + ExtractVersionString(name, info); + } const char* description = NULL; NP_GetValue(NULL, nsPluginVariable_DescriptionString, &description); - if (description) + if (description) { info->desc = UTF8ToUTF16(description); + if (info->version.empty()) + ExtractVersionString(description, info); + } LOG_IF(ERROR, PluginList::DebugPluginLoading()) << "Got info for plugin " << filename.value() << " Name = \"" << UTF16ToUTF8(info->name) - << "\", Description = \"" << UTF16ToUTF8(info->desc) << "\"."; + << "\", Description = \"" << UTF16ToUTF8(info->desc) + << "\", Version = \"" << UTF16ToUTF8(info->version) + << "\"."; } else { LOG_IF(ERROR, PluginList::DebugPluginLoading()) << "Plugin " << filename.value() @@ -252,6 +259,38 @@ void PluginLib::ParseMIMEDescription( } } +// static +void PluginLib::ExtractVersionString(const std::string& desc, + WebPluginInfo* info) { + // This matching works by extracting a version substring, along the lines of: + // No postfix: second match in .*<prefix>.*$ + // With postfix: second match .*<prefix>.*<postfix> + static const struct { + const char* kPrefix; + const char* kPostfix; + } kPrePostFixes[] = { + { "Shockwave Flash ", 0 }, + { "Java(TM) Plug-in ", 0 }, + { "(using IcedTea6 ", " " }, + { 0, 0 } + }; + std::string version; + for (size_t i = 0; kPrePostFixes[i].kPrefix; ++i) { + size_t pos; + if ((pos = desc.find(kPrePostFixes[i].kPrefix)) != std::string::npos) { + version = desc.substr(pos + strlen(kPrePostFixes[i].kPrefix)); + pos = std::string::npos; + if (kPrePostFixes[i].kPostfix) + pos = version.find(kPrePostFixes[i].kPostfix); + if (pos != std::string::npos) + version = version.substr(0, pos); + break; + } + } + if (!version.empty()) { + info->version = UTF8ToUTF16(version); + } +} } // namespace npapi } // namespace webkit |