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 0b67773d146ea07fe4d0df6f1509e3b5a5daef3c..9cc95dcb9784c6d6e051aca5a087c5c687f61606 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 6f13777f4e5e2f15d95da6df5c91ee2db6adf912..a55ae67b27ded734de59abd2e94a0eafa97da42f 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