Commit f69ea0c5 authored by hausmann@webkit.org's avatar hausmann@webkit.org

2008-07-04 Tor Arne Vestbø <tavestbo@trolltech.com>

        Reviewed by Simon.

        Move duplicated code from each PluginDatabaseXX-implementation
        to PluginDabase.cpp -- ifdefed based on the XP_PLATFORM we are
        compiling plugins for.

        This make the code cleaner and we can share common patterns.
        The only implementation left which is specific is the Win
        implementation (also used by QtWebKit/Win), but we might
        want to move that too.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35000 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 41429a06
2008-07-04 Tor Arne Vestbø <tavestbo@trolltech.com>
Reviewed by Simon.
Move duplicated code from each PluginDatabaseXX-implementation
to PluginDabase.cpp -- ifdefed based on the XP_PLATFORM we are
compiling plugins for.
This make the code cleaner and we can share common patterns.
The only implementation left which is specific is the Win
implementation (also used by QtWebKit/Win), but we might
want to move that too.
* GNUmakefile.am: Removed PluginDatabaseGtk.cpp from the build.
* WebCore.pro: Removed PluginDatabaseQt.cpp from the build.
* plugins/PluginDatabase.cpp:
(WebCore::PluginDatabase::defaultPluginDirectories):
(WebCore::PluginDatabase::isPreferredPluginDirectory):
(WebCore::PluginDatabase::getPluginPathsInDirectories):
* plugins/gtk/PluginDatabaseGtk.cpp: Removed.
* plugins/qt/PluginDatabaseQt.cpp: Removed.
* plugins/wx/PluginDatabaseWx.cpp: Removed.
* webcore-wx.bkl: Removed PluginDatabaseWx.cpp from the build.
2008-07-04 Simon Hausmann <hausmann@webkit.org>
Fix the Wx build.
......@@ -1044,7 +1044,6 @@ webcore_sources += \
webcoregtk_sources += \
WebCore/plugins/gtk/PluginDataGtk.cpp \
WebCore/plugins/gtk/PluginDatabaseGtk.cpp \
WebCore/plugins/gtk/PluginPackageGtk.cpp \
WebCore/plugins/gtk/PluginViewGtk.cpp
......
......@@ -1049,7 +1049,6 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
unix:!mac {
SOURCES += \
plugins/qt/PluginPackageQt.cpp \
plugins/qt/PluginDatabaseQt.cpp \
plugins/qt/PluginViewQt.cpp
}
......
......@@ -264,15 +264,17 @@ void PluginDatabase::remove(PluginPackage* package)
m_pluginsByPath.remove(package->path());
}
#if PLATFORM(GTK) || (PLATFORM(QT) && defined(Q_WS_X11))
#if !PLATFORM(WIN)
// For Safari/Win the following three methods are implemented
// in PluginDatabaseWin.cpp, but if we can use WebCore constructs
// for the logic we should perhaps move it here under XP_WIN?
#if PLATFORM(GTK)
#include <gdkconfig.h>
#endif
static void addMozillaPluginDirectories(Vector<String>& paths)
Vector<String> PluginDatabase::defaultPluginDirectories()
{
#if PLATFORM(QT) || defined(GDK_WINDOWING_X11)
Vector<String> paths;
// Add paths specific to each platform
#if defined(XP_UNIX)
String userPluginPath = homeDirectoryPath();
userPluginPath.append(String("/.mozilla/plugins"));
paths.append(userPluginPath);
......@@ -306,19 +308,18 @@ static void addMozillaPluginDirectories(Vector<String>& paths)
String mozPath(getenv("MOZ_PLUGIN_PATH"));
mozPath.split(UChar(':'), /* allowEmptyEntries */ false, mozPaths);
paths.append(mozPaths);
#elif defined(XP_MACOSX)
String userPluginPath = homeDirectoryPath();
userPluginPath.append(String("/Library/Internet Plug-Ins"));
paths.append(userPluginPath);
paths.append("/Library/Internet Plug-Ins");
#elif defined(XP_WIN)
String userPluginPath = homeDirectoryPath();
userPluginPath.append(String("\\Application Data\\Mozilla\\plugins"));
paths.append(userPluginPath);
#endif
#if defined(GDK_WINDOWING_WIN32)
gchar* directory = g_build_filename(g_get_home_dir(), "Application Data", "Mozilla", "plugins", NULL);
paths.append(directory);
g_free(directory);
#endif
}
Vector<String> PluginDatabase::defaultPluginDirectories()
{
Vector<String> paths;
// Add paths specific to each port
#if PLATFORM(QT)
Vector<String> qtPaths;
String qtPath(getenv("QTWEBKIT_PLUGIN_PATH"));
......@@ -326,22 +327,49 @@ Vector<String> PluginDatabase::defaultPluginDirectories()
paths.append(qtPaths);
#endif
addMozillaPluginDirectories(paths);
return paths;
}
#if PLATFORM(QT) || (PLATFORM(GTK) && !defined(GDK_WINDOWING_WIN32))
bool PluginDatabase::isPreferredPluginDirectory(const String& path)
{
// TODO: We should normalize the path before doing a comparison.
String prefPath = homeDirectoryPath();
prefPath.append(String("/.mozilla/plugins"));
String preferredPath = homeDirectoryPath();
#if defined(XP_UNIX)
preferredPath.append(String("/.mozilla/plugins"));
#elif defined(XP_MACOSX)
preferredPath.append(String("/Library/Internet Plug-Ins"));
#elif defined(XP_WIN)
preferredPath.append(String("\\Application Data\\Mozilla\\plugins"));
#endif
return path == prefPath;
// TODO: We should normalize the path before doing a comparison.
return path == preferredPath;
}
void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
{
// FIXME: This should be a case insensitive set.
HashSet<String> uniqueFilenames;
#if defined(XP_UNIX)
String fileNameFilter("*.so");
#else
String fileNameFilter("");
#endif
Vector<String>::const_iterator dirsEnd = m_pluginDirectories.end();
for (Vector<String>::const_iterator dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter);
Vector<String>::const_iterator pluginsEnd = pluginPaths.end();
for (Vector<String>::const_iterator pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
if (!fileExists(*pIt))
continue;
paths.add(*pIt);
}
}
}
#endif
}
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora, Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "PluginDatabase.h"
#include "CString.h"
#include "PluginPackage.h"
#include <gdkconfig.h>
namespace WebCore {
void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
{
// FIXME: This should be a case insensitive set.
HashSet<String> uniqueFilenames;
Vector<String>::const_iterator end = m_pluginDirectories.end();
for (Vector<String>::const_iterator it = m_pluginDirectories.begin(); it != end; ++it) {
GDir* dir = g_dir_open((it->utf8()).data(), 0, 0);
if (!dir)
continue;
while (const char* name = g_dir_read_name(dir)) {
if (!g_str_has_suffix(name, "." G_MODULE_SUFFIX))
continue;
gchar* filename = g_build_filename((it->utf8()).data(), name, NULL);
paths.add(filename);
g_free(filename);
}
g_dir_close(dir);
}
}
#if defined(GDK_WINDOWING_WIN32)
bool PluginDatabase::isPreferredPluginDirectory(const String& directory)
{
gchar* homePath = g_build_filename(g_get_home_dir(), "Application Data", "Mozilla", "plugins", NULL);
bool retval = false;
if (homePath)
retval = (strcmp(homePath, (directory.utf8()).data()) == 0);
g_free(homePath);
return retval;
}
#endif
}
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007 Staikos Computing Services Inc. All rights reserved.
* Copyright (C) 2008 Collabora Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "PluginDatabase.h"
#include <QDir>
#include <QFileInfo>
#include <QStringList>
#include "CString.h"
#include "PluginPackage.h"
namespace WebCore {
void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
{
// FIXME: This should be a case insensitive set.
HashSet<String> uniqueFilenames;
QStringList nameFilters;
nameFilters << "*.so";
Vector<String>::const_iterator end = m_pluginDirectories.end();
for (Vector<String>::const_iterator it = m_pluginDirectories.begin(); it != end; ++it) {
QDir dir = QDir(QString(*it));
if (!dir.exists())
continue;
QFileInfoList fl = dir.entryInfoList(nameFilters, QDir::Files);
foreach (const QFileInfo fi, fl) {
String filename = String(fi.absoluteFilePath());
paths.add(filename);
}
}
}
}
/*
* Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "PluginDatabase.h"
#include "CString.h"
#include "NotImplemented.h"
#include "PluginPackage.h"
namespace WebCore {
void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
{
notImplemented();
}
Vector<String> PluginDatabase::defaultPluginDirectories()
{
Vector<String> paths;
notImplemented();
return paths;
}
bool PluginDatabase::isPreferredPluginDirectory(const String& path)
{
notImplemented();
return false;
}
}
......@@ -95,7 +95,6 @@ wxWebCore port Bakefile project file.
platform/network/curl/ResourceHandleCurl.cpp
platform/network/curl/ResourceHandleManager.cpp
plugins/wx/PluginDatabaseWx.cpp
plugins/wx/PluginDataWx.cpp
plugins/wx/PluginPackageWx.cpp
plugins/wx/PluginViewWx.cpp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment