[WebKit-devel] playground/libs/webkitkde/kdewebkit

Urs Wolfer uwolfer at kde.org
Sat Dec 20 19:22:52 CET 2008


SVN commit 899421 by uwolfer:

Plugins seem to work now (at least with Qt 4.5 snapshots tested).
Flash, using KDEs nsplugins, works on most pages basically! :)

Now also other KParts should be embedable, though I have not tested yet.
CCMAIL:webkit-devel at kde.org

 M  +29 -7     kwebpluginfactory.cpp  


--- trunk/playground/libs/webkitkde/kdewebkit/kwebpluginfactory.cpp #899420:899421
@@ -2,6 +2,7 @@
  * This file is part of the KDE project.
  *
  * Copyright (C) 2008 Michael Howell <mhowell123 at gmail.com>
+ * Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -21,6 +22,7 @@
  */
 
 #include "kwebpluginfactory.h"
+#include "kwebpage.h"
 
 #include <QWebPluginFactory>
 #include <QStringList>
@@ -51,17 +53,37 @@
 
 QObject* KWebPluginFactory::create(const QString& mimeType, const QUrl& url, const QStringList& argumentNames, const QStringList& argumentValues) const
 {
-    Q_UNUSED(argumentNames);
-    Q_UNUSED(argumentValues);
-    QWidget* w = new QWidget;
-    KParts::ReadOnlyPart* part = KMimeTypeTrader::createPartInstanceFromQuery<KParts::ReadOnlyPart>(mimeType, w, w);
+    QVariantList arguments;
+    int i = 0;
+    Q_FOREACH(const QString &key, argumentNames) {
+        arguments << key + "=\"" + argumentValues.at(i) + '\"';
+        ++i;
+    }
+//     arguments << "__KHTML__PLUGINEMBED=\"YES\""; //### following arguments are also set by khtml
+//     arguments << "__KHTML__PLUGINBASEURL=\"" + url.scheme() + "://" + url.host() + "/\"";
+//     arguments << "Browser/View";
+
+    KParts::ReadOnlyPart* part = KMimeTypeTrader::createPartInstanceFromQuery<KParts::ReadOnlyPart>(mimeType, qobject_cast<KWebPage*>(parent())->view(), parent(), QString(), arguments);
     if (part) {
+        QMap<QString, QString> metaData = part->arguments().metaData();
+        metaData.insert("PropagateHttpHeader", "true");
+        metaData.insert("cross-domain", url.scheme() + "://" + url.host() + "/");
+        metaData.insert("main_frame_request", "TRUE");
+//         metaData.insert("referrer", url.scheme() + "://" + url.host() + "/"); //### following metadata is also set by khtml
+//         metaData.insert("ssl_activate_warnings", "TRUE");
+//         metaData.insert("ssl_parent_cert", "");
+//         metaData.insert("ssl_parent_ip", "");
+//         metaData.insert("ssl_was_in_use", "FALSE");
+
+        KParts::OpenUrlArguments openUrlArgs = part->arguments();
+        openUrlArgs.metaData() = metaData;
+        openUrlArgs.setMimeType(mimeType);
+        part->setArguments(openUrlArgs);
+        kDebug()<< part->arguments().metaData();
         part->openUrl(url);
-        if (part->widget() != w)
-            part->widget()->setParent(w);
     }
     kDebug() << "Asked for plugin, got" << part;
-    return w;
+    return part->widget();
 }
 
 QList<KWebPluginFactory::Plugin> KWebPluginFactory::plugins() const


More information about the WebKit-devel mailing list