From 4f96f569b05d0637417211ce355d3ef13b8f6fa0 Mon Sep 17 00:00:00 2001 From: wuxinzao Date: Thu, 3 Jul 2025 19:48:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86save=20cookie?= =?UTF-8?q?=E7=9A=84ndk=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuxinzao --- .../interfaces/native/arkweb_error_code.h | 7 +++++ .../native/native_interface_arkweb.h | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/zh-cn/native_sdk/web/webview/interfaces/native/arkweb_error_code.h b/zh-cn/native_sdk/web/webview/interfaces/native/arkweb_error_code.h index 0b67773d..9cc95dcb 100644 --- a/zh-cn/native_sdk/web/webview/interfaces/native/arkweb_error_code.h +++ b/zh-cn/native_sdk/web/webview/interfaces/native/arkweb_error_code.h @@ -75,6 +75,13 @@ ARKWEB_LIBRARY_OPEN_FAILURE = 17100105, * @since 15 */ ARKWEB_LIBRARY_SYMBOL_NOT_FOUND = 17100106, + +/** + * @brief CookieManager未初始化。 + * + * @since 20 + */ +ARKWEB_COOKIE_MANAGER_NOT_INITIALIZED = 17100107, } ArkWeb_ErrorCode; #endif // ARKWEB_ERROR_CODE_H diff --git a/zh-cn/native_sdk/web/webview/interfaces/native/native_interface_arkweb.h b/zh-cn/native_sdk/web/webview/interfaces/native/native_interface_arkweb.h index 6f13777f..a55ae67b 100644 --- a/zh-cn/native_sdk/web/webview/interfaces/native/native_interface_arkweb.h +++ b/zh-cn/native_sdk/web/webview/interfaces/native/native_interface_arkweb.h @@ -71,6 +71,13 @@ typedef void (*NativeArkWeb_OnValidCallback)(const char*); */ typedef void (*NativeArkWeb_OnDestroyCallback)(const char*); +/** + * @brief 定义保存cookie的回调函数的类型。 + * + * @since 20 + */ +typedef void (*OH_ArkWeb_OnCookieSaveCallback)(); + /** * @brief 在当前显示页面的环境下,加载并执行一段JavaScript代码。 * @@ -195,6 +202,26 @@ ArkWeb_ErrorCode OH_NativeArkWeb_LoadData(const char* webTag, void OH_NativeArkWeb_RegisterAsyncThreadJavaScriptProxy(const char* webTag, const ArkWeb_ProxyObjectWithResult* proxyObject, const char* permission); +/** + * @brief 将当前可通过CookieManager API访问的所有Cookie持久化到磁盘。 + * 如果要在非UI线程中使用此接口,则需要先使用OH_ArkWeb_GetNativeAPI初始化CookieManager接口。 + * @return SaveCookieSync错误码。 + * {@link ARKWEB_SUCCESS} 保存cookie成功。 + * {@link ARKWEB_COOKIE_MANAGER_NOT_INITIALIZED} 在非UI线程中,不允许在不初始化CookieManager接口的情况下调用该接口。 + * 请先使用OH_ArkWeb_GetNativeAPI初始化CookieManager接口。 + * @since 20 + */ +ArkWeb_ErrorCode OH_ArkWebCookieManager_SaveCookieSync(); + +/** + * @brief 将当前可通过CookieManager API访问的所有Cookie持久化到磁盘。 + * 在不初始化CookieManager接口的情况下,此接口将在UI线程上自动执行。 + * 如果要在非UI线程中使用此接口,则需要首先使用OH_ArkWeb_GetNativeAPI初始化CookieManager接口。 + * @param callback 保存cookie完成后执行该回调。 + * @since 20 + */ +void OH_ArkWebCookieManager_SaveCookieAsync(OH_ArkWeb_OnCookieSaveCallback callback); + #ifdef __cplusplus }; #endif -- Gitee