2008-05-07 Ariya Hidayat <ariya.hidayat@trolltech.com>
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2008 12:10:01 +0000 (12:10 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 May 2008 12:10:01 +0000 (12:10 +0000)
        Reviewed by Simon.

        Share the plug-in directories between Gtk and Qt/X11 port.

        * platform/qt/FileSystemQt.cpp:
        (WebCore::homeDirectoryPath): Implement it for Qt.
        * plugins/PluginDatabase.cpp:
        (WebCore::addMozillaPluginDirectories): Shared code.
        (WebCore::PluginDatabase::defaultPluginDirectories):
        (WebCore::PluginDatabase::isPreferredPluginDirectory): Shared code.
        * plugins/gtk/PluginDatabaseGtk.cpp:
        (WebCore::PluginDatabase::isPreferredPluginDirectory): Refactored.
        * plugins/qt/PluginDatabaseQt.cpp: Refactored.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32954 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/qt/FileSystemQt.cpp
WebCore/plugins/PluginDatabase.cpp
WebCore/plugins/gtk/PluginDatabaseGtk.cpp
WebCore/plugins/qt/PluginDatabaseQt.cpp

index 35cb977..8fa6388 100644 (file)
@@ -1,3 +1,19 @@
+2008-05-07  Ariya Hidayat  <ariya.hidayat@trolltech.com>
+
+        Reviewed by Simon.
+
+        Share the plug-in directories between Gtk and Qt/X11 port.
+
+        * platform/qt/FileSystemQt.cpp:
+        (WebCore::homeDirectoryPath): Implement it for Qt.
+        * plugins/PluginDatabase.cpp:
+        (WebCore::addMozillaPluginDirectories): Shared code.
+        (WebCore::PluginDatabase::defaultPluginDirectories):
+        (WebCore::PluginDatabase::isPreferredPluginDirectory): Shared code.
+        * plugins/gtk/PluginDatabaseGtk.cpp:
+        (WebCore::PluginDatabase::isPreferredPluginDirectory): Refactored.
+        * plugins/qt/PluginDatabaseQt.cpp: Refactored.
+
 2008-05-07  Tor Arne Vestbø  <tavestbo@trolltech.com>
 
         Reviewed by Simon
index 454f570..cb9a14c 100644 (file)
@@ -85,6 +85,11 @@ String pathByAppendingComponent(const String& path, const String& component)
     return QDir(path).filePath(component);
 }
 
+String homeDirectoryPath()
+{
+    return QDir::homePath();
+}
+
 String pathGetFileName(const String& path)
 {
     return QFileInfo(path).fileName();
index 1bb35af..18043bc 100644 (file)
@@ -264,4 +264,62 @@ void PluginDatabase::remove(PluginPackage* package)
     m_pluginsByPath.remove(package->path());
 }
 
+#if PLATFORM(GTK) || (PLATFORM(QT) && defined(Q_WS_X11))
+
+#if PLATFORM(GTK)
+#include <gdkconfig.h>
+#endif
+
+static void addMozillaPluginDirectories(Vector<String>& paths)
+{
+#if PLATFORM(QT) || defined(GDK_WINDOWING_X11)
+    String userPluginPath = homeDirectoryPath();
+    userPluginPath.append(String(".mozilla/plugins"));
+    paths.append(userPluginPath);
+
+    paths.append("/usr/lib/browser/plugins");
+    paths.append("/usr/local/lib/mozilla/plugins");
+    paths.append("/usr/lib/mozilla/plugins");
+
+    Vector<String> mozPaths;
+    String mozPath(getenv("MOZ_PLUGIN_PATH"));
+    mozPath.split(UChar(':'), /* allowEmptyEntries */ false, mozPaths);
+    paths.append(mozPaths);
+#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;
+
+#if PLATFORM(QT)
+    Vector<String> qtPaths;
+    String qtPath(getenv("QTWEBKIT_PLUGIN_PATH"));
+    qtPath.split(UChar(':'), /* allowEmptyEntries */ false, qtPaths);
+    paths.append(qtPaths);
+#endif
+
+    addMozillaPluginDirectories(paths);
+
+    return paths;
+}
+
+#if PLATFORM(QT) || defined(GDK_WINDOWING_X11)
+bool PluginDatabase::isPreferredPluginDirectory(const String& path)
+{
+    String prefPath = homeDirectoryPath();
+    prefPath.append(String(".mozilla/plugins"));
+
+    return path == prefPath;
+}
+#endif
+
+#endif
+
 }
index 53adeae..069b150 100644 (file)
@@ -56,46 +56,7 @@ void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
     }
 }
 
-Vector<String> PluginDatabase::defaultPluginDirectories()
-{
-    Vector<String> directories;
-    gchar* directory;
-
-    directory = 0;
-
-#if defined(GDK_WINDOWING_X11)
-    directory = g_build_filename(g_get_home_dir(), ".mozilla", "plugins", NULL);
-    directories.append(directory);
-    g_free(directory);
-
-    const gchar* mozPath = g_getenv("MOZ_PLUGIN_PATH");
-    if (mozPath) {
-        gchar** pluginPaths = g_strsplit(mozPath, ":", -1);
-
-        for (gint i = 0; pluginPaths[i]; i++)
-            directories.append(pluginPaths[i]);
-
-        g_strfreev(pluginPaths);
-    }
-
-    directory = g_build_filename(G_DIR_SEPARATOR_S "usr", "lib", "browser", "plugins", NULL);
-    directories.append(directory);
-    g_free(directory);
-    directory = g_build_filename(G_DIR_SEPARATOR_S "usr", "local", "lib", "mozilla", "plugins", NULL);
-    directories.append(directory);
-    g_free (directory);
-    directory = g_build_filename(G_DIR_SEPARATOR_S "usr", "lib", "mozilla", "plugins", NULL);
-    directories.append(directory);
-    g_free (directory);
-#elif defined(GDK_WINDOWING_WIN32)
-    directory = g_build_filename(g_get_home_dir(), "Application Data", "Mozilla", "plugins", NULL);
-    directories.append(directory);
-    g_free(directory);
-#endif
-
-    return directories;
-}
-
+#if defined(GDK_WINDOWING_WIN32)
 bool PluginDatabase::isPreferredPluginDirectory(const String& directory)
 {
     gchar* homePath;
@@ -103,11 +64,7 @@ bool PluginDatabase::isPreferredPluginDirectory(const String& directory)
 
     homePath = 0;
 
-#if defined(GDK_WINDOWING_X11)
-    homePath = g_build_filename(g_get_home_dir(), ".mozilla", "plugins", NULL);
-#elif defined(GDK_WINDOWING_WIN32)
     homePath = g_build_filename(g_get_home_dir(), "Application Data", "Mozilla", "plugins", NULL);
-#endif
 
     if (homePath)
     retval = (strcmp(homePath, (directory.utf8()).data()) == 0);
index f287632..5c692ec 100644 (file)
@@ -58,45 +58,4 @@ void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
     }
 }
 
-static void addQtWebKitPluginDirectories(Vector<String>& paths)
-{
-    QString qtPath(getenv("QTWEBKIT_PLUGIN_PATH"));
-    QStringList qtPaths = qtPath.split(":", QString::SkipEmptyParts);
-    for(int i = 0; i < qtPaths.size(); i++) {
-        paths.append(qtPaths.at(i));
-    }
-}
-
-static void addMozillaPluginDirectories(Vector<String>& paths)
-{
-    QDir path = QDir::home(); path.cd(".mozilla/plugins"); 
-    paths.append(path.absolutePath());
-    paths.append("/usr/lib/browser/plugins");
-    paths.append("/usr/local/lib/mozilla/plugins");
-    paths.append("/usr/lib/mozilla/plugins");
-    
-    QString mozPath(getenv("MOZ_PLUGIN_PATH"));
-    QStringList mozPaths = mozPath.split(":", QString::SkipEmptyParts);
-    for(int i = 0; i < mozPaths.size(); i++) {
-        paths.append(mozPaths.at(i));
-    }
-}
-
-Vector<String> PluginDatabase::defaultPluginDirectories()
-{
-    Vector<String> paths;
-
-    addQtWebKitPluginDirectories(paths);
-    addMozillaPluginDirectories(paths);
-
-    return paths;
-}
-
-bool PluginDatabase::isPreferredPluginDirectory(const String& path)
-{
-    QDir prefPath = QDir::home();
-    prefPath.cd(".mozilla/plugins");
-    return (path == prefPath.absolutePath());
-}
-
 }