1 Star 0 Fork 39

libing23/security_security_component

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webview.patch 8.76 KB
一键复制 编辑 原始数据 按行查看 历史
libing23 提交于 2024-06-19 16:23 +08:00 . upload patch
diff --git a/interfaces/kits/napi/common/web_errors.cpp b/interfaces/kits/napi/common/web_errors.cpp
index 574936d6..eec5c783 100644
--- a/interfaces/kits/napi/common/web_errors.cpp
+++ b/interfaces/kits/napi/common/web_errors.cpp
@@ -57,6 +57,7 @@ namespace ParamCheckErrorMsgTemplate {
const char* PARAM_NOT_NULL = "BusinessError 401: Parameter error. The type of '%s' can not be ignored.";
const char* PARAM_NOT_NULL_TWO = "BusinessError 401: Parameter error. The type of '%s' and '%s' can not be ignored.";
const char* PARAM_TYPE_INVALID = "BusinessError 401: Parameter error. The type of '%s' is invalid.";
+ const char* PARAM_DETAIL_ERROR_MSG = "BusinessError 401: Parameter error. detail: %s.";
}
namespace NWebError {
std::unordered_map<ErrCode, std::string> g_errCodeMsgMap = {
diff --git a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp
index 303a3b23..ee5811ef 100644
--- a/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp
+++ b/interfaces/kits/napi/webviewcontroller/napi_webview_controller.cpp
@@ -5791,10 +5791,12 @@ napi_value NapiWebviewController::SetUrlTrustList(napi_env env, napi_callback_in
return result;
}
- ErrCode ret = webviewController->SetUrlTrustList(urlTrustList);
+ std::string detailMsg;
+ ErrCode ret = webviewController->SetUrlTrustList(urlTrustList, detailMsg);
if (ret != NO_ERROR) {
WVLOG_E("SetUrlTrustList failed, error code: %{public}d", ret);
- BusinessError::ThrowErrorByErrcode(env, ret);
+ BusinessError::ThrowErrorByErrcode(env, ret,
+ NWebError::FormatString(ParamCheckErrorMsgTemplate::PARAM_DETAIL_ERROR_MSG, detailMsg));
return result;
}
return result;
diff --git a/interfaces/kits/napi/webviewcontroller/webview_controller.cpp b/interfaces/kits/napi/webviewcontroller/webview_controller.cpp
index 91415541..26cd903a 100644
--- a/interfaces/kits/napi/webviewcontroller/webview_controller.cpp
+++ b/interfaces/kits/napi/webviewcontroller/webview_controller.cpp
@@ -1769,7 +1769,7 @@ void WebviewController::UpdateInstanceId(int32_t newId)
}
}
-ErrCode WebviewController::SetUrlTrustList(const std::string& urlTrustList)
+ErrCode WebviewController::SetUrlTrustList(const std::string& urlTrustList, std::string& detailErrMsg)
{
auto nweb_ptr = NWebHelper::Instance().GetNWeb(nwebId_);
if (!nweb_ptr) {
@@ -1777,7 +1777,7 @@ ErrCode WebviewController::SetUrlTrustList(const std::string& urlTrustList)
}
int ret = NWebError::NO_ERROR;
- switch (nweb_ptr->SetUrlTrustList(urlTrustList)) {
+ switch (nweb_ptr->SetUrlTrustList(urlTrustList, detailErrMsg)) {
case static_cast<int>(UrlListSetResult::INIT_ERROR):
ret = NWebError::INIT_ERROR;
break;
diff --git a/interfaces/kits/napi/webviewcontroller/webview_controller.h b/interfaces/kits/napi/webviewcontroller/webview_controller.h
index e7623fc3..0cfd667e 100644
--- a/interfaces/kits/napi/webviewcontroller/webview_controller.h
+++ b/interfaces/kits/napi/webviewcontroller/webview_controller.h
@@ -346,7 +346,7 @@ public:
const std::vector<uint8_t>& resource,
const std::map<std::string, std::string>& response_headers,
const uint32_t type);
- ErrCode SetUrlTrustList(const std::string& urlTrustList);
+ ErrCode SetUrlTrustList(const std::string& urlTrustList, std::string& detailErrMsg);
void EnableAdsBlock(bool enable);
diff --git a/ohos_interface/include/ohos_nweb/nweb.h b/ohos_interface/include/ohos_nweb/nweb.h
index 413517bc..47da4ff6 100644
--- a/ohos_interface/include/ohos_nweb/nweb.h
+++ b/ohos_interface/include/ohos_nweb/nweb.h
@@ -1311,8 +1311,10 @@ public:
/**
* @brief Set url trust list.
*
+ * @param urlTrustList The url Trust list.
+ * @param detailErrMsg The url trust list detail message.
*/
- virtual int SetUrlTrustList(const std::string& urlTrustList) {
+ virtual int SetUrlTrustList(const std::string& urlTrustList, std::string& detailErrMsg) {
return 0;
}
diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.cpp
index 1d7a1a5f..f7998093 100644
--- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.cpp
+++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.cpp
@@ -1016,9 +1016,13 @@ void ArkWebNWebImpl::NotifyForNextTouchEvent()
nweb_nweb_->NotifyForNextTouchEvent();
}
-int ArkWebNWebImpl::SetUrlTrustList(const ArkWebString& urlTrustList)
+int ArkWebNWebImpl::SetUrlTrustList(const ArkWebString& urlTrustList, ArkWebString& detailErrMsg)
{
- return nweb_nweb_->SetUrlTrustList(ArkWebStringStructToClass(urlTrustList));
+ std::string detailMsg;
+ int res = nweb_nweb_->SetUrlTrustList(ArkWebStringStructToClass(urlTrustList),
+ detailMsg);
+ detailErrMsg = ArkWebStringClassToStruct(detailMsg);
+ return res;
}
void ArkWebNWebImpl::PutSpanstringConvertHtmlCallback(
diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.h b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.h
index 899c9700..cd6e5fd1 100644
--- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.h
+++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webcore/ark_web_nweb_impl.h
@@ -1141,9 +1141,12 @@ public:
/**
* @brief Set url trust list.
+ *
+ * @param urlTrustList The url trust list.
+ * @param detailErrMsg The detail error message.
*/
/*--ark web()--*/
- int SetUrlTrustList(const ArkWebString& urlTrustList) override;
+ int SetUrlTrustList(const ArkWebString& urlTrustList, ArkWebString& detailErrMsg) override;
/**
* @brief Put the callback for convert spanstring to html.
diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.cpp b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.cpp
index 7126861c..e2d941f2 100644
--- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.cpp
+++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.cpp
@@ -1181,11 +1181,14 @@ void ArkWebNWebWrapper::NotifyForNextTouchEvent()
ark_web_nweb_->NotifyForNextTouchEvent();
}
-int ArkWebNWebWrapper::SetUrlTrustList(const std::string& urlTrustList)
+int ArkWebNWebWrapper::SetUrlTrustList(const std::string& urlTrustList, std::string& detailErrMsg)
{
ArkWebString stUrlTrustList = ArkWebStringClassToStruct(urlTrustList);
- int res = ark_web_nweb_->SetUrlTrustList(stUrlTrustList);
+ ArkWebString stDetailErrMsg = ark_web_string_default;
+ int res = ark_web_nweb_->SetUrlTrustList(stUrlTrustList, stDetailErrMsg);
+ detailErrMsg = ArkWebStringStructToClass(stDetailErrMsg);
ArkWebStringStructRelease(stUrlTrustList);
+ ArkWebStringStructRelease(stDetailErrMsg);
return res;
}
diff --git a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.h b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.h
index b4548545..df488db1 100644
--- a/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.h
+++ b/ohos_interface/ohos_glue/ohos_nweb/bridge/webview/ark_web_nweb_wrapper.h
@@ -1155,7 +1155,7 @@ public:
* @brief Set url trust list.
*/
/*--ark web()--*/
- int SetUrlTrustList(const std::string& urlTrustList) override;
+ int SetUrlTrustList(const std::string& urlTrustList, std::string& detailErrMsg) override;
/**
* @brief Put the callback for convert spanstring to html.
diff --git a/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_nweb.h b/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_nweb.h
index de2931e1..3de308dd 100644
--- a/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_nweb.h
+++ b/ohos_interface/ohos_glue/ohos_nweb/include/ark_web_nweb.h
@@ -1306,7 +1306,7 @@ public:
*
*/
/*--ark web()--*/
- virtual int SetUrlTrustList(const ArkWebString& urlTrustList) = 0;
+ virtual int SetUrlTrustList(const ArkWebString& urlTrustList, ArkWebString& detailErrMsg) = 0;
/**
* @brief Put the callback, convert sapnstring to html.
diff --git a/test/unittest/common/nweb_create_window.h b/test/unittest/common/nweb_create_window.h
index 10043c1d..1f07c8ba 100644
--- a/test/unittest/common/nweb_create_window.h
+++ b/test/unittest/common/nweb_create_window.h
@@ -288,7 +288,7 @@ public:
}
void SendTouchpadFlingEvent(double x, double y, double vx, double vy) override
{}
- int SetUrlTrustList(const std::string& urlTrustList) override
+ int SetUrlTrustList(const std::string& urlTrustList, std::string& detailErrMsg) override
{
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/libing23/security_security_component.git
git@gitee.com:libing23/security_security_component.git
libing23
security_security_component
security_security_component
master

搜索帮助