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| void(\* [registerJavaScriptProxyEx](#registerjavascriptproxyex) )(const char \*webTag, const [ArkWeb_ProxyObjectWithResult](_ark_web___proxy_object_with_result.md) \*proxyObject, const char \*permission) | Pointer to the function used to register a JavaScript object with the window. APIs of this object can then be invoked in the window. The synchronization method of this object can contain return values. | 31| void(\* [registerAsyncJavaScriptProxyEx](#registerasyncjavascriptproxyex) )(const char \*webTag, const [ArkWeb_ProxyObject](_ark_web___proxy_object.md) \*proxyObject, const char \*permission) | 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. | 32 33 34## Member Variable Description 35 36 37### createWebMessagePorts 38 39``` 40ArkWeb_WebMessagePortPtr*(* ArkWeb_ControllerAPI::createWebMessagePorts) (const char *webTag, size_t *size) 41``` 42**Description** 43 44Pointer to the function used to create message ports. 45 46**Parameters** 47 48| Name| Description| 49| -------- | -------- | 50| webTag | Name of a **Web** component. | 51| size | Number of ports, which is an output parameter. | 52 53**Returns** 54 55Pointer to the message port struct. 56 57 58### deleteJavaScriptRegister 59 60``` 61void(* ArkWeb_ControllerAPI::deleteJavaScriptRegister) (const char *webTag, const char *objName) 62``` 63**Description** 64 65Pointer to the function used to delete a specific application JavaScript object that is registered with the window using **registerJavaScriptProxy**. 66 67 68### destroyWebMessagePorts 69 70``` 71void(* ArkWeb_ControllerAPI::destroyWebMessagePorts) (ArkWeb_WebMessagePortPtr **ports, size_t size) 72``` 73**Description** 74 75Pointer to the function used to destroy message ports. 76 77**Parameters** 78 79| Name| Description| 80| -------- | -------- | 81| ports | Pointer array of the message port struct. | 82| size | Number of ports.| 83 84 85### getLastJavascriptProxyCallingFrameUrl 86 87``` 88const char*(* ArkWeb_ControllerAPI::getLastJavascriptProxyCallingFrameUrl) () 89``` 90**Description** 91 92Pointer 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. 93 94**Since**: 14 95 96**Returns** 97 98URL of the last frame that invokes the **JavaScriptProxy**. 99 100 101### postWebMessage 102 103``` 104ArkWeb_ErrorCode(* ArkWeb_ControllerAPI::postWebMessage) (const char *webTag, const char *name, ArkWeb_WebMessagePortPtr *webMessagePorts, size_t size, const char *url) 105``` 106**Description** 107 108Pointer to the function used to send the message port to the HTML page. 109 110**Parameters** 111 112| Name| Description| 113| -------- | -------- | 114| webTag | Name of a **Web** component. | 115| name | Name of the message sent to the HTML page. | 116| webMessagePorts | Pointer to the message port struct. | 117| size | Number of ports. | 118| url | URL of the page that receives the message. | 119 120**Returns** 121 122 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. 123 124 125### refresh 126 127``` 128void(* ArkWeb_ControllerAPI::refresh) (const char *webTag) 129``` 130**Description** 131 132Pointer to the function used to refresh the web page. 133 134 135### registerAsyncJavaScriptProxy 136 137``` 138void(* ArkWeb_ControllerAPI::registerAsyncJavaScriptProxy) (const char *webTag, const ArkWeb_ProxyObject *proxyObject) 139``` 140**Description** 141 142Pointer to the function used to register a JavaScript proxy with the window. Asynchronous APIs of this object can then be invoked in the window. 143 144 145### registerAsyncJavaScriptProxyEx 146 147``` 148void(* ArkWeb_ControllerAPI::registerAsyncJavaScriptProxyEx) (const char *webTag, const ArkWeb_ProxyObject *proxyObject, const char *permission) 149``` 150**Description** 151 152Pointer to the function used to register a JavaScript proxy with the window. Asynchronous APIs of this object can then be invoked in the window. 153 154**Since**: 14 155 156**Parameters** 157 158| Name| Description| 159| -------- | -------- | 160| webTag | Name of a **Web** component. | 161| proxyObject | The proxy object to be registered. | 162| permission | A JSON string used to configure the object and method levels of the JSBridge permission. This value is empty by default.| 163 164 165### registerJavaScriptProxy 166 167``` 168void(* ArkWeb_ControllerAPI::registerJavaScriptProxy) (const char *webTag, const ArkWeb_ProxyObject *proxyObject) 169``` 170**Description** 171 172Pointer to the function used to register a JavaScript object with the window. APIs of this object can then be invoked in the window. 173 174 175### registerJavaScriptProxyEx 176 177``` 178void(* ArkWeb_ControllerAPI::registerJavaScriptProxyEx) (const char *webTag, const ArkWeb_ProxyObjectWithResult *proxyObject, const char *permission) 179``` 180**Description** 181 182Pointer to the function used to register a JavaScript object with the window. APIs of this object can then be invoked in the window. The synchronization method of this object can contain return values. 183 184**Since**: 14 185 186**Parameters** 187 188| Name| Description| 189| -------- | -------- | 190| webTag | Name of a **Web** component. | 191| proxyObject | The proxy object to be registered. | 192| permission | A JSON string used to configure the object and method levels of the JSBridge permission. This value is empty by default.| 193 194 195### runJavaScript 196 197``` 198void(* ArkWeb_ControllerAPI::runJavaScript) (const char *webTag, const ArkWeb_JavaScriptObject *javascriptObject) 199``` 200**Description** 201 202Pointer to the function used to inject a JavaScript script. 203 204 205### size 206 207``` 208size_t ArkWeb_ControllerAPI::size 209``` 210**Description** 211 212Size of the struct. 213