1/*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef WEBPLUGIN_H
21#define WEBPLUGIN_H
22
23#include "qwebkitplatformplugin.h"
24#include "WebNotificationPresenter.h"
25
26#include <QDialog>
27#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA
28#include <QVideoWidget>
29#endif
30
31class QListWidgetItem;
32class QListWidget;
33
34class Popup : public QDialog {
35    Q_OBJECT
36public:
37    Popup(const QWebSelectData& data) : m_data(data) { setModal(true); }
38
39signals:
40    void itemClicked(int idx);
41
42protected slots:
43    void onItemSelected(QListWidgetItem* item);
44
45protected:
46    void populateList();
47
48    const QWebSelectData& m_data;
49    QListWidget* m_list;
50};
51
52
53class SingleSelectionPopup : public Popup {
54    Q_OBJECT
55public:
56    SingleSelectionPopup(const QWebSelectData& data);
57};
58
59
60class MultipleSelectionPopup : public Popup {
61    Q_OBJECT
62public:
63    MultipleSelectionPopup(const QWebSelectData& data);
64};
65
66
67class WebPopup : public QWebSelectMethod {
68    Q_OBJECT
69public:
70    WebPopup();
71    ~WebPopup();
72
73    virtual void show(const QWebSelectData& data);
74    virtual void hide();
75
76private slots:
77    void popupClosed();
78    void itemClicked(int idx);
79
80private:
81    Popup* m_popup;
82
83    Popup* createPopup(const QWebSelectData& data);
84    Popup* createSingleSelectionPopup(const QWebSelectData& data);
85    Popup* createMultipleSelectionPopup(const QWebSelectData& data);
86};
87
88class TouchModifier : public QWebTouchModifier
89{
90    Q_OBJECT
91public:
92    unsigned hitTestPaddingForTouch(const PaddingDirection direction) const {
93        // Use 10 as padding in each direction but Up.
94        if (direction == QWebTouchModifier::Up)
95            return 15;
96        return 10;
97    }
98};
99
100#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA
101class FullScreenVideoWidget : public QVideoWidget {
102    Q_OBJECT
103public:
104    FullScreenVideoWidget(QMediaPlayer*);
105    virtual ~FullScreenVideoWidget() {}
106
107Q_SIGNALS:
108    void fullScreenClosed();
109
110protected:
111    bool event(QEvent*);
112    void keyPressEvent(QKeyEvent*);
113
114private:
115    QMediaPlayer* m_mediaPlayer; // not owned
116};
117
118class FullScreenVideoHandler : public QWebFullScreenVideoHandler {
119    Q_OBJECT
120public:
121    FullScreenVideoHandler();
122    virtual ~FullScreenVideoHandler();
123    bool requiresFullScreenForVideoPlayback() const;
124
125public Q_SLOTS:
126    void enterFullScreen(QMediaPlayer*);
127    void exitFullScreen();
128
129private:
130    FullScreenVideoWidget* m_mediaWidget; // owned
131};
132#endif
133
134class WebPlugin : public QObject, public QWebKitPlatformPlugin
135{
136    Q_OBJECT
137    Q_INTERFACES(QWebKitPlatformPlugin)
138public:
139    virtual bool supportsExtension(Extension extension) const;
140    virtual QObject* createExtension(Extension extension) const;
141};
142
143#endif // WEBPLUGIN_H
144