qwebpluginfactory.cpp 6.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
    Copyright (C) 2007 Trolltech ASA

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/
19

20
21
22
#include "config.h"
#include "qwebpluginfactory.h"

23
24
25
/*!
    \class QWebPluginFactory
    \since 4.4
26
27
    \brief The QWebPluginFactory class creates plugins to be embedded into web
    pages.
28

29
30
    QWebPluginFactory is a factory for creating plugins for QWebPage. A plugin
    factory can be installed on a QWebPage using QWebPage::setPluginFactory().
31

32
33
    \note The plugin factory is only used if plugins are enabled through QWebSettings.

34
35
    You can provide a QWebPluginFactory by implementing the plugins() and the
    create() method. For plugins() it is necessary to describe the plugins the
36
37
38
    factory can create, including a description and the supported MIME types.
    The MIME types each plugin can handle should match the ones specified in
    in the HTML \c{<object>} tag.
39

40
41
42
    The create() method is called if the requested MIME type is supported. The
    implementation has to return a new instance of the plugin requested for the
    given MIME type and the specified URL.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
*/


/*!
    \class QWebPluginFactory::Plugin
    \since 4.4
    \brief the QWebPluginFactory::Plugin structure describes the properties of a plugin a QWebPluginFactory can create.
*/

/*!
    \variable QWebPluginFactory::Plugin::name
    The name of the plugin.
*/

/*!
    \variable QWebPluginFactory::Plugin::description
    The description of the plugin.
*/

/*!
    \variable QWebPluginFactory::Plugin::mimeTypes
    The list of mime types supported by the plugin.
*/

/*!
    \class QWebPluginFactory::MimeType
69
    \since 4.4
70
71
72
73
74
    \brief The QWebPluginFactory::MimeType structure describes a mime type supported by a plugin.
*/

/*!
    \variable QWebPluginFactory::MimeType::name
75
76

    The full name of the MIME type; e.g., \c{text/plain} or \c{image/png}.
77
78
79
80
81
82
83
84
85
86
*/

/*!
    \variable QWebPluginFactory::MimeType::description
    The description of the mime type.
*/

/*!
    \variable QWebPluginFactory::MimeType::fileExtensions
    The list of file extensions that are used by this mime type.
87
88

    For example, a mime type for PDF documents would return "pdf" as its file extension.
89
90
91
92
93
*/

/*!
    Constructs a QWebPluginFactory with parent \a parent.
*/
94
95
96
97
98
QWebPluginFactory::QWebPluginFactory(QObject *parent)
    : QObject(parent)
{
}

99
100
101
/*!
    Destructor.
*/
102
103
104
105
QWebPluginFactory::~QWebPluginFactory()
{
}

106
107
108
/*!
    \fn QList<Plugin> QWebPluginFactory::plugins() const = 0

109
110
111
112
113
    This function is reimplemented in subclasses to return a list of
    supported plugins the factory can create.

    \note Currently, this function is only called when JavaScript programs
    access the global \c plugins or \c mimetypes objects. 
114
115
116
117
118
119
*/

/*!
    This function is called to refresh the list of supported plugins. It may be called after a new plugin
    has been installed in the system.
*/
120
121
122
123
void QWebPluginFactory::refreshPlugins()
{
}

124
/*!
125
126
    \fn QObject *QWebPluginFactory::create(const QString &mimeType, const QUrl &url,
    const QStringList &argumentNames, const QStringList &argumentValues) const = 0
127

128
129
130
    Implemented in subclasses to create a new plugin that can display content of
    the MIME type given by \a mimeType. The URL of the content is provided in \a url.
    The returned object should be a QWidget.
131

132
133
134
    The HTML object element can provide parameters through the \c{<param>} tag.
    The name and the value attributes of these tags are specified by the
    \a argumentNames and \a argumentValues string lists.
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

    For example:

    \code
    <object type="application/x-pdf" data="http://www.trolltech.com/document.pdf" width="500" height="400">
        <param name="showTableOfContents" value="true" />
        <param name="hideThumbnails" value="false" />
    </object>
    \endcode

    The above object element will result in a call to create() with the following arguments:
    \table
    \header \o Parameter
            \o Value
    \row    \o mimeType
            \o "application/x-pdf"
    \row    \o url
            \o "http://www.trolltech.com/document.pdf"
    \row    \o argumentNames
            \o "showTableOfContents" "hideThumbnails"
    \row    \o argumentVaues
            \o "true" "false"
    \endtable
158

159
    \note Ownership of the returned object will be transferred to the caller.
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
*/

/*!
    \enum QWebPluginFactory::Extension

    This enum describes the types of extensions that the plugin factory can support. Before using these extensions, you
    should verify that the extension is supported by calling supportsExtension().

    Currently there are no extensions.
*/

/*!
    \class QWebPluginFactory::ExtensionOption
    \since 4.4
    \brief The ExtensionOption class provides an extended input argument to QWebPluginFactory's extension support.

    \sa QWebPluginFactory::extension()
*/

/*!
    \class QWebPluginFactory::ExtensionReturn
    \since 4.4
    \brief The ExtensionOption class provides an extended output argument to QWebPluginFactory's extension support.

    \sa QWebPluginFactory::extension()
*/

/*!
    This virtual function can be reimplemented in a QWebPluginFactory subclass to provide support for extensions. The \a option
    argument is provided as input to the extension; the output results can be stored in \a output.

    The behaviour of this function is determined by \a extension.

    You can call supportsExtension() to check if an extension is supported by the factory.

    By default, no extensions are supported, and this function returns false.

    \sa supportsExtension(), Extension
*/
199
200
bool QWebPluginFactory::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output)
{
201
202
203
    Q_UNUSED(extension)
    Q_UNUSED(option)
    Q_UNUSED(output)
hausmann@webkit.org's avatar
hausmann@webkit.org committed
204
    return false;
205
206
}

207
208
209
210
211
/*!
    This virtual function returns true if the plugin factory supports \a extension; otherwise false is returned.

    \sa extension()
*/
212
213
bool QWebPluginFactory::supportsExtension(Extension extension) const
{
214
    Q_UNUSED(extension)
hausmann@webkit.org's avatar
hausmann@webkit.org committed
215
    return false;
216
}