1 /* ============================================================
2 * QuiteRSS is a open-source cross-platform RSS/Atom news feeds reader
3 * Copyright (C) 2011-2020 QuiteRSS Team <quiterssteam@gmail.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 * ============================================================ */
18 /* ============================================================
19 * QupZilla - WebKit based browser
20 * Copyright (C) 2010-2012  David Rosca <nowrep@gmail.com>
21 *
22 * This program is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
34 * ============================================================ */
35 /* ============================================================
36 *
37 * Copyright (C) 2009 by Benjamin C. Meyer <ben@meyerhome.net>
38 * Copyright (C) 2010 by Matthieu Gicquel <matgic78@gmail.com>
39 *
40 *
41 * This program is free software; you can redistribute it and/or
42 * modify it under the terms of the GNU General Public License as
43 * published by the Free Software Foundation; either version 2 of
44 * the License or (at your option) version 3 or any later version
45 * accepted by the membership of KDE e.V. (or its successor approved
46 * by the membership of KDE e.V.), which shall act as a proxy
47 * defined in Section 14 of version 3 of the license.
48 *
49 * This program is distributed in the hope that it will be useful,
50 * but WITHOUT ANY WARRANTY; without even the implied warranty of
51 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
52 * GNU General Public License for more details.
53 *
54 * You should have received a copy of the GNU General Public License
55 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
56 *
57 * ============================================================ */
58 
59 #ifndef CLICKTOFLASH_H
60 #define CLICKTOFLASH_H
61 
62 #include <QUrl>
63 #include <QWidget>
64 #include <QWebElement>
65 
66 class QToolButton;
67 class QHBoxLayout;
68 class QFrame;
69 
70 class WebPage;
71 
72 class ClickToFlash : public QWidget
73 {
74   Q_OBJECT
75 
76 public:
77   explicit ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNames,
78                         const QStringList &argumentValues, WebPage *parentPage,
79                         QWidget *parent = 0);
80 
81   static bool isAlreadyAccepted(const QUrl &url, const QStringList &argumentNames,
82                                 const QStringList &argumentValues);
83 
84 private slots:
85   void load();
86   void customContextMenuRequested(const QPoint &pos);
87   void toWhitelist();
88   void findElement();
89 
90   void hideObject();
91   void ensurePluginVisible();
92 
93 private:
94   bool checkElement(QWebElement el);
95   bool checkUrlOnElement(QWebElement el);
96   QStringList argumentNames_;
97   QStringList argumentValues_;
98   QWebElement element_;
99 
100   QToolButton* loadButton_;
101   QFrame* frame_;
102   /**
103     used to find the right QWebElement between the ones of the different plugins
104     */
105   const QUrl url_;
106 
107   static QUrl acceptedUrl;
108   static QStringList acceptedArgNames;
109   static QStringList acceptedArgValues;
110 
111   WebPage* page_;
112 };
113 
114 #endif // CLICKTOFLASH_H
115 
116