1# ArkWeb_ControllerAPI
2
3
4## Overview
5
6Defines a native API struct of the Web controller. Before calling the API, you are advised to use **ARKWEB_MEMBER_MISSING** to check whether the function struct has the corresponding pointer to avoid crash caused by mismatch between the SDK and the device ROM.
7
8**Since**: 12
9
10**Related module**: [Web](_web.md)
11
12
13## Summary
14
15
16### Member Variables
17
18| Name| Description|
19| -------- | -------- |
20| size_t [size](#size) | Size of the struct. |
21| void(\* [runJavaScript](#runjavascript) )(const char \*webTag, const [ArkWeb_JavaScriptObject](_ark_web___java_script_object.md) \*javascriptObject) | Pointer to the function used to inject a JavaScript script. |
22| void(\* [registerJavaScriptProxy](#registerjavascriptproxy) )(const char \*webTag, const [ArkWeb_ProxyObject](_ark_web___proxy_object.md) \*proxyObject) | Pointer to the function used to register a JavaScript proxy with the window. APIs of this object can then be invoked in the window. |
23| void(\* [deleteJavaScriptRegister](#deletejavascriptregister) )(const char \*webTag, const char \*objName) | Pointer to the function used to delete a specific application JavaScript object that is registered with the window using **registerJavaScriptProxy**. |
24| void(\* [refresh](#refresh) )(const char \*webTag) | Pointer to the function used to refresh the web page. |
25| void(\* [registerAsyncJavaScriptProxy](#registerasyncjavascriptproxy) )(const char \*webTag, const [ArkWeb_ProxyObject](_ark_web___proxy_object.md) \*proxyObject) | Pointer to the function used to register a JavaScript proxy with the window. Asynchronous APIs of this object can then be invoked in the window. |
26| [ArkWeb_WebMessagePortPtr](_web.md#arkweb_webmessageportptr) \*(\* [createWebMessagePorts](#createwebmessageports) )(const char \*webTag, size_t \*[size](#size)) | Pointer to the function used to create message ports. |
27| void(\* [destroyWebMessagePorts](#destroywebmessageports) )([ArkWeb_WebMessagePortPtr](_web.md#arkweb_webmessageportptr) \*\*ports, size_t [size](#size)) | Pointer to the function used to destroy message ports. |
28| [ArkWeb_ErrorCode](_web.md#arkweb_errorcode)(\* [postWebMessage](#postwebmessage) )(const char \*webTag, const char \*name, [ArkWeb_WebMessagePortPtr](_web.md#arkweb_webmessageportptr) \*webMessagePorts, size_t [size](#size), const char \*url) | Pointer to the function used to send the message port to the HTML page. |
29| const char \*(\* [getLastJavascriptProxyCallingFrameUrl](#getlastjavascriptproxycallingframeurl) )() | Pointer to the function used to obtain the URL of the last frame that calls **JavaScriptProxy**. This function is invoked on the thread invoked by the **JavaScriptProxy**. You can use **registerJavaScriptProxy** or **JavaScriptProxy** to inject a JavaScript object to a window object.   You need to save the URL obtained from the invoked function. |
30
31
32## Member Variable Description
33
34
35### createWebMessagePorts
36
37```
38ArkWeb_WebMessagePortPtr*(* ArkWeb_ControllerAPI::createWebMessagePorts) (const char *webTag, size_t *size)
39```
40**Description**
41
42Pointer to the function used to create message ports.
43
44**Parameters**
45
46| Name| Description|
47| -------- | -------- |
48| webTag | Name of a **Web** component. |
49| size | Number of ports, which is an output parameter. |
50
51**Returns**
52
53Pointer to the message port struct.
54
55
56### deleteJavaScriptRegister
57
58```
59void(* ArkWeb_ControllerAPI::deleteJavaScriptRegister) (const char *webTag, const char *objName)
60```
61**Description**
62
63Pointer to the function used to delete a specific application JavaScript object that is registered with the window using **registerJavaScriptProxy**.
64
65
66### destroyWebMessagePorts
67
68```
69void(* ArkWeb_ControllerAPI::destroyWebMessagePorts) (ArkWeb_WebMessagePortPtr **ports, size_t size)
70```
71**Description**
72
73Pointer to the function used to destroy message ports.
74
75**Parameters**
76
77| Name| Description|
78| -------- | -------- |
79| ports | Pointer array of the message port struct. |
80| size | Number of ports.|
81
82
83### getLastJavascriptProxyCallingFrameUrl
84
85```
86const char*(* ArkWeb_ControllerAPI::getLastJavascriptProxyCallingFrameUrl) ()
87```
88**Description**
89
90Pointer to the function used to obtain the URL of the last frame that calls **JavaScriptProxy**. This function is invoked on the thread invoked by the **JavaScriptProxy**. You can use **registerJavaScriptProxy** or **JavaScriptProxy** to inject a JavaScript object to a window object.   You need to save the URL obtained from the invoked function.
91
92**Since**: 14
93
94**Returns**
95
96URL of the last frame that invokes the **JavaScriptProxy**.
97
98
99### postWebMessage
100
101```
102ArkWeb_ErrorCode(* ArkWeb_ControllerAPI::postWebMessage) (const char *webTag, const char *name, ArkWeb_WebMessagePortPtr *webMessagePorts, size_t size, const char *url)
103```
104**Description**
105
106Pointer to the function used to send the message port to the HTML page.
107
108**Parameters**
109
110| Name| Description|
111| -------- | -------- |
112| webTag | Name of a **Web** component. |
113| name | Name of the message sent to the HTML page. |
114| webMessagePorts | Pointer to the message port struct. |
115| size | Number of ports. |
116| url | URL of the page that receives the message. |
117
118**Returns**
119
120  Returns [ARKWEB_SUCCESS](_web.md) if the operation is successful. Returns [ARKWEB_INVALID_PARAM](_web.md) if the parameter is invalid. Returns [ARKWEB_INIT_ERROR](_web.md) if the initialization fails, that is, the **Web** component bound to the **webTag** is not found.
121
122
123### refresh
124
125```
126void(* ArkWeb_ControllerAPI::refresh) (const char *webTag)
127```
128**Description**
129
130Pointer to the function used to refresh the web page.
131
132
133### registerAsyncJavaScriptProxy
134
135```
136void(* ArkWeb_ControllerAPI::registerAsyncJavaScriptProxy) (const char *webTag, const ArkWeb_ProxyObject *proxyObject)
137```
138**Description**
139
140Pointer to the function used to register a JavaScript proxy with the window. Asynchronous APIs of this object can then be invoked in the window.
141
142
143### registerJavaScriptProxy
144
145```
146void(* ArkWeb_ControllerAPI::registerJavaScriptProxy) (const char *webTag, const ArkWeb_ProxyObject *proxyObject)
147```
148**Description**
149
150Pointer to the function used to register a JavaScript proxy with the window. APIs of this object can then be invoked in the window.
151
152
153### runJavaScript
154
155```
156void(* ArkWeb_ControllerAPI::runJavaScript) (const char *webTag, const ArkWeb_JavaScriptObject *javascriptObject)
157```
158**Description**
159
160Pointer to the function used to inject a JavaScript script.
161
162
163### size
164
165```
166size_t ArkWeb_ControllerAPI::size
167```
168**Description**
169
170Size of the struct.
171