1 /* 2 * This file is part of the KDE project. 3 * 4 * Copyright (C) 2008 Michael Howell <mhowell123@gmail.com> 5 * Copyright (C) 2009 Dawit Alemayehu <adawit@kde.org> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 */ 23 #ifndef KWEBPLUGINFACTORY_H 24 #define KWEBPLUGINFACTORY_H 25 26 #include <kdewebkit_export.h> 27 28 #include <QtWebKit/QWebPluginFactory> 29 30 namespace KParts 31 { 32 class ReadOnlyPart; 33 } 34 35 /** 36 * @short A QWebPluginFactory that is integrated with KDE frameworks. 37 * 38 * This class will attempt to find a KPart to satisfy a plugin request. 39 * 40 * @author Michael Howell <mhowell123@gmail.com> 41 * @author Dawit Alemayehu <adawit@kde.org> 42 * 43 * @see QWebPluginFactory 44 * @since 4.4 45 */ 46 class KDEWEBKIT_EXPORT KWebPluginFactory : public QWebPluginFactory 47 { 48 Q_OBJECT 49 public: 50 /** 51 * Constructs a KWebPluginFactory with parent @p parent. 52 */ 53 KWebPluginFactory(QObject *parent); 54 55 /** 56 * Destroys the KWebPage. 57 */ 58 ~KWebPluginFactory(); 59 60 /** 61 * @reimp 62 * 63 * Reimplemented for internal reasons, the API is not affected. 64 * 65 * @see QWebPluginFactory::create 66 * @internal 67 */ 68 virtual QObject *create(const QString &mimeType, 69 const QUrl &url, 70 const QStringList &argumentNames, 71 const QStringList &argumentValues) const override; 72 73 /** 74 * @reimp 75 * 76 * Reimplemented for internal reasons, the API is not affected. 77 * 78 * @see QWebPluginFactory::plugins 79 * @internal 80 */ 81 QList<Plugin> plugins() const override; 82 83 protected: 84 /** 85 * Sets @p mimeType to the content type guessed from @p url. 86 * 87 * Note that attempting to guess mime-type will not always produce the 88 * correct content-type. This is especially true for the HTTP protocol 89 * since the URL present might be for a cgi script URL instead of a static 90 * URL that directly points to the content. 91 * 92 * If @p mimeType is not NULL, this function will set it to the content 93 * type determined from @p url. 94 * 95 * @since 4.8.3 96 */ 97 void extractGuessedMimeType(const QUrl &url, QString *mimeType) const; 98 99 /** 100 * Returns true if the given mime-type is excluded from being used to create 101 * a web plugin using KService's trader. 102 * 103 * Currently this function only returns true for mimetypes 'x-java', 104 * 'x-shockwave-flash', and 'futuresplash' in the 'application' category 105 * and everything under the 'inode' category. 106 * 107 * @since 4.8.3 108 */ 109 bool excludedMimeType(const QString &mimeType) const; 110 111 /** 112 * Returns an instance of the service associated with @p mimeType. 113 * 114 * This function uses KService's trader to create an instance of the service 115 * associated with the given parameters. The parameters are the <param> 116 * tags of the HTML object. The name and the value attributes of these 117 * tags are specified by the @p argumentNames and @p argumentValues 118 * respectively. 119 * 120 * The @p parentWidget and @p parent parameters specify the widget to use 121 * as the parent of the newly created part and the parent for the part 122 * itself respectively. 123 * 124 * The parameters for this function mirror that of @ref QWebPluginFactory::create. 125 * 126 * @see QWebPluginFactory::create 127 * @since 4.8.3 128 */ 129 KParts::ReadOnlyPart *createPartInstanceFrom(const QString &mimeType, 130 const QStringList &argumentNames, 131 const QStringList &argumentValues, 132 QWidget *parentWidget = nullptr, 133 QObject *parent = nullptr) const; 134 private: 135 class KWebPluginFactoryPrivate; 136 KWebPluginFactoryPrivate *const d; 137 }; 138 139 #endif // KWEBPLUGINFACTORY_H 140