1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ohos_nweb/bridge/ark_web_handler_wrapper.h"
17
18 #include "ohos_nweb/bridge/ark_web_access_request_impl.h"
19 #include "ohos_nweb/bridge/ark_web_applink_callback_impl.h"
20 #include "ohos_nweb/bridge/ark_web_console_log_impl.h"
21 #include "ohos_nweb/bridge/ark_web_context_menu_callback_impl.h"
22 #include "ohos_nweb/bridge/ark_web_context_menu_params_impl.h"
23 #include "ohos_nweb/bridge/ark_web_controller_handler_impl.h"
24 #include "ohos_nweb/bridge/ark_web_core_struct_utils.h"
25 #include "ohos_nweb/bridge/ark_web_cursor_info_impl.h"
26 #include "ohos_nweb/bridge/ark_web_custom_keyboard_handler_impl.h"
27 #include "ohos_nweb/bridge/ark_web_data_resubmission_callback_impl.h"
28 #include "ohos_nweb/bridge/ark_web_date_time_chooser_callback_impl.h"
29 #include "ohos_nweb/bridge/ark_web_date_time_chooser_impl.h"
30 #include "ohos_nweb/bridge/ark_web_drag_data_impl.h"
31 #include "ohos_nweb/bridge/ark_web_file_selector_params_impl.h"
32 #include "ohos_nweb/bridge/ark_web_first_meaningful_paint_details_impl.h"
33 #include "ohos_nweb/bridge/ark_web_full_screen_exit_handler_impl.h"
34 #include "ohos_nweb/bridge/ark_web_geo_location_callback_impl.h"
35 #include "ohos_nweb/bridge/ark_web_image_options_impl.h"
36 #include "ohos_nweb/bridge/ark_web_js_dialog_result_impl.h"
37 #include "ohos_nweb/bridge/ark_web_js_http_auth_result_impl.h"
38 #include "ohos_nweb/bridge/ark_web_js_ssl_error_result_impl.h"
39 #include "ohos_nweb/bridge/ark_web_js_ssl_select_cert_result_impl.h"
40 #include "ohos_nweb/bridge/ark_web_key_event_impl.h"
41 #include "ohos_nweb/bridge/ark_web_largest_contentful_paint_details_impl.h"
42 #include "ohos_nweb/bridge/ark_web_load_committed_details_impl.h"
43 #include "ohos_nweb/bridge/ark_web_native_embed_data_info_impl.h"
44 #include "ohos_nweb/bridge/ark_web_native_embed_touch_event_impl.h"
45 #include "ohos_nweb/bridge/ark_web_nweb_impl.h"
46 #include "ohos_nweb/bridge/ark_web_quick_menu_callback_impl.h"
47 #include "ohos_nweb/bridge/ark_web_quick_menu_params_impl.h"
48 #include "ohos_nweb/bridge/ark_web_screen_capture_access_request_impl.h"
49 #include "ohos_nweb/bridge/ark_web_select_popup_menu_callback_impl.h"
50 #include "ohos_nweb/bridge/ark_web_select_popup_menu_param_impl.h"
51 #include "ohos_nweb/bridge/ark_web_string_vector_value_callback_impl.h"
52 #include "ohos_nweb/bridge/ark_web_touch_handle_hot_zone_impl.h"
53 #include "ohos_nweb/bridge/ark_web_touch_handle_state_impl.h"
54 #include "ohos_nweb/bridge/ark_web_url_resource_error_impl.h"
55 #include "ohos_nweb/bridge/ark_web_url_resource_request_impl.h"
56 #include "ohos_nweb/bridge/ark_web_url_resource_response_impl.h"
57 #include "ohos_nweb/cpptoc/ark_web_date_time_suggestion_vector_cpptoc.h"
58
59 #include "base/bridge/ark_web_bridge_macros.h"
60
61 namespace OHOS::ArkWeb {
62
ArkWebHandlerWrapper(ArkWebRefPtr<ArkWebHandler> ark_web_handler)63 ArkWebHandlerWrapper::ArkWebHandlerWrapper(ArkWebRefPtr<ArkWebHandler> ark_web_handler)
64 : ark_web_handler_(ark_web_handler)
65 {}
66
SetNWeb(std::shared_ptr<OHOS::NWeb::NWeb> nweb)67 void ArkWebHandlerWrapper::SetNWeb(std::shared_ptr<OHOS::NWeb::NWeb> nweb)
68 {
69 if (CHECK_SHARED_PTR_IS_NULL(nweb)) {
70 ark_web_handler_->SetNWeb(nullptr);
71 return;
72 }
73
74 ark_web_handler_->SetNWeb(new ArkWebNWebImpl(nweb));
75 }
76
OnFocus()77 bool ArkWebHandlerWrapper::OnFocus()
78 {
79 return ark_web_handler_->OnFocus();
80 }
81
OnMessage(const std::string & param)82 void ArkWebHandlerWrapper::OnMessage(const std::string& param)
83 {
84 ArkWebString stParam = ArkWebStringClassToStruct(param);
85
86 ark_web_handler_->OnMessage(stParam);
87
88 ArkWebStringStructRelease(stParam);
89 }
90
OnResource(const std::string & url)91 void ArkWebHandlerWrapper::OnResource(const std::string& url)
92 {
93 ArkWebString stUrl = ArkWebStringClassToStruct(url);
94
95 ark_web_handler_->OnResource(stUrl);
96
97 ArkWebStringStructRelease(stUrl);
98 }
99
OnPageIcon(const void * data,size_t width,size_t height,ArkWebImageColorType color_type,ArkWebImageAlphaType alpha_type)100 void ArkWebHandlerWrapper::OnPageIcon(
101 const void* data, size_t width, size_t height, ArkWebImageColorType color_type, ArkWebImageAlphaType alpha_type)
102 {
103 ark_web_handler_->OnPageIcon(data, width, height, static_cast<int>(color_type), static_cast<int>(alpha_type));
104 }
105
OnPageTitle(const std::string & title)106 void ArkWebHandlerWrapper::OnPageTitle(const std::string& title)
107 {
108 ArkWebString stTitle = ArkWebStringClassToStruct(title);
109
110 ark_web_handler_->OnPageTitle(stTitle);
111
112 ArkWebStringStructRelease(stTitle);
113 }
114
OnProxyDied()115 void ArkWebHandlerWrapper::OnProxyDied()
116 {
117 ark_web_handler_->OnProxyDied();
118 }
119
OnHttpError(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request,std::shared_ptr<OHOS::NWeb::NWebUrlResourceResponse> response)120 void ArkWebHandlerWrapper::OnHttpError(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request,
121 std::shared_ptr<OHOS::NWeb::NWebUrlResourceResponse> response)
122 {
123 ArkWebRefPtr<ArkWebUrlResourceRequest> ark_web_request = nullptr;
124 if (!CHECK_SHARED_PTR_IS_NULL(request)) {
125 ark_web_request = new ArkWebUrlResourceRequestImpl(request);
126 }
127
128 ArkWebRefPtr<ArkWebUrlResourceResponse> ark_web_response = nullptr;
129 if (!CHECK_SHARED_PTR_IS_NULL(response)) {
130 ark_web_response = new ArkWebUrlResourceResponseImpl(response);
131 }
132
133 ark_web_handler_->OnHttpError(ark_web_request, ark_web_response);
134 }
135
OnConsoleLog(std::shared_ptr<OHOS::NWeb::NWebConsoleLog> console_log)136 bool ArkWebHandlerWrapper::OnConsoleLog(std::shared_ptr<OHOS::NWeb::NWebConsoleLog> console_log)
137 {
138 if (CHECK_SHARED_PTR_IS_NULL(console_log)) {
139 return ark_web_handler_->OnConsoleLog(nullptr);
140 }
141
142 return ark_web_handler_->OnConsoleLog(new ArkWebConsoleLogImpl(console_log));
143 }
144
OnRouterPush(const std::string & param)145 void ArkWebHandlerWrapper::OnRouterPush(const std::string& param)
146 {
147 ArkWebString stParam = ArkWebStringClassToStruct(param);
148
149 ark_web_handler_->OnRouterPush(stParam);
150
151 ArkWebStringStructRelease(stParam);
152 }
153
OnPageLoadEnd(int http_status_code,const std::string & url)154 void ArkWebHandlerWrapper::OnPageLoadEnd(int http_status_code, const std::string& url)
155 {
156 ArkWebString stUrl = ArkWebStringClassToStruct(url);
157
158 ark_web_handler_->OnPageLoadEnd(http_status_code, stUrl);
159
160 ArkWebStringStructRelease(stUrl);
161 }
162
OnPageLoadBegin(const std::string & url)163 void ArkWebHandlerWrapper::OnPageLoadBegin(const std::string& url)
164 {
165 ArkWebString stUrl = ArkWebStringClassToStruct(url);
166
167 ark_web_handler_->OnPageLoadBegin(stUrl);
168
169 ArkWebStringStructRelease(stUrl);
170 }
171
OnPageLoadError(int error_code,const std::string & description,const std::string & url)172 void ArkWebHandlerWrapper::OnPageLoadError(int error_code, const std::string& description, const std::string& url)
173 {
174 ArkWebString stUrl = ArkWebStringClassToStruct(url);
175 ArkWebString stDescription = ArkWebStringClassToStruct(description);
176
177 ark_web_handler_->OnPageLoadError(error_code, stDescription, stUrl);
178
179 ArkWebStringStructRelease(stUrl);
180 ArkWebStringStructRelease(stDescription);
181 }
182
OnDesktopIconUrl(const std::string & icon_url,bool precomposed)183 void ArkWebHandlerWrapper::OnDesktopIconUrl(const std::string& icon_url, bool precomposed)
184 {
185 ArkWebString stIconUrl = ArkWebStringClassToStruct(icon_url);
186
187 ark_web_handler_->OnDesktopIconUrl(stIconUrl, precomposed);
188
189 ArkWebStringStructRelease(stIconUrl);
190 }
191
OnLoadingProgress(int new_progress)192 void ArkWebHandlerWrapper::OnLoadingProgress(int new_progress)
193 {
194 ark_web_handler_->OnLoadingProgress(new_progress);
195 }
196
OnGeolocationShow(const std::string & origin,std::shared_ptr<OHOS::NWeb::NWebGeolocationCallbackInterface> callback)197 void ArkWebHandlerWrapper::OnGeolocationShow(
198 const std::string& origin, std::shared_ptr<OHOS::NWeb::NWebGeolocationCallbackInterface> callback)
199 {
200 ArkWebString stOrigin = ArkWebStringClassToStruct(origin);
201
202 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
203 ark_web_handler_->OnGeolocationShow(stOrigin, nullptr);
204 } else {
205 ark_web_handler_->OnGeolocationShow(stOrigin, new ArkWebGeoLocationCallbackImpl(callback));
206 }
207
208 ArkWebStringStructRelease(stOrigin);
209 }
210
OnGeolocationHide()211 void ArkWebHandlerWrapper::OnGeolocationHide()
212 {
213 ark_web_handler_->OnGeolocationHide();
214 }
215
OnFileSelectorShow(std::shared_ptr<OHOS::NWeb::NWebStringVectorValueCallback> callback,std::shared_ptr<OHOS::NWeb::NWebFileSelectorParams> params)216 bool ArkWebHandlerWrapper::OnFileSelectorShow(std::shared_ptr<OHOS::NWeb::NWebStringVectorValueCallback> callback,
217 std::shared_ptr<OHOS::NWeb::NWebFileSelectorParams> params)
218 {
219 ArkWebRefPtr<ArkWebStringVectorValueCallback> ark_web_callback = nullptr;
220 if (!CHECK_SHARED_PTR_IS_NULL(callback)) {
221 ark_web_callback = new ArkWebStringVectorValueCallbackImpl(callback);
222 }
223
224 ArkWebRefPtr<ArkWebFileSelectorParams> ark_web_params = nullptr;
225 if (!CHECK_SHARED_PTR_IS_NULL(params)) {
226 ark_web_params = new ArkWebFileSelectorParamsImpl(params);
227 }
228
229 return ark_web_handler_->OnFileSelectorShow(ark_web_callback, ark_web_params);
230 }
231
OnResourceLoadError(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request,std::shared_ptr<OHOS::NWeb::NWebUrlResourceError> error)232 void ArkWebHandlerWrapper::OnResourceLoadError(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request,
233 std::shared_ptr<OHOS::NWeb::NWebUrlResourceError> error)
234 {
235 ArkWebRefPtr<ArkWebUrlResourceRequest> ark_web_request = nullptr;
236 if (!CHECK_SHARED_PTR_IS_NULL(request)) {
237 ark_web_request = new ArkWebUrlResourceRequestImpl(request);
238 }
239
240 ArkWebRefPtr<ArkWebUrlResourceError> ark_web_error = nullptr;
241 if (!CHECK_SHARED_PTR_IS_NULL(error)) {
242 ark_web_error = new ArkWebUrlResourceErrorImpl(error);
243 }
244
245 ark_web_handler_->OnResourceLoadError(ark_web_request, ark_web_error);
246 }
247
OnPermissionRequest(std::shared_ptr<OHOS::NWeb::NWebAccessRequest> request)248 void ArkWebHandlerWrapper::OnPermissionRequest(std::shared_ptr<OHOS::NWeb::NWebAccessRequest> request)
249 {
250 if (CHECK_SHARED_PTR_IS_NULL(request)) {
251 ark_web_handler_->OnPermissionRequest(nullptr);
252 return;
253 }
254
255 ark_web_handler_->OnPermissionRequest(new ArkWebAccessRequestImpl(request));
256 }
257
OnQuickMenuDismissed()258 void ArkWebHandlerWrapper::OnQuickMenuDismissed()
259 {
260 ark_web_handler_->OnQuickMenuDismissed();
261 }
262
OnContextMenuDismissed()263 void ArkWebHandlerWrapper::OnContextMenuDismissed()
264 {
265 ark_web_handler_->OnContextMenuDismissed();
266 }
267
OnTouchSelectionChanged(std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> insert_handle,std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> start_selection_handle,std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> end_selection_handle)268 void ArkWebHandlerWrapper::OnTouchSelectionChanged(std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> insert_handle,
269 std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> start_selection_handle,
270 std::shared_ptr<OHOS::NWeb::NWebTouchHandleState> end_selection_handle)
271 {
272 ArkWebRefPtr<ArkWebTouchHandleState> ark_web_insert_handle = nullptr;
273 if (!CHECK_SHARED_PTR_IS_NULL(insert_handle)) {
274 ark_web_insert_handle = new ArkWebTouchHandleStateImpl(insert_handle);
275 }
276
277 ArkWebRefPtr<ArkWebTouchHandleState> ark_web_start_selection_handle = nullptr;
278 if (!CHECK_SHARED_PTR_IS_NULL(start_selection_handle)) {
279 ark_web_start_selection_handle = new ArkWebTouchHandleStateImpl(start_selection_handle);
280 }
281
282 ArkWebRefPtr<ArkWebTouchHandleState> ark_web_end_selection_handle = nullptr;
283 if (!CHECK_SHARED_PTR_IS_NULL(end_selection_handle)) {
284 ark_web_end_selection_handle = new ArkWebTouchHandleStateImpl(end_selection_handle);
285 }
286
287 ark_web_handler_->OnTouchSelectionChanged(
288 ark_web_insert_handle, ark_web_start_selection_handle, ark_web_end_selection_handle);
289 }
290
OnHandleInterceptRequest(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request,std::shared_ptr<OHOS::NWeb::NWebUrlResourceResponse> response)291 bool ArkWebHandlerWrapper::OnHandleInterceptRequest(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request,
292 std::shared_ptr<OHOS::NWeb::NWebUrlResourceResponse> response)
293 {
294 ArkWebRefPtr<ArkWebUrlResourceRequest> ark_web_request = nullptr;
295 if (!CHECK_SHARED_PTR_IS_NULL(request)) {
296 ark_web_request = new ArkWebUrlResourceRequestImpl(request);
297 }
298
299 ArkWebRefPtr<ArkWebUrlResourceResponse> ark_web_response = nullptr;
300 if (!CHECK_SHARED_PTR_IS_NULL(response)) {
301 ark_web_response = new ArkWebUrlResourceResponseImpl(response);
302 }
303
304 return ark_web_handler_->OnHandleInterceptRequest(ark_web_request, ark_web_response);
305 }
306
OnRefreshAccessedHistory(const std::string & url,bool is_reload)307 void ArkWebHandlerWrapper::OnRefreshAccessedHistory(const std::string& url, bool is_reload)
308 {
309 ArkWebString stUrl = ArkWebStringClassToStruct(url);
310
311 ark_web_handler_->OnRefreshAccessedHistory(stUrl, is_reload);
312
313 ArkWebStringStructRelease(stUrl);
314 }
315
OnPermissionRequestCanceled(std::shared_ptr<OHOS::NWeb::NWebAccessRequest> request)316 void ArkWebHandlerWrapper::OnPermissionRequestCanceled(std::shared_ptr<OHOS::NWeb::NWebAccessRequest> request)
317 {
318 if (CHECK_SHARED_PTR_IS_NULL(request)) {
319 ark_web_handler_->OnPermissionRequestCanceled(nullptr);
320 return;
321 }
322
323 ark_web_handler_->OnPermissionRequestCanceled(new ArkWebAccessRequestImpl(request));
324 }
325
OnHandleInterceptUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request)326 bool ArkWebHandlerWrapper::OnHandleInterceptUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request)
327 {
328 if (CHECK_SHARED_PTR_IS_NULL(request)) {
329 return ark_web_handler_->OnHandleInterceptUrlLoading(nullptr);
330 }
331
332 return ark_web_handler_->OnHandleInterceptUrlLoading(new ArkWebUrlResourceRequestImpl(request));
333 }
334
RunQuickMenu(std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> params,std::shared_ptr<OHOS::NWeb::NWebQuickMenuCallback> callback)335 bool ArkWebHandlerWrapper::RunQuickMenu(std::shared_ptr<OHOS::NWeb::NWebQuickMenuParams> params,
336 std::shared_ptr<OHOS::NWeb::NWebQuickMenuCallback> callback)
337 {
338 ArkWebRefPtr<ArkWebQuickMenuParams> ark_web_params = nullptr;
339 if (!CHECK_SHARED_PTR_IS_NULL(params)) {
340 ark_web_params = new ArkWebQuickMenuParamsImpl(params);
341 }
342
343 ArkWebRefPtr<ArkWebQuickMenuCallback> ark_web_callback = nullptr;
344 if (!CHECK_SHARED_PTR_IS_NULL(callback)) {
345 ark_web_callback = new ArkWebQuickMenuCallbackImpl(callback);
346 }
347
348 return ark_web_handler_->RunQuickMenu(ark_web_params, ark_web_callback);
349 }
350
RunContextMenu(std::shared_ptr<OHOS::NWeb::NWebContextMenuParams> params,std::shared_ptr<OHOS::NWeb::NWebContextMenuCallback> callback)351 bool ArkWebHandlerWrapper::RunContextMenu(std::shared_ptr<OHOS::NWeb::NWebContextMenuParams> params,
352 std::shared_ptr<OHOS::NWeb::NWebContextMenuCallback> callback)
353 {
354 ArkWebRefPtr<ArkWebContextMenuParams> ark_web_params = nullptr;
355 if (!CHECK_SHARED_PTR_IS_NULL(params)) {
356 ark_web_params = new ArkWebContextMenuParamsImpl(params);
357 }
358
359 ArkWebRefPtr<ArkWebContextMenuCallback> ark_web_callback = nullptr;
360 if (!CHECK_SHARED_PTR_IS_NULL(callback)) {
361 ark_web_callback = new ArkWebContextMenuCallbackImpl(callback);
362 }
363
364 return ark_web_handler_->RunContextMenu(ark_web_params, ark_web_callback);
365 }
366
UpdateDragCursor(ArkWebDragOperation op)367 void ArkWebHandlerWrapper::UpdateDragCursor(ArkWebDragOperation op)
368 {
369 ark_web_handler_->UpdateDragCursor(static_cast<unsigned char>(op));
370 }
371
FilterScrollEvent(const float x,const float y,const float x_velocity,const float y_velocity)372 bool ArkWebHandlerWrapper::FilterScrollEvent(
373 const float x, const float y, const float x_velocity, const float y_velocity)
374 {
375 return ark_web_handler_->FilterScrollEvent(x, y, x_velocity, y_velocity);
376 }
377
VisitedUrlHistory()378 std::vector<std::string> ArkWebHandlerWrapper::VisitedUrlHistory()
379 {
380 ArkWebStringVector stUrlHistory = ark_web_handler_->VisitedUrlHistory();
381
382 std::vector<std::string> objUrlHistory = ArkWebStringVectorStructToClass(stUrlHistory);
383 ArkWebStringVectorStructRelease(stUrlHistory);
384 return objUrlHistory;
385 }
386
OnWindowNewByJS(const std::string & target_url,bool is_alert,bool is_user_trigger,std::shared_ptr<OHOS::NWeb::NWebControllerHandler> handler)387 void ArkWebHandlerWrapper::OnWindowNewByJS(const std::string& target_url, bool is_alert, bool is_user_trigger,
388 std::shared_ptr<OHOS::NWeb::NWebControllerHandler> handler)
389 {
390 ArkWebString stTargetUrl = ArkWebStringClassToStruct(target_url);
391
392 if (CHECK_SHARED_PTR_IS_NULL(handler)) {
393 ark_web_handler_->OnWindowNewByJS(stTargetUrl, is_alert, is_user_trigger, nullptr);
394 } else {
395 ark_web_handler_->OnWindowNewByJS(
396 stTargetUrl, is_alert, is_user_trigger, new ArkWebControllerHandlerImpl(handler));
397 }
398
399 ArkWebStringStructRelease(stTargetUrl);
400 }
401
OnWindowExitByJS()402 void ArkWebHandlerWrapper::OnWindowExitByJS()
403 {
404 ark_web_handler_->OnWindowExitByJS();
405 }
406
OnAlertDialogByJS(const std::string & url,const std::string & message,std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)407 bool ArkWebHandlerWrapper::OnAlertDialogByJS(
408 const std::string& url, const std::string& message, std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)
409 {
410 ArkWebString stUrl = ArkWebStringClassToStruct(url);
411 ArkWebString stMessage = ArkWebStringClassToStruct(message);
412
413 bool flag = false;
414 if (CHECK_SHARED_PTR_IS_NULL(result)) {
415 flag = ark_web_handler_->OnAlertDialogByJS(stUrl, stMessage, nullptr);
416 } else {
417 flag = ark_web_handler_->OnAlertDialogByJS(stUrl, stMessage, new ArkWebJsDialogResultImpl(result));
418 }
419
420 ArkWebStringStructRelease(stUrl);
421 ArkWebStringStructRelease(stMessage);
422 return flag;
423 }
424
OnBeforeUnloadByJS(const std::string & url,const std::string & message,std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)425 bool ArkWebHandlerWrapper::OnBeforeUnloadByJS(
426 const std::string& url, const std::string& message, std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)
427 {
428 ArkWebString stUrl = ArkWebStringClassToStruct(url);
429 ArkWebString stMessage = ArkWebStringClassToStruct(message);
430
431 bool flag = false;
432 if (CHECK_SHARED_PTR_IS_NULL(result)) {
433 flag = ark_web_handler_->OnBeforeUnloadByJS(stUrl, stMessage, nullptr);
434 } else {
435 flag = ark_web_handler_->OnBeforeUnloadByJS(stUrl, stMessage, new ArkWebJsDialogResultImpl(result));
436 }
437
438 ArkWebStringStructRelease(stUrl);
439 ArkWebStringStructRelease(stMessage);
440 return flag;
441 }
442
OnPromptDialogByJS(const std::string & url,const std::string & message,const std::string & default_value,std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)443 bool ArkWebHandlerWrapper::OnPromptDialogByJS(const std::string& url, const std::string& message,
444 const std::string& default_value, std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)
445 {
446 ArkWebString stUrl = ArkWebStringClassToStruct(url);
447 ArkWebString stMessage = ArkWebStringClassToStruct(message);
448 ArkWebString stDefaultValue = ArkWebStringClassToStruct(default_value);
449
450 bool flag = false;
451 if (CHECK_SHARED_PTR_IS_NULL(result)) {
452 flag = ark_web_handler_->OnPromptDialogByJS(stUrl, stMessage, stDefaultValue, nullptr);
453 } else {
454 flag = ark_web_handler_->OnPromptDialogByJS(
455 stUrl, stMessage, stDefaultValue, new ArkWebJsDialogResultImpl(result));
456 }
457
458 ArkWebStringStructRelease(stUrl);
459 ArkWebStringStructRelease(stMessage);
460 ArkWebStringStructRelease(stDefaultValue);
461 return flag;
462 }
463
OnConfirmDialogByJS(const std::string & url,const std::string & message,std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)464 bool ArkWebHandlerWrapper::OnConfirmDialogByJS(
465 const std::string& url, const std::string& message, std::shared_ptr<OHOS::NWeb::NWebJSDialogResult> result)
466 {
467 ArkWebString stUrl = ArkWebStringClassToStruct(url);
468 ArkWebString stMessage = ArkWebStringClassToStruct(message);
469
470 bool flag = false;
471 if (CHECK_SHARED_PTR_IS_NULL(result)) {
472 flag = ark_web_handler_->OnConfirmDialogByJS(stUrl, stMessage, nullptr);
473 } else {
474 flag = ark_web_handler_->OnConfirmDialogByJS(stUrl, stMessage, new ArkWebJsDialogResultImpl(result));
475 }
476
477 ArkWebStringStructRelease(stUrl);
478 ArkWebStringStructRelease(stMessage);
479 return flag;
480 }
481
OnHttpAuthRequestByJS(std::shared_ptr<OHOS::NWeb::NWebJSHttpAuthResult> result,const std::string & host,const std::string & realm)482 bool ArkWebHandlerWrapper::OnHttpAuthRequestByJS(
483 std::shared_ptr<OHOS::NWeb::NWebJSHttpAuthResult> result, const std::string& host, const std::string& realm)
484 {
485 ArkWebString stHost = ArkWebStringClassToStruct(host);
486 ArkWebString stRealm = ArkWebStringClassToStruct(realm);
487
488 bool flag = false;
489 if (CHECK_SHARED_PTR_IS_NULL(result)) {
490 flag = ark_web_handler_->OnHttpAuthRequestByJS(nullptr, stHost, stRealm);
491 } else {
492 flag = ark_web_handler_->OnHttpAuthRequestByJS(new ArkWebJsHttpAuthResultImpl(result), stHost, stRealm);
493 }
494
495 ArkWebStringStructRelease(stHost);
496 ArkWebStringStructRelease(stRealm);
497 return flag;
498 }
499
OnSslErrorRequestByJS(std::shared_ptr<OHOS::NWeb::NWebJSSslErrorResult> result,ArkWebSslError error)500 bool ArkWebHandlerWrapper::OnSslErrorRequestByJS(
501 std::shared_ptr<OHOS::NWeb::NWebJSSslErrorResult> result, ArkWebSslError error)
502 {
503 if (CHECK_SHARED_PTR_IS_NULL(result)) {
504 return ark_web_handler_->OnSslErrorRequestByJS(nullptr, static_cast<int>(error));
505 }
506
507 return ark_web_handler_->OnSslErrorRequestByJS(new ArkWebJsSslErrorResultImpl(result), static_cast<int>(error));
508 }
509
OnSslSelectCertRequestByJS(std::shared_ptr<OHOS::NWeb::NWebJSSslSelectCertResult> result,const std::string & host,int port,const std::vector<std::string> & key_types,const std::vector<std::string> & issuers)510 bool ArkWebHandlerWrapper::OnSslSelectCertRequestByJS(std::shared_ptr<OHOS::NWeb::NWebJSSslSelectCertResult> result,
511 const std::string& host, int port, const std::vector<std::string>& key_types,
512 const std::vector<std::string>& issuers)
513 {
514 ArkWebString stHost = ArkWebStringClassToStruct(host);
515 ArkWebStringVector stIssuers = ArkWebStringVectorClassToStruct(issuers);
516 ArkWebStringVector stKeyTypes = ArkWebStringVectorClassToStruct(key_types);
517
518 bool flag = false;
519 if (CHECK_SHARED_PTR_IS_NULL(result)) {
520 flag = ark_web_handler_->OnSslSelectCertRequestByJS(nullptr, stHost, port, stKeyTypes, stIssuers);
521 } else {
522 flag = ark_web_handler_->OnSslSelectCertRequestByJS(
523 new ArkWebJsSslSelectCertResultImpl(result), stHost, port, stKeyTypes, stIssuers);
524 }
525
526 ArkWebStringStructRelease(stHost);
527 ArkWebStringVectorStructRelease(stIssuers);
528 ArkWebStringVectorStructRelease(stKeyTypes);
529 return flag;
530 }
531
OnScroll(double x_offset,double y_offset)532 void ArkWebHandlerWrapper::OnScroll(double x_offset, double y_offset)
533 {
534 ark_web_handler_->OnScroll(x_offset, y_offset);
535 }
536
OnOverScroll(float x_offset,float y_offset)537 void ArkWebHandlerWrapper::OnOverScroll(float x_offset, float y_offset)
538 {
539 ark_web_handler_->OnOverScroll(x_offset, y_offset);
540 }
541
OnScrollState(bool scroll_state)542 void ArkWebHandlerWrapper::OnScrollState(bool scroll_state)
543 {
544 ark_web_handler_->OnScrollState(scroll_state);
545 }
546
OnPageVisible(const std::string & url)547 void ArkWebHandlerWrapper::OnPageVisible(const std::string& url)
548 {
549 ArkWebString stUrl = ArkWebStringClassToStruct(url);
550
551 ark_web_handler_->OnPageVisible(stUrl);
552
553 ArkWebStringStructRelease(stUrl);
554 }
555
OnPreKeyEvent(std::shared_ptr<OHOS::NWeb::NWebKeyEvent> event)556 bool ArkWebHandlerWrapper::OnPreKeyEvent(std::shared_ptr<OHOS::NWeb::NWebKeyEvent> event)
557 {
558 if (CHECK_SHARED_PTR_IS_NULL(event)) {
559 return ark_web_handler_->OnPreKeyEvent(nullptr);
560 }
561
562 return ark_web_handler_->OnPreKeyEvent(new ArkWebKeyEventImpl(event));
563 }
564
OnScaleChanged(float old_scale_factor,float new_scale_factor)565 void ArkWebHandlerWrapper::OnScaleChanged(float old_scale_factor, float new_scale_factor)
566 {
567 ark_web_handler_->OnScaleChanged(old_scale_factor, new_scale_factor);
568 }
569
OnCursorChange(const ArkWebCursorType & type,std::shared_ptr<OHOS::NWeb::NWebCursorInfo> info)570 bool ArkWebHandlerWrapper::OnCursorChange(
571 const ArkWebCursorType& type, std::shared_ptr<OHOS::NWeb::NWebCursorInfo> info)
572 {
573 if (CHECK_SHARED_PTR_IS_NULL(info)) {
574 return ark_web_handler_->OnCursorChange(static_cast<int32_t>(type), nullptr);
575 }
576
577 return ark_web_handler_->OnCursorChange(static_cast<int32_t>(type), new ArkWebCursorInfoImpl(info));
578 }
579
OnRenderExited(ArkWebRenderExitReason reason)580 void ArkWebHandlerWrapper::OnRenderExited(ArkWebRenderExitReason reason)
581 {
582 ark_web_handler_->OnRenderExited(static_cast<int>(reason));
583 }
584
OnResizeNotWork()585 void ArkWebHandlerWrapper::OnResizeNotWork()
586 {
587 ark_web_handler_->OnResizeNotWork();
588 }
589
OnFullScreenExit()590 void ArkWebHandlerWrapper::OnFullScreenExit()
591 {
592 ark_web_handler_->OnFullScreenExit();
593 }
594
OnFullScreenEnter(std::shared_ptr<OHOS::NWeb::NWebFullScreenExitHandler> handler)595 void ArkWebHandlerWrapper::OnFullScreenEnter(std::shared_ptr<OHOS::NWeb::NWebFullScreenExitHandler> handler)
596 {
597 if (CHECK_SHARED_PTR_IS_NULL(handler)) {
598 ark_web_handler_->OnFullScreenEnter(nullptr);
599 return;
600 }
601
602 ark_web_handler_->OnFullScreenEnter(new ArkWebFullScreenExitHandlerImpl(handler));
603 }
604
OnDragAndDropData(const void * data,size_t len,std::shared_ptr<OHOS::NWeb::NWebImageOptions> opt)605 bool ArkWebHandlerWrapper::OnDragAndDropData(
606 const void* data, size_t len, std::shared_ptr<OHOS::NWeb::NWebImageOptions> opt)
607 {
608 if (CHECK_SHARED_PTR_IS_NULL(opt)) {
609 return ark_web_handler_->OnDragAndDropData(data, len, nullptr);
610 }
611
612 return ark_web_handler_->OnDragAndDropData(data, len, new ArkWebImageOptionsImpl(opt));
613 }
614
OnSelectPopupMenu(std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuParam> params,std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuCallback> callback)615 void ArkWebHandlerWrapper::OnSelectPopupMenu(std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuParam> params,
616 std::shared_ptr<OHOS::NWeb::NWebSelectPopupMenuCallback> callback)
617 {
618 ArkWebRefPtr<ArkWebSelectPopupMenuParam> ark_web_params = nullptr;
619 if (!CHECK_SHARED_PTR_IS_NULL(params)) {
620 ark_web_params = new ArkWebSelectPopupMenuParamImpl(params);
621 }
622
623 ArkWebRefPtr<ArkWebSelectPopupMenuCallback> ark_web_callback = nullptr;
624 if (!CHECK_SHARED_PTR_IS_NULL(callback)) {
625 ark_web_callback = new ArkWebSelectPopupMenuCallbackImpl(callback);
626 }
627
628 ark_web_handler_->OnSelectPopupMenu(ark_web_params, ark_web_callback);
629 }
630
OnDataResubmission(std::shared_ptr<OHOS::NWeb::NWebDataResubmissionCallback> handler)631 void ArkWebHandlerWrapper::OnDataResubmission(std::shared_ptr<OHOS::NWeb::NWebDataResubmissionCallback> handler)
632 {
633 if (CHECK_SHARED_PTR_IS_NULL(handler)) {
634 ark_web_handler_->OnDataResubmission(nullptr);
635 return;
636 }
637
638 ark_web_handler_->OnDataResubmission(new ArkWebDataResubmissionCallbackImpl(handler));
639 }
640
OnRootLayerChanged(int width,int height)641 void ArkWebHandlerWrapper::OnRootLayerChanged(int width, int height)
642 {
643 ark_web_handler_->OnRootLayerChanged(width, height);
644 }
645
OnAudioStateChanged(bool playing)646 void ArkWebHandlerWrapper::OnAudioStateChanged(bool playing)
647 {
648 ark_web_handler_->OnAudioStateChanged(playing);
649 }
650
OnOverScrollFlingEnd()651 void ArkWebHandlerWrapper::OnOverScrollFlingEnd()
652 {
653 ark_web_handler_->OnOverScrollFlingEnd();
654 }
655
OnUnProcessedKeyEvent(std::shared_ptr<OHOS::NWeb::NWebKeyEvent> event)656 bool ArkWebHandlerWrapper::OnUnProcessedKeyEvent(std::shared_ptr<OHOS::NWeb::NWebKeyEvent> event)
657 {
658 if (CHECK_SHARED_PTR_IS_NULL(event)) {
659 return ark_web_handler_->OnUnProcessedKeyEvent(nullptr);
660 }
661
662 return ark_web_handler_->OnUnProcessedKeyEvent(new ArkWebKeyEventImpl(event));
663 }
664
OnDragAndDropDataUdmf(std::shared_ptr<OHOS::NWeb::NWebDragData> drag_data)665 bool ArkWebHandlerWrapper::OnDragAndDropDataUdmf(std::shared_ptr<OHOS::NWeb::NWebDragData> drag_data)
666 {
667 if (CHECK_SHARED_PTR_IS_NULL(drag_data)) {
668 return ark_web_handler_->OnDragAndDropDataUdmf(nullptr);
669 }
670
671 return ark_web_handler_->OnDragAndDropDataUdmf(new ArkWebDragDataImpl(drag_data));
672 }
673
OnFirstContentfulPaint(int64_t navigation_start_tick,int64_t first_contentful_paint_ms)674 void ArkWebHandlerWrapper::OnFirstContentfulPaint(int64_t navigation_start_tick, int64_t first_contentful_paint_ms)
675 {
676 ark_web_handler_->OnFirstContentfulPaint(navigation_start_tick, first_contentful_paint_ms);
677 }
678
OnDateTimeChooserPopup(std::shared_ptr<OHOS::NWeb::NWebDateTimeChooser> chooser,const std::vector<std::shared_ptr<OHOS::NWeb::NWebDateTimeSuggestion>> & suggestions,std::shared_ptr<OHOS::NWeb::NWebDateTimeChooserCallback> callback)679 void ArkWebHandlerWrapper::OnDateTimeChooserPopup(std::shared_ptr<OHOS::NWeb::NWebDateTimeChooser> chooser,
680 const std::vector<std::shared_ptr<OHOS::NWeb::NWebDateTimeSuggestion>>& suggestions,
681 std::shared_ptr<OHOS::NWeb::NWebDateTimeChooserCallback> callback)
682 {
683 ArkWebDateTimeSuggestionVector st_date_time_suggestion_vector =
684 ArkWebDateTimeSuggestionVectorClassToStruct(suggestions);
685
686 ArkWebRefPtr<ArkWebDateTimeChooser> ark_web_date_time_chooser = nullptr;
687 if (!CHECK_SHARED_PTR_IS_NULL(chooser)) {
688 ark_web_date_time_chooser = new ArkWebDateTimeChooserImpl(chooser);
689 }
690
691 ArkWebRefPtr<ArkWebDateTimeChooserCallback> ark_web_date_time_chooser_callback = nullptr;
692 if (!CHECK_SHARED_PTR_IS_NULL(callback)) {
693 ark_web_date_time_chooser_callback = new ArkWebDateTimeChooserCallbackImpl(callback);
694 }
695
696 ark_web_handler_->OnDateTimeChooserPopup(
697 ark_web_date_time_chooser, st_date_time_suggestion_vector, ark_web_date_time_chooser_callback);
698
699 ArkWebDateTimeSuggestionVectorStructRelease(st_date_time_suggestion_vector);
700 }
701
OnDateTimeChooserClose()702 void ArkWebHandlerWrapper::OnDateTimeChooserClose()
703 {
704 ark_web_handler_->OnDateTimeChooserClose();
705 }
706
OnScreenCaptureRequest(std::shared_ptr<OHOS::NWeb::NWebScreenCaptureAccessRequest> request)707 void ArkWebHandlerWrapper::OnScreenCaptureRequest(std::shared_ptr<OHOS::NWeb::NWebScreenCaptureAccessRequest> request)
708 {
709 if (CHECK_SHARED_PTR_IS_NULL(request)) {
710 ark_web_handler_->OnScreenCaptureRequest(nullptr);
711 return;
712 }
713
714 ark_web_handler_->OnScreenCaptureRequest(new ArkWebScreenCaptureAccessRequestImpl(request));
715 }
716
OnActivityStateChanged(int state,ArkWebActivityType type)717 void ArkWebHandlerWrapper::OnActivityStateChanged(int state, ArkWebActivityType type)
718 {
719 ark_web_handler_->OnActivityStateChanged(state, static_cast<int>(type));
720 }
721
OnGetTouchHandleHotZone(std::shared_ptr<OHOS::NWeb::NWebTouchHandleHotZone> hot_zone)722 void ArkWebHandlerWrapper::OnGetTouchHandleHotZone(std::shared_ptr<OHOS::NWeb::NWebTouchHandleHotZone> hot_zone)
723 {
724 if (CHECK_SHARED_PTR_IS_NULL(hot_zone)) {
725 ark_web_handler_->OnGetTouchHandleHotZone(nullptr);
726 return;
727 }
728
729 ark_web_handler_->OnGetTouchHandleHotZone(new ArkWebTouchHandleHotZoneImpl(hot_zone));
730 }
731
OnCompleteSwapWithNewSize()732 void ArkWebHandlerWrapper::OnCompleteSwapWithNewSize()
733 {
734 ark_web_handler_->OnCompleteSwapWithNewSize();
735 }
736
OnOverScrollFlingVelocity(float x_velocity,float y_velocity,bool is_fling)737 void ArkWebHandlerWrapper::OnOverScrollFlingVelocity(float x_velocity, float y_velocity, bool is_fling)
738 {
739 ark_web_handler_->OnOverScrollFlingVelocity(x_velocity, y_velocity, is_fling);
740 }
741
OnNavigationEntryCommitted(std::shared_ptr<OHOS::NWeb::NWebLoadCommittedDetails> details)742 void ArkWebHandlerWrapper::OnNavigationEntryCommitted(std::shared_ptr<OHOS::NWeb::NWebLoadCommittedDetails> details)
743 {
744 if (CHECK_SHARED_PTR_IS_NULL(details)) {
745 ark_web_handler_->OnNavigationEntryCommitted(nullptr);
746 return;
747 }
748
749 ark_web_handler_->OnNavigationEntryCommitted(new ArkWebLoadCommittedDetailsImpl(details));
750 }
751
OnNativeEmbedLifecycleChange(std::shared_ptr<OHOS::NWeb::NWebNativeEmbedDataInfo> dataInfo)752 void ArkWebHandlerWrapper::OnNativeEmbedLifecycleChange(std::shared_ptr<OHOS::NWeb::NWebNativeEmbedDataInfo> dataInfo)
753 {
754 if (CHECK_SHARED_PTR_IS_NULL(dataInfo)) {
755 ark_web_handler_->OnNativeEmbedLifecycleChange(nullptr);
756 return;
757 }
758
759 ark_web_handler_->OnNativeEmbedLifecycleChange(new ArkWebNativeEmbedDataInfoImpl(dataInfo));
760 }
761
OnNativeEmbedGestureEvent(std::shared_ptr<OHOS::NWeb::NWebNativeEmbedTouchEvent> touchEvent)762 void ArkWebHandlerWrapper::OnNativeEmbedGestureEvent(std::shared_ptr<OHOS::NWeb::NWebNativeEmbedTouchEvent> touchEvent)
763 {
764 if (CHECK_SHARED_PTR_IS_NULL(touchEvent)) {
765 ark_web_handler_->OnNativeEmbedGestureEvent(nullptr);
766 return;
767 }
768
769 ark_web_handler_->OnNativeEmbedGestureEvent(new ArkWebNativeEmbedTouchEventImpl(touchEvent));
770 }
771
OnSafeBrowsingCheckResult(int threat_type)772 void ArkWebHandlerWrapper::OnSafeBrowsingCheckResult(int threat_type)
773 {
774 ark_web_handler_->OnSafeBrowsingCheckResult(threat_type);
775 }
776
OnFullScreenEnterWithVideoSize(std::shared_ptr<OHOS::NWeb::NWebFullScreenExitHandler> handler,int video_natural_width,int video_natural_height)777 void ArkWebHandlerWrapper::OnFullScreenEnterWithVideoSize(
778 std::shared_ptr<OHOS::NWeb::NWebFullScreenExitHandler> handler, int video_natural_width, int video_natural_height)
779 {
780 if (CHECK_SHARED_PTR_IS_NULL(handler)) {
781 ark_web_handler_->OnFullScreenEnterWithVideoSize(nullptr, video_natural_width, video_natural_height);
782 return;
783 }
784
785 ark_web_handler_->OnFullScreenEnterWithVideoSize(
786 new ArkWebFullScreenExitHandlerImpl(handler), video_natural_width, video_natural_height);
787 }
788
OnHandleOverrideUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request)789 bool ArkWebHandlerWrapper::OnHandleOverrideUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request)
790 {
791 if (CHECK_SHARED_PTR_IS_NULL(request)) {
792 return ark_web_handler_->OnHandleOverrideUrlLoading(nullptr);
793 }
794
795 return ark_web_handler_->OnHandleOverrideUrlLoading(new ArkWebUrlResourceRequestImpl(request));
796 }
797
OnIntelligentTrackingPreventionResult(const std::string & website_host,const std::string & tracker_host)798 void ArkWebHandlerWrapper::OnIntelligentTrackingPreventionResult(
799 const std::string& website_host, const std::string& tracker_host)
800 {
801 ArkWebString stWebsiteHost = ArkWebStringClassToStruct(website_host);
802 ArkWebString stTrackerHost = ArkWebStringClassToStruct(tracker_host);
803
804 ark_web_handler_->OnIntelligentTrackingPreventionResult(stWebsiteHost, stTrackerHost);
805
806 ArkWebStringStructRelease(stWebsiteHost);
807 ArkWebStringStructRelease(stTrackerHost);
808 }
809
OnFirstMeaningfulPaint(std::shared_ptr<OHOS::NWeb::NWebFirstMeaningfulPaintDetails> details)810 void ArkWebHandlerWrapper::OnFirstMeaningfulPaint(std::shared_ptr<OHOS::NWeb::NWebFirstMeaningfulPaintDetails> details)
811 {
812 if (CHECK_SHARED_PTR_IS_NULL(details)) {
813 ark_web_handler_->OnFirstMeaningfulPaint(nullptr);
814 return;
815 }
816
817 ark_web_handler_->OnFirstMeaningfulPaint(new ArkWebFirstMeaningfulPaintDetailsImpl(details));
818 }
819
OnLargestContentfulPaint(std::shared_ptr<OHOS::NWeb::NWebLargestContentfulPaintDetails> details)820 void ArkWebHandlerWrapper::OnLargestContentfulPaint(
821 std::shared_ptr<OHOS::NWeb::NWebLargestContentfulPaintDetails> details)
822 {
823 if (CHECK_SHARED_PTR_IS_NULL(details)) {
824 ark_web_handler_->OnLargestContentfulPaint(nullptr);
825 return;
826 }
827
828 ark_web_handler_->OnLargestContentfulPaint(new ArkWebLargestContentfulPaintDetailsImpl(details));
829 }
830
OnAllSslErrorRequestByJS(std::shared_ptr<OHOS::NWeb::NWebJSAllSslErrorResult> result,ArkWebSslError error,const std::string & url,const std::string & originalUrl,const std::string & referrer,bool isFatalError,bool isMainFrame)831 bool ArkWebHandlerWrapper::OnAllSslErrorRequestByJS(std::shared_ptr<OHOS::NWeb::NWebJSAllSslErrorResult> result,
832 ArkWebSslError error, const std::string& url, const std::string& originalUrl, const std::string& referrer,
833 bool isFatalError, bool isMainFrame)
834 {
835 if (CHECK_SHARED_PTR_IS_NULL(result)) {
836 return ark_web_handler_->OnAllSslErrorRequestByJS(nullptr, static_cast<int>(error),
837 ArkWebStringClassToStruct(url), ArkWebStringClassToStruct(originalUrl), ArkWebStringClassToStruct(referrer),
838 isFatalError, isMainFrame);
839 }
840
841 return ark_web_handler_->OnAllSslErrorRequestByJS(new ArkWebJsAllSslErrorResultImpl(result),
842 static_cast<int>(error), ArkWebStringClassToStruct(url), ArkWebStringClassToStruct(originalUrl),
843 ArkWebStringClassToStruct(referrer), isFatalError, isMainFrame);
844 }
845
OnTooltip(const std::string & tooltip)846 void ArkWebHandlerWrapper::OnTooltip(const std::string& tooltip)
847 {
848 ArkWebString stTooltip = ArkWebStringClassToStruct(tooltip);
849
850 ark_web_handler_->OnTooltip(stTooltip);
851
852 ArkWebStringStructRelease(stTooltip);
853 }
854
ReleaseResizeHold()855 void ArkWebHandlerWrapper::ReleaseResizeHold()
856 {
857 ark_web_handler_->ReleaseResizeHold();
858 }
859
GetWordSelection(const std::string & text,int8_t offset)860 std::vector<int8_t> ArkWebHandlerWrapper::GetWordSelection(const std::string& text, int8_t offset)
861 {
862 ArkWebString ark_text = ArkWebStringClassToStruct(text);
863 ArkWebCharVector ark_result = ark_web_handler_->GetWordSelection(ark_text, offset);
864 std::vector<int8_t> result = ArkWebBasicVectorStructToClass<int8_t, ArkWebCharVector>(ark_result);
865
866 ArkWebBasicVectorStructRelease(ark_result);
867 ArkWebStringStructRelease(ark_text);
868 return result;
869 }
870
UpdateClippedSelectionBounds(int x,int y,int w,int h)871 void ArkWebHandlerWrapper::UpdateClippedSelectionBounds(int x, int y, int w, int h)
872 {
873 ark_web_handler_->UpdateClippedSelectionBounds(x, y, w, h);
874 }
875
OnRenderProcessNotResponding(const std::string & js_stack,int pid,ArkWebRenderProcessNotRespondingReason reason)876 void ArkWebHandlerWrapper::OnRenderProcessNotResponding(
877 const std::string& js_stack, int pid, ArkWebRenderProcessNotRespondingReason reason)
878 {
879 ArkWebString js_stack_str = ArkWebStringClassToStruct(js_stack);
880 ark_web_handler_->OnRenderProcessNotResponding(js_stack_str, pid, static_cast<int>(reason));
881 }
882
OnRenderProcessResponding()883 void ArkWebHandlerWrapper::OnRenderProcessResponding()
884 {
885 ark_web_handler_->OnRenderProcessResponding();
886 }
887
OnOpenAppLink(const std::string & url,std::shared_ptr<OHOS::NWeb::NWebAppLinkCallback> callback)888 bool ArkWebHandlerWrapper::OnOpenAppLink(
889 const std::string& url, std::shared_ptr<OHOS::NWeb::NWebAppLinkCallback> callback)
890 {
891 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
892 return false;
893 }
894
895 return ark_web_handler_->OnOpenAppLink(ArkWebStringClassToStruct(url), new ArkWebAppLinkCallbackImpl(callback));
896 }
897
OnShowAutofillPopup(const float offsetX,const float offsetY,const std::vector<std::string> & menu_items)898 void ArkWebHandlerWrapper::OnShowAutofillPopup(
899 const float offsetX, const float offsetY, const std::vector<std::string>& menu_items)
900 {
901 ArkWebStringVector stMenuItems = ArkWebStringVectorClassToStruct(menu_items);
902 ark_web_handler_->OnShowAutofillPopup(offsetX, offsetY, stMenuItems);
903 }
904
OnHideAutofillPopup()905 void ArkWebHandlerWrapper::OnHideAutofillPopup()
906 {
907 ark_web_handler_->OnHideAutofillPopup();
908 }
909
OnFocus(ArkWebFocusSource source)910 bool ArkWebHandlerWrapper::OnFocus(ArkWebFocusSource source)
911 {
912 return ark_web_handler_->OnFocus(static_cast<int>(source));
913 }
914
OnOverScroll(float xOffset,float yOffset,float xVelocity,float yVelocity)915 bool ArkWebHandlerWrapper::OnOverScroll(float xOffset, float yOffset, float xVelocity, float yVelocity)
916 {
917 return ark_web_handler_->OnOverScroll(xOffset, yOffset, xVelocity, yVelocity);
918 }
919
CreateOverlay(void * data,size_t len,int width,int height,int offset_x,int offset_y,int rect_width,int rect_height,int point_x,int point_y)920 void ArkWebHandlerWrapper::CreateOverlay(void* data, size_t len, int width, int height, int offset_x, int offset_y,
921 int rect_width, int rect_height, int point_x, int point_y)
922 {
923 ark_web_handler_->CreateOverlay(
924 data, len, width, height, offset_x, offset_y, rect_width, rect_height, point_x, point_y);
925 }
926
OnOverlayStateChanged(int offset_x,int offset_y,int rect_width,int rect_height)927 void ArkWebHandlerWrapper::OnOverlayStateChanged(int offset_x, int offset_y, int rect_width, int rect_height)
928 {
929 ark_web_handler_->OnOverlayStateChanged(offset_x, offset_y, rect_width, rect_height);
930 }
931
OnViewportFitChange(ArkWebViewportFit viewportFit)932 void ArkWebHandlerWrapper::OnViewportFitChange(ArkWebViewportFit viewportFit)
933 {
934 ark_web_handler_->OnViewportFitChange(static_cast<int>(viewportFit));
935 }
936
OnAdsBlocked(const std::string & url,const std::vector<std::string> & adsBlocked)937 void ArkWebHandlerWrapper::OnAdsBlocked(const std::string& url, const std::vector<std::string>& adsBlocked)
938 {
939 ArkWebString stUrl = ArkWebStringClassToStruct(url);
940 ArkWebStringVector stAdsBlocked = ArkWebStringVectorClassToStruct(adsBlocked);
941
942 ark_web_handler_->OnAdsBlocked(stUrl, stAdsBlocked);
943
944 ArkWebStringVectorStructRelease(stAdsBlocked);
945 ArkWebStringStructRelease(stUrl);
946 }
947
OnInterceptKeyboardAttach(const std::shared_ptr<OHOS::NWeb::NWebCustomKeyboardHandler> keyboardHandler,const std::map<std::string,std::string> & attributes,bool & useSystemKeyboard,int32_t & enterKeyType)948 void ArkWebHandlerWrapper::OnInterceptKeyboardAttach(
949 const std::shared_ptr<OHOS::NWeb::NWebCustomKeyboardHandler> keyboardHandler,
950 const std::map<std::string, std::string> &attributes, bool &useSystemKeyboard, int32_t &enterKeyType)
951 {
952 if (CHECK_SHARED_PTR_IS_NULL(keyboardHandler)) {
953 return;
954 }
955
956 ark_web_handler_->OnInterceptKeyboardAttach(new ArkWebCustomKeyboardHandlerImpl(keyboardHandler),
957 ArkWebStringMapClassToStruct(attributes), useSystemKeyboard, enterKeyType);
958 }
959
OnCustomKeyboardAttach()960 void ArkWebHandlerWrapper::OnCustomKeyboardAttach()
961 {
962 ark_web_handler_->OnCustomKeyboardAttach();
963 }
964
OnCustomKeyboardClose()965 void ArkWebHandlerWrapper::OnCustomKeyboardClose()
966 {
967 ark_web_handler_->OnCustomKeyboardClose();
968 }
969
KeyboardReDispatch(std::shared_ptr<OHOS::NWeb::NWebKeyEvent> event,bool isUsed)970 void ArkWebHandlerWrapper::KeyboardReDispatch(std::shared_ptr<OHOS::NWeb::NWebKeyEvent> event, bool isUsed)
971 {
972 if (CHECK_SHARED_PTR_IS_NULL(event)) {
973 ark_web_handler_->KeyboardReDispatch(nullptr, isUsed);
974 return;
975 }
976
977 ark_web_handler_->KeyboardReDispatch(new ArkWebKeyEventImpl(event), isUsed);
978 }
979
HideHandleAndQuickMenuIfNecessary(bool hide)980 void ArkWebHandlerWrapper::HideHandleAndQuickMenuIfNecessary(bool hide)
981 {
982 ark_web_handler_->HideHandleAndQuickMenuIfNecessary(hide);
983 }
984
OnCursorUpdate(double x,double y,double width,double height)985 void ArkWebHandlerWrapper::OnCursorUpdate(double x, double y, double width, double height)
986 {
987 ark_web_handler_->OnCursorUpdate(x, y, width, height);
988 }
989
990
ChangeVisibilityOfQuickMenu()991 void ArkWebHandlerWrapper::ChangeVisibilityOfQuickMenu()
992 {
993 ark_web_handler_->ChangeVisibilityOfQuickMenu();
994 }
995
StartVibraFeedback(const std::string & vibratorType)996 void ArkWebHandlerWrapper::StartVibraFeedback(const std::string& vibratorType)
997 {
998 ArkWebString stVibratorType = ArkWebStringClassToStruct(vibratorType);
999
1000 ark_web_handler_->StartVibraFeedback(stVibratorType);
1001
1002 ArkWebStringStructRelease(stVibratorType);
1003 }
1004
OnNativeEmbedVisibilityChange(const std::string & embed_id,bool visibility)1005 void ArkWebHandlerWrapper::OnNativeEmbedVisibilityChange(const std::string& embed_id, bool visibility)
1006 {
1007 ArkWebString stEmbedId = ArkWebStringClassToStruct(embed_id);
1008
1009 ark_web_handler_->OnNativeEmbedVisibilityChange(stEmbedId, visibility);
1010 }
1011
CloseImageOverlaySelection()1012 bool ArkWebHandlerWrapper::CloseImageOverlaySelection()
1013 {
1014 return ark_web_handler_->CloseImageOverlaySelection();
1015 }
1016
GetVisibleRectToWeb(int & visibleX,int & visibleY,int & visibleWidth,int & visibleHeight)1017 void ArkWebHandlerWrapper::GetVisibleRectToWeb(int& visibleX, int& visibleY, int& visibleWidth, int& visibleHeight)
1018 {
1019 ark_web_handler_->GetVisibleRectToWeb(visibleX, visibleY, visibleWidth, visibleHeight);
1020 }
1021
OnScrollStart(const float x,const float y)1022 void ArkWebHandlerWrapper::OnScrollStart(const float x, const float y)
1023 {
1024 ark_web_handler_->OnScrollStart(x, y);
1025 }
1026 } // namespace OHOS::ArkWeb
1027