summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/clicktoflash.cpp123
-rw-r--r--src/clicktoflash.h58
-rw-r--r--src/mainwindow.cpp6
-rw-r--r--src/rekonq.kcfg4
-rw-r--r--src/settings/settings_webkit.ui50
-rw-r--r--src/webpluginfactory.cpp36
-rw-r--r--src/webpluginfactory.h14
8 files changed, 275 insertions, 29 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8faa93b1..1f9127f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -18,24 +18,25 @@ SET( rekonq_KDEINIT_SRCS
webpluginfactory.cpp
websnap.cpp
webview.cpp
-#----------------------------------------
+ clicktoflash.cpp
+ #----------------------------------------
history/autosaver.cpp
history/historymanager.cpp
history/historymodels.cpp
history/historypanel.cpp
history/sidepanel.cpp
-#----------------------------------------
+ #----------------------------------------
rekonqpage/newtabpage.cpp
-#----------------------------------------
+ #----------------------------------------
settings/settingsdialog.cpp
-#----------------------------------------
+ #----------------------------------------
bookmarks/bookmarksmanager.cpp
bookmarks/bookmarkspanel.cpp
bookmarks/bookmarkstreemodel.cpp
bookmarks/bookmarksproxy.cpp
-#----------------------------------------
+ #----------------------------------------
adblock/adblockmanager.cpp
-#----------------------------------------
+ #----------------------------------------
urlbar/urlbar.cpp
urlbar/lineedit.cpp
)
diff --git a/src/clicktoflash.cpp b/src/clicktoflash.cpp
new file mode 100644
index 00000000..1fd36e4c
--- /dev/null
+++ b/src/clicktoflash.cpp
@@ -0,0 +1,123 @@
+/**
+ * Copyright (c) 2009, Benjamin C. Meyer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Benjamin Meyer nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "clicktoflash.h"
+
+#include <QWebFrame>
+#include <QWebView>
+#include <QWebElement>
+#include <QHBoxLayout>
+#include <QToolButton>
+
+#include <KLocalizedString>
+
+
+ClickToFlash::ClickToFlash(QUrl pluginUrl, QWidget *parent)
+ : QWidget(parent)
+ , m_url(pluginUrl)
+{
+ QHBoxLayout *l = new QHBoxLayout(this);
+ setLayout(l);
+
+ QToolButton *button = new QToolButton(this);
+ button->setPopupMode(QToolButton::InstantPopup);
+ button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ button->setText(i18n("Load animation"));
+ button->setAutoRaise(false);
+ layout()->addWidget(button);
+ connect(button, SIGNAL(clicked(bool)), this, SLOT(load()));
+}
+
+
+void ClickToFlash::load()
+{
+ QWidget *parent = parentWidget();
+ QWebView *view = 0;
+ while (parent)
+ {
+ if (QWebView *aView = qobject_cast<QWebView*>(parent))
+ {
+ view = aView;
+ break;
+ }
+ parent = parent->parentWidget();
+ }
+ if (!view)
+ return;
+
+ const QString selector = QLatin1String("%1[type=\"application/x-shockwave-flash\"]");
+
+ hide();
+
+ QList<QWebFrame*> frames;
+ frames.append(view->page()->mainFrame());
+ while (!frames.isEmpty())
+ {
+ QWebFrame *frame = frames.takeFirst();
+ QWebElement docElement = frame->documentElement();
+
+ QWebElementCollection elements;
+ elements.append(docElement.findAll(selector.arg(QLatin1String("object"))));
+ elements.append(docElement.findAll(selector.arg(QLatin1String("embed"))));
+
+ bool isRightElement = false;
+ foreach (QWebElement element, elements)
+ {
+ // TODO : find a proper solution to compare a QWebElement with a plugin
+ // With this "manual" test, it's probably not working everywhere
+ if(QUrl(element.attribute("data")) == m_url
+ || QUrl(element.attribute("src")) == m_url)
+ isRightElement = true;
+ else
+ {
+ QWebElementCollection collec = element.findAll("param");
+ int i = 0;
+ while(i < collec.count() && isRightElement == false)
+ {
+ if(QUrl(collec.at(i).attribute("value")) == m_url)
+ isRightElement = true;
+ i++;
+ }
+ }
+
+ if(isRightElement)
+ {
+ QWebElement substitute = element.clone();
+ emit signalLoadClickToFlash(true);
+ element.replace(substitute);
+ return;
+ }
+ }
+
+ frames += frame->childFrames();
+ }
+
+ deleteLater();
+}
+
+
diff --git a/src/clicktoflash.h b/src/clicktoflash.h
new file mode 100644
index 00000000..a55ecbcc
--- /dev/null
+++ b/src/clicktoflash.h
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2009, Benjamin C. Meyer
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Benjamin Meyer nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef CLICKTOFLASH_H
+#define CLICKTOFLASH_H
+
+#include <QWidget>
+#include <QUrl>
+
+
+class WebPluginFactory;
+
+class ClickToFlash : public QWidget
+{
+ Q_OBJECT
+public:
+ ClickToFlash(QUrl pluginUrl, QWidget *parent = 0);
+
+signals:
+ void signalLoadClickToFlash(bool);
+
+private slots:
+ void load();
+
+private:
+ /**
+ used to find the right QWebElement between the ones of the different plugins
+ */
+ const QUrl m_url;
+};
+
+#endif // CLICKTOFLASH_H
+
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 628743ee..8b43f6ae 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -514,12 +514,16 @@ void MainWindow::updateConfiguration()
defaultSettings->setAttribute(QWebSettings::AutoLoadImages, ReKonfig::autoLoadImages());
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, ReKonfig::javascriptEnabled());
defaultSettings->setAttribute(QWebSettings::JavaEnabled, ReKonfig::javaEnabled());
- defaultSettings->setAttribute(QWebSettings::PluginsEnabled, ReKonfig::pluginsEnabled());
defaultSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, ReKonfig::javascriptCanOpenWindows());
defaultSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, ReKonfig::javascriptCanAccessClipboard());
defaultSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, ReKonfig::linksIncludedInFocusChain());
defaultSettings->setAttribute(QWebSettings::ZoomTextOnly, ReKonfig::zoomTextOnly());
defaultSettings->setAttribute(QWebSettings::PrintElementBackgrounds, ReKonfig::printElementBackgrounds());
+
+ if(ReKonfig::pluginsEnabled() == 2)
+ defaultSettings->setAttribute(QWebSettings::PluginsEnabled, false);
+ else
+ defaultSettings->setAttribute(QWebSettings::PluginsEnabled, true);
// ===== HTML 5 features WebKit support ======
defaultSettings->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, ReKonfig::offlineStorageDatabaseEnabled());
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index cc9c4317..0875342c 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -100,8 +100,8 @@
<entry name="javaEnabled" type="Bool">
<default>true</default>
</entry>
- <entry name="pluginsEnabled" type="Bool">
- <default>true</default>
+ <entry name="pluginsEnabled" type="Int">
+ <default>0</default>
</entry>
<entry name="javascriptCanOpenWindows" type="Bool">
<default>true</default>
diff --git a/src/settings/settings_webkit.ui b/src/settings/settings_webkit.ui
index 129bcf03..c59dc9c3 100644
--- a/src/settings/settings_webkit.ui
+++ b/src/settings/settings_webkit.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>622</width>
+ <width>485</width>
<height>360</height>
</rect>
</property>
@@ -66,46 +66,58 @@
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="kcfg_pluginsEnabled">
+ <item row="3" column="3">
+ <widget class="QCheckBox" name="kcfg_offlineStorageDatabaseEnabled">
<property name="text">
- <string>Plugins</string>
+ <string>Offline storage database</string>
</property>
</widget>
</item>
- <item row="3" column="3">
- <widget class="QCheckBox" name="kcfg_offlineStorageDatabaseEnabled">
+ <item row="4" column="3">
+ <widget class="QCheckBox" name="kcfg_offlineWebApplicationCacheEnabled">
<property name="text">
- <string>Offline storage database</string>
+ <string>Offline web application cache</string>
</property>
</widget>
</item>
- <item row="4" column="0" colspan="2">
- <widget class="QCheckBox" name="kcfg_javascriptCanOpenWindows">
+ <item row="5" column="3">
+ <widget class="QCheckBox" name="kcfg_localStorageDatabaseEnabled">
<property name="text">
- <string>JavaScript can open windows</string>
+ <string>Local storage database</string>
</property>
</widget>
</item>
- <item row="4" column="3">
- <widget class="QCheckBox" name="kcfg_offlineWebApplicationCacheEnabled">
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="kcfg_javascriptCanOpenWindows">
<property name="text">
- <string>Offline web application cache</string>
+ <string>JavaScript can open windows</string>
</property>
</widget>
</item>
- <item row="5" column="0" colspan="2">
+ <item row="4" column="0">
<widget class="QCheckBox" name="kcfg_javascriptCanAccessClipboard">
<property name="text">
<string>JavaScript can access clipboard</string>
</property>
</widget>
</item>
- <item row="5" column="3">
- <widget class="QCheckBox" name="kcfg_localStorageDatabaseEnabled">
- <property name="text">
- <string>Local storage database</string>
- </property>
+ <item row="5" column="0">
+ <widget class="QComboBox" name="kcfg_pluginsEnabled">
+ <item>
+ <property name="text">
+ <string>Autoload plugins</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Manually load plugins</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Never load plugins</string>
+ </property>
+ </item>
</widget>
</item>
</layout>
diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp
index af799905..aec4e18d 100644
--- a/src/webpluginfactory.cpp
+++ b/src/webpluginfactory.cpp
@@ -29,9 +29,11 @@
#include "webpluginfactory.moc"
// Local Includes
+#include "rekonq.h"
#include "application.h"
#include "mainwindow.h"
#include "previewimage.h"
+#include "clicktoflash.h"
// KDE Includes
#include <KDebug>
@@ -40,6 +42,8 @@
WebPluginFactory::WebPluginFactory(QObject *parent)
: KWebPluginFactory(parent)
{
+ loadClickToFlash = false;
+ connect(this, SIGNAL(signalLoadClickToFlash(bool)), SLOT(setLoadClickToFlash(bool)));
}
@@ -48,6 +52,13 @@ WebPluginFactory::~WebPluginFactory()
}
+
+void WebPluginFactory::setLoadClickToFlash(bool load)
+{
+ loadClickToFlash = load;
+}
+
+
QObject *WebPluginFactory::create(const QString &mimeType,
const QUrl &url,
const QStringList &argumentNames,
@@ -74,7 +85,25 @@ QObject *WebPluginFactory::create(const QString &mimeType,
return new PreviewImage(url, title, number, isFavorite);
}
-
+
+ if(ReKonfig::pluginsEnabled() == 0) // plugins are enabled
+ {
+ kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones...";
+ return 0;
+ }
+
+ if(mimeType == QString("application/x-shockwave-flash")
+ && !loadClickToFlash)
+ {
+ ClickToFlash* ctf = new ClickToFlash(url);
+ connect(ctf, SIGNAL(signalLoadClickToFlash(bool)), this, SLOT(setLoadClickToFlash(bool)));
+ return ctf;
+ }
+
+ // this let QtWebKit using builtin plugins
+ // to load in example flash contents and so on..
+ kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones...";
+ emit signalLoadClickToFlash(false);
return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues);
}
@@ -88,5 +117,10 @@ QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const
p.description = "plugin for embedding Web snapped images";
plugins.append(p);
+ p.name = "application/x-shockwave-flash";
+ p.description = "Plugin for flash animations";
+ plugins.append(p);
+
+
return plugins;
}
diff --git a/src/webpluginfactory.h b/src/webpluginfactory.h
index 30a366d4..c1e4c28f 100644
--- a/src/webpluginfactory.h
+++ b/src/webpluginfactory.h
@@ -50,6 +50,20 @@ public:
const QStringList &argumentValues) const;
virtual QList<Plugin> plugins() const;
+
+signals:
+
+ void signalLoadClickToFlash(bool) const;
+
+public slots:
+ void setLoadClickToFlash(bool load);
+
+private:
+ /**
+ When true, force loading of next flash animation (don't show clicktoflash)
+ We use signals/slots to set this property because QWebPluginFactory::create is const
+ */
+ bool loadClickToFlash;
};
#endif // WEB_PLUGIN_FACTORY_H