From 6ecfd185296d844ba549f49ed43ddc8399771c7a Mon Sep 17 00:00:00 2001 From: Curve Date: Tue, 27 Aug 2024 17:58:15 +0200 Subject: [PATCH] feat(webview): wrap `natives` --- include/saucer/webview.h | 4 ++++ private/webview.hpp | 6 ++++++ src/webview.cpp | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/saucer/webview.h b/include/saucer/webview.h index 0a89da4..c12db75 100644 --- a/include/saucer/webview.h +++ b/include/saucer/webview.h @@ -25,6 +25,7 @@ extern "C" SAUCER_WEB_EVENT_DOM_READY, }; + struct saucer_natives; struct saucer_embedded_file; /*[[sc::requires_free]]*/ SAUCER_EXPORT saucer_embedded_file *saucer_embed(saucer_stash *content, const char *mime); @@ -36,6 +37,9 @@ extern "C" typedef bool (*saucer_on_message)(const char *); SAUCER_EXPORT void saucer_webview_on_message(saucer_handle *, saucer_on_message callback); + /*[[sc::requires_free]]*/ SAUCER_EXPORT saucer_natives *saucer_webview_natives(saucer_handle *); + SAUCER_EXPORT void saucer_natives_free(saucer_natives *); + /*[[sc::requires_free]]*/ SAUCER_EXPORT saucer_icon *saucer_webview_favicon(saucer_handle *); /*[[sc::requires_free]]*/ SAUCER_EXPORT char *saucer_webview_page_title(saucer_handle *); diff --git a/private/webview.hpp b/private/webview.hpp index c3774ec..8f584a7 100644 --- a/private/webview.hpp +++ b/private/webview.hpp @@ -1,6 +1,8 @@ #pragma once #include "webview.h" +#include "utils/handle.hpp" + #include struct saucer_handle : saucer::webview @@ -26,3 +28,7 @@ struct saucer_handle : saucer::webview return m_on_message(message.c_str()); } }; + +struct saucer_natives : bindings::handle +{ +}; diff --git a/src/webview.cpp b/src/webview.cpp index a651f2f..87e54ec 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -46,6 +46,16 @@ extern "C" handle->m_on_message = callback; } + saucer_natives *saucer_webview_natives(saucer_handle *handle) + { + return saucer_natives::from(handle->natives()); + } + + void saucer_natives_free(saucer_natives *handle) + { + delete handle; + } + saucer_icon *saucer_webview_favicon(saucer_handle *handle) { return saucer_icon::from(handle->favicon());