harmony 鸿蒙ArkWeb_ControllerAPI

2025-06-12 浏览 (1)

ArkWeb_ControllerAPI

Overview

Defines 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.

Since: 12

Related module: Web

Summary

Member Variables

NameDescription
size_t sizeSize of the struct.
void(* runJavaScript )(const char *webTag, const ArkWeb_JavaScriptObject *javascriptObject)Pointer to the function used to inject a JavaScript script.
void(* registerJavaScriptProxy )(const char *webTag, const ArkWeb_ProxyObject *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.
void(* 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.
void(* refresh )(const char *webTag)Pointer to the function used to refresh the web page.
void(* registerAsyncJavaScriptProxy )(const char *webTag, const ArkWeb_ProxyObject *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.
ArkWeb_WebMessagePortPtr *(* createWebMessagePorts )(const char *webTag, size_t *size)Pointer to the function used to create message ports.
void(* destroyWebMessagePorts )(ArkWeb_WebMessagePortPtr **ports, size_t size)Pointer to the function used to destroy message ports.
ArkWeb_ErrorCode(* postWebMessage )(const char *webTag, const char *name, ArkWeb_WebMessagePortPtr *webMessagePorts, size_t size, const char *url)Pointer to the function used to send the message port to the HTML page.
const char *(* 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.
void(* registerJavaScriptProxyEx )(const char *webTag, const ArkWeb_ProxyObjectWithResult *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.
void(* registerAsyncJavaScriptProxyEx )(const char *webTag, const ArkWeb_ProxyObject *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.

Member Variable Description

createWebMessagePorts

ArkWeb_WebMessagePortPtr*(* ArkWeb_ControllerAPI::createWebMessagePorts) (const char *webTag, size_t *size)

Description

Pointer to the function used to create message ports.

Parameters

NameDescription
webTagName of a Web component.
sizeNumber of ports, which is an output parameter.

Returns

Pointer to the message port struct.

deleteJavaScriptRegister

void(* ArkWeb_ControllerAPI::deleteJavaScriptRegister) (const char *webTag, const char *objName)

Description

Pointer to the function used to delete a specific application JavaScript object that is registered with the window using registerJavaScriptProxy.

destroyWebMessagePorts

void(* ArkWeb_ControllerAPI::destroyWebMessagePorts) (ArkWeb_WebMessagePortPtr **ports, size_t size)

Description

Pointer to the function used to destroy message ports.

Parameters

NameDescription
portsPointer array of the message port struct.
sizeNumber of ports.

getLastJavascriptProxyCallingFrameUrl

const char*(* ArkWeb_ControllerAPI::getLastJavascriptProxyCallingFrameUrl) ()

Description

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.

Since: 14

Returns

URL of the last frame that invokes the JavaScriptProxy.

postWebMessage

ArkWeb_ErrorCode(* ArkWeb_ControllerAPI::postWebMessage) (const char *webTag, const char *name, ArkWeb_WebMessagePortPtr *webMessagePorts, size_t size, const char *url)

Description

Pointer to the function used to send the message port to the HTML page.

Parameters

NameDescription
webTagName of a Web component.
nameName of the message sent to the HTML page.
webMessagePortsPointer to the message port struct.
sizeNumber of ports.
urlURL of the page that receives the message.

Returns

Returns ARKWEB_SUCCESS if the operation is successful. Returns ARKWEB_INVALID_PARAM if the parameter is invalid. Returns ARKWEB_INIT_ERROR if the initialization fails, that is, the Web component bound to the webTag is not found.

refresh

void(* ArkWeb_ControllerAPI::refresh) (const char *webTag)

Description

Pointer to the function used to refresh the web page.

registerAsyncJavaScriptProxy

void(* ArkWeb_ControllerAPI::registerAsyncJavaScriptProxy) (const char *webTag, const ArkWeb_ProxyObject *proxyObject)

Description

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.

registerAsyncJavaScriptProxyEx

void(* ArkWeb_ControllerAPI::registerAsyncJavaScriptProxyEx) (const char *webTag, const ArkWeb_ProxyObject *proxyObject, const char *permission)

Description

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.

Since: 14

Parameters

NameDescription
webTagName of a Web component.
proxyObjectThe proxy object to be registered.
permissionA JSON string used to configure the object and method levels of the JSBridge permission. This value is empty by default.

registerJavaScriptProxy

void(* ArkWeb_ControllerAPI::registerJavaScriptProxy) (const char *webTag, const ArkWeb_ProxyObject *proxyObject)

Description

Pointer to the function used to register a JavaScript object with the window. APIs of this object can then be invoked in the window.

registerJavaScriptProxyEx

void(* ArkWeb_ControllerAPI::registerJavaScriptProxyEx) (const char *webTag, const ArkWeb_ProxyObjectWithResult *proxyObject, const char *permission)

Description

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.

Since: 14

Parameters

NameDescription
webTagName of a Web component.
proxyObjectThe proxy object to be registered.
permissionA JSON string used to configure the object and method levels of the JSBridge permission. This value is empty by default.

runJavaScript

void(* ArkWeb_ControllerAPI::runJavaScript) (const char *webTag, const ArkWeb_JavaScriptObject *javascriptObject)

Description

Pointer to the function used to inject a JavaScript script.

size

size_t ArkWeb_ControllerAPI::size

Description

Size of the struct.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkWeb API Reference

harmony 鸿蒙ArkWeb_AnyNativeAPI

harmony 鸿蒙ArkWeb_ComponentAPI

harmony 鸿蒙ArkWeb_CookieManagerAPI

harmony 鸿蒙ArkWeb_JavaScriptBridgeData

harmony 鸿蒙ArkWeb_JavaScriptObject

harmony 鸿蒙ArkWeb_JavaScriptValueAPI

harmony 鸿蒙ArkWeb_ProxyMethod

harmony 鸿蒙ArkWeb_ProxyMethodWithResult

harmony 鸿蒙ArkWeb_ProxyObject

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/rKxr5i