1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
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.
*/
#include "config.h"
#include "qwebpluginfactory.h"
/*!
\class QWebPluginFactory
\since 4.4
\brief The QWebPluginFactory class creates plugins to be embedded into web
pages.
QWebPluginFactory is a factory for creating plugins for QWebPage. A plugin
factory can be installed on a QWebPage using QWebPage::setPluginFactory().
\note The plugin factory is only used if plugins are enabled through QWebSettings.
You can provide a QWebPluginFactory by implementing the plugins() and the
create() method. For plugins() it is necessary to describe the plugins the
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.
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.
*/
/*!
\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
\since 4.4
\brief The QWebPluginFactory::MimeType structure describes a mime type supported by a plugin.
*/
/*!
\variable QWebPluginFactory::MimeType::name
The full name of the MIME type; e.g., \c{text/plain} or \c{image/png}.
*/
/*!
\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.
For example, a mime type for PDF documents would return "pdf" as its file extension.
*/
/*!
Constructs a QWebPluginFactory with parent \a parent.
*/
QWebPluginFactory::QWebPluginFactory(QObject *parent)
: QObject(parent)
{
}
/*!
Destructor.
*/
QWebPluginFactory::~QWebPluginFactory()
{
}
/*!
\fn QList<Plugin> QWebPluginFactory::plugins() const = 0
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.
*/
/*!
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.
*/
void QWebPluginFactory::refreshPlugins()
{
}
/*!
\fn QObject *QWebPluginFactory::create(const QString &mimeType, const QUrl &url,
const QStringList &argumentNames, const QStringList &argumentValues) const = 0
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.
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.
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
\note Ownership of the returned object will be transferred to the caller.
*/
/*!
\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
*/
bool QWebPluginFactory::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output)
{
Q_UNUSED(extension)
Q_UNUSED(option)
Q_UNUSED(output)
return false;
}
/*!
This virtual function returns true if the plugin factory supports \a extension; otherwise false is returned.
\sa extension()
*/
bool QWebPluginFactory::supportsExtension(Extension extension) const
{
Q_UNUSED(extension)
return false;
}
|