From: aroben@apple.com Date: Fri, 5 Nov 2010 18:15:26 +0000 (+0000) Subject: Implement PluginInfoStore::shouldUsePlugin on Windows X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=03ecfb536a85d6d348ad3aaeb01e3f83d60c07df Implement PluginInfoStore::shouldUsePlugin on Windows Fixes WebKit2 should refuse to load the same plugins that old-WebKit refuses to load Reviewed by Anders Carlsson. * UIProcess/Plugins/win/PluginInfoStoreWin.cpp: (WebKit::fileVersion): Helper function to construct a 64-bit file version from two 32-bit numbers. (WebKit::PluginInfoStore::getPluginInfo): Ported code from WebCore::PluginPackage::fetchInfo to get the plugin's version. We now store it in Plugin::fileVersion. (WebKit::isOldWindowsMediaPlayerPlugin): (WebKit::isNewWindowsMediaPlayerPlugin): Added these helpers. The code came from WebCore::PluginDatabase::getPluginPathsInDirectories. (WebKit::PluginInfoStore::shouldUsePlugin): Implemented. The code was ported from WebCore::PluginDatabase::getPluginPathsInDirectories and WebCore::PluginPackage::isPluginBlacklisted. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@71436 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog index 6665c50..d5d0474 100644 --- a/WebKit2/ChangeLog +++ b/WebKit2/ChangeLog @@ -1,5 +1,30 @@ 2010-11-05 Adam Roben + Implement PluginInfoStore::shouldUsePlugin on Windows + + Fixes WebKit2 + should refuse to load the same plugins that old-WebKit refuses to load + + Reviewed by Anders Carlsson. + + * UIProcess/Plugins/win/PluginInfoStoreWin.cpp: + (WebKit::fileVersion): Helper function to construct a 64-bit file + version from two 32-bit numbers. + (WebKit::PluginInfoStore::getPluginInfo): Ported code from + WebCore::PluginPackage::fetchInfo to get the plugin's version. We now + store it in Plugin::fileVersion. + + (WebKit::isOldWindowsMediaPlayerPlugin): + (WebKit::isNewWindowsMediaPlayerPlugin): + Added these helpers. The code came from + WebCore::PluginDatabase::getPluginPathsInDirectories. + + (WebKit::PluginInfoStore::shouldUsePlugin): Implemented. The code was + ported from WebCore::PluginDatabase::getPluginPathsInDirectories and + WebCore::PluginPackage::isPluginBlacklisted. + +2010-11-05 Adam Roben + Operate on m_plugins directly in PluginInfoStore::shouldUsePlugin We'll need to operate on m_plugins if we ever want to unload an diff --git a/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp b/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp index 8eb860e..fe7d896 100644 --- a/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp +++ b/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp @@ -352,6 +352,14 @@ static String getVersionInfo(const LPVOID versionInfoData, const String& info) return String(reinterpret_cast(buffer), bufferLength - 1); } +static uint64_t fileVersion(DWORD leastSignificant, DWORD mostSignificant) +{ + ULARGE_INTEGER version; + version.LowPart = leastSignificant; + version.HighPart = mostSignificant; + return version.QuadPart; +} + bool PluginInfoStore::getPluginInfo(const String& pluginPath, Plugin& plugin) { String pathCopy = pluginPath; @@ -368,6 +376,11 @@ bool PluginInfoStore::getPluginInfo(const String& pluginPath, Plugin& plugin) if (name.isNull() || description.isNull()) return false; + VS_FIXEDFILEINFO* info; + UINT infoSize; + if (!::VerQueryValueW(versionInfoData.get(), L"\\", reinterpret_cast(&info), &infoSize) || infoSize < sizeof(VS_FIXEDFILEINFO)) + return false; + Vector types; getVersionInfo(versionInfoData.get(), "MIMEType").split('|', types); Vector extensionLists; @@ -403,14 +416,72 @@ bool PluginInfoStore::getPluginInfo(const String& pluginPath, Plugin& plugin) plugin.info.name = name; plugin.info.file = pathGetFileName(pluginPath); plugin.info.mimes.swap(mimes); + plugin.fileVersion = fileVersion(info->dwFileVersionLS, info->dwFileVersionMS); + return true; } +static bool isOldWindowsMediaPlayerPlugin(const PluginInfoStore::Plugin& plugin) +{ + return equalIgnoringCase(plugin.info.file, "npdsplay.dll"); +} + +static bool isNewWindowsMediaPlayerPlugin(const PluginInfoStore::Plugin& plugin) +{ + return equalIgnoringCase(plugin.info.file, "np-mswmp.dll"); +} + bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin) { - // FIXME: Migrate logic here from - // PluginDatabase::getPluginPathsInDirectories and PluginPackage::isPluginBlacklisted. - notImplemented(); + // FIXME: We should prefer a newer version of a plugin to an older version, rather than loading + // both. + + if (plugin.info.name == "Citrix ICA Client") { + // The Citrix ICA Client plug-in requires a Mozilla-based browser; see . + return false; + } + + if (plugin.info.name == "Silverlight Plug-In") { + // workaround for Crash in Silverlight when opening microsoft.com. + // the latest 1.0 version of Silverlight does not reproduce this crash, so allow it + // and any newer versions + static const uint64_t minimumRequiredVersion = fileVersion(0x51BE0000, 0x00010000); + return plugin.fileVersion >= minimumRequiredVersion; + } + + if (equalIgnoringCase(plugin.info.file, "npmozax.dll")) { + // Bug 15217: Mozilla ActiveX control complains about missing xpcom_core.dll + return false; + } + + if (plugin.info.name == "Yahoo Application State Plugin") { + // https://bugs.webkit.org/show_bug.cgi?id=26860 + // Bug in Yahoo Application State plug-in earlier than 1.0.0.6 leads to heap corruption. + static const uint64_t minimumRequiredVersion = fileVersion(0x00000006, 0x00010000); + return plugin.fileVersion >= minimumRequiredVersion; + } + + if (isOldWindowsMediaPlayerPlugin(plugin)) { + // Don't load the old Windows Media Player plugin if we've already loaded the new Windows + // Media Player plugin. + for (size_t i = 0; i < m_plugins.size(); ++i) { + if (!isNewWindowsMediaPlayerPlugin(m_plugins[i])) + continue; + return false; + } + return true; + } + + if (isNewWindowsMediaPlayerPlugin(plugin)) { + // Unload the old Windows Media Player plugin if we've already loaded it. + for (size_t i = 0; i < m_plugins.size(); ++i) { + if (!isOldWindowsMediaPlayerPlugin(m_plugins[i])) + continue; + m_plugins.remove(i); + } + return true; + } + return true; }