summaryrefslogtreecommitdiffstats
path: root/lib/web_contents_adapter.h
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-09-09 17:49:18 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-04 12:15:19 +0100
commita99fdc02797ece15253ff863102d3257945abfab (patch)
treecead6337f019ab87afff0c0f0865a18d8a075556 /lib/web_contents_adapter.h
parent1b3be641e660f9f87ec290e9adbb42558860ea37 (diff)
Implement QWebEnginePage::runJavaScript
We can't have QWebFrame::evaluateJavascript in its old form for several reasons, the first of which being that we don't have a QWebEngineFrame class anymore. This is worked around by adding an optional QString parameter with the frame's XPath. Another issue is that the WebKit1 API was synchronous, and this would not play nicely with the very asynchronous nature of chromium we're now sitting on top of. In order to make this obvious when porting, we rename it to runJavaScript which doesn't return any result. This also introduces a template member function overload that will accept function pointers, functors and lambdas,much like Qt5's new signal/slot syntax, in order to get the result of the javascript evaluation back. Change-Id: I64e15a6f5a168936c52a4da2cef6285dfd16e0d5 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com> Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'lib/web_contents_adapter.h')
-rw-r--r--lib/web_contents_adapter.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/web_contents_adapter.h b/lib/web_contents_adapter.h
index 306e55e45..75db8207c 100644
--- a/lib/web_contents_adapter.h
+++ b/lib/web_contents_adapter.h
@@ -48,12 +48,18 @@
#include <QString>
#include <QUrl>
+QT_FORWARD_DECLARE_CLASS(QVariant)
namespace content {
class WebContents;
}
class WebContentsAdapterClient;
class WebContentsAdapterPrivate;
+struct JSCallbackBase {
+ virtual ~JSCallbackBase() {}
+ virtual void call(const QVariant&) = 0;
+};
+
class QWEBENGINE_EXPORT WebContentsAdapter : public QSharedData {
public:
@@ -82,6 +88,7 @@ public:
void setZoomFactor(qreal);
qreal currentZoomFactor() const;
void enableInspector(bool);
+ void runJavaScript(const QString &javaScript, const QString &xPath = QString(), JSCallbackBase * = 0);
private:
Q_DISABLE_COPY(WebContentsAdapter);