Changeset 89256 in webkit


Ignore:
Timestamp:
Jun 20, 2011 10:49:13 AM (13 years ago)
Author:
Carlos Garcia Campos
Message:

2011-06-20 Carlos Garcia Campos <cgarcia@igalia.com>

Reviewed by Martin Robinson.

[UNIX] Don't use WebCore::PluginPackage to get plugin information
https://bugs.webkit.org/show_bug.cgi?id=62899

The problem is that both PluginPackage in WebCore and
NetscapePluginModule in webkit2 install their own netscape browser
functions and that can cause conflicts in some situations.

  • Shared/Plugins/Netscape/NetscapePluginModule.h: Add helper function to set plugin mime type descriptions.
  • Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp: (WebKit::NetscapePluginModule::setMIMEDescription): Helper function to set plugin mime type descriptions. (WebKit::NetscapePluginModule::getPluginInfo): Use NetscapePluginModule instead of PluginPackage.
  • UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp: Remove unneeded header include.
  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp: (WebKit::NPN_GetValue): Do not try to get the XDisplay if the plugin doesn't have a view. It fixes a crash with flash plugin and matches WebCore.
Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r89251 r89256  
     12011-06-20  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [UNIX] Don't use WebCore::PluginPackage to get plugin information
     6        https://bugs.webkit.org/show_bug.cgi?id=62899
     7
     8        The problem is that both PluginPackage in WebCore and
     9        NetscapePluginModule in webkit2 install their own netscape browser
     10        functions and that can cause conflicts in some situations.
     11
     12        * Shared/Plugins/Netscape/NetscapePluginModule.h: Add helper
     13        function to set plugin mime type descriptions.
     14        * Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:
     15        (WebKit::NetscapePluginModule::setMIMEDescription): Helper
     16        function to set plugin mime type descriptions.
     17        (WebKit::NetscapePluginModule::getPluginInfo): Use
     18        NetscapePluginModule instead of PluginPackage.
     19        * UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp: Remove unneeded
     20        header include.
     21        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     22        (WebKit::NPN_GetValue): Do not try to get the XDisplay if the
     23        plugin doesn't have a view. It fixes a crash with flash plugin and
     24        matches WebCore.
     25
    1262011-06-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h

    r88819 r89256  
    6969#if PLUGIN_ARCHITECTURE(X11)
    7070    void applyX11QuirksBeforeLoad();
     71    static void setMIMEDescription(const String& mimeDescription, PluginModuleInfo&);
    7172#endif
    7273
  • trunk/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp

    r89150 r89256  
    2929#include "NetscapePluginModule.h"
    3030
    31 #include "PluginDatabase.h"
    32 #include "PluginPackage.h"
     31#include "NetscapeBrowserFuncs.h"
     32#include <WebCore/FileSystem.h>
    3333
    3434#if PLATFORM(QT)
     
    9494}
    9595
     96void NetscapePluginModule::setMIMEDescription(const String& mimeDescription, PluginModuleInfo& plugin)
     97{
     98    Vector<String> types;
     99    mimeDescription.lower().split(UChar(';'), false, types);
     100    plugin.info.mimes.reserveCapacity(types.size());
     101
     102    size_t mimeInfoCount = 0;
     103    for (size_t i = 0; i < types.size(); ++i) {
     104        Vector<String> mimeTypeParts;
     105        types[i].split(UChar(':'), true, mimeTypeParts);
     106        if (mimeTypeParts.size() <= 0)
     107            continue;
     108
     109        plugin.info.mimes.uncheckedAppend(MimeClassInfo());
     110        MimeClassInfo& mimeInfo = plugin.info.mimes[mimeInfoCount++];
     111        mimeInfo.type = mimeTypeParts[0];
     112
     113        if (mimeTypeParts.size() > 1)
     114            mimeTypeParts[1].split(UChar(','), false, mimeInfo.extensions);
     115
     116        if (mimeTypeParts.size() > 2)
     117            mimeInfo.desc = mimeTypeParts[2];
     118    }
     119}
     120
    96121bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
    97122{
     
    102127    // We are loading the plugin here since it does not seem to be a standardized way to
    103128    // get the needed informations from a UNIX plugin without loading it.
    104 
    105     RefPtr<PluginPackage> package = PluginPackage::createPackage(pluginPath, 0 /*lastModified*/);
    106     if (!package)
     129    RefPtr<NetscapePluginModule> pluginModule = NetscapePluginModule::getOrCreate(pluginPath);
     130    if (!pluginModule)
    107131        return false;
    108132
    109133    plugin.path = pluginPath;
    110     plugin.info.desc = package->description();
    111     plugin.info.file = package->fileName();
     134    plugin.info.file = pathGetFileName(pluginPath);
    112135
    113     const MIMEToDescriptionsMap& descriptions = package->mimeToDescriptions();
    114     const MIMEToExtensionsMap& extensions = package->mimeToExtensions();
    115     MIMEToDescriptionsMap::const_iterator descEnd = descriptions.end();
    116     plugin.info.mimes.reserveCapacity(descriptions.size());
    117     unsigned i = 0;
    118     for (MIMEToDescriptionsMap::const_iterator it = descriptions.begin(); it != descEnd; ++it) {
    119         plugin.info.mimes.uncheckedAppend(MimeClassInfo());
    120         MimeClassInfo& mime = plugin.info.mimes[i++];
    121         mime.type = it->first;
    122         mime.desc = it->second;
    123         MIMEToExtensionsMap::const_iterator extensionIt = extensions.find(it->first);
    124         ASSERT(extensionIt != extensions.end());
    125         mime.extensions = extensionIt->second;
    126     }
     136    Module* module = pluginModule->module();
     137    NPP_GetValueProcPtr NPP_GetValue = module->functionPointer<NPP_GetValueProcPtr>("NP_GetValue");
     138    if (!NPP_GetValue)
     139        return false;
    127140
    128     package->unload();
     141    NP_GetMIMEDescriptionFuncPtr NP_GetMIMEDescription = module->functionPointer<NP_GetMIMEDescriptionFuncPtr>("NP_GetMIMEDescription");
     142    if (!NP_GetMIMEDescription)
     143        return false;
     144
     145    char* buffer = 0;
     146    NPError err = NPP_GetValue(0, NPPVpluginDescriptionString, &buffer);
     147    if (err == NPERR_NO_ERROR)
     148        plugin.info.desc = buffer;
     149
     150    const char* mimeDescription = NP_GetMIMEDescription();
     151    if (!mimeDescription)
     152        return false;
     153
     154    setMIMEDescription(mimeDescription, plugin);
     155
    129156    return true;
    130157}
  • trunk/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp

    r88839 r89256  
    3131#include "NetscapePluginModule.h"
    3232#include "PluginDatabase.h"
    33 #include "PluginPackage.h"
    3433
    3534using namespace WebCore;
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r87945 r89256  
    504504           break;
    505505#elif PLUGIN_ARCHITECTURE(X11)
    506        case NPNVxDisplay:
     506       case NPNVxDisplay: {
     507           RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
     508           if (!plugin)
     509               return NPERR_GENERIC_ERROR;
    507510#if PLATFORM(QT)
    508511           *reinterpret_cast<Display**>(value) = QX11Info::display();
     
    514517           goto default;
    515518#endif
     519       }
    516520       case NPNVSupportsXEmbedBool:
    517521           *static_cast<NPBool*>(value) = true;
Note: See TracChangeset for help on using the changeset viewer.