diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-01-15 18:22:24 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-22 08:45:09 +0100 |
commit | 6d760436bc0d7081d5bdb50e4141171b6ba940ee (patch) | |
tree | 9f17b8122a09b89a818373d9a269072d984ca0a6 /src/core/web_contents_adapter.h | |
parent | e6b846f3800eed35d31a45122f7f8c3215dc38ef (diff) |
Refactor the callback mechanism used by runJavaScript
This prepares the way for other API made async like toHtml and
toPlainText.
Use a callback class with an implicit templated constructor to carry
the functor across the API boundary and avoid the intermediate helper
method as the ABI that we have to maintain.
Also pass the callback result through WebContentsAdapterClient using
a bookkeeping ID instead of transferring the callback to
WebContentsAdapter. This will allow other calls, which might not
already allow passing a callback functor, to use a consisten way
of carrying back the result to the top API layer.
Change-Id: Ia923767b9c1021a108c26da17d4c41878ef7cb95
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'src/core/web_contents_adapter.h')
-rw-r--r-- | src/core/web_contents_adapter.h | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index c4c25c8a5..49c1de4c0 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -49,17 +49,11 @@ #include <QString> #include <QUrl> -QT_FORWARD_DECLARE_CLASS(QVariant) namespace content { class WebContents; } class WebContentsAdapterPrivate; -struct JSCallbackBase { - virtual ~JSCallbackBase() {} - virtual void call(const QVariant&) = 0; -}; - class QWEBENGINE_EXPORT WebContentsAdapter : public QSharedData { public: // Takes ownership of the WebContents. @@ -89,8 +83,9 @@ public: void setZoomFactor(qreal); qreal currentZoomFactor() const; void enableInspector(bool); - void runJavaScript(const QString &javaScript, const QString &xPath = QString(), JSCallbackBase * = 0); void filesSelectedInChooser(const QStringList &fileList, WebContentsAdapterClient::FileChooserMode); + void runJavaScript(const QString &javaScript, const QString &xPath); + quint64 runJavaScriptCallbackResult(const QString &javaScript, const QString &xPath); void dpiScaleChanged(); |