summaryrefslogtreecommitdiffstats
path: root/src/plugins/android/qandroidwebview_p.h
diff options
context:
space:
mode:
authorKaloyan Chehlarski <kaloyan.chehlarski@qt.io>2025-11-05 16:25:46 +0100
committerMichal Klocek <michal.klocek@qt.io>2025-12-01 17:39:09 +0100
commit388251ce343c617fc7a383485e9417a5306adb14 (patch)
treed658d527356e3ebea469c59ef15af5dc05d3a8e8 /src/plugins/android/qandroidwebview_p.h
parentc0b0855c702854c65ecdfe39a97d3f969b8780ad (diff)
Add runJavascript() to C++ API
The API follows what we have in WebEngine, with an optional std::function callback. No world ID argument is provided, however; most of the backends don't support the concept. The new function is not exposed to QML, since we cannot expose std::function arguments. Instead, the existing QML API is kept, and calls to it simply redirect to the C++ implementation. Also removes runJavaScriptPrivate() from QWebView, and its related implementation details in the plugins. Task-number: QTBUG-131837 Change-Id: Idc1e492916e17caa3f061c0b2738b3c735837cf8 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/plugins/android/qandroidwebview_p.h')
-rw-r--r--src/plugins/android/qandroidwebview_p.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/android/qandroidwebview_p.h b/src/plugins/android/qandroidwebview_p.h
index 1cacd19..5a8d229 100644
--- a/src/plugins/android/qandroidwebview_p.h
+++ b/src/plugins/android/qandroidwebview_p.h
@@ -80,16 +80,21 @@ public:
void deleteCookie(const QString &domain, const QString &name) override;
void deleteAllCookies() override;
+ void runJavaScript(const QString &script,
+ const std::function<void(const QVariant &)> &resultCallback) override;
+
+ void javaScriptResult(int id, const QVariant &result);
+
protected:
- void runJavaScriptPrivate(const QString& script,
- int callbackId) override;
QWebViewSettingsPrivate *settings() const override;
private Q_SLOTS:
void onApplicationStateChanged(Qt::ApplicationState state);
private:
- quint64 m_callbackId;
+ int m_callbackId;
+ QMap<int, std::function<void(const QVariant &)>> m_callbacks;
+
QWindow *m_window;
QtJniTypes::WebViewController m_viewController;
QtJniTypes::WebView m_webView;