|
+
+#### 使用说明
+
+1. 打开DEMO进入首页,展示html。
+2. 点击各链接进入不同属性的拦截结果页面或读取结果页面。
+
+### 拦截视频资源
+
+#### 介绍
+
+1. 此处模块主要介绍通过Web组件,拦截视频资源请求,读取本地mp4文件。
+
+#### 效果预览
+
+| 拦截视频资源 |
+| ------------------------------------------------------------ |
+|
|
+
+#### 使用说明
+
+1. 通过点击主页的“拦截视频资源请求,读取本地mp4文件”链接,拦截页面请求并跳转到此页面并展示本地的mp4文件。
+
+### 忽略csp检查并拦截
+
+#### 介绍
+
+1. 此处模块主要介绍通过Web组件,测试三方协议忽略csp检查,并成功拦截。
+
+#### 效果预览
+
+| 忽略csp检查并拦截 |
+| ------------------------------------------------------------ |
+|
|
+
+#### 使用说明
+
+1. 通过点击主页的“测试三方协议忽略csp检查,并成功拦截”链接,展示被拦截的自定义scheme请求,该scheme需要遵循标准的scheme规则,允许忽略CSP检查。
+2. 如果要拦截自定义scheme的请求,需要提前将自定义scheme注册到Web内核。需要在Web组件初始化之前进行注册,Web组件初始化后再注册会失败。
+
+### 拦截ISOLATED属性
+
+#### 介绍
+
+1. 此处模块主要介绍通过Web组件,测试拦截设置ISOLATED属性的三方协议。
+
+#### 效果预览
+
+| 拦截ISOLATED属性 |
+| ------------------------------------------------------------ |
+|
|
+
+#### 使用说明
+
+1. 通过点击主页的“测试拦截设置ISOLATED属性的三方协议”链接,展示被拦截的带有ISOLATED属性的自定义scheme请求,该scheme的请求必须从相同scheme加载的网页中发起。
+2. 如果要拦截自定义scheme的请求,需要提前将自定义scheme注册到Web内核。需要在Web组件初始化之前进行注册,Web组件初始化后再注册会失败。
+
+### 拦截LOCAL属性
+
+#### 介绍
+
+1. 此处模块主要介绍通过Web组件,测试拦截设置LOCAL属性的三方协议。
+
+#### 效果预览
+
+| 拦截LOCAL属性 |
+| ------------------------------------------------------------ |
+|
|
+
+#### 使用说明
+
+1. 通过点击主页的“测试拦截设置LOCAL属性的三方协议”链接,展示被拦截的带有LOCAL属性的自定义scheme请求,该scheme需要遵循与“file” scheme一样的规则。
+2. 如果要拦截自定义scheme的请求,需要提前将自定义scheme注册到Web内核。需要在Web组件初始化之前进行注册,Web组件初始化后再注册会失败。
+
+### 拦截service worker
+
+#### 介绍
+
+1. 此处模块主要介绍通过Web组件,测试拦截service worker触发的请求。
+
+#### 效果预览
+
+| 拦截service worker |
+| ------------------------------------------------------------ |
+|
|
+
+#### 使用说明
+
+1. 通过点击主页的“测试拦截service worker触发的请求”链接,展示被拦截的Web组件发出的scheme为“custom”的请求。
+2. 如果要拦截自定义scheme的请求,需要提前将自定义scheme注册到Web内核。需要在Web组件初始化之前进行注册,Web组件初始化后再注册会失败。
+
+### 测试读取blob类型http body stream
+
+#### 介绍
+
+1. 此处模块主要介绍通过Web组件,测试读取blob类型http body stream。
+
+#### 效果预览
+
+| 测试读取blob类型http body stream |
+| ------------------------------------------------------------ |
+|
|
+
+#### 使用说明
+
+1. 通过点击主页的“测试读取blob类型http body stream”链接,跳转至post_data.html,通过"test xhr post"或"test xhr put"按键,创建blob类型的对应请求,并发送至服务端,在设备日志中可查看发送结果。
+
+### 测试读取chunked类型http body stream
+
+#### 介绍
+
+1. 此处模块主要介绍通过Web组件,测试读取chunked类型http body stream。
+
+#### 效果预览
+
+| 测试读取chunked类型http body stream |
+| ------------------------------------------------------------ |
+|
|
+
+#### 使用说明
+
+1. 通过点击主页的“测试读取chunked类型http body stream”链接,跳转至pchunked_post_stream.html,通过"test post chunked http body"按键,创建chunked类型的请求,并以POST方式发送至服务端,在设备日志中可查看发送结果。
+
+### 工程目录
+
+
+```
+├── entry
+│ └── src
+│ └── main
+│ ├── cpp // C++代码区
+│ │ ├── CMakeLists.txt // CMAKE配置文件
+│ │ ├── hello.cpp // Native业务代码实现
+│ │ ├── rawfile_request.cpp // RawfileRequest实现
+│ │ ├── rawfile_request.h // RawfileRequest类
+│ │ └── types
+│ │ └── libentry // C++接口导出
+│ │ ├── Index.d.ts
+│ │ └── oh-package.json5
+│ ├── ets // ArkTS代码区
+│ │ ├── entryability
+│ │ │ └── EntryAbility.ets // 入口类
+│ │ ├── entrybackupability
+│ │ │ └── EntryBackupAbility.ets // 备份恢复框架
+│ │ └── pages
+│ │ └── Index.ets // 主页
+│ └── resources // 应用资源文件
+```
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo ArkWeb/ArkWebSchemeHandler > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ArkWeb/ArkWebSchemeHandler/build-profile.json5 b/ArkWeb/ArkWebSchemeHandler/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..023caeeb56c41dc1ce697cbf21433d4fd6ee6543
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ {
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/ArkWeb/ArkWebSchemeHandler/code-linter.json5 b/ArkWeb/ArkWebSchemeHandler/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..5c4682f8164874ec7e9cb8f99ff8b3228ffbc126
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/code-linter.json5
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ "@security/no-unsafe-aes": "error",
+ "@security/no-unsafe-hash": "error",
+ "@security/no-unsafe-mac": "warn",
+ "@security/no-unsafe-dh": "error",
+ "@security/no-unsafe-dsa": "error",
+ "@security/no-unsafe-ecdsa": "error",
+ "@security/no-unsafe-rsa-encrypt": "error",
+ "@security/no-unsafe-rsa-sign": "error",
+ "@security/no-unsafe-rsa-key": "error",
+ "@security/no-unsafe-dsa-key": "error",
+ "@security/no-unsafe-dh-key": "error",
+ "@security/no-unsafe-3des": "error"
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ArkWebSchemeHandler/entry/build-profile.json5 b/ArkWeb/ArkWebSchemeHandler/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..fea31f4580540c7c560b62bf531292c471c410f1
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/entry/build-profile.json5
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": ["arm64-v8a", "x86_64"]
+ }
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ },
+ "nativeLib": {
+ "debugSymbol": {
+ "strip": true,
+ "exclude": []
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ArkWebSchemeHandler/entry/hvigorfile.ts b/ArkWeb/ArkWebSchemeHandler/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ArkWeb/ArkWebSchemeHandler/entry/obfuscation-rules.txt b/ArkWeb/ArkWebSchemeHandler/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ArkWeb/ArkWebSchemeHandler/entry/oh-package.json5 b/ArkWeb/ArkWebSchemeHandler/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..118bdd4fe7699368a010e04c24f5bfc887cf1298
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/entry/oh-package.json5
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ "libentry.so": "file:./src/main/cpp/types/libentry"
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/CMakeLists.txt b/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..27bc12820c74e082ddcb3dbdb80db75951d72222
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/CMakeLists.txt
@@ -0,0 +1,19 @@
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.4.1)
+project(schemehandler)
+
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+
+if(DEFINED PACKAGE_INFO_FILE)
+ include(${PACKAGE_INFO_FILE})
+endif()
+
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+
+add_library(entry SHARED rawfile_request.cpp hello.cpp)
+target_link_libraries(entry PUBLIC librawfile.z.so libace_napi.z.so libohweb.so libhilog_ndk.z.so)
\ No newline at end of file
diff --git a/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/hello.cpp b/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/hello.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c5ec9335a06ff09c025923a959cc8cb7e1c24ff2
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/hello.cpp
@@ -0,0 +1,137 @@
+#include "hilog/log.h"
+#include "napi/native_api.h"
+#include "rawfile_request.h"
+#include "rawfile/raw_file_manager.h"
+#include "web/arkweb_scheme_handler.h"
+#include "web/arkweb_net_error_list.h"
+
+#undef LOG_TAG
+#define LOG_TAG "ss-handler"
+
+ArkWeb_SchemeHandler *g_schemeHandler;
+ArkWeb_SchemeHandler *g_schemeHandlerForSW;
+NativeResourceManager *g_resourceManager;
+
+// 注册三方协议的配置,需要在Web内核初始化之前调用,否则会注册失败。
+static napi_value RegisterCustomSchemes(napi_env env, napi_callback_info info)
+{
+ OH_LOG_INFO(LOG_APP, "register custom schemes");
+ OH_ArkWeb_RegisterCustomSchemes("custom", ARKWEB_SCHEME_OPTION_STANDARD | ARKWEB_SCHEME_OPTION_CORS_ENABLED);
+ OH_ArkWeb_RegisterCustomSchemes("custom-local", ARKWEB_SCHEME_OPTION_LOCAL);
+ OH_ArkWeb_RegisterCustomSchemes("custom-csp-bypassing", ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD);
+ OH_ArkWeb_RegisterCustomSchemes("custom-isolated", ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED);
+ return nullptr;
+}
+
+// 请求开始的回调,在该函数中我们创建一个RawfileRequest来实现对Web内核请求的拦截。
+void OnURLRequestStart(const ArkWeb_SchemeHandler *schemeHandler,
+ ArkWeb_ResourceRequest *resourceRequest,
+ const ArkWeb_ResourceHandler *resourceHandler,
+ bool *intercept)
+{
+ *intercept = true;
+ RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager);
+ OH_ArkWebResourceRequest_SetUserData(resourceRequest, request);
+ request->Start();
+}
+
+// 请求结束的回调,在该函数中我们需要标记RawfileRequest已经结束了,内部不应该再使用ResourceHandler。
+void OnURLRequestStop(const ArkWeb_SchemeHandler *schemeHandler,
+ const ArkWeb_ResourceRequest *request)
+{
+ if (!request) {
+ OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr.");
+ return;
+ }
+
+ RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request);
+ if (rawfileRequest) {
+ rawfileRequest->Stop();
+ }
+}
+
+void OnURLRequestStartForSW(const ArkWeb_SchemeHandler *schemeHandler,
+ ArkWeb_ResourceRequest *resourceRequest,
+ const ArkWeb_ResourceHandler *resourceHandler,
+ bool *intercept)
+{
+ *intercept = true;
+ RawfileRequest* request = new RawfileRequest(resourceRequest, resourceHandler, g_resourceManager);
+ OH_ArkWebResourceRequest_SetUserData(resourceRequest, request);
+ request->Start();
+}
+
+void OnURLRequestStopForSW(const ArkWeb_SchemeHandler *schemeHandler,
+ const ArkWeb_ResourceRequest *request)
+{
+ if (!request) {
+ OH_LOG_ERROR(LOG_APP, "on request stop request is nullptr.");
+ return;
+ }
+
+ RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebResourceRequest_GetUserData(request);
+ if (rawfileRequest) {
+ rawfileRequest->Stop();
+ }
+}
+
+// 设置SchemeHandler。
+static napi_value SetSchemeHandler(napi_env env, napi_callback_info info)
+{
+ OH_LOG_INFO(LOG_APP, "set scheme handler");
+ OH_ArkWeb_CreateSchemeHandler(&g_schemeHandler);
+ OH_ArkWeb_CreateSchemeHandler(&g_schemeHandlerForSW);
+
+ OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandler, OnURLRequestStart);
+ OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandler, OnURLRequestStop);
+
+ OH_ArkWebSchemeHandler_SetOnRequestStart(g_schemeHandlerForSW, OnURLRequestStart);
+ OH_ArkWebSchemeHandler_SetOnRequestStop(g_schemeHandlerForSW, OnURLRequestStop);
+
+ OH_ArkWeb_SetSchemeHandler("custom", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("custom-csp-bypassing", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("custom-isolated", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("custom-local", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("https", "scheme-handler", g_schemeHandler);
+ OH_ArkWeb_SetSchemeHandler("http", "scheme-handler", g_schemeHandler);
+
+ OH_ArkWebServiceWorker_SetSchemeHandler("https", g_schemeHandlerForSW);
+ return nullptr;
+}
+
+static napi_value InitResourceManager(napi_env env, napi_callback_info info)
+{
+ size_t argc = 2;
+ napi_value argv[2] = {nullptr};
+ napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
+ g_resourceManager = OH_ResourceManager_InitNativeResourceManager(env, argv[0]);
+ return nullptr;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"setSchemeHandler", nullptr, SetSchemeHandler, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"initResourceManager", nullptr, InitResourceManager, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"registerCustomSchemes", nullptr, RegisterCustomSchemes, nullptr, nullptr, nullptr, napi_default, nullptr}
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
\ No newline at end of file
diff --git a/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/rawfile_request.cpp b/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/rawfile_request.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a35e9066b403cac1b56ba0d0960a0a25fe21329a
--- /dev/null
+++ b/ArkWeb/ArkWebSchemeHandler/entry/src/main/cpp/rawfile_request.cpp
@@ -0,0 +1,257 @@
+#include "rawfile_request.h"
+
+
+#include "threads.h"
+
+
+#include "hilog/log.h"
+#include "rawfile/raw_file.h"
+#include "rawfile/raw_file_manager.h"
+
+
+#undef LOG_TAG
+#define LOG_TAG "ss-handler"
+
+
+namespace {
+
+
+uint8_t buffer[1024];
+cnd_t http_body_cnd;
+mtx_t http_body_mtx;
+
+
+// HttpBodyStream的读回调。
+void ReadCallback(const ArkWeb_HttpBodyStream *httpBodyStream, uint8_t* buffer, int bytesRead)
+{
+ OH_LOG_INFO(LOG_APP, "read http body back.");
+ bool isEof = OH_ArkWebHttpBodyStream_IsEof(httpBodyStream);
+ if (!isEof && bytesRead != 0) {
+ memset(buffer, 0, 1000);
+ OH_ArkWebHttpBodyStream_Read(httpBodyStream, buffer, 1000);
+ } else {
+ RawfileRequest *rawfileRequest = (RawfileRequest *)OH_ArkWebHttpBodyStream_GetUserData(httpBodyStream);
+ if (rawfileRequest) {
+ rawfileRequest->ReadRawfileDataOnWorkerThread();
+ cnd_signal(&http_body_cnd);
+ }
+ }
+}
+
+
+int ReadHttpBodyOnWorkerThread(void* userData)
+{
+ memset(buffer, 0, 1000);
+ ArkWeb_HttpBodyStream *httpBodyStream = (ArkWeb_HttpBodyStream *)userData;
+ OH_ArkWebHttpBodyStream_Read(httpBodyStream, buffer, 1000);
+ cnd_init(&http_body_cnd);
+ mtx_init(&http_body_mtx, mtx_plain);
+ cnd_wait(&http_body_cnd, &http_body_mtx);
+ return 0;
+}
+
+
+int ReadRawfileOnWorkerThread(void* userData)
+{
+ RawfileRequest * rawfileRequest = (RawfileRequest *)userData;
+ if (rawfileRequest) {
+ rawfileRequest->ReadRawfileDataOnWorkerThread();
+ }
+ return 0;
+}
+
+
+// ArkWeb_HttpBodyStream的初始化回调。
+void InitCallback(const ArkWeb_HttpBodyStream *httpBodyStream, ArkWeb_NetError result)
+{
+ OH_LOG_INFO(LOG_APP, "init http body stream done %{public}d.", result);
+ bool isChunked = OH_ArkWebHttpBodyStream_IsChunked(httpBodyStream);
+ OH_LOG_INFO(LOG_APP, "http body stream is chunked %{public}d.", isChunked);
+ thrd_t th;
+ if (thrd_create(&th, ReadHttpBodyOnWorkerThread, (void *)httpBodyStream) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "create thread failed.");
+ return;
+ }
+
+
+ if (thrd_detach(th) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "detach thread failed.");
+ }
+}
+
+
+const int blockSize = 1024 * 8;
+
+
+} // namespace
+
+
+RawfileRequest::RawfileRequest(const ArkWeb_ResourceRequest *resourceRequest,
+ const ArkWeb_ResourceHandler *resourceHandler,
+ const NativeResourceManager* resourceManager)
+ : resourceRequest_(resourceRequest),
+ resourceHandler_(resourceHandler),
+ resourceManager_(resourceManager) {}
+
+
+RawfileRequest::~RawfileRequest() {}
+
+
+void RawfileRequest::Start()
+{
+ OH_LOG_INFO(LOG_APP, "start a rawfile request.");
+ char* url;
+ OH_ArkWebResourceRequest_GetUrl(resourceRequest_, &url);
+ std::string urlStr(url);
+ std::size_t position = urlStr.rfind('/');
+ if (position != std::string::npos) {
+ rawfilePath_ = urlStr.substr(position + 1);
+ }
+ OH_ArkWeb_ReleaseString(url);
+
+
+ OH_ArkWeb_CreateResponse(&response_);
+ OH_ArkWebResourceRequest_GetHttpBodyStream(resourceRequest(), &stream_);
+ if (stream_) {
+ OH_LOG_ERROR(LOG_APP, "have http body stream");
+ OH_ArkWebHttpBodyStream_SetUserData(stream_, this);
+ OH_ArkWebHttpBodyStream_SetReadCallback(stream_, ReadCallback);
+ OH_ArkWebHttpBodyStream_Init(stream_, InitCallback);
+ } else {
+ thrd_t th;
+ if (thrd_create(&th, ReadRawfileOnWorkerThread, (void *)this) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "create thread failed.");
+ return;
+ }
+
+
+ if (thrd_detach(th) != thrd_success) {
+ OH_LOG_ERROR(LOG_APP, "detach thread failed.");
+ }
+ }
+}
+
+
+// 在worker线程中读取rawfile,并通过ResourceHandler返回给Web内核。
+void RawfileRequest::ReadRawfileDataOnWorkerThread()
+{
+ OH_LOG_INFO(LOG_APP, "read rawfile in worker thread.");
+ const struct UrlInfo {
+ std::string resource;
+ std::string mimeType;
+ } urlInfos[] = {
+ {"test.html", "text/html"},
+ {"video.html", "text/html"},
+ {"isolated.html", "text/html"},
+ {"csp_bypassing.html", "text/html"},
+ {"post_data.html", "text/html"},
+ {"chunked_post_stream.html", "text/html"},
+ {"local.html", "text/html"},
+ {"service_worker.html", "text/html"},
+ {"csp_script.js", "text/javascript"},
+ {"sw.js", "text/javascript"},
+ {"isolated_script.js", "text/javascript"},
+ {"local_script.js", "text/javascript"},
+ {"test.mp4", "video/mp4"},
+ {"xhr", "application/json"}
+ };
+
+
+ if (!resourceManager()) {
+ OH_LOG_ERROR(LOG_APP, "read rawfile error, resource manager is nullptr.");
+ return;
+ }
+
+
+ RawFile *rawfile = OH_ResourceManager_OpenRawFile(resourceManager(), rawfilePath().c_str());
+ if (!rawfile) {
+ OH_ArkWebResponse_SetStatus(response(), 404);
+ } else {
+ OH_ArkWebResponse_SetStatus(response(), 200);
+ }
+
+
+ for (auto &urlInfo : urlInfos) {
+ if (urlInfo.resource == rawfilePath()) {
+ OH_ArkWebResponse_SetMimeType(response(), urlInfo.mimeType.c_str());
+ break;
+ }
+ }
+ OH_ArkWebResponse_SetCharset(response(), "UTF-8");
+
+
+ long len = OH_ResourceManager_GetRawFileSize(rawfile);
+ OH_ArkWebResponse_SetHeaderByName(response(), "content-length", std::to_string(len).c_str(), false);
+ DidReceiveResponse();
+
+
+ long consumed = 0;
+ uint8_t buffer[blockSize];
+ while (true) {
+ int ret = OH_ResourceManager_ReadRawFile(rawfile, buffer, blockSize);
+ OH_LOG_INFO(LOG_APP, "read rawfile %{public}d bytes.", ret);
+ if (ret == 0) {
+ break;
+ }
+ consumed += ret;
+ OH_ResourceManager_SeekRawFile(rawfile, consumed, 0);
+ DidReceiveData(buffer, ret);
+ memset(buffer, 0, blockSize);
+ }
+
+
+ OH_ResourceManager_CloseRawFile(rawfile);
+ DidFinish();
+}
+
+
+void RawfileRequest::Stop()
+{
+ OH_LOG_INFO(LOG_APP, "stop the rawfile request.");
+ std::lock_guardscheme: custom-csp-bypassing
+options: ARKWEB_SCHEME_OPTION_CSP_BYPASSING | ARKWEB_SCHEME_OPTION_STANDARD
+ + + \ No newline at end of file diff --git a/ArkWeb/ArkWebSchemeHandler/entry/src/main/resources/rawfile/csp_script.js b/ArkWeb/ArkWebSchemeHandler/entry/src/main/resources/rawfile/csp_script.js new file mode 100644 index 0000000000000000000000000000000000000000..07a301212fc48d7bc73d81f7e441c9aba461f07f --- /dev/null +++ b/ArkWeb/ArkWebSchemeHandler/entry/src/main/resources/rawfile/csp_script.js @@ -0,0 +1,19 @@ +/* +* Copyright (c) 2025 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +const body = document.body; +const element = document.createElement('div'); +element.textContent = 'csp_script.js bypass the csp rules'; +body.appendChild(element); \ No newline at end of file diff --git a/ArkWeb/ArkWebSchemeHandler/entry/src/main/resources/rawfile/isolated.html b/ArkWeb/ArkWebSchemeHandler/entry/src/main/resources/rawfile/isolated.html new file mode 100644 index 0000000000000000000000000000000000000000..0ef20f02ff5c3ce6ca5094d78fd54cddabb476b5 --- /dev/null +++ b/ArkWeb/ArkWebSchemeHandler/entry/src/main/resources/rawfile/isolated.html @@ -0,0 +1,26 @@ + + + + + + + +scheme: custom-isolated
+options: ARKWEB_SCHEME_OPTION_DISPLAY_ISOLATED
+scheme: custom-local
+options: ARKWEB_SCHEME_OPTION_LOCAL
+
|
+
+使用说明
+
+1. 针对本地index.html,使用http或者https协议代替file协议或者resource协议,构造一个属于自己的域名。
+
+#### LocCrossOriginResAccSol_two
+
+##### 介绍
+
+1. 本示例主要介绍解决Web组件本地资源跨域问题,通过setPathAllowingUniversalAccess设置一个路径列表。当使用file协议访问该列表中的资源时,允许进行跨域访问本地文件。
+
+##### 效果预览
+
+| 主页 | 跨域访问 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 通过setPathAllowingUniversalAccess设置一个路径列表。当使用file协议访问该列表中的资源时,允许进行跨域访问本地文件。
+1. index.html页面加载完成后,页面上显示一个按钮stealFile,点击stealFile按钮触发getFile函数跨域访问本地resfile/js/script.js文件。
+
+## 使用智能防跟踪功能
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-intelligent-tracking-prevention.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### AddIntTrackPreventByPassList
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,调用addIntelligentTrackingPreventionBypassingList接口设置需要绕过智能防跟踪功能的域名列表。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击addIntelligentTrackingPreventionBypassingList按钮设置需要绕过智能防跟踪功能的域名。
+
+#### ClearIntTrackPreventByPassList
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用clearIntelligentTrackingPreventionBypassingList接口清除通过addIntelligentTrackingPreventionBypassingList接口设置的所有域名。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击clearIntelligentTrackingPreventionBypassingList按钮清除通过addIntelligentTrackingPreventionBypassingList接口设置的所有域名。
+
+#### EnableIntTrackPrevent
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,调用enableIntelligentTrackingPrevention接口使能或者关闭相应Web组件的智能防跟踪功能。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击enableIntelligentTrackingPrevention按钮使能相应Web组件的智能防跟踪功能。
+
+#### IsIntTrackPreventEnabled
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用isIntelligentTrackingPreventionEnabled接口判断当前Web组件是否开启了智能防跟踪功能。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击isIntelligentTrackingPreventionEnabled按钮判断当前Web组件是否开启了智能防跟踪功能。
+
+#### OnIntTrackPreventResult
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用onIntelligentTrackingPreventionResult接口,以回调的方式异步获取拦截的跟踪型网站的域名和访问的网站域名信息。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击onIntelligentTrackingPreventionResult按钮,获取拦截的跟踪型网站的域名和访问的网站域名信息。
+
+#### RemoveIntTrackPreventByPassList
+
+##### 介绍
+
+1. 本示例主要介绍使用智能防跟踪功能,通过调用removeIntelligentTrackingPreventionBypassingList接口移除通过addIntelligentTrackingPreventionBypassingList接口设置的部分域名列表。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击removeIntelligentTrackingPreventionBypassingList按钮,移除通过addIntelligentTrackingPreventionBypassingList接口设置的部分域名列表。
+
+## 使用Web组件的广告过滤功能
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-adsblock.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### EnablingAdsBlocking
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,应用可以通过AdsBlockManager提供的setAdsBlockRules()接口设置自定义的easylist过滤规则,并通过Web组件的enableAdsBlock()接口使能广告过滤特性。
+
+##### 效果预览
+
+| 主页 | 文件选择器 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
/> |
|
+
+使用说明
+
+1. 点击setAdsBlockRules按钮,通过文件选择器设置自定义的easylist过滤规则。
+
+#### DisAdsBlockSpecDomPages_one
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,在Web组件的广告过滤开关开启后,应用有时候会期望关闭一些特定页面的广告过滤功能,AdsBlockManager提供了addAdsBlockDisallowedList()接口完成此功能。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击addAdsBlockDisallowedList按钮关闭特定域名页面的广告过滤。
+
+#### DisAdsBlockSpecDomPages_two
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,使用addAdsBlockDisallowedList()接口添加域名。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击addAdsBlockDisallowedList按钮添加域名。
+
+#### CollectingAdsBlockingInformation
+
+##### 介绍
+
+1. 本示例主要介绍使用Web组件的广告过滤功能,在Web组件的广告过滤开关开启后,访问的网页如果发生了广告过滤,会通过Web组件的onAdsBlocked()回调接口通知到应用,应用可根据需要进行过滤信息的收集和统计。
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 使用onAdsBlocked接口收集广告过滤的信息。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---CollectingAdsBlockingInformation
+|---|---|---DisAdsBlockSpecDomPages_one
+|---|---|---DisAdsBlockSpecDomPages_two
+|---|---|---LocCrossOriginResAccSol_one
+|---|---|---LocCrossOriginResAccSol_two
+|---|---|---AddIntTrackPreventByPassList
+|---|---|---ClearIntTrackPreventByPassList
+|---|---|---EnableIntTrackPrevent
+|---|---|---IsIntTrackPreventEnabled
+|---|---|---OnIntTrackPreventResult
+|---|---|---RemoveIntTrackPreventByPassList
+|---|---|---EnablingAdsBlocking
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo ArkWeb/ManageWebCompSecPriv > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
diff --git a/ArkWeb/ManageWebCompSecPriv/build-profile.json5 b/ArkWeb/ManageWebCompSecPriv/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..edcfa0a0b72fb77e6fa0828177e088eec84f61eb
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ {
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/code-linter.json5 b/ArkWeb/ManageWebCompSecPriv/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/.gitignore b/ArkWeb/ManageWebCompSecPriv/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5 b/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/hvigorfile.ts b/ArkWeb/ManageWebCompSecPriv/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/obfuscation-rules.txt b/ArkWeb/ManageWebCompSecPriv/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5 b/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets
new file mode 100644
index 0000000000000000000000000000000000000000..aa1655f7bbde61df1c1a081b565110487297ab79
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/AddIntTrackPreventByPassList.ets
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start set_domains_to_bypass_intelligent_tracking]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('addIntelligentTrackingPreventionBypassingList')
+ .onClick(() => {
+ try {
+ let hostList = ['www.test1.com', 'www.test2.com', 'www.test3.com'];
+ webview.WebviewController.addIntelligentTrackingPreventionBypassingList(hostList);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller });
+ }
+ }
+}
+// [End set_domains_to_bypass_intelligent_tracking]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets
new file mode 100644
index 0000000000000000000000000000000000000000..49754ae2a245269f8aaec2dbcd2934e959e8bcb4
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/ClearIntTrackPreventByPassList.ets
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start clear_all_intelligent_tracking_prevention_bypasses]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('clearIntelligentTrackingPreventionBypassingList')
+ .onClick(() => {
+ webview.WebviewController.clearIntelligentTrackingPreventionBypassingList();
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller })
+ }
+ }
+}
+// [End clear_all_intelligent_tracking_prevention_bypasses]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets
new file mode 100644
index 0000000000000000000000000000000000000000..2d271fae7990654324db8a7e4aeb8b3b363caec9
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/CollectingAdsBlockingInformation.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start collect_information_about_ad_filtering]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebComponent {
+ @State totalAdsBlockCounts: number = 0;
+ // [StartExclude collect_information_about_ad_filtering]
+ @State myString: string = 'onAdsBlocked';
+ // [EndExclude collect_information_about_ad_filtering]
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $r('app.string.web_path'), controller: this.controller })
+ .onAdsBlocked((details: AdsBlockedDetails) => {
+ if (details) {
+ console.log(' Blocked ' + details.adsBlocked.length + ' in ' + details.url);
+ let adList: string[] = Array.from(new Set(details.adsBlocked));
+ this.totalAdsBlockCounts += adList.length;
+ console.log('Total blocked counts :' + this.totalAdsBlockCounts);
+ }
+ })
+ }
+ }
+}
+// [End collect_information_about_ad_filtering]
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f7649e9937a547b1fc4a4034afce0a877e524fc5
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_one.ets
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start turn_off_ad_filtering_for_specific_domain_pages]
+import { webview } from '@kit.ArkWeb';
+
+// [StartExclude turn_off_ad_filtering_for_specific_domain_pages]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude turn_off_ad_filtering_for_specific_domain_pages]
+@Entry
+@Component
+struct WebComponent {
+ mainUrl: string = resourceToString($r('app.string.web_path'));
+ textInputController: TextInputController = new TextInputController();
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ @State inputText: string = resourceToString($r('app.string.web_path'));
+
+ build() {
+ Column() {
+ Row() {
+ Flex() {
+ TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController})
+ .id('input_url')
+ .height(40)
+ .margin(5)
+ .borderColor(Color.Blue)
+ .onChange((value: string) => {
+ this.inputText = value;
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('Go') }
+ .onClick(() => {
+ this.controller.loadUrl(this.inputText);
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('addAdsBlockDisallowedList') }
+ .onClick(() => {
+ let arrDomainSuffixes: string[] = [];
+ arrDomainSuffixes.push('example.com');
+ arrDomainSuffixes.push('abcdefg.cn');
+ webview.AdsBlockManager.addAdsBlockDisallowedList(arrDomainSuffixes);
+ })
+ }
+ }
+ Web({ src: this.mainUrl, controller: this.controller })
+ .onControllerAttached(()=>{
+ this.controller.enableAdsBlock(true);
+ })
+ }
+ }
+}
+// [End turn_off_ad_filtering_for_specific_domain_pages]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c407061e161f5f86af1b1272e265f1d59262e821
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/DisAdsBlockSpecDomPages_two.ets
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start set_up_page_level_ad_filtering_switch]
+import { webview } from '@kit.ArkWeb';
+
+// [StartExclude set_up_page_level_ad_filtering_switch]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude set_up_page_level_ad_filtering_switch]
+@Entry
+@Component
+struct WebComponent {
+ mainUrl: string = resourceToString($r('app.string.web_path'));
+ textInputController: TextInputController = new TextInputController();
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ @State inputText: string = resourceToString($r('app.string.web_path'));
+
+ build() {
+ Column() {
+ Row() {
+ Flex() {
+ TextInput({ text: this.inputText, placeholder: this.mainUrl, controller: this.textInputController})
+ .id('input_url')
+ .height(40)
+ .margin(5)
+ .borderColor(Color.Blue)
+ .onChange((value: string) => {
+ this.inputText = value;
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('Go'); }
+ .onClick(() => {
+ this.controller.loadUrl(this.inputText);
+ })
+
+ Button({type: ButtonType.Capsule}) { Text('addAdsBlockAllowedList'); }
+ .onClick(() => {
+ let arrDisallowDomainSuffixes = ['example.com'];
+ webview.AdsBlockManager.addAdsBlockDisallowedList(arrDisallowDomainSuffixes);
+
+ let arrAllowedDomainSuffixes = ['news.example.com', 'sport.example.com'];
+ webview.AdsBlockManager.addAdsBlockAllowedList(arrAllowedDomainSuffixes);
+ })
+ }
+ }
+ Web({ src: this.mainUrl, controller: this.controller })
+ .onControllerAttached(()=>{
+ this.controller.enableAdsBlock(true);
+ })
+ }
+ }
+}
+// [End set_up_page_level_ad_filtering_switch]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ab7767a6c6bb65d34e0c320e9d6b126039a8e77d
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnableIntTrackPrevent.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start enable_or_disable_web_component_anti_tracking]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('enableIntelligentTrackingPrevention')
+ .onClick(() => {
+ try {
+ this.controller.enableIntelligentTrackingPrevention(true);
+ console.log('enableIntelligentTrackingPrevention: true');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller });
+ }
+ }
+}
+// [End enable_or_disable_web_component_anti_tracking]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8eb4a81e2d203fc04af163a09aaf5601ef77c7c7
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/EnablingAdsBlocking.ets
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start app_select_list_rule_file_for_ad_filter]
+import { webview } from '@kit.ArkWeb';
+import { picker, fileUri } from '@kit.CoreFileKit';
+
+// [StartExclude app_select_list_rule_file_for_ad_filter]
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+// [EndExclude app_select_list_rule_file_for_ad_filter]
+@Entry
+@Component
+struct WebComponent {
+ mainUrl: string = resourceToString($r('app.string.web_path'));
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ @State inputText: string = resourceToString($r('app.string.web_path'));
+
+ build() {
+ Column() {
+ Row() {
+ Flex() {
+ Button({type: ButtonType.Capsule}) {
+ Text('setAdsBlockRules');
+ }
+ .onClick(() => {
+ try {
+ let documentSelectionOptions: picker.DocumentSelectOptions = new picker.DocumentSelectOptions();
+ let documentPicker: picker.DocumentViewPicker = new picker.DocumentViewPicker();
+ documentPicker.select(documentSelectionOptions).then((documentSelectResult: string[]) => {
+ if (documentSelectResult && documentSelectResult.length > 0) {
+ let fileRealPath = new fileUri.FileUri(documentSelectResult[0]);
+ console.info('DocumentViewPicker.select successfully, uri: ' + fileRealPath);
+ webview.AdsBlockManager.setAdsBlockRules(fileRealPath.path, true);
+ }
+ })
+ } catch (err) {
+ console.error('DocumentViewPicker.select failed with err:' + err);
+ }
+ })
+ }
+ }
+ Web({ src: this.mainUrl, controller: this.controller })
+ .onControllerAttached(()=>{
+ this.controller.enableAdsBlock(true);
+ })
+ }
+ }
+}
+// [End app_select_list_rule_file_for_ad_filter]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..cb5f033b5edc90ee98d926d2590e6c02294df4b6
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('LocCrossOriginResAccSol_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_one' });
+ })
+ Button('LocCrossOriginResAccSol_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/LocCrossOriginResAccSol_two' });
+ })
+ Button('AddIntTrackPreventByPassList')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/AddIntTrackPreventByPassList' });
+ })
+ Button('ClearIntTrackPreventByPassList')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ClearIntTrackPreventByPassList' });
+ })
+ Button('EnableIntTrackPrevent')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/EnableIntTrackPrevent' });
+ })
+ Button('IsIntTrackPreventEnabled')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/IsIntTrackPreventEnabled' });
+ })
+ Button('OnIntTrackPreventResult')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/OnIntTrackPreventResult' });
+ })
+ Button('RemoveIntTrackPreventByPassList')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/RemoveIntTrackPreventByPassList' });
+ })
+ Button('EnablingAdsBlocking')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/EnablingAdsBlocking' });
+ })
+ Button('DisAdsBlockSpecDomPages_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_one' });
+ })
+ Button('DisAdsBlockSpecDomPages_two')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/DisAdsBlockSpecDomPages_two' });
+ })
+ Button('CollectingAdsBlockingInformation')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/CollectingAdsBlockingInformation' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b33603d2c083d817a71949d8e8c4ac533582e4fc
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/IsIntTrackPreventEnabled.ets
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start check_if_web_component_anti_tracking_on]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('isIntelligentTrackingPreventionEnabled')
+ .onClick(() => {
+ try {
+ let result = this.controller.isIntelligentTrackingPreventionEnabled();
+ console.log('result: ' + result);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller });
+ }
+ }
+}
+// [End check_if_web_component_anti_tracking_on]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets
new file mode 100644
index 0000000000000000000000000000000000000000..89333b69cb353cc31ca718d0175cae53d6bd1de7
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_one.ets
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start cors_loccross_one]
+import { webview } from '@kit.ArkWeb';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World';
+ webviewController: webview.WebviewController = new webview.WebviewController();
+ // 构造域名和本地文件的映射表
+ schemeMap = new Map([
+ [resourceToString($r('app.string.web_path')) + '/index.html', 'index.html'],
+ [resourceToString($r('app.string.web_path')) + '/js/script.js', 'js/script.js'],
+ ]);
+ // 构造本地文件和构造返回的格式mimeType
+ mimeTypeMap = new Map([
+ ['index.html', 'text/html'],
+ ['js/script.js', 'text/javascript']
+ ]);
+
+ build() {
+ Row() {
+ Column() {
+ // 针对本地index1.html,使用http或者https协议代替file协议或者resource协议,并且构造一个属于自己的域名。
+ // 本例中构造www.example.com为例。
+ Web({ src: resourceToString($r('app.string.web_path')) + '/index.html', controller: this.webviewController })
+ .javaScriptAccess(true)
+ .fileAccess(true)
+ .domStorageAccess(true)
+ .geolocationAccess(true)
+ .width('100%')
+ .height('100%')
+ .onInterceptRequest((event) => {
+ if (!event) {
+ return;
+ }
+ // 此处匹配自己想要加载的本地离线资源,进行资源拦截替换,绕过跨域
+ if (this.schemeMap.has(event.request.getRequestUrl())) {
+ let rawfileName: string = this.schemeMap.get(event.request.getRequestUrl())!;
+ let mimeType = this.mimeTypeMap.get(rawfileName);
+ if (typeof mimeType === 'string') {
+ let response = new WebResourceResponse();
+ // 构造响应数据,如果本地文件在rawfile下,可以通过如下方式设置
+ response.setResponseData($rawfile(rawfileName));
+ response.setResponseEncoding('utf-8');
+ response.setResponseMimeType(mimeType);
+ response.setResponseCode(200);
+ response.setReasonMessage('OK');
+ response.setResponseIsReady(true);
+ return response;
+ }
+ }
+ return null;
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+// [End cors_loccross_one]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets
new file mode 100644
index 0000000000000000000000000000000000000000..aae56aaced7fd6f3c2611a7080e2c823b87ea13d
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/LocCrossOriginResAccSol_two.ets
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start cors_loccross_two]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: WebviewController = new webview.WebviewController();
+
+ build() {
+ Row() {
+ Web({ src: '', controller: this.controller })
+ .onControllerAttached(() => {
+ try {
+ // 设置允许可以跨域访问的路径列表
+ this.controller.setPathAllowingUniversalAccess([
+ getContext().resourceDir,
+ getContext().filesDir + '/example'
+ ]);
+ this.controller.loadUrl('file://' + getContext().resourceDir + '/index.html');
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ .javaScriptAccess(true)
+ .fileAccess(true)
+ .domStorageAccess(true)
+ }
+ }
+}
+// [End cors_loccross_two]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets
new file mode 100644
index 0000000000000000000000000000000000000000..23fdec43f07cb906691e0505bdc65cd5306e1e36
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/OnIntTrackPreventResult.ets
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start retrieve_blocked_and_visited_domain_names]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ // 需要打开智能防跟踪功能,才会触发onIntelligentTrackingPreventionResult回调
+ Button('enableIntelligentTrackingPrevention')
+ .onClick(() => {
+ try {
+ this.controller.enableIntelligentTrackingPrevention(true);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $r('app.string.web_path'), controller: this.controller })
+ .onIntelligentTrackingPreventionResult((details) => {
+ console.log('onIntelligentTrackingPreventionResult: [websiteHost]= ' + details.host +
+ ', [trackerHost]=' + details.trackerHost);
+ })
+ }
+ }
+}
+// [End retrieve_blocked_and_visited_domain_names]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ed8c741879f229405e43b14fbc72650b4df53ec9
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/ets/pages/RemoveIntTrackPreventByPassList.ets
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// [Start partial_domain_name_list]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Button('removeIntelligentTrackingPreventionBypassingList')
+ .onClick(() => {
+ try {
+ let hostList = [ 'www.test1.com', 'www.test2.com' ];
+ webview.WebviewController.removeIntelligentTrackingPreventionBypassingList(hostList);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller })
+ }
+ }
+}
+// [End partial_domain_name_list]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5 b/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..68f2a3f7cd4e6b25d5f6224c60837ba99c25ec76
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebCompSecPriv"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/background.png differ
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..8a72c3b7803a5e5cd787f8239bc1a60b9f60391c
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,17 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/LocCrossOriginResAccSol_one",
+ "pages/LocCrossOriginResAccSol_two",
+ "pages/AddIntTrackPreventByPassList",
+ "pages/ClearIntTrackPreventByPassList",
+ "pages/EnableIntTrackPrevent",
+ "pages/IsIntTrackPreventEnabled",
+ "pages/OnIntTrackPreventResult",
+ "pages/RemoveIntTrackPreventByPassList",
+ "pages/EnablingAdsBlocking",
+ "pages/DisAdsBlockSpecDomPages_one",
+ "pages/DisAdsBlockSpecDomPages_two",
+ "pages/CollectingAdsBlockingInformation"
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..6aba54ea1bb3ac12f412cb39a46e76081f6fcc31
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebCompSecPriv"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..01ba29a16a4306f3ed6bd10c2c7a9cdb84e5285e
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/index.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js
new file mode 100644
index 0000000000000000000000000000000000000000..dfd1c0b8cb035c61be2f521a59d66908d4b4c023
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/rawfile/js/script.js
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start cors_script_raw]
+const body = document.body;
+const element = document.createElement('div');
+element.textContent = 'success';
+body.appendChild(element);
+// [End cors_script_raw]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html
new file mode 100644
index 0000000000000000000000000000000000000000..e8aa15081537f3f522e4ed361345524ca955f8f3
--- /dev/null
+++ b/ArkWeb/ManageWebCompSecPriv/entry/src/main/resources/resfile/index.html
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
|
|
+
+使用方法
+
+1. 在主页点击选择文件按钮触发onShowFileSelector事件创建DocumentSelectOptions和DocumentViewPicker,用于打开文件选择器,弹出文件选择器,用户可选择一个文件。
+
+## 使用Web组件的下载能力
+
+### 介绍
+
+1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-download.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。
+
+### ListenForPageDown
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件监听页面触发的下载功能,通过setDownloadDelegate()向Web组件注册一个DownloadDelegate来监听页面触发的下载任务。资源由Web组件来下载,Web组件会通过DownloadDelegate将下载的进度通知给应用。
+
+#### 效果预览
+
+| 主页 | 下载 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击setDownloadDelegate按钮,定义下载委托回调。
+2. 点击下载download.html链接,触发下载任务。
+
+### InitiatingADownloadTask
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件的下载能力。在Web组件启动时,可通过resumeDownload()接口恢复未完成的下载任务。
+
+
+#### 效果预览
+
+| 主页 | 下载 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击setDownloadDelegate按钮,定义下载委托回调。
+1. 使用startDownload()接口发起一个下载。
+
+### ResumeDownload
+
+#### 介绍
+
+1. 本示例主要介绍使用Web组件的下载能力。使用startDownload()接口发起一个下载,Web组件发起的下载会根据当前显示的url以及Web组件默认的Referrer Policy来计算referrer。
+
+
+#### 效果预览
+
+| 主页 |
+| ----------------------------------------------------------- |
+|
|
+
+使用说明
+
+1. 点击setDownloadDelegate按钮,定义下载委托回调。
+1. 使用startDownload()接口发起一个下载。
+1. 通过record按钮将当前下载任务保存至持久化文件中,记录下载任务信息。
+1. 点击recovery按钮恢复下载任务。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---UploadFiles.ets
+|---|---|---downloadUtil.ets
+|---|---|---Index.ets // 首页
+|---|---|---InitiatingADownloadTask.ets
+|---|---|---ListenForPageDown.ets
+|---|---|---ResumeDownload.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo ArkWeb/ManageWebPageFileIO > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/build-profile.json5 b/ArkWeb/ManageWebPageFileIO/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..9c284a291dc2cd15abf8025431e67aa253f01b81
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/build-profile.json5
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/code-linter.json5 b/ArkWeb/ManageWebPageFileIO/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/.gitignore b/ArkWeb/ManageWebPageFileIO/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5 b/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/hvigorfile.ts b/ArkWeb/ManageWebPageFileIO/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ArkWeb/ManageWebPageFileIO/entry/obfuscation-rules.txt b/ArkWeb/ManageWebPageFileIO/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5 b/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..80e8214f747914b9b3b64331d9eb37fd1619a007
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('UploadFiles')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/UploadFiles' });
+ })
+ Button('ListenForPageDown')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ListenForPageDown' });
+ })
+ Button('InitiatingADownloadTask')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/InitiatingADownloadTask' });
+ })
+ Button('ResumeDownload')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ResumeDownload' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets
new file mode 100644
index 0000000000000000000000000000000000000000..5b876e5f292321bcd2a884cd16a2f360516b7f02
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/InitiatingADownloadTask.ets
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start init_download_task]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate();
+ @State myText: string = 'download';
+
+ build() {
+ Column() {
+ Text(this.myText)
+ Button('setDownloadDelegate')
+ .onClick(() => {
+ try {
+ this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('will start a download.');
+ // 传入一个下载路径,并开始下载。
+ webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName());
+ })
+ this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download update guid: ' + webDownloadItem.getGuid());
+ })
+ this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download failed guid: ' + webDownloadItem.getGuid());
+ })
+ this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download finish guid: ' + webDownloadItem.getGuid());
+ this.myText = 'download finish';
+ })
+ this.controller.setDownloadDelegate(this.delegate);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('startDownload')
+ .onClick(() => {
+ try {
+ // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。
+ // 开发者需要替换为自己想要下载的内容的地址。
+ this.controller.startDownload(resourceToString($r('app.string.web_path')));
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: 'www.example.com', controller: this.controller })
+ }
+ }
+}
+// [End init_download_task]
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets
new file mode 100644
index 0000000000000000000000000000000000000000..733a26d4b9600db7f50a41cc0b338561f1584951
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ListenForPageDown.ets
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start download_delegate]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate();
+ @State myText: string = 'download';
+
+ build() {
+ Column() {
+ Text(this.myText)
+ Button('setDownloadDelegate')
+ .onClick(() => {
+ try {
+ this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('will start a download.');
+ // Pass in a download path and start the download.
+ // If the path is invalid, the file will be downloaded to the
+ // default directory at /data/storage/el2/base/cache/web/.
+ webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName());
+ })
+ this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => {
+ // Unique ID of a download task.
+ console.log('download update guid: ' + webDownloadItem.getGuid());
+ // Download progress.
+ console.log('download update guid: ' + webDownloadItem.getPercentComplete());
+ // Current download speed.
+ console.log('download update speed: ' + webDownloadItem.getCurrentSpeed());
+ })
+ this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download failed guid: ' + webDownloadItem.getGuid());
+ // Error code of a download task failure.
+ console.log('download failed guid: ' + webDownloadItem.getLastErrorCode());
+ })
+ this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download finish guid: ' + webDownloadItem.getGuid());
+ this.myText = 'download finish';
+ })
+ this.controller.setDownloadDelegate(this.delegate);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Web({ src: $rawfile('index.html'), controller: this.controller })
+ }
+ }
+}
+// [End download_delegate]
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets
new file mode 100644
index 0000000000000000000000000000000000000000..c0d230cdc7916565a9760fad159c3f84b950243c
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/ResumeDownload.ets
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start recovery_download_task]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { DownloadUtil, fileName, filePath } from './downloadUtil'; // downloadUtil.ets 见下文
+
+function resourceToString(resource: Resource) {
+ return getContext().resourceManager.getStringSync(resource);
+}
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ delegate: webview.WebDownloadDelegate = new webview.WebDownloadDelegate();
+ download: webview.WebDownloadItem = new webview.WebDownloadItem();
+ // 用于记录失败的下载任务。
+ failedData: Uint8Array = new Uint8Array();
+
+ build() {
+ Column() {
+ Button('setDownloadDelegate')
+ .onClick(() => {
+ try {
+ this.delegate.onBeforeDownload((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('will start a download.');
+ // 传入一个下载路径,并开始下载。
+ webDownloadItem.start('/data/storage/el2/base/cache/web/' + webDownloadItem.getSuggestedFileName());
+ })
+ this.delegate.onDownloadUpdated((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download update percent complete: ' + webDownloadItem.getPercentComplete());
+ this.download = webDownloadItem;
+ })
+ this.delegate.onDownloadFailed((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download failed guid: ' + webDownloadItem.getGuid());
+ // 序列化失败的下载任务到一个字节数组。
+ this.failedData = webDownloadItem.serialize();
+ })
+ this.delegate.onDownloadFinish((webDownloadItem: webview.WebDownloadItem) => {
+ console.log('download finish guid: ' + webDownloadItem.getGuid());
+ })
+ this.controller.setDownloadDelegate(this.delegate);
+ webview.WebDownloadManager.setDownloadDelegate(this.delegate);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ Button('startDownload')
+ .onClick(() => {
+ try {
+ // 这里指定下载地址为 https://www.example.com/,Web组件会发起一个下载任务将该页面下载下来。
+ // 开发者需要替换为自己想要下载的内容的地址。
+ this.controller.startDownload(resourceToString($r('app.string.web_path')));
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // 将当前的下载任务信息序列化保存,用于后续恢复下载任务。
+ // 当前用例仅展示下载一个任务的场景,多任务场景请按需扩展。
+ Button('record')
+ .onClick(() => {
+ try {
+ // 保存当前下载数据到持久化文档中。
+ DownloadUtil.saveDownloadInfo(DownloadUtil.uint8ArrayToStr(this.download.serialize()));
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+ // 从序列化的下载任务信息中,恢复下载任务。
+ // 按钮触发时必须保证WebDownloadManager.setDownloadDelegate设置完成。
+ Button('recovery')
+ .onClick(() => {
+ try {
+ // 当前默认持久化文件存在,用户根据实际情况增加判断。
+ let webDownloadItem =
+ webview.WebDownloadItem.deserialize(
+ DownloadUtil.strToUint8Array(DownloadUtil.readFileSync(filePath, fileName)));
+ webview.WebDownloadManager.resumeDownload(webDownloadItem);
+ } catch (error) {
+ console.error(
+ `ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`);
+ }
+ })
+
+ Web({ src: 'www.example.com', controller: this.controller })
+ }
+ }
+}
+// [End recovery_download_task]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f5e26614ec7193c00bd97c8ca7aca9b5d14d66b1
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/UploadFiles.ets
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start web_file_upload]
+import { webview } from '@kit.ArkWeb';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { picker } from '@kit.CoreFileKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('local.html'), controller: this.controller })
+ .onShowFileSelector((event) => {
+ console.log('MyFileUploader onShowFileSelector invoked');
+ const documentSelectOptions = new picker.DocumentSelectOptions();
+ let uri: string | null = null;
+ const documentViewPicker = new picker.DocumentViewPicker();
+ documentViewPicker.select(documentSelectOptions).then((documentSelectResult) => {
+ uri = documentSelectResult[0];
+ console.info('documentViewPicker.select to file succeed and uri is:' + uri);
+ if (event) {
+ event.result.handleFileList([uri]);
+ }
+ }).catch((err: BusinessError) => {
+ console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`);
+ })
+ return true;
+ })
+ }
+ }
+}
+// [End web_file_upload]
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets
new file mode 100644
index 0000000000000000000000000000000000000000..be9907e29f5341089f5e24a75fbefb6b08917e44
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/ets/pages/downloadUtil.ets
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start task_info_persistence_util]
+import { util } from '@kit.ArkTS';
+import fileStream from '@ohos.file.fs';
+
+const helper = new util.Base64Helper();
+
+export const filePath = getContext().filesDir;
+export const fileName = 'demoFile.txt';
+export namespace DownloadUtil {
+
+ export function uint8ArrayToStr(uint8Array: Uint8Array): string {
+ return helper.encodeToStringSync(uint8Array);
+ }
+
+ export function strToUint8Array(str: string): Uint8Array {
+ return helper.decodeSync(str);
+ }
+
+ export function saveDownloadInfo(downloadInfo: string): void {
+ if (!fileExists(filePath)) {
+ mkDirectorySync(filePath);
+ }
+
+ writeToFileSync(filePath, fileName, downloadInfo);
+ }
+
+ export function fileExists(filePath: string): boolean {
+ try {
+ return fileStream.accessSync(filePath);
+ } catch (error) {
+ return false;
+ }
+ }
+
+ export function mkDirectorySync(directoryPath: string, recursion?: boolean): void {
+ try {
+ fileStream.mkdirSync(directoryPath, recursion ?? false);
+ } catch (error) {
+ console.error(`mk dir error. err message: ${error.message}, err code: ${error.code}`);
+ }
+ }
+
+ export function writeToFileSync(dir: string, fileName: string, msg: string): void {
+ let file = fileStream.openSync(dir + '/' + fileName, fileStream.OpenMode.WRITE_ONLY | fileStream.OpenMode.CREATE);
+ fileStream.writeSync(file.fd, msg);
+ }
+
+ export function readFileSync(dir: string, fileName: string): string {
+ return fileStream.readTextSync(dir + '/' + fileName);
+ }
+
+}
+// [End task_info_persistence_util]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5 b/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e9db80c0ac2d7edb8e5ed53f5e5eb5ccbb272a57
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/module.json5
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "module": {
+ "name": "entry",
+ "type": "entry",
+ "description": "$string:module_desc",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..883cf5800d2f788f5b396cc9fbe250677c524829
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,20 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageFileIO"
+ },
+ {
+ "name": "web_path",
+ "value": "https://www.example.com/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d
Binary files /dev/null and b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/background.png differ
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902
Binary files /dev/null and b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/foreground.png differ
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b
Binary files /dev/null and b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/media/startIcon.png differ
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/backup_config.json
@@ -0,0 +1,3 @@
+{
+ "allowToBackupRestore": true
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..c163d886b69f969ad6975c6ac9fc06556384d468
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/base/profile/main_pages.json
@@ -0,0 +1,9 @@
+{
+ "src": [
+ "pages/Index",
+ "pages/UploadFiles",
+ "pages/ListenForPageDown",
+ "pages/InitiatingADownloadTask",
+ "pages/ResumeDownload"
+ ]
+}
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..3b22824ad2f373eba1f5d72ee7ae6cddd9f82a8f
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "ManageWebPageFileIO"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html
new file mode 100644
index 0000000000000000000000000000000000000000..79e8cc88be2c00e1a49303cd9ddffeb2e55b6c25
--- /dev/null
+++ b/ArkWeb/ManageWebPageFileIO/entry/src/main/resources/rawfile/download.html
@@ -0,0 +1,21 @@
+
+
+
+
+
+
|
+
+##### 使用说明
+
+1. 设置滚动模式(前)
+ - 在 切换前滚动模式 区域,点击 SELF_ONLY、SELF_FIRST、PARENT_FIRST、PARALLEL 按钮,可分别将 NestedScrollModeF 设置为相应的滚动模式,此模式用于控制 Web 视图向前滚动(scrollForward)时与父组件的交互方式。
+2. 设置滚动模式(后)
+ - 在 切换后滚动模式 区域,同样点击上述按钮,可设置NestedScrollModeB,用于控制 Web 视图向后滚动(scrollBackward)时的交互模式。
+
+## Web组件对接软键盘
+
+### 介绍
+
+1. 实现对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-docking-softkeyboard.md 示例代码片段的工程化,保证指南中示例代码与sample工程文件同源。
+
+#### SetSKBMode_one
+
+##### 介绍
+
+1. 本示例主要介绍Web组件对接软键盘,在UIContext的键盘避让模式为Offset模式情况下,通过WebKeyboardAvoidMode()设置ArkWeb组件的键盘避让模式。
+
+##### 效果预览
+
+| 主页 | 软键盘 |
+| ------------------------------------------------------------ | ------------------------------------------------------------ |
+|
|
|
+
+使用说明
+
+1. 点击输入框拉起软键盘。
+
+#### OnIntKbdAttachSysCustIn
+
+##### 介绍
+
+1. 本示例主要介绍拦截系统软键盘与自定义软键盘输入,调用onInterceptKeyboardAttach来拦截系统软键盘的弹出。
+
+
+##### 效果预览
+
+| 主页 |
+| ------------------------------------------------------------ |
+|
|
+
+使用说明
+
+1. 点击未设置特殊属性的输入框,将默认使用系统默认键盘。
+2. 点击设置了keyboard-return属性的输入框,根据属性值获取对应的enterKeyType,以改变系统键盘回车键的行为。
+
+### 工程目录
+
+```
+entry/src/main/
+|---ets
+|---|---entryability
+|---|---|---EntryAbility.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---|---|---OnIntKbdAttachSysCustIn.ets
+|---|---|---SetSKBMode_one.ets
+|---|---|---ImpNestedScroll.ets
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+## entry2:
+
+### SetSKBMode_two
+
+#### 介绍
+
+1. 本示例主要介绍Web组件对接软键盘,设置UIContext的软键盘避让模式setKeyboardAvoidMode(KeyboardAvoidMode.RESIZE),应用窗口高度可缩小避开软键盘,ArkWeb组件跟随ArkUI重新布局。
+
+#### 效果预览
+
+| 主页 | 软键盘 |
+| ----------------------------------------------------------- | ----------------------------------------------------------- |
+|
|
|
+
+使用说明
+
+1. 点击输入框拉起软键盘。
+
+### 工程目录
+
+```
+entry2/src/main/
+|---ets
+|---|---entry2ability
+|---|---|---Entry2Ability.ets
+|---|---pages
+|---|---|---Index.ets // 首页
+|---resources // 静态资源
+|---ohosTest
+|---|---ets
+|---|---|---tests
+|---|---|---|---Ability.test.ets // 自动化测试用例
+```
+
+
+### 相关权限
+
+无。
+
+## 依赖
+
+不涉及。
+
+## 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:华为手机。
+
+2. HarmonyOS系统:HarmonyOS 5.0.2 Release及以上。
+
+3. DevEco Studio版本:DevEco Studio 5.0.2 Release及以上。
+
+4. HarmonyOS SDK版本:HarmonyOS 5.0.2 Release及以上。
+
+## 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo ArkWeb/ManageWebPageInteracts > .git/info/sparse-checkout
+git remote add origin https://gitee.com/harmonyos_samples/guide-snippets.git
+git pull origin master
+```
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/build-profile.json5 b/ArkWeb/ManageWebPageInteracts/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c00db5abef42d324e414e34ba929de407db76b8a
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/build-profile.json5
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.2(14)",
+ "targetSdkVersion": "5.0.2(14)",
+ "runtimeOS": "HarmonyOS",
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "entry2",
+ "srcPath": "./entry2",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/code-linter.json5 b/ArkWeb/ManageWebPageInteracts/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/code-linter.json5
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/entry/.gitignore b/ArkWeb/ManageWebPageInteracts/entry/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5 b/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/build-profile.json5
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/entry/hvigorfile.ts b/ArkWeb/ManageWebPageInteracts/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2025 Huawei Device Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ArkWeb/ManageWebPageInteracts/entry/obfuscation-rules.txt b/ArkWeb/ManageWebPageInteracts/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5 b/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/oh-package.json5
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..b1e212947256c5533c7b06285a597c94f840a6e3
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets
new file mode 100644
index 0000000000000000000000000000000000000000..502a4cc8780ad87d5ceff274637b369f27c1af63
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/ImpNestedScroll.ets
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start nested_scrolling]
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct NestedScroll {
+ private scrollerForScroll: Scroller = new Scroller();
+ controller: webview.WebviewController = new webview.WebviewController();
+ controller2: webview.WebviewController = new webview.WebviewController();
+ // NestedScrollMode设置成SELF_ONLY时,Web网页滚动到页面边缘后,不与父组件联动,父组件仍无法滚动。
+ @State nestedScrollMode0: NestedScrollMode = NestedScrollMode.SELF_ONLY;
+ // NestedScrollMode设置成SELF_FIRST时,Web网页滚动到页面边缘后,父组件继续滚动。
+ @State nestedScrollMode1: NestedScrollMode = NestedScrollMode.SELF_FIRST;
+ // NestedScrollMode设置为PARENT_FIRST时,父组件先滚动,滚动至边缘后通知Web继续滚动。
+ @State nestedScrollMode2: NestedScrollMode = NestedScrollMode.PARENT_FIRST;
+ // NestedScrollMode设置为PARALLEL时,父组件与Web同时滚动。
+ @State nestedScrollMode3: NestedScrollMode = NestedScrollMode.PARALLEL;
+ @State nestedScrollModeF: NestedScrollMode = NestedScrollMode.SELF_FIRST;
+ @State nestedScrollModeB: NestedScrollMode = NestedScrollMode.SELF_FIRST;
+ // scroll竖向的滚动
+ @State scrollDirection: ScrollDirection = ScrollDirection.Vertical;
+
+ build() {
+ Flex() {
+ Scroll(this.scrollerForScroll) {
+ Column({ space: 5 }) {
+ Row({}) {
+ Text('切换前滚动模式').fontSize(5)
+ Button('SELF_ONLY').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode0
+ }).fontSize(5)
+ Button('SELF_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode1
+ }).fontSize(5)
+ Button('PARENT_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode2
+ }).fontSize(5)
+ Button('PARALLEL').onClick((event: ClickEvent) => {
+ this.nestedScrollModeF = this.nestedScrollMode3
+ }).fontSize(5)
+ }
+
+ Row({}) {
+ Text('切换后滚动模式').fontSize(5)
+ Button('SELF_ONLY').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode0
+ }).fontSize(5)
+ Button('SELF_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode1
+ }).fontSize(5)
+ Button('PARENT_FIRST').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode2
+ }).fontSize(5)
+ Button('PARALLEL').onClick((event: ClickEvent) => {
+ this.nestedScrollModeB = this.nestedScrollMode3
+ }).fontSize(5)
+ }
+
+ Text('当前内嵌前滚动模式 scrollForward ---' + `${this.nestedScrollModeF}`).fontSize(10)
+ Text('当前内嵌后滚动模式 scrollBackward ---' + `${this.nestedScrollModeB}`).fontSize(10)
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('10%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ Text('Scroll Area')
+ .width('100%')
+ .height('10%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+ Text('Scroll Area')
+ .width('100%')
+ .height('10%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ Web({ src: 'www.example.com', controller: this.controller })
+ .nestedScroll({
+ scrollForward: this.nestedScrollModeF,
+ scrollBackward: this.nestedScrollModeB,
+ })
+ .height('40%')
+ .width('100%')
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('20%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('20%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ Web({ src: 'www.example.com', controller: this.controller2 })
+ .nestedScroll({
+ scrollForward: this.nestedScrollModeF,
+ scrollBackward: this.nestedScrollModeB,
+ })
+ .height('40%')
+ .width('90%')
+
+ Text('Scroll Area')
+ .width('100%')
+ .height('20%')
+ .backgroundColor(0X330000FF)
+ .fontSize(16)
+ .textAlign(TextAlign.Center)
+
+ }.width('95%').border({ width: 5 })
+ }
+ .width('100%').height('120%').border({ width: 5 }).scrollable(this.scrollDirection)
+ }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding(20)
+ }
+}
+// [End nested_scrolling]
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..f9b6f41e802970502c50ee0ea64b70bc455da97a
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { router } from '@kit.ArkUI';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Column({ space: 10 }) {
+ Button('ImpNestedScroll')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ImpNestedScroll' });
+ })
+ Button('OnIntKbdAttachSysCustIn')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/OnIntKbdAttachSysCustIn' });
+ })
+ Button('SetSKBMode_one')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/SetSKBMode_one' });
+ })
+ }.height('100%')
+ .width('100%')
+ }
+}
\ No newline at end of file
diff --git a/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ed6dd8f9d0e1e447a3f91400877713906f6e9d57
--- /dev/null
+++ b/ArkWeb/ManageWebPageInteracts/entry/src/main/ets/pages/OnIntKbdAttachSysCustIn.ets
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2025 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// [Start soft_keyboard_web]
+import { webview } from '@kit.ArkWeb';
+import { inputMethodEngine } from '@kit.IMEKit';
+
+@Entry
+@Component
+struct WebComponent {
+ controller: webview.WebviewController = new webview.WebviewController();
+ webKeyboardController: WebKeyboardController = new WebKeyboardController();
+ inputAttributeMap: Mapinput标签,原有默认行为:
+input标签,系统键盘自定义enterKeyType属性 enter key UNSPECIFIED:
+input标签,系统键盘自定义enterKeyType属性 enter key GO:
+input标签,系统键盘自定义enterKeyType属性 enter key SEARCH:
+input标签,系统键盘自定义enterKeyType属性 enter key SEND:
+input标签,系统键盘自定义enterKeyType属性 enter key NEXT:
+input标签,系统键盘自定义enterKeyType属性 enter key DONE:
+input标签,系统键盘自定义enterKeyType属性 enter key PREVIOUS:
+input标签,应用自定义键盘:
+