• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup Web
18  * @{
19  *
20  * @brief Provide the definition of the C interface for the native ArkWeb.
21  * @since 12
22  */
23 /**
24  * @file arkweb_interface.h
25  *
26  * @brief Provides a unified entry for the native ArkWeb.
27  * @kit ArkWeb
28  * @library libohweb.so
29  * @syscap SystemCapability.Web.Webview.Core
30  * @since 12
31  */
32 
33 #ifndef ARKWEB_INTERFACE_H
34 #define ARKWEB_INTERFACE_H
35 
36 #include "arkweb_type.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /**
43  * @brief Defines the native API type of any size.
44  *
45  * @since 12
46  */
47 typedef struct {
48     /** Defines the size information of the native API set. */
49     size_t size;
50 } ArkWeb_AnyNativeAPI;
51 
52 /**
53  * @brief Defines the native API set type.
54  *
55  * @since 12
56  */
57 typedef enum {
58     /** API type related to ArkWeb component. */
59     ARKWEB_NATIVE_COMPONENT,
60     /** API type related to ArkWeb controller. */
61     ARKWEB_NATIVE_CONTROLLER,
62     /** API type related to ArkWeb WebMessagePort. */
63     ARKWEB_NATIVE_WEB_MESSAGE_PORT,
64     /** API type related to ArkWeb WebMessage. */
65     ARKWEB_NATIVE_WEB_MESSAGE,
66     /** API type related to ArkWeb cookie manager. */
67     ARKWEB_NATIVE_COOKIE_MANAGER,
68     /**
69      * @brief API type related to ArkWeb JavaScript value.
70      *
71      * @since 16
72      */
73     ARKWEB_NATIVE_JAVASCRIPT_VALUE,
74 } ArkWeb_NativeAPIVariantKind;
75 
76 /**
77  * @brief Obtains the native API set of a specified type.
78  * @param type Indicates the type of the native API set provided by ArkWeb.
79  * @return Return the pointer to the native API abstract object that carries the size.
80  *         If the type is incorrect, a null pointer is returned.
81  *
82  * @syscap SystemCapability.Web.Webview.Core
83  * @since 12
84  */
85 ArkWeb_AnyNativeAPI* OH_ArkWeb_GetNativeAPI(ArkWeb_NativeAPIVariantKind type);
86 
87 /*
88  * @brief Register a scrolling event callback.
89  * @param webTag The name of the web component.
90  * @param callback The ArkWeb scrolling callback.
91  * @param userData The data set by user.
92  * @return Return whether the registration was successful, false indicates failure.
93  *
94  * @syscap SystemCapability.Web.Webview.Core
95  * @since 16
96  */
97 bool OH_ArkWeb_RegisterScrollCallback(const char* webTag, ArkWeb_OnScrollCallback callback, void* userData);
98 
99 void OH_ArkWeb_DestroyGlobalPointersForTest(void);
100 
101 #ifdef __cplusplus
102 };
103 #endif
104 #endif // ARKWEB_INTERFACE_H