Changeset 30650 in webkit


Ignore:
Timestamp:
Feb 28, 2008 12:46:37 PM (16 years ago)
Author:
pewtermoose@webkit.org
Message:

2008-02-28 Rodney Dawes <dobey@wayofthemonkey.com>

Reviewed by Adam Roben.

Copy PluginPackageWin.cpp to shared PluginPackage.cpp.
Add PluginPackage.cpp to build configurations.
Remove PluginPackage destructor from TemporaryLinkStubs.cpp.
Use cross-platform pathGetFilename method.
Remove platform-specific code from shared PluginPackage implementation.
Remove shared code from PluginPackageWin.cpp.

  • GNUmakefile.am:
  • WebCore.pro:
  • WebCoreSources.bkl:
  • WebCore.vcproj/WebCore.vcproj:
  • platform/gtk/TemporaryLinkStubs.cpp:
  • platform/qt/TemporaryLinkStubs.cpp:
  • platform/wx/TemporaryLinkStubs.cpp:
  • plugins/PluginPackage.cpp:
  • plugins/win/PluginPackageWin.cpp:
Location:
trunk/WebCore
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r30649 r30650  
     12008-02-28  Rodney Dawes  <dobey@wayofthemonkey.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        Copy PluginPackageWin.cpp to shared PluginPackage.cpp.
     6        Add PluginPackage.cpp to build configurations.
     7        Remove PluginPackage destructor from TemporaryLinkStubs.cpp.
     8        Use cross-platform pathGetFilename method.
     9        Remove platform-specific code from shared PluginPackage implementation.
     10        Remove shared code from PluginPackageWin.cpp.
     11
     12        * GNUmakefile.am:
     13        * WebCore.pro:
     14        * WebCoreSources.bkl:
     15        * WebCore.vcproj/WebCore.vcproj:
     16        * platform/gtk/TemporaryLinkStubs.cpp:
     17        * platform/qt/TemporaryLinkStubs.cpp:
     18        * platform/wx/TemporaryLinkStubs.cpp:
     19        * plugins/PluginPackage.cpp:
     20        * plugins/win/PluginPackageWin.cpp:
     21
    1222008-02-28  Justin Garcia  <justin.garcia@apple.com>
    223
  • trunk/WebCore/GNUmakefile.am

    r30616 r30650  
    851851        WebCore/plugins/PluginDatabase.cpp \
    852852        WebCore/plugins/PluginInfoStore.cpp \
     853        WebCore/plugins/PluginPackage.cpp \
    853854        WebCore/plugins/PluginStream.cpp \
    854855        WebCore/rendering/AutoTableLayout.cpp \
  • trunk/WebCore/WebCore.pro

    r30616 r30650  
    791791    plugins/PluginDatabase.cpp \
    792792    plugins/PluginInfoStore.cpp \
     793    plugins/PluginPackage.cpp \
    793794    plugins/PluginStream.cpp \
    794795    rendering/AutoTableLayout.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r30616 r30650  
    79907990                        </File>
    79917991                        <File
     7992                                RelativePath="..\plugins\PluginPackage.cpp"
     7993                                >
     7994                        </File>
     7995                        <File
    79927996                                RelativePath="..\plugins\PluginPackage.h"
    79937997                                >
  • trunk/WebCore/WebCoreSources.bkl

    r30616 r30650  
    636636        plugins/PluginDatabase.cpp
    637637        plugins/PluginInfoStore.cpp
     638        plugins/PluginPackage.cpp
    638639        plugins/PluginStream.cpp
    639640    </set>
  • trunk/WebCore/platform/gtk/TemporaryLinkStubs.cpp

    r30574 r30650  
    6868bool PluginPackage::equal(const PluginPackage&, const PluginPackage&) { notImplemented(); return false; }
    6969bool PluginPackage::load() { notImplemented(); return false; }
    70 PluginPackage::~PluginPackage() { notImplemented(); }
    7170
    7271Color WebCore::focusRingColor() { return 0xFF0000FF; }
  • trunk/WebCore/platform/qt/TemporaryLinkStubs.cpp

    r30574 r30650  
    8080bool PluginPackage::equal(const PluginPackage&, const PluginPackage&) { notImplemented(); return false; }
    8181bool PluginPackage::load() { notImplemented(); return false; }
    82 PluginPackage::~PluginPackage() { notImplemented(); }
    8382
    8483namespace WebCore {
  • trunk/WebCore/platform/wx/TemporaryLinkStubs.cpp

    r30574 r30650  
    127127bool PluginPackage::equal(const PluginPackage&, const PluginPackage&) { notImplemented(); return false; }
    128128bool PluginPackage::load() { notImplemented(); return false; }
    129 PluginPackage::~PluginPackage() { notImplemented(); }
    130129
    131130void Widget::setIsSelected(bool) { notImplemented(); }
  • trunk/WebCore/plugins/PluginPackage.cpp

    r30648 r30650  
    2525 */
    2626
    27 #include <shlwapi.h>
    28 
    2927#include "config.h"
    3028#include "PluginPackage.h"
     
    4341}
    4442
    45 static String getVersionInfo(const LPVOID versionInfoData, const String& info)
    46 {
    47     LPVOID buffer;
    48     UINT bufferLength;
    49     String subInfo = "\\StringfileInfo\\040904E4\\" + info;
    50     bool retval = VerQueryValueW(versionInfoData,
    51         const_cast<UChar*>(subInfo.charactersWithNullTermination()),
    52         &buffer, &bufferLength);
    53     if (!retval || bufferLength == 0)
    54         return String();
    55 
    56     // Subtract 1 from the length; we don't want the trailing null character.
    57     return String(reinterpret_cast<UChar*>(buffer), bufferLength - 1);
    58 }
    59 
    6043void PluginPackage::freeLibrarySoon()
    6144{
     
    7255    ASSERT(m_loadCount == 0);
    7356
    74     ::FreeLibrary(m_module);
     57    unloadModule(m_module);
    7558    m_module = 0;
    7659}
    7760
    78 PluginPackage::PluginPackage(const String& path, const FILETIME& lastModified)
     61PluginPackage::PluginPackage(const String& path, const PlatformFileTime& lastModified)
    7962    : RefCounted<PluginPackage>(0)
    8063    , m_path(path)
     
    8669    , m_freeLibraryTimer(this, &PluginPackage::freeLibraryTimerFired)
    8770{
    88     m_fileName = String(PathFindFileName(m_path.charactersWithNullTermination()));
     71    m_fileName = pathGetFileName(m_path);
    8972    m_parentDirectory = m_path.left(m_path.length() - m_fileName.length() - 1);
    90 }
    91 
    92 int PluginPackage::compareFileVersion(const PlatformModuleVersion& compareVersion) const
    93 {
    94     // return -1, 0, or 1 if plug-in version is less than, equal to, or greater than
    95     // the passed version
    96     if (m_moduleVersion.mostSig != compareVersion.mostSig)
    97         return m_moduleVersion.mostSig > compareVersion.mostSig ? 1 : -1;
    98     if (m_moduleVersion.leastSig != compareVersion.leastSig)
    99         return m_moduleVersion.leastSig > compareVersion.leastSig ? 1 : -1;
    100     return 0;
    101 }
    102 
    103 bool PluginPackage::isPluginBlacklisted()
    104 {
    105     static const PlatformModuleVersion slPluginMinRequired(0x51BE0000, 0x00010000);
    106 
    107     if (name() == "Silverlight Plug-In") {
    108         // workaround for <rdar://5557379> Crash in Silverlight when opening microsoft.com.
    109         // the latest 1.0 version of Silverlight does not reproduce this crash, so allow it
    110         // and any newer versions
    111         if (compareFileVersion(slPluginMinRequired) < 0)
    112             return true;
    113     } else if (fileName() == "npmozax.dll")
    114         // Bug 15217: Mozilla ActiveX control complains about missing xpcom_core.dll
    115         return true;
    116 
    117     return false;
    118 }
    119 
    120 void PluginPackage::determineQuirks(const String& mimeType)
    121 {
    122     static const PlatformModuleVersion lastKnownUnloadableRealPlayerVersion(0x000B0B24, 0x00060000);
    123 
    124     if (mimeType == "application/x-shockwave-flash") {
    125         // The flash plugin only requests windowless plugins if we return a mozilla user agent
    126         m_quirks.add(PluginQuirkWantsMozillaUserAgent);
    127         m_quirks.add(PluginQuirkThrottleInvalidate);
    128         m_quirks.add(PluginQuirkThrottleWMUserPlusOneMessages);
    129         m_quirks.add(PluginQuirkFlashURLNotifyBug);
    130     }
    131 
    132     if (name().contains("Microsoft") && name().contains("Windows Media")) {
    133         // The WMP plugin sets its size on the first NPP_SetWindow call and never updates its size, so
    134         // call SetWindow when the plugin view has a correct size
    135         m_quirks.add(PluginQuirkDeferFirstSetWindowCall);
    136 
    137         // Windowless mode does not work at all with the WMP plugin so just remove that parameter
    138         // and don't pass it to the plug-in.
    139         m_quirks.add(PluginQuirkRemoveWindowlessVideoParam);
    140 
    141         // WMP has a modal message loop that it enters whenever we call it or
    142         // ask it to paint. This modal loop can deliver messages to other
    143         // windows in WebKit at times when they are not expecting them (for
    144         // example, delivering a WM_PAINT message during a layout), and these
    145         // can cause crashes.
    146         m_quirks.add(PluginQuirkHasModalMessageLoop);
    147     }
    148 
    149     // VLC hangs on NPP_Destroy if we call NPP_SetWindow with a null window handle
    150     if (name() == "VLC Multimedia Plugin")
    151         m_quirks.add(PluginQuirkDontSetNullWindowHandleOnDestroy);
    152 
    153     // The DivX plugin sets its size on the first NPP_SetWindow call and never updates its size, so
    154     // call SetWindow when the plugin view has a correct size
    155     if (mimeType == "video/divx")
    156         m_quirks.add(PluginQuirkDeferFirstSetWindowCall);
    157 
    158     // FIXME: This is a workaround for a problem in our NPRuntime bindings; if a plug-in creates an
    159     // NPObject and passes it to a function it's not possible to see what root object that NPObject belongs to.
    160     // Thus, we don't know that the object should be invalidated when the plug-in instance goes away.
    161     // See <rdar://problem/5487742>.
    162     if (mimeType == "application/x-silverlight")
    163         m_quirks.add(PluginQuirkDontUnloadPlugin);
    164 
    165     if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType)) {
    166         // Because a single process cannot create multiple VMs, and we cannot reliably unload a
    167         // Java VM, we cannot unload the Java plugin, or we'll lose reference to our only VM
    168         m_quirks.add(PluginQuirkDontUnloadPlugin);
    169 
    170         // Setting the window region to an empty region causes bad scrolling repaint problems
    171         // with the Java plug-in.
    172         m_quirks.add(PluginQuirkDontClipToZeroRectWhenScrolling);
    173     }
    174 
    175     if (mimeType == "audio/x-pn-realaudio-plugin") {
    176         // Prevent the Real plugin from calling the Window Proc recursively, causing the stack to overflow.
    177         m_quirks.add(PluginQuirkDontCallWndProcForSameMessageRecursively);
    178 
    179         // Unloading RealPlayer versions newer than 10.5 can cause a hang; see rdar://5669317.
    180         // FIXME: Resume unloading when this bug in the RealPlayer Plug-In is fixed (rdar://5713147)
    181         if (compareFileVersion(lastKnownUnloadableRealPlayerVersion) > 0)
    182             m_quirks.add(PluginQuirkDontUnloadPlugin);
    183     }
    184 }
    185 
    186 bool PluginPackage::fetchInfo()
    187 {
    188     DWORD versionInfoSize, zeroHandle;
    189     versionInfoSize = GetFileVersionInfoSizeW(m_path.charactersWithNullTermination(), &zeroHandle);
    190     if (versionInfoSize == 0)
    191         return false;
    192 
    193     OwnArrayPtr<char> versionInfoData(new char[versionInfoSize]);
    194 
    195     if (!GetFileVersionInfoW(m_path.charactersWithNullTermination(), 0, versionInfoSize, versionInfoData.get()))
    196         return false;
    197 
    198     m_name = getVersionInfo(versionInfoData.get(), "ProductName");
    199     m_description = getVersionInfo(versionInfoData.get(), "FileDescription");
    200     if (m_name.isNull() || m_description.isNull())
    201         return false;
    202 
    203     VS_FIXEDFILEINFO* info;
    204     UINT infoSize;
    205     if (!VerQueryValue(versionInfoData.get(), TEXT("\\"), (LPVOID*) &info, &infoSize) || infoSize < sizeof(VS_FIXEDFILEINFO))
    206         return false;
    207     m_moduleVersion.leastSig = info->dwFileVersionLS;
    208     m_moduleVersion.mostSig = info->dwFileVersionMS;
    209 
    210     if (isPluginBlacklisted())
    211         return false;
    212 
    213     Vector<String> types;
    214     getVersionInfo(versionInfoData.get(), "MIMEType").split('|', types);
    215     Vector<String> extensionLists;
    216     getVersionInfo(versionInfoData.get(), "FileExtents").split('|', extensionLists);
    217     Vector<String> descriptions;
    218     getVersionInfo(versionInfoData.get(), "FileOpenName").split('|', descriptions);
    219 
    220     for (unsigned i = 0; i < types.size(); i++) {
    221         String type = types[i].lower();
    222         String description = i < descriptions.size() ? descriptions[i] : "";
    223         String extensionList = i < extensionLists.size() ? extensionLists[i] : "";
    224 
    225         Vector<String> extensionsVector;
    226         extensionList.split(',', extensionsVector);
    227 
    228         // Get rid of the extension list that may be at the end of the description string.
    229         int pos = description.find("(*");
    230         if (pos != -1) {
    231             // There might be a space that we need to get rid of.
    232             if (pos > 1 && description[pos - 1] == ' ')
    233                 pos--;
    234             description = description.left(pos);
    235         }
    236 
    237         // Determine the quirks for the MIME types this plug-in supports
    238         determineQuirks(type);
    239 
    240         m_mimeToExtensions.add(type, extensionsVector);
    241         m_mimeToDescriptions.add(type, description);
    242     }
    243 
    244     return true;
    245 }
    246 
    247 bool PluginPackage::load()
    248 {
    249     if (m_freeLibraryTimer.isActive()) {
    250         ASSERT(m_module);
    251         m_freeLibraryTimer.stop();
    252     } else if (m_isLoaded) {
    253         m_loadCount++;
    254         return true;
    255     } else {
    256         WCHAR currentPath[MAX_PATH];
    257 
    258         if (!::GetCurrentDirectoryW(MAX_PATH, currentPath))
    259             return false;
    260 
    261         String path = m_path.substring(0, m_path.reverseFind('\\'));
    262 
    263         if (!::SetCurrentDirectoryW(path.charactersWithNullTermination()))
    264             return false;
    265 
    266         // Load the library
    267         m_module = ::LoadLibraryW(m_path.charactersWithNullTermination());
    268 
    269         if (!::SetCurrentDirectoryW(currentPath)) {
    270             if (m_module)
    271                 ::FreeLibrary(m_module);
    272             return false;
    273         }
    274     }
    275 
    276     if (!m_module)
    277         return false;
    278 
    279     m_isLoaded = true;
    280 
    281     NP_GetEntryPointsFuncPtr NP_GetEntryPoints = 0;
    282     NP_InitializeFuncPtr NP_Initialize = 0;
    283     NPError npErr;
    284 
    285     NP_Initialize = (NP_InitializeFuncPtr)GetProcAddress(m_module, "NP_Initialize");
    286     NP_GetEntryPoints = (NP_GetEntryPointsFuncPtr)GetProcAddress(m_module, "NP_GetEntryPoints");
    287     m_NPP_Shutdown = (NPP_ShutdownProcPtr)GetProcAddress(m_module, "NP_Shutdown");
    288 
    289     if (!NP_Initialize || !NP_GetEntryPoints || !m_NPP_Shutdown)
    290         goto abort;
    291  
    292     memset(&m_pluginFuncs, 0, sizeof(m_pluginFuncs));
    293     m_pluginFuncs.size = sizeof(m_pluginFuncs);
    294 
    295     npErr = NP_GetEntryPoints(&m_pluginFuncs);
    296     LOG_NPERROR(npErr);
    297     if (npErr != NPERR_NO_ERROR)
    298         goto abort;
    299 
    300     memset(&m_browserFuncs, 0, sizeof(m_browserFuncs));
    301     m_browserFuncs.size = sizeof (m_browserFuncs);
    302     m_browserFuncs.version = NP_VERSION_MINOR;
    303 
    304     m_browserFuncs.geturl = NPN_GetURL;
    305     m_browserFuncs.posturl = NPN_PostURL;
    306     m_browserFuncs.requestread = NPN_RequestRead;
    307     m_browserFuncs.newstream = NPN_NewStream;
    308     m_browserFuncs.write = NPN_Write;
    309     m_browserFuncs.destroystream = NPN_DestroyStream;
    310     m_browserFuncs.status = NPN_Status;
    311     m_browserFuncs.uagent = NPN_UserAgent;
    312     m_browserFuncs.memalloc = NPN_MemAlloc;
    313     m_browserFuncs.memfree = NPN_MemFree;
    314     m_browserFuncs.memflush = NPN_MemFlush;
    315     m_browserFuncs.reloadplugins = NPN_ReloadPlugins;
    316     m_browserFuncs.geturlnotify = NPN_GetURLNotify;
    317     m_browserFuncs.posturlnotify = NPN_PostURLNotify;
    318     m_browserFuncs.getvalue = NPN_GetValue;
    319     m_browserFuncs.setvalue = NPN_SetValue;
    320     m_browserFuncs.invalidaterect = NPN_InvalidateRect;
    321     m_browserFuncs.invalidateregion = NPN_InvalidateRegion;
    322     m_browserFuncs.forceredraw = NPN_ForceRedraw;
    323     m_browserFuncs.getJavaEnv = NPN_GetJavaEnv;
    324     m_browserFuncs.getJavaPeer = NPN_GetJavaPeer;
    325     m_browserFuncs.pushpopupsenabledstate = NPN_PushPopupsEnabledState;
    326     m_browserFuncs.poppopupsenabledstate = NPN_PopPopupsEnabledState;
    327 
    328     m_browserFuncs.releasevariantvalue = _NPN_ReleaseVariantValue;
    329     m_browserFuncs.getstringidentifier = _NPN_GetStringIdentifier;
    330     m_browserFuncs.getstringidentifiers = _NPN_GetStringIdentifiers;
    331     m_browserFuncs.getintidentifier = _NPN_GetIntIdentifier;
    332     m_browserFuncs.identifierisstring = _NPN_IdentifierIsString;
    333     m_browserFuncs.utf8fromidentifier = _NPN_UTF8FromIdentifier;
    334     m_browserFuncs.intfromidentifier = _NPN_IntFromIdentifier;
    335     m_browserFuncs.createobject = _NPN_CreateObject;
    336     m_browserFuncs.retainobject = _NPN_RetainObject;
    337     m_browserFuncs.releaseobject = _NPN_ReleaseObject;
    338     m_browserFuncs.invoke = _NPN_Invoke;
    339     m_browserFuncs.invokeDefault = _NPN_InvokeDefault;
    340     m_browserFuncs.evaluate = _NPN_Evaluate;
    341     m_browserFuncs.getproperty = _NPN_GetProperty;
    342     m_browserFuncs.setproperty = _NPN_SetProperty;
    343     m_browserFuncs.removeproperty = _NPN_RemoveProperty;
    344     m_browserFuncs.hasproperty = _NPN_HasProperty;
    345     m_browserFuncs.hasmethod = _NPN_HasMethod;
    346     m_browserFuncs.setexception = _NPN_SetException;
    347     m_browserFuncs.enumerate = _NPN_Enumerate;
    348 
    349     npErr = NP_Initialize(&m_browserFuncs);
    350     LOG_NPERROR(npErr);
    351 
    352     if (npErr != NPERR_NO_ERROR)
    353         goto abort;
    354 
    355     m_loadCount++;
    356     return true;
    357 
    358 abort:
    359     unloadWithoutShutdown();
    360     return false;
    36173}
    36274
     
    393105}
    394106
    395 PluginPackage* PluginPackage::createPackage(const String& path, const FILETIME& lastModified)
     107PluginPackage* PluginPackage::createPackage(const String& path, const PlatformFileTime& lastModified)
    396108{
    397109    PluginPackage* package = new PluginPackage(path, lastModified);
     
    405117}
    406118
    407 unsigned PluginPackage::hash() const
    408 {
    409     const unsigned hashCodes[3] = {
    410         m_description.impl()->hash(),
    411         m_lastModified.dwLowDateTime,
    412         m_lastModified.dwHighDateTime
    413     };
    414 
    415     return StringImpl::computeHash(reinterpret_cast<const UChar*>(hashCodes), 3 * sizeof(unsigned) / sizeof(UChar));
    416119}
    417 
    418 bool PluginPackage::equal(const PluginPackage& a, const PluginPackage& b)
    419 {
    420     return a.m_description == b.m_description && (CompareFileTime(&a.m_lastModified, &b.m_lastModified) == 0);
    421 }
    422 
    423 }
  • trunk/WebCore/plugins/win/PluginPackageWin.cpp

    r30574 r30650  
    3838namespace WebCore {
    3939
    40 PluginPackage::~PluginPackage()
    41 {
    42     ASSERT(!m_isLoaded);
    43 }
    44 
    4540static String getVersionInfo(const LPVOID versionInfoData, const String& info)
    4641{
     
    5651    // Subtract 1 from the length; we don't want the trailing null character.
    5752    return String(reinterpret_cast<UChar*>(buffer), bufferLength - 1);
    58 }
    59 
    60 void PluginPackage::freeLibrarySoon()
    61 {
    62     ASSERT(!m_freeLibraryTimer.isActive());
    63     ASSERT(m_module);
    64     ASSERT(m_loadCount == 0);
    65 
    66     m_freeLibraryTimer.startOneShot(0);
    67 }
    68 
    69 void PluginPackage::freeLibraryTimerFired(Timer<PluginPackage>*)
    70 {
    71     ASSERT(m_module);
    72     ASSERT(m_loadCount == 0);
    73 
    74     ::FreeLibrary(m_module);
    75     m_module = 0;
    76 }
    77 
    78 PluginPackage::PluginPackage(const String& path, const FILETIME& lastModified)
    79     : RefCounted<PluginPackage>(0)
    80     , m_path(path)
    81     , m_moduleVersion(0)
    82     , m_module(0)
    83     , m_lastModified(lastModified)
    84     , m_isLoaded(false)
    85     , m_loadCount(0)
    86     , m_freeLibraryTimer(this, &PluginPackage::freeLibraryTimerFired)
    87 {
    88     m_fileName = String(PathFindFileName(m_path.charactersWithNullTermination()));
    89     m_parentDirectory = m_path.left(m_path.length() - m_fileName.length() - 1);
    9053}
    9154
     
    361324}
    362325
    363 void PluginPackage::unload()
    364 {
    365     if (!m_isLoaded)
    366         return;
    367 
    368     if (--m_loadCount > 0)
    369         return;
    370 
    371     m_NPP_Shutdown();
    372 
    373     unloadWithoutShutdown();
    374 }
    375 
    376 void PluginPackage::unloadWithoutShutdown()
    377 {
    378     if (!m_isLoaded)
    379         return;
    380 
    381     ASSERT(m_loadCount == 0);
    382     ASSERT(m_module);
    383 
    384     // <rdar://5530519>: Crash when closing tab with pdf file (Reader 7 only)
    385     // If the plugin has subclassed its parent window, as with Reader 7, we may have
    386     // gotten here by way of the plugin's internal window proc forwarding a message to our
    387     // original window proc. If we free the plugin library from here, we will jump back
    388     // to code we just freed when we return, so delay calling FreeLibrary at least until
    389     // the next message loop
    390     freeLibrarySoon();
    391 
    392     m_isLoaded = false;
    393 }
    394 
    395 PluginPackage* PluginPackage::createPackage(const String& path, const FILETIME& lastModified)
    396 {
    397     PluginPackage* package = new PluginPackage(path, lastModified);
    398 
    399     if (!package->fetchInfo()) {
    400         delete package;
    401         return 0;
    402     }
    403    
    404     return package;
    405 }
    406 
    407326unsigned PluginPackage::hash() const
    408327{
Note: See TracChangeset for help on using the changeset viewer.