Changeset 33570 in webkit


Ignore:
Timestamp:
May 19, 2008 3:09:38 AM (16 years ago)
Author:
zecke@webkit.org
Message:

2008-05-14 Marc Ordinas i Llopis <marc.ordinasillopis@collabora.co.uk>

Reviewed by Holger.

https://bugs.webkit.org/show_bug.cgi?id=18882
https://bugs.webkit.org/show_bug.cgi?id=18892
Based also on work by Chris Lord.

Provides support for NPAPI plugins that pass NULL as their instance
info. There are two kinds:

  • Some call NPN_UserAgent and NPN_GetValue before a PluginView has been created. For those we provide static versions of those functions.
  • Others call NPN_* functions with a NULL instance inside NPP_* calls, for those we've added extra currentPluginView guards.
  • plugins/PluginView.cpp: Add additional currentPluginView guards and some small style changes. (WebCore::PluginView::start): (WebCore::PluginView::performRequest): (WebCore::PluginView::bindingInstance): (WebCore::PluginView::handlePost):
  • plugins/PluginView.h: Added static versions of NPN_UserAgent and NPN_GetValue.
  • plugins/gtk/PluginViewGtk.cpp: Add additional currentPluginView guards and some small style changes. (WebCore::PluginView::setNPWindowRect): (WebCore::PluginView::stop): (WebCore::PluginView::userAgentStatic): Added to deal with plugins that query this before having a PluginView. (WebCore::PluginView::getValueStatic): Added to deal with plugins that call this before we have created a PluginView. (WebCore::PluginView::getValue): Moved some code to getValueStatic. (WebCore::PluginView::init):
  • plugins/npapi.cpp: Call PluginView::userAgentStatic and PluginView::getValueStatic if no PluginView is present. (NPN_UserAgent): (NPN_GetValue):
  • plugins/qt/PluginPackageQt.cpp: (WebCore::PluginPackage::fetchInfo): Corrected split args because ignoring empty entries crashed. (WebCore::PluginPackage::load): Resolve all symbols when loading plugins to protect against XPCOM dependencies.
  • plugins/qt/PluginViewQt.cpp: Add additional currentPluginView guards and some small style changes. (WebCore::PluginView::updateWindow): (WebCore::PluginView::setNPWindowRect): (WebCore::PluginView::stop): (WebCore::PluginView::userAgentStatic): Added to deal with plugins that query this before having a PluginView. (WebCore::PluginView::handlePostReadFile): (WebCore::PluginView::getValueStatic): Added to deal with plugins that call this before we have created a PluginView. (WebCore::PluginView::getValue): Moved some code to getValueStatic. (WebCore::PluginView::init): m_needsXEmbed init was moved to constructor.
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r33569 r33570  
     12008-05-14  Marc Ordinas i Llopis  <marc.ordinasillopis@collabora.co.uk>
     2
     3        Reviewed by Holger.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=18882
     6        https://bugs.webkit.org/show_bug.cgi?id=18892
     7        Based also on work by Chris Lord.
     8       
     9        Provides support for NPAPI plugins that pass NULL as their instance
     10        info. There are two kinds:
     11        - Some call NPN_UserAgent and NPN_GetValue before a PluginView has
     12        been created. For those we provide static versions of those functions.
     13        - Others call NPN_* functions with a NULL instance inside NPP_*
     14        calls, for those we've added extra currentPluginView guards.
     15
     16        * plugins/PluginView.cpp: Add additional currentPluginView guards and
     17        some small style changes.
     18        (WebCore::PluginView::start):
     19        (WebCore::PluginView::performRequest):
     20        (WebCore::PluginView::bindingInstance):
     21        (WebCore::PluginView::handlePost):
     22        * plugins/PluginView.h: Added static versions of NPN_UserAgent and
     23        NPN_GetValue.
     24        * plugins/gtk/PluginViewGtk.cpp: Add additional currentPluginView
     25        guards and some small style changes.
     26        (WebCore::PluginView::setNPWindowRect):
     27        (WebCore::PluginView::stop):
     28        (WebCore::PluginView::userAgentStatic): Added to deal with plugins
     29        that query this before having a PluginView.
     30        (WebCore::PluginView::getValueStatic): Added to deal with plugins
     31        that call this before we have created a PluginView.
     32        (WebCore::PluginView::getValue): Moved some code to getValueStatic.
     33        (WebCore::PluginView::init):
     34        * plugins/npapi.cpp: Call PluginView::userAgentStatic
     35        and PluginView::getValueStatic if no PluginView is
     36        present.
     37        (NPN_UserAgent):
     38        (NPN_GetValue):
     39        * plugins/qt/PluginPackageQt.cpp:
     40        (WebCore::PluginPackage::fetchInfo): Corrected split args because ignoring
     41        empty entries crashed.
     42        (WebCore::PluginPackage::load): Resolve all symbols when loading plugins
     43        to protect against XPCOM dependencies.
     44        * plugins/qt/PluginViewQt.cpp: Add additional currentPluginView guards and
     45        some small style changes.
     46        (WebCore::PluginView::updateWindow):
     47        (WebCore::PluginView::setNPWindowRect):
     48        (WebCore::PluginView::stop):
     49        (WebCore::PluginView::userAgentStatic): Added to deal with plugins
     50        that query this before having a PluginView.
     51        (WebCore::PluginView::handlePostReadFile):
     52        (WebCore::PluginView::getValueStatic): Added to deal with plugins
     53        that call this before we have created a PluginView.
     54        (WebCore::PluginView::getValue): Moved some code to getValueStatic.
     55        (WebCore::PluginView::init): m_needsXEmbed init was moved to constructor.
     56
    1572008-05-19  Alp Toker  <alp@nuanti.com>
    258
  • trunk/WebCore/plugins/PluginView.cpp

    r33441 r33570  
    152152
    153153    NPError npErr;
    154     PluginView::setCurrentPluginView(this);
    155154    {
     155        PluginView::setCurrentPluginView(this);
    156156        KJS::JSLock::DropAllLocks dropAllLocks;
    157157        setCallingPlugin(true);
     
    159159        setCallingPlugin(false);
    160160        LOG_NPERROR(npErr);
    161     }
    162     PluginView::setCurrentPluginView(0);
     161        PluginView::setCurrentPluginView(0);
     162    }
    163163
    164164    if (npErr != NPERR_NO_ERROR)
     
    235235            // FIXME: <rdar://problem/4807469> This should be sent when the document has finished loading
    236236            if (request->sendNotification()) {
     237                PluginView::setCurrentPluginView(this);
    237238                KJS::JSLock::DropAllLocks dropAllLocks;
    238239                setCallingPlugin(true);
    239240                m_plugin->pluginFuncs()->urlnotify(m_instance, requestURL.string().utf8().data(), NPRES_DONE, request->notifyData());
    240241                setCallingPlugin(false);
     242                PluginView::setCurrentPluginView(0);
    241243            }
    242244        }
     
    462464    NPError npErr;
    463465    {
     466        PluginView::setCurrentPluginView(this);
    464467        KJS::JSLock::DropAllLocks dropAllLocks;
    465468        setCallingPlugin(true);
    466469        npErr = m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginScriptableNPObject, &object);
    467470        setCallingPlugin(false);
     471        PluginView::setCurrentPluginView(0);
    468472    }
    469473
  • trunk/WebCore/plugins/PluginView.h

    r33452 r33570  
    119119        NPError destroyStream(NPStream* stream, NPReason reason);
    120120        const char* userAgent();
     121        static const char* userAgentStatic();
    121122        void status(const char* message);
    122123        NPError getValue(NPNVariable variable, void* value);
     124        static NPError getValueStatic(NPNVariable variable, void* value);
    123125        NPError setValue(NPPVariable variable, void* value);
    124126        void invalidateRect(NPRect*);
  • trunk/WebCore/plugins/gtk/PluginViewGtk.cpp

    r33569 r33570  
    226226
    227227    if (m_plugin->pluginFuncs()->setwindow) {
     228        PluginView::setCurrentPluginView(this);
    228229        KJS::JSLock::DropAllLocks dropAllLocks;
    229230        setCallingPlugin(true);
    230231        m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
    231232        setCallingPlugin(false);
     233        PluginView::setCurrentPluginView(0);
    232234
    233235        if (!m_isWindowed)
     
    283285#endif
    284286    if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) {
     287        PluginView::setCurrentPluginView(this);
    285288        setCallingPlugin(true);
    286289        m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
    287290        setCallingPlugin(false);
     291        PluginView::setCurrentPluginView(0);
    288292    }
    289293
    290294    // Destroy the plugin
    291295    {
     296        PluginView::setCurrentPluginView(this);
    292297        setCallingPlugin(true);
    293298        m_plugin->pluginFuncs()->destroy(m_instance, 0);
    294299        setCallingPlugin(false);
     300        PluginView::setCurrentPluginView(0);
    295301    }
    296302
     
    309315
    310316    return m_userAgent.data();
     317}
     318
     319const char* PluginView::userAgentStatic()
     320{
     321    //FIXME - Lie and say we are Mozilla
     322    return MozillaUserAgent;
    311323}
    312324
     
    340352}
    341353
    342 NPError PluginView::getValue(NPNVariable variable, void* value)
     354NPError PluginView::getValueStatic(NPNVariable variable, void* value)
    343355{
    344356    switch (variable) {
    345 #if defined(GDK_WINDOWING_X11)
    346         case NPNVxtAppContext: {
    347             if (!m_needsXEmbed) {
    348                 *(void **)value = XtDisplayToApplicationContext (GTK_XTBIN(m_window)->xtclient.xtdisplay);
    349 
    350                 return NPERR_NO_ERROR;
    351             } else
    352                 return NPERR_GENERIC_ERROR;
    353         }
    354 #endif
    355 
    356357        case NPNVToolkit: {
    357358#if PLATFORM(GTK)
     
    372373        }
    373374
     375    case NPNVjavascriptEnabledBool: {
     376        *((uint32 *)value) = true;
     377        return NPERR_NO_ERROR;
     378    }
     379
     380    default:
     381        return NPERR_GENERIC_ERROR;
     382    }
     383}
     384
     385NPError PluginView::getValue(NPNVariable variable, void* value)
     386{
     387    switch (variable) {
     388    case NPNVxDisplay: {
     389#if defined(GDK_WINDOWING_X11)
     390        if (m_needsXEmbed)
     391            *(void **)value = (void *)GDK_DISPLAY();
     392        else
     393            *(void **)value = (void *)GTK_XTBIN(m_window)->xtclient.xtdisplay;
     394        return NPERR_NO_ERROR;
     395#else
     396        return NPERR_GENERIC_ERROR;
     397#endif
     398    }
     399
     400#if defined(GDK_WINDOWING_X11)
     401    case NPNVxtAppContext: {
     402        if (!m_needsXEmbed) {
     403            *(void **)value = XtDisplayToApplicationContext (GTK_XTBIN(m_window)->xtclient.xtdisplay);
     404
     405            return NPERR_NO_ERROR;
     406        } else
     407            return NPERR_GENERIC_ERROR;
     408    }
     409#endif
     410
    374411#if ENABLE(NETSCAPE_PLUGIN_API)
    375412        case NPNVWindowNPObject: {
     
    421458        }
    422459        default:
    423             return NPERR_GENERIC_ERROR;
     460            return getValueStatic(variable, value);
    424461    }
    425462}
     
    487524    }
    488525
    489     if (m_plugin->pluginFuncs()->getvalue)
     526    if (m_plugin->pluginFuncs()->getvalue) {
     527        PluginView::setCurrentPluginView(this);
     528        KJS::JSLock::DropAllLocks dropAllLocks;
     529        setCallingPlugin(true);
    490530        m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginNeedsXEmbed, &m_needsXEmbed);
     531        setCallingPlugin(false);
     532        PluginView::setCurrentPluginView(0);
     533    }
    491534
    492535#if defined(GDK_WINDOWING_X11)
  • trunk/WebCore/plugins/npapi.cpp

    r32766 r33570  
    108108    PluginView* view = pluginViewForInstance(instance);
    109109
    110      // FIXME: Some plug-ins call NPN_UserAgent with a null instance in their NP_initialize function!
    111      // We'd need a way to get a user agent without having a frame around.
    112110     if (!view)
    113          return 0;
     111         return PluginView::userAgentStatic();
    114112 
    115113    return view->userAgent();
     
    138136NPError NPN_GetValue(NPP instance, NPNVariable variable, void* value)
    139137{
    140     // FIXME: Acrobat reader plugin calls NPN_GetValue before a PluginView
    141     // has been created
    142     if (!instance)
    143         return NPERR_GENERIC_ERROR;
     138    PluginView* view = pluginViewForInstance(instance);
     139
     140     if (!view)
     141         return PluginView::getValueStatic(variable, value);
    144142
    145143    return pluginViewForInstance(instance)->getValue(variable, value);
  • trunk/WebCore/plugins/qt/PluginPackageQt.cpp

    r32809 r33570  
    8888    for (int i = 0; i < types.size(); ++i) {
    8989        Vector<String> mime;
    90         types[i].split(UChar(':'), false, mime);
     90        types[i].split(UChar(':'), true, mime);
    9191        if (mime.size() > 0) {
    9292            Vector<String> exts;
     
    111111
    112112    m_module = new QLibrary((QString)m_path);
     113    m_module->setLoadHints(QLibrary::ResolveAllSymbolsHint);
    113114    if (!m_module->load()) {
    114115        LOG(Plugin, "%s not loaded", m_path.utf8().data());
  • trunk/WebCore/plugins/qt/PluginViewQt.cpp

    r32766 r33570  
    186186
    187187    if (m_plugin->pluginFuncs()->setwindow) {
     188        PluginView::setCurrentPluginView(this);
    188189        KJS::JSLock::DropAllLocks dropAllLocks;
    189190        setCallingPlugin(true);
    190191        m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
    191192        setCallingPlugin(false);
     193        PluginView::setCurrentPluginView(0);
     194
     195        if (!m_isWindowed)
     196            return;
    192197
    193198        ASSERT(m_window);
     
    238243    m_npWindow.ws_info = 0;
    239244    if (m_plugin->pluginFuncs()->setwindow && !m_plugin->quirks().contains(PluginQuirkDontSetNullWindowHandleOnDestroy)) {
     245        PluginView::setCurrentPluginView(this);
    240246        setCallingPlugin(true);
    241247        m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
    242248        setCallingPlugin(false);
     249        PluginView::setCurrentPluginView(0);
    243250    }
    244251
    245252    // Destroy the plugin
    246253    {
     254        PluginView::setCurrentPluginView(this);
    247255        setCallingPlugin(true);
    248256        m_plugin->pluginFuncs()->destroy(m_instance, 0);
    249257        setCallingPlugin(false);
     258        PluginView::setCurrentPluginView(0);
    250259    }
    251260
     
    264273
    265274    return m_userAgent.data();
     275}
     276
     277const char* PluginView::userAgentStatic()
     278{
     279    //FIXME - Just say we are Mozilla
     280    return MozillaUserAgent;
    266281}
    267282
     
    292307
    293308    return NPERR_NO_ERROR;
     309}
     310
     311NPError PluginView::getValueStatic(NPNVariable variable, void* value)
     312{
     313    switch (variable) {
     314    case NPNVToolkit: {
     315        *((uint32 *)value) = 0;
     316        return NPERR_NO_ERROR;
     317    }
     318
     319    case NPNVSupportsXEmbedBool: {
     320        *((uint32 *)value) = true;
     321        return NPERR_NO_ERROR;
     322    }
     323
     324    case NPNVjavascriptEnabledBool: {
     325        *((uint32 *)value) = true;
     326        return NPERR_NO_ERROR;
     327    }
     328
     329    default:
     330        return NPERR_GENERIC_ERROR;
     331    }
    294332}
    295333
     
    309347        }
    310348
    311         case NPNVToolkit: {
    312             *((uint32 *)value) = 0;
    313             return NPERR_NO_ERROR;
    314         }
    315 
    316         case NPNVSupportsXEmbedBool: {
    317             *((uint32 *)value) = true;
    318             return NPERR_NO_ERROR;
    319         }
    320 
    321349#if ENABLE(NETSCAPE_PLUGIN_API)
    322350        case NPNVWindowNPObject: {
     
    362390        }
    363391
    364         case NPNVjavascriptEnabledBool: {
    365             *((uint32 *)value) = true;
    366             return NPERR_NO_ERROR;
    367         }
    368 
    369392        default:
    370             return NPERR_GENERIC_ERROR;
     393            return getValueStatic(variable, value);
    371394    }
    372395}
     
    426449    }
    427450
    428     m_needsXEmbed = false;
    429     if (m_plugin->pluginFuncs()->getvalue)
     451    if (m_plugin->pluginFuncs()->getvalue) {
     452        PluginView::setCurrentPluginView(this);
     453        KJS::JSLock::DropAllLocks dropAllLocks;
     454        setCallingPlugin(true);
    430455        m_plugin->pluginFuncs()->getvalue(m_instance, NPPVpluginNeedsXEmbed, &m_needsXEmbed);
     456        setCallingPlugin(false);
     457        PluginView::setCurrentPluginView(0);
     458    }
    431459
    432460    if (m_needsXEmbed) {
Note: See TracChangeset for help on using the changeset viewer.