diff --git a/web/webview/interfaces/native/arkweb_scheme_handler.h b/web/webview/interfaces/native/arkweb_scheme_handler.h index 9de9b94b4fb12ef9511732e4a4e6e9c7e0021009..b746fcff1e89133ae56a4d60529549aee772113e 100644 --- a/web/webview/interfaces/native/arkweb_scheme_handler.h +++ b/web/webview/interfaces/native/arkweb_scheme_handler.h @@ -121,6 +121,175 @@ typedef enum ArkWeb_CustomSchemeOption { ARKWEB_SCHEME_OPTION_CODE_CACHE_ENABLED = 1 << 7, } ArkWeb_CustomSchemeOption; +/* + * @brief Resource type for a request. These constants match their equivalents in + * Chromium's ResourceType and should not be renumbered. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +typedef enum ArkWeb_ResourceType { + /* + * @brief Top level page. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + MAIN_FRAME = 0, + + /* + * @brief Frame or Iframe. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SUB_FRAME = 1, + + /* + * @brief CSS stylesheet. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + STYLE_SHEET = 2, + + /* + * @brief External script. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SCRIPT = 3, + + /* + * @brief Image (jpg/gif/png/etc). + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + IMAGE = 4, + + /* + * @brief Font. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + FONT_RESOURCE = 5, + + /* + * @brief Some other subresource. This is the default type if the actual type is unknown. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SUB_RESOURCE = 6, + + /* + * @brief Object (or embed) tag for a plugin, or a resource that a plugin requested. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + OBJECT = 7, + + /* + * @brief Media resource. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + MEDIA = 8, + + /* + * @brief Main resource of a dedicated worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + WORKER = 9, + + /* + * @brief Main resource of a shared worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SHARED_WORKER = 10, + + /* + * @brief Explicitly requested prefetch. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PREFETCH = 11, + + /* + * @brief Favicon. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + FAVICON = 12, + + /* + * @brief XMLHttpRequest. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + XHR = 13, + + /* + * @brief Ping request for /sendBeacon. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PING = 14, + + /* + * @brief The main resource of a service worker. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + SERVICE_WORKER = 15, + + /* + * @brief Report of Content Security Policy violations. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + CSP_REPORT = 16, + + /* + * @brief Resource that a plugin requested. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + PLUGIN_RESOURCE = 17, + + /* + * @brief A main-frame service worker navigation preload request. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + NAVIGATION_PRELOAD_MAIN_FRAME = 19, + + /* + * @brief A sub-frame service worker navigation preload request. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ + NAVIGATION_PRELOAD_SUB_FRAME = 20, +} ArkWeb_ResourceType; + /* * @brief This class is used to intercept requests for a specified scheme. * @@ -324,6 +493,16 @@ void OH_ArkWebResourceRequest_GetHttpBodyStream(const ArkWeb_ResourceRequest* re */ void OH_ArkWebResourceRequest_DestroyHttpBodyStream(ArkWeb_HttpBodyStream* httpBodyStream); +/* + * @brief Get the resource type of request. + * @param resourceRequest The ArkWeb_ResourceRequest. + * @return The resource type of request. -1 if resourceRequest is invalid. + * + * @syscap SystemCapability.Web.Webview.Core + * @since 12 + */ +int32_t OH_ArkWebResourceRequest_GetResourceType(const ArkWeb_ResourceRequest* resourceRequest); + /* * @brief Set a user data to ArkWeb_HttpBodyStream. * @param httpBodyStream The ArkWeb_HttpBodyStream. diff --git a/web/webview/interfaces/native/libohweb.ndk.json b/web/webview/interfaces/native/libohweb.ndk.json index 4e226f72c15cc3872d96c4557f6d9753f7245fc6..4451e5d5ab97e23cb7e06a514aa6e32be345ad90 100644 --- a/web/webview/interfaces/native/libohweb.ndk.json +++ b/web/webview/interfaces/native/libohweb.ndk.json @@ -91,6 +91,10 @@ "first_introduced": "12", "name": "OH_ArkWebResourceRequest_DestroyHttpBodyStream" }, + { + "first_introduced": "12", + "name": "OH_ArkWebResourceRequest_GetResourceType" + }, { "first_introduced": "12", "name": "OH_ArkWebHttpBodyStream_SetReadCallback"