Changeset 64744 in webkit


Ignore:
Timestamp:
Aug 5, 2010 7:02:15 AM (14 years ago)
Author:
Adam Roben
Message:

Get WebKitTestRunner loading TestNetscapePlugin on Windows

Fixes <http://webkit.org/b/43513> WebKitTestRunner on Windows fails to
load TestNetscapePlugin

Reviewed by Jon Honeycutt.

WebKit2:

Teach WebKit2 how to load the TestNetscapePlugin

  • Platform/Module.cpp:

(WebKit::Module::Module): Initialize m_module on Windows.

  • Platform/Module.h: Added m_module on Windows.
  • Platform/win/ModuleWin.cpp:

(WebKit::Module::load): Implemented using ::LoadLibraryExW.
(WebKit::Module::unload): Implemented using ::FreeLibrary.
(WebKit::Module::platformFunctionPointer): Implemented using
::GetProcAddress.

  • Platform/win/RunLoopWin.cpp:

(RunLoop::TimerBase::timerFired): Kill the native timer before calling
the fired callback. This makes all our timers non-repeating, but
that's all we need currently.
(RunLoop::TimerBase::start): Added an assertion to help us figure out
when we need to implement repeating timers. Also fixed a typo.

  • UIProcess/Plugins/win/PluginInfoStoreWin.cpp:

(WebKit::PluginInfoStore::pluginsDirectories): Added a FIXME.

(WebKit::PathWalker::PathWalker):
(WebKit::PathWalker::~PathWalker):
(WebKit::PathWalker::isValid):
(WebKit::PathWalker::data):
(WebKit::PathWalker::step):
Added. This class wraps the ::FindFirstFile/::FindNextFile APIs.

(WebKit::PluginInfoStore::pluginPathsInDirectory): Implemented by
porting logic from
WebCore::PluginDatabase::getPluginPathsInDirectories.
(WebKit::getVersionInfo): Copied from PluginDatabaseWin.cpp.
(WebKit::PluginInfoStore::getPluginInfo): Implemented by porting logic
from WebCore::PluginPackage::fetchInfo.
(WebKit::PluginInfoStore::shouldUsePlugin): Changed to always return
true for now. Added a FIXME about implementing this for real.

  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::didReceiveSyncMessage):

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::createPlugin):
Removed PLATFORM(MAC) guards around plugin code.

  • win/WebKit2.vcproj: Let VS sort the file.

WebKitTools:

Fix the path to TestNetscapePlugin's directory on Windows

  • WebKitTestRunner/win/TestControllerWin.cpp:

(WTR::TestController::initializeTestPluginDirectory):
TestNetscapePlugin is in a TestNetscapePlugin[_Debug] directory that's
next to WebKitTestRunner.exe. Previously we were passing the directory
that contains WebKitTestRunner.exe. Also fixed some leaks.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r64739 r64744  
     12010-08-04  Adam Roben  <aroben@apple.com>
     2
     3        Teach WebKit2 how to load the TestNetscapePlugin
     4
     5        Fixes <http://webkit.org/b/43513> WebKitTestRunner on Windows fails to
     6        load TestNetscapePlugin
     7
     8        Reviewed by Jon Honeycutt.
     9
     10        * Platform/Module.cpp:
     11        (WebKit::Module::Module): Initialize m_module on Windows.
     12
     13        * Platform/Module.h: Added m_module on Windows.
     14
     15        * Platform/win/ModuleWin.cpp:
     16        (WebKit::Module::load): Implemented using ::LoadLibraryExW.
     17        (WebKit::Module::unload): Implemented using ::FreeLibrary.
     18        (WebKit::Module::platformFunctionPointer): Implemented using
     19        ::GetProcAddress.
     20
     21        * Platform/win/RunLoopWin.cpp:
     22        (RunLoop::TimerBase::timerFired): Kill the native timer before calling
     23        the fired callback. This makes all our timers non-repeating, but
     24        that's all we need currently.
     25        (RunLoop::TimerBase::start): Added an assertion to help us figure out
     26        when we need to implement repeating timers. Also fixed a typo.
     27
     28        * UIProcess/Plugins/win/PluginInfoStoreWin.cpp:
     29        (WebKit::PluginInfoStore::pluginsDirectories): Added a FIXME.
     30
     31        (WebKit::PathWalker::PathWalker):
     32        (WebKit::PathWalker::~PathWalker):
     33        (WebKit::PathWalker::isValid):
     34        (WebKit::PathWalker::data):
     35        (WebKit::PathWalker::step):
     36        Added. This class wraps the ::FindFirstFile/::FindNextFile APIs.
     37
     38        (WebKit::PluginInfoStore::pluginPathsInDirectory): Implemented by
     39        porting logic from
     40        WebCore::PluginDatabase::getPluginPathsInDirectories.
     41        (WebKit::getVersionInfo): Copied from PluginDatabaseWin.cpp.
     42        (WebKit::PluginInfoStore::getPluginInfo): Implemented by porting logic
     43        from WebCore::PluginPackage::fetchInfo.
     44        (WebKit::PluginInfoStore::shouldUsePlugin): Changed to always return
     45        true for now. Added a FIXME about implementing this for real.
     46
     47        * UIProcess/WebProcessProxy.cpp:
     48        (WebKit::WebProcessProxy::didReceiveSyncMessage):
     49        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     50        (WebKit::WebFrameLoaderClient::createPlugin):
     51        Removed PLATFORM(MAC) guards around plugin code.
     52
     53        * win/WebKit2.vcproj: Let VS sort the file.
     54
    1552010-08-05  Antti Koivisto  <koivisto@iki.fi>
    256
  • trunk/WebKit2/Platform/Module.cpp

    r64663 r64744  
    3232Module::Module(const String& path)
    3333    : m_path(path)
     34#if PLATFORM(WIN)
     35    , m_module(0)
     36#endif
    3437{
    3538}
  • trunk/WebKit2/Platform/Module.h

    r64663 r64744  
    5454#if PLATFORM(MAC)
    5555    RetainPtr<CFBundleRef> m_bundle;
     56#elif PLATFORM(WIN)
     57    HMODULE m_module;
    5658#endif
    5759};
  • trunk/WebKit2/Platform/win/ModuleWin.cpp

    r64663 r64744  
    2626#include "Module.h"
    2727
    28 #include "NotImplemented.h"
     28#include <shlwapi.h>
    2929
    3030namespace WebKit {
     
    3232bool Module::load()
    3333{
    34     notImplemented();
    35     return false;
     34    ASSERT(!::PathIsRelativeW(m_path.charactersWithNullTermination()));
     35    m_module = ::LoadLibraryExW(m_path.charactersWithNullTermination(), 0, LOAD_WITH_ALTERED_SEARCH_PATH);
     36    return m_module;
    3637}
    3738
    3839void Module::unload()
    3940{
    40     notImplemented();
     41    if (!m_module)
     42        return;
     43    ::FreeLibrary(m_module);
     44    m_module = 0;
    4145}
    4246
    4347void* Module::platformFunctionPointer(const char* functionName) const
    4448{
    45     notImplemented();
    46     return 0;
     49    if (!m_module)
     50        return 0;
     51
     52    return ::GetProcAddress(m_module, functionName);
    4753}
    4854
    49 }
     55} // namespace WebKit
  • trunk/WebKit2/Platform/win/RunLoopWin.cpp

    r57739 r64744  
    122122    TimerBase* timer = it->second;
    123123
     124    // FIMXE: Support repeating timers.
     125
     126    ::KillTimer(runLoop->m_runLoopMessageWindow, ID);
    124127    timer->fired();
    125128}
     
    142145}
    143146
    144 void RunLoop::TimerBase::start(double nextFireInterval, double /*repeatInterval*/)
     147void RunLoop::TimerBase::start(double nextFireInterval, double repeatInterval)
    145148{
    146     // FIMXE: Support repeating timers.
     149    // FIXME: Support repeating timers.
     150    ASSERT_ARG(repeatInterval, !repeatInterval);
    147151
    148152    m_runLoop->m_activeTimers.set(m_ID, this);
  • trunk/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp

    r64287 r64744  
    2727
    2828#include "NotImplemented.h"
     29#include <WebCore/FileSystem.h>
     30#include <wtf/OwnArrayPtr.h>
    2931
    3032using namespace WebCore;
     
    3436Vector<String> PluginInfoStore::pluginsDirectories()
    3537{
     38    // FIXME: <http://webkit.org/b/43510> Migrate logic here from PluginDatabase::defaultPluginDirectories.
    3639    notImplemented();
    3740    return Vector<String>();
    3841}
    3942
     43class PathWalker : public Noncopyable {
     44public:
     45    PathWalker(const String& directory)
     46    {
     47        String pattern = directory + "\\*";
     48        m_handle = ::FindFirstFileW(pattern.charactersWithNullTermination(), &m_data);
     49    }
     50
     51    ~PathWalker()
     52    {
     53        if (!isValid())
     54            return;
     55        ::FindClose(m_handle);
     56    }
     57
     58    bool isValid() const { return m_handle != INVALID_HANDLE_VALUE; }
     59    const WIN32_FIND_DATAW& data() const { return m_data; }
     60
     61    bool step() { return ::FindNextFileW(m_handle, &m_data); }
     62
     63private:
     64    HANDLE m_handle;
     65    WIN32_FIND_DATAW m_data;
     66};
     67
    4068Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
    4169{
    42     notImplemented();
    43     return Vector<String>();
     70    Vector<String> paths;
     71
     72    PathWalker walker(directory);
     73    if (!walker.isValid())
     74        return paths;
     75
     76    do {
     77        if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
     78            continue;
     79
     80        String filename = walker.data().cFileName;
     81        if ((!filename.startsWith("np", false) || !filename.endsWith("dll", false)) && (!equalIgnoringCase(filename, "Plugin.dll") || !directory.endsWith("Shockwave 10", false)))
     82            continue;
     83
     84        paths.append(directory + "\\" + filename);
     85    } while (walker.step());
     86
     87    return paths;
     88}
     89
     90static String getVersionInfo(const LPVOID versionInfoData, const String& info)
     91{
     92    LPVOID buffer;
     93    UINT bufferLength;
     94    String subInfo = "\\StringfileInfo\\040904E4\\" + info;
     95    if (!::VerQueryValueW(versionInfoData, const_cast<UChar*>(subInfo.charactersWithNullTermination()), &buffer, &bufferLength) || !bufferLength)
     96        return String();
     97
     98    // Subtract 1 from the length; we don't want the trailing null character.
     99    return String(reinterpret_cast<UChar*>(buffer), bufferLength - 1);
    44100}
    45101
    46102bool PluginInfoStore::getPluginInfo(const String& pluginPath, Plugin& plugin)
    47103{
    48     notImplemented();
    49     return false;
     104    String pathCopy = pluginPath;
     105    DWORD versionInfoSize = ::GetFileVersionInfoSizeW(pathCopy.charactersWithNullTermination(), 0);
     106    if (!versionInfoSize)
     107        return false;
     108
     109    OwnArrayPtr<char> versionInfoData(new char[versionInfoSize]);
     110    if (!::GetFileVersionInfoW(pathCopy.charactersWithNullTermination(), 0, versionInfoSize, versionInfoData.get()))
     111        return false;
     112
     113    String name = getVersionInfo(versionInfoData.get(), "ProductName");
     114    String description = getVersionInfo(versionInfoData.get(), "FileDescription");
     115    if (name.isNull() || description.isNull())
     116        return false;
     117
     118    Vector<String> types;
     119    getVersionInfo(versionInfoData.get(), "MIMEType").split('|', types);
     120    Vector<String> extensionLists;
     121    getVersionInfo(versionInfoData.get(), "FileExtents").split('|', extensionLists);
     122    Vector<String> descriptions;
     123    getVersionInfo(versionInfoData.get(), "FileOpenName").split('|', descriptions);
     124
     125    Vector<MimeClassInfo> mimes(types.size());
     126    for (size_t i = 0; i < types.size(); i++) {
     127        String type = types[i].lower();
     128        String description = i < descriptions.size() ? descriptions[i] : "";
     129        String extensionList = i < extensionLists.size() ? extensionLists[i] : "";
     130
     131        Vector<String> extensionsVector;
     132        extensionList.split(',', extensionsVector);
     133
     134        // Get rid of the extension list that may be at the end of the description string.
     135        int pos = description.find("(*");
     136        if (pos != -1) {
     137            // There might be a space that we need to get rid of.
     138            if (pos > 1 && description[pos - 1] == ' ')
     139                pos--;
     140            description = description.left(pos);
     141        }
     142
     143        mimes[i].type = type;
     144        mimes[i].desc = description;
     145        mimes[i].extensions.swap(extensionsVector);
     146    }
     147
     148    plugin.path = pluginPath;
     149    plugin.info.desc = description;
     150    plugin.info.name = name;
     151    plugin.info.file = pathGetFileName(pluginPath);
     152    plugin.info.mimes.swap(mimes);
     153    return true;
    50154}
    51155
    52156bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin, const Vector<Plugin>& loadedPlugins)
    53157{
     158    // FIXME: <http://webkit.org/b/43509> Migrate logic here from
     159    // PluginDatabase::getPluginPathsInDirectories and PluginPackage::isPluginBlacklisted.
    54160    notImplemented();
    55     return false;
     161    return true;
    56162}
    57163
  • trunk/WebKit2/UIProcess/WebProcessProxy.cpp

    r64396 r64744  
    338338
    339339            case WebProcessProxyMessage::GetPluginHostConnection: {
    340 #if PLATFORM(MAC)
    341340                String mimeType;
    342341                String urlString;
     
    348347                getPluginHostConnection(mimeType, KURL(ParsedURLString, urlString), pluginPath);
    349348                reply->encode(CoreIPC::In(pluginPath));
    350 #endif
    351349                break;
    352350            }
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r64494 r64744  
    2929#include "NotImplemented.h"
    3030
    31 #if PLATFORM(MAC)
    3231#include "NetscapePlugin.h"
    33 #endif
    34 
    3532#include "PluginView.h"
    3633#include "WebCoreArgumentCoders.h"
     
    837834        return 0;
    838835
    839     // FIXME: This is Mac specific now because Windows doesn't have the necessary parts of NetscapePluginModule implemented.
    840 #if PLATFORM(MAC)
    841836    RefPtr<NetscapePluginModule> pluginModule = NetscapePluginModule::getOrCreate(pluginPath);
    842837    if (!pluginModule)
     
    852847    RefPtr<Plugin> plugin = NetscapePlugin::create(pluginModule.release());
    853848    return PluginView::create(pluginElement, plugin.release(), parameters);
    854 #else
    855     return 0;
    856 #endif
    857849}
    858850
  • trunk/WebKit2/win/WebKit2.vcproj

    r64688 r64744  
    13421342                        >
    13431343                        <File
     1344                                RelativePath="..\Platform\Module.cpp"
     1345                                >
     1346                        </File>
     1347                        <File
     1348                                RelativePath="..\Platform\Module.h"
     1349                                >
     1350                        </File>
     1351                        <File
    13441352                                RelativePath="..\Platform\PlatformProcessIdentifier.h"
    1345                                 >
    1346                         </File>
    1347                         <File
    1348                                 RelativePath="..\Platform\Module.cpp"
    1349                                 >
    1350                         </File>
    1351                         <File
    1352                                 RelativePath="..\Platform\Module.h"
    13531353                                >
    13541354                        </File>
  • trunk/WebKitTools/ChangeLog

    r64743 r64744  
     12010-08-04  Adam Roben  <aroben@apple.com>
     2
     3        Fix the path to TestNetscapePlugin's directory on Windows
     4
     5        Fixes <http://webkit.org/b/43513> WebKitTestRunner on Windows fails to
     6        load TestNetscapePlugin
     7
     8        Reviewed by Jon Honeycutt.
     9
     10        * WebKitTestRunner/win/TestControllerWin.cpp:
     11        (WTR::TestController::initializeTestPluginDirectory):
     12        TestNetscapePlugin is in a TestNetscapePlugin[_Debug] directory that's
     13        next to WebKitTestRunner.exe. Previously we were passing the directory
     14        that contains WebKitTestRunner.exe. Also fixed some leaks.
     15
    1162010-08-05  Kenichi Ishibashi  <bashi@google.com>
    217
  • trunk/WebKitTools/WebKitTestRunner/win/TestControllerWin.cpp

    r64286 r64744  
    2929#include <io.h>
    3030#include <WebKit2/WKStringCF.h>
     31#include <wtf/RetainPtr.h>
    3132
    3233namespace WTR {
     34
     35#if !defined(NDEBUG) && (!defined(DEBUG_INTERNAL) || defined(DEBUG_ALL))
     36const LPWSTR testPluginDirectoryName = L"TestNetscapePlugin_Debug";
     37#else
     38const LPWSTR testPluginDirectoryName = L"TestNetscapePlugin";
     39#endif
    3340
    3441void TestController::platformInitialize()
     
    5360void TestController::initializeTestPluginDirectory()
    5461{
    55     CFStringRef exeContainerPath = CFURLCopyFileSystemPath(CFURLCreateCopyDeletingLastPathComponent(0, CFBundleCopyExecutableURL(CFBundleGetMainBundle())), kCFURLWindowsPathStyle);
    56     CFMutableStringRef bundlePath = CFStringCreateMutableCopy(0, 0, exeContainerPath);
    57     m_testPluginDirectory.adopt(WKStringCreateWithCFString(bundlePath));
     62    RetainPtr<CFURLRef> bundleURL(AdoptCF, CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
     63    RetainPtr<CFURLRef> bundleDirectoryURL(AdoptCF, CFURLCreateCopyDeletingLastPathComponent(0, bundleURL.get()));
     64    RetainPtr<CFStringRef> testPluginDirectoryNameString(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(testPluginDirectoryName), wcslen(testPluginDirectoryName)));
     65    RetainPtr<CFURLRef> testPluginDirectoryURL(AdoptCF, CFURLCreateCopyAppendingPathComponent(0, bundleDirectoryURL.get(), testPluginDirectoryNameString.get(), true));
     66    RetainPtr<CFStringRef> testPluginDirectoryPath(AdoptCF, CFURLCopyFileSystemPath(testPluginDirectoryURL.get(), kCFURLWindowsPathStyle));
     67    m_testPluginDirectory.adopt(WKStringCreateWithCFString(testPluginDirectoryPath.get()));
    5868}
    5969
Note: See TracChangeset for help on using the changeset viewer.