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_nweb_wrapper.h"
17
18 #include "ohos_nweb/bridge/ark_web_accessibility_event_callback_impl.h"
19 #include "ohos_nweb/bridge/ark_web_accessibility_node_info_wrapper.h"
20 #include "ohos_nweb/bridge/ark_web_array_buffer_value_callback_impl.h"
21 #include "ohos_nweb/bridge/ark_web_bool_value_callback_impl.h"
22 #include "ohos_nweb/bridge/ark_web_cache_options_impl.h"
23 #include "ohos_nweb/bridge/ark_web_create_native_media_player_callback_impl.h"
24 #include "ohos_nweb/bridge/ark_web_download_callback_impl.h"
25 #include "ohos_nweb/bridge/ark_web_drag_data_wrapper.h"
26 #include "ohos_nweb/bridge/ark_web_drag_event_impl.h"
27 #include "ohos_nweb/bridge/ark_web_find_callback_impl.h"
28 #include "ohos_nweb/bridge/ark_web_handler_impl.h"
29 #include "ohos_nweb/bridge/ark_web_history_list_wrapper.h"
30 #include "ohos_nweb/bridge/ark_web_hit_test_result_wrapper.h"
31 #include "ohos_nweb/bridge/ark_web_js_proxy_method_impl.h"
32 #include "ohos_nweb/bridge/ark_web_js_result_callback_impl.h"
33 #include "ohos_nweb/bridge/ark_web_keyboard_event_impl.h"
34 #include "ohos_nweb/bridge/ark_web_message_value_callback_impl.h"
35 #include "ohos_nweb/bridge/ark_web_mouse_event_impl.h"
36 #include "ohos_nweb/bridge/ark_web_pdfconfig_args_impl.h"
37 #include "ohos_nweb/bridge/ark_web_preference_wrapper.h"
38 #include "ohos_nweb/bridge/ark_web_release_surface_callback_impl.h"
39 #include "ohos_nweb/bridge/ark_web_rom_value_impl.h"
40 #include "ohos_nweb/bridge/ark_web_screen_lock_callback_impl.h"
41 #include "ohos_nweb/bridge/ark_web_spanstring_convert_html_callback_impl.h"
42 #include "ohos_nweb/bridge/ark_web_string_value_callback_impl.h"
43 #include "ohos_nweb/bridge/ark_web_system_configuration_impl.h"
44 #include "ohos_nweb/bridge/ark_web_view_struct_utils.h"
45 #include "ohos_nweb/bridge/ark_web_print_document_adapter_adapter_wrapper.h"
46 #include "ohos_nweb/cpptoc/ark_web_js_proxy_callback_vector_cpptoc.h"
47 #include "ohos_nweb/cpptoc/ark_web_rom_value_vector_cpptoc.h"
48 #include "ohos_nweb/cpptoc/ark_web_touch_point_info_vector_cpptoc.h"
49 #include "ohos_nweb/cpptoc/ark_web_value_vector_cpptoc.h"
50
51 #include "base/bridge/ark_web_bridge_macros.h"
52
53 namespace OHOS::ArkWeb {
54
ArkWebNWebWrapper(ArkWebRefPtr<ArkWebNWeb> ark_web_nweb)55 ArkWebNWebWrapper::ArkWebNWebWrapper(ArkWebRefPtr<ArkWebNWeb> ark_web_nweb) : ark_web_nweb_(ark_web_nweb) {}
56
Resize(uint32_t width,uint32_t height,bool is_keyboard)57 void ArkWebNWebWrapper::Resize(uint32_t width, uint32_t height, bool is_keyboard)
58 {
59 ark_web_nweb_->Resize(width, height, is_keyboard);
60 }
61
OnPause()62 void ArkWebNWebWrapper::OnPause()
63 {
64 ark_web_nweb_->OnPause();
65 }
66
OnContinue()67 void ArkWebNWebWrapper::OnContinue()
68 {
69 ark_web_nweb_->OnContinue();
70 }
71
OnDestroy()72 void ArkWebNWebWrapper::OnDestroy()
73 {
74 ark_web_nweb_->OnDestroy();
75 }
76
OnFocus(const ArkWebFocusReason & focus_reason)77 void ArkWebNWebWrapper::OnFocus(const ArkWebFocusReason& focus_reason)
78 {
79 ark_web_nweb_->OnFocus(static_cast<int32_t>(focus_reason));
80 }
81
OnBlur(const ArkWebBlurReason & blur_reason)82 void ArkWebNWebWrapper::OnBlur(const ArkWebBlurReason& blur_reason)
83 {
84 ark_web_nweb_->OnBlur(static_cast<int32_t>(blur_reason));
85 }
86
OnTouchPress(int32_t id,double x,double y,bool from_overlay)87 void ArkWebNWebWrapper::OnTouchPress(int32_t id, double x, double y, bool from_overlay)
88 {
89 ark_web_nweb_->OnTouchPress(id, x, y, from_overlay);
90 }
91
OnTouchRelease(int32_t id,double x,double y,bool from_overlay)92 void ArkWebNWebWrapper::OnTouchRelease(int32_t id, double x, double y, bool from_overlay)
93 {
94 ark_web_nweb_->OnTouchRelease(id, x, y, from_overlay);
95 }
96
OnTouchMove(int32_t id,double x,double y,bool from_overlay)97 void ArkWebNWebWrapper::OnTouchMove(int32_t id, double x, double y, bool from_overlay)
98 {
99 ark_web_nweb_->OnTouchMove(id, x, y, from_overlay);
100 }
101
OnTouchMove(const std::vector<std::shared_ptr<OHOS::NWeb::NWebTouchPointInfo>> & touch_point_infos,bool from_overlay)102 void ArkWebNWebWrapper::OnTouchMove(
103 const std::vector<std::shared_ptr<OHOS::NWeb::NWebTouchPointInfo>>& touch_point_infos, bool from_overlay)
104 {
105 ArkWebTouchPointInfoVector st_touch_point_infos = ArkWebTouchPointInfoVectorClassToStruct(touch_point_infos);
106
107 ark_web_nweb_->OnTouchMove(st_touch_point_infos, from_overlay);
108
109 ArkWebTouchPointInfoVectorStructRelease(st_touch_point_infos);
110 }
111
OnTouchCancel()112 void ArkWebNWebWrapper::OnTouchCancel()
113 {
114 ark_web_nweb_->OnTouchCancel();
115 }
116
OnNavigateBack()117 void ArkWebNWebWrapper::OnNavigateBack()
118 {
119 ark_web_nweb_->OnNavigateBack();
120 }
121
SendKeyEvent(int32_t key_code,int32_t key_action)122 bool ArkWebNWebWrapper::SendKeyEvent(int32_t key_code, int32_t key_action)
123 {
124 return ark_web_nweb_->SendKeyEvent(key_code, key_action);
125 }
126
SendMouseWheelEvent(double x,double y,double delta_x,double delta_y)127 void ArkWebNWebWrapper::SendMouseWheelEvent(double x, double y, double delta_x, double delta_y)
128 {
129 ark_web_nweb_->SendMouseWheelEvent(x, y, delta_x, delta_y);
130 }
131
SendMouseEvent(int x,int y,int button,int action,int count)132 void ArkWebNWebWrapper::SendMouseEvent(int x, int y, int button, int action, int count)
133 {
134 ark_web_nweb_->SendMouseEvent(x, y, button, action, count);
135 }
136
Load(const std::string & url)137 int ArkWebNWebWrapper::Load(const std::string& url)
138 {
139 ArkWebString stUrl = ArkWebStringClassToStruct(url);
140
141 int code = ark_web_nweb_->Load(stUrl);
142
143 ArkWebStringStructRelease(stUrl);
144 return code;
145 }
146
IsNavigatebackwardAllowed()147 bool ArkWebNWebWrapper::IsNavigatebackwardAllowed()
148 {
149 return ark_web_nweb_->IsNavigatebackwardAllowed();
150 }
151
IsNavigateForwardAllowed()152 bool ArkWebNWebWrapper::IsNavigateForwardAllowed()
153 {
154 return ark_web_nweb_->IsNavigateForwardAllowed();
155 }
156
CanNavigateBackOrForward(int num_steps)157 bool ArkWebNWebWrapper::CanNavigateBackOrForward(int num_steps)
158 {
159 return ark_web_nweb_->CanNavigateBackOrForward(num_steps);
160 }
161
NavigateBack()162 void ArkWebNWebWrapper::NavigateBack()
163 {
164 ark_web_nweb_->NavigateBack();
165 }
166
NavigateForward()167 void ArkWebNWebWrapper::NavigateForward()
168 {
169 ark_web_nweb_->NavigateForward();
170 }
171
NavigateBackOrForward(int step)172 void ArkWebNWebWrapper::NavigateBackOrForward(int step)
173 {
174 ark_web_nweb_->NavigateBackOrForward(step);
175 }
176
DeleteNavigateHistory()177 void ArkWebNWebWrapper::DeleteNavigateHistory()
178 {
179 ark_web_nweb_->DeleteNavigateHistory();
180 }
181
Reload()182 void ArkWebNWebWrapper::Reload()
183 {
184 ark_web_nweb_->Reload();
185 }
186
Zoom(float zoom_factor)187 int ArkWebNWebWrapper::Zoom(float zoom_factor)
188 {
189 return ark_web_nweb_->Zoom(zoom_factor);
190 }
191
ZoomIn()192 int ArkWebNWebWrapper::ZoomIn()
193 {
194 return ark_web_nweb_->ZoomIn();
195 }
196
ZoomOut()197 int ArkWebNWebWrapper::ZoomOut()
198 {
199 return ark_web_nweb_->ZoomOut();
200 }
201
Stop()202 void ArkWebNWebWrapper::Stop()
203 {
204 ark_web_nweb_->Stop();
205 }
206
ExecuteJavaScript(const std::string & code)207 void ArkWebNWebWrapper::ExecuteJavaScript(const std::string& code)
208 {
209 ArkWebString stCode = ArkWebStringClassToStruct(code);
210
211 ark_web_nweb_->ExecuteJavaScript(stCode);
212
213 ArkWebStringStructRelease(stCode);
214 }
215
ExecuteJavaScript(const std::string & code,std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback,bool extention)216 void ArkWebNWebWrapper::ExecuteJavaScript(
217 const std::string& code, std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback, bool extention)
218 {
219 ArkWebString stCode = ArkWebStringClassToStruct(code);
220
221 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
222 ark_web_nweb_->ExecuteJavaScript(stCode, nullptr, extention);
223 } else {
224 ark_web_nweb_->ExecuteJavaScript(stCode, new ArkWebMessageValueCallbackImpl(callback), extention);
225 }
226
227 ArkWebStringStructRelease(stCode);
228 }
229
GetPreference()230 std::shared_ptr<OHOS::NWeb::NWebPreference> ArkWebNWebWrapper::GetPreference()
231 {
232 ArkWebRefPtr<ArkWebPreference> ark_web_preference = ark_web_nweb_->GetPreference();
233 if (CHECK_REF_PTR_IS_NULL(ark_web_preference)) {
234 return nullptr;
235 }
236
237 return std::make_shared<ArkWebPreferenceWrapper>(ark_web_preference);
238 }
239
GetWebId()240 unsigned int ArkWebNWebWrapper::GetWebId()
241 {
242 return ark_web_nweb_->GetWebId();
243 }
244
GetHitTestResult()245 std::shared_ptr<OHOS::NWeb::HitTestResult> ArkWebNWebWrapper::GetHitTestResult()
246 {
247 ArkWebRefPtr<ArkWebHitTestResult> ark_web_hit_test_result = ark_web_nweb_->GetHitTestResult();
248 if (CHECK_REF_PTR_IS_NULL(ark_web_hit_test_result)) {
249 return nullptr;
250 }
251
252 return std::make_shared<ArkWebHitTestResultWrapper>(ark_web_hit_test_result);
253 }
254
PutBackgroundColor(int color)255 void ArkWebNWebWrapper::PutBackgroundColor(int color)
256 {
257 ark_web_nweb_->PutBackgroundColor(color);
258 }
259
InitialScale(float scale)260 void ArkWebNWebWrapper::InitialScale(float scale)
261 {
262 ark_web_nweb_->InitialScale(scale);
263 }
264
PutDownloadCallback(std::shared_ptr<OHOS::NWeb::NWebDownloadCallback> download_listener)265 void ArkWebNWebWrapper::PutDownloadCallback(std::shared_ptr<OHOS::NWeb::NWebDownloadCallback> download_listener)
266 {
267 if (CHECK_SHARED_PTR_IS_NULL(download_listener)) {
268 ark_web_nweb_->PutDownloadCallback(nullptr);
269 return;
270 }
271
272 ark_web_nweb_->PutDownloadCallback(new ArkWebDownloadCallbackImpl(download_listener));
273 }
274
PutAccessibilityEventCallback(std::shared_ptr<OHOS::NWeb::NWebAccessibilityEventCallback> accessibility_event_listener)275 void ArkWebNWebWrapper::PutAccessibilityEventCallback(
276 std::shared_ptr<OHOS::NWeb::NWebAccessibilityEventCallback> accessibility_event_listener)
277 {
278 if (CHECK_SHARED_PTR_IS_NULL(accessibility_event_listener)) {
279 ark_web_nweb_->PutAccessibilityEventCallback(nullptr);
280 return;
281 }
282
283 ark_web_nweb_->PutAccessibilityEventCallback(
284 new ArkWebAccessibilityEventCallbackImpl(accessibility_event_listener));
285 }
286
PutAccessibilityIdGenerator(const AccessibilityIdGenerateFunc accessibility_id_generator)287 void ArkWebNWebWrapper::PutAccessibilityIdGenerator(const AccessibilityIdGenerateFunc accessibility_id_generator)
288 {
289 ark_web_nweb_->PutAccessibilityIdGenerator(accessibility_id_generator);
290 }
291
SetNWebHandler(std::shared_ptr<OHOS::NWeb::NWebHandler> handler)292 void ArkWebNWebWrapper::SetNWebHandler(std::shared_ptr<OHOS::NWeb::NWebHandler> handler)
293 {
294 if (CHECK_SHARED_PTR_IS_NULL(handler)) {
295 ark_web_nweb_->SetNWebHandler(nullptr);
296 return;
297 }
298
299 ark_web_nweb_->SetNWebHandler(new ArkWebHandlerImpl(handler));
300 }
301
Title()302 std::string ArkWebNWebWrapper::Title()
303 {
304 return ArkWebStringStructToClass(ark_web_nweb_->Title());
305 }
306
PageLoadProgress()307 int ArkWebNWebWrapper::PageLoadProgress()
308 {
309 return ark_web_nweb_->PageLoadProgress();
310 }
311
ContentHeight()312 int ArkWebNWebWrapper::ContentHeight()
313 {
314 return ark_web_nweb_->ContentHeight();
315 }
316
Scale()317 float ArkWebNWebWrapper::Scale()
318 {
319 return ark_web_nweb_->Scale();
320 }
321
Load(const std::string & url,const std::map<std::string,std::string> & additional_http_headers)322 int ArkWebNWebWrapper::Load(const std::string& url, const std::map<std::string, std::string>& additional_http_headers)
323 {
324 ArkWebString stUrl = ArkWebStringClassToStruct(url);
325 ArkWebStringMap stHeaders = ArkWebStringMapClassToStruct(additional_http_headers);
326
327 int code = ark_web_nweb_->Load(stUrl, stHeaders);
328
329 ArkWebStringStructRelease(stUrl);
330 ArkWebStringMapStructRelease(stHeaders);
331 return code;
332 }
333
LoadWithDataAndBaseUrl(const std::string & base_url,const std::string & data,const std::string & mime_type,const std::string & encoding,const std::string & history_url)334 int ArkWebNWebWrapper::LoadWithDataAndBaseUrl(const std::string& base_url, const std::string& data,
335 const std::string& mime_type, const std::string& encoding, const std::string& history_url)
336 {
337 ArkWebString stData = ArkWebStringClassToStruct(data);
338 ArkWebString stBaseUrl = ArkWebStringClassToStruct(base_url);
339 ArkWebString stEncoding = ArkWebStringClassToStruct(encoding);
340 ArkWebString stMimeType = ArkWebStringClassToStruct(mime_type);
341 ArkWebString stHistoryUrl = ArkWebStringClassToStruct(history_url);
342
343 int code = ark_web_nweb_->LoadWithDataAndBaseUrl(stBaseUrl, stData, stMimeType, stEncoding, stHistoryUrl);
344
345 ArkWebStringStructRelease(stData);
346 ArkWebStringStructRelease(stBaseUrl);
347 ArkWebStringStructRelease(stEncoding);
348 ArkWebStringStructRelease(stMimeType);
349 ArkWebStringStructRelease(stHistoryUrl);
350 return code;
351 }
352
LoadWithData(const std::string & data,const std::string & mime_type,const std::string & encoding)353 int ArkWebNWebWrapper::LoadWithData(const std::string& data, const std::string& mime_type, const std::string& encoding)
354 {
355 ArkWebString stData = ArkWebStringClassToStruct(data);
356 ArkWebString stEncoding = ArkWebStringClassToStruct(encoding);
357 ArkWebString stMimeType = ArkWebStringClassToStruct(mime_type);
358
359 int code = ark_web_nweb_->LoadWithData(stData, stMimeType, stEncoding);
360
361 ArkWebStringStructRelease(stData);
362 ArkWebStringStructRelease(stEncoding);
363 ArkWebStringStructRelease(stMimeType);
364 return code;
365 }
366
RegisterArkJSfunction(const std::string & object_name,const std::vector<std::string> & method_list,const int32_t object_id)367 void ArkWebNWebWrapper::RegisterArkJSfunction(
368 const std::string& object_name, const std::vector<std::string>& method_list, const int32_t object_id)
369 {
370 ArkWebString stName = ArkWebStringClassToStruct(object_name);
371 ArkWebStringVector stMethods = ArkWebStringVectorClassToStruct(method_list);
372
373 ark_web_nweb_->RegisterArkJSfunction(stName, stMethods, object_id);
374
375 ArkWebStringStructRelease(stName);
376 ArkWebStringVectorStructRelease(stMethods);
377 }
378
UnregisterArkJSfunction(const std::string & object_name,const std::vector<std::string> & method_list)379 void ArkWebNWebWrapper::UnregisterArkJSfunction(
380 const std::string& object_name, const std::vector<std::string>& method_list)
381 {
382 ArkWebString stName = ArkWebStringClassToStruct(object_name);
383 ArkWebStringVector stMethods = ArkWebStringVectorClassToStruct(method_list);
384
385 ark_web_nweb_->UnregisterArkJSfunction(stName, stMethods);
386
387 ArkWebStringStructRelease(stName);
388 ArkWebStringVectorStructRelease(stMethods);
389 }
390
SetNWebJavaScriptResultCallBack(std::shared_ptr<OHOS::NWeb::NWebJavaScriptResultCallBack> callback)391 void ArkWebNWebWrapper::SetNWebJavaScriptResultCallBack(
392 std::shared_ptr<OHOS::NWeb::NWebJavaScriptResultCallBack> callback)
393 {
394 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
395 ark_web_nweb_->SetNWebJavaScriptResultCallBack(nullptr);
396 return;
397 }
398
399 ark_web_nweb_->SetNWebJavaScriptResultCallBack(new ArkWebJsResultCallbackImpl(callback));
400 }
401
PutFindCallback(std::shared_ptr<OHOS::NWeb::NWebFindCallback> find_listener)402 void ArkWebNWebWrapper::PutFindCallback(std::shared_ptr<OHOS::NWeb::NWebFindCallback> find_listener)
403 {
404 if (CHECK_SHARED_PTR_IS_NULL(find_listener)) {
405 ark_web_nweb_->PutFindCallback(nullptr);
406 return;
407 }
408
409 ark_web_nweb_->PutFindCallback(new ArkWebFindCallbackImpl(find_listener));
410 }
411
FindAllAsync(const std::string & search_str)412 void ArkWebNWebWrapper::FindAllAsync(const std::string& search_str)
413 {
414 ArkWebString stSearchStr = ArkWebStringClassToStruct(search_str);
415
416 ark_web_nweb_->FindAllAsync(stSearchStr);
417
418 ArkWebStringStructRelease(stSearchStr);
419 }
420
ClearMatches()421 void ArkWebNWebWrapper::ClearMatches()
422 {
423 ark_web_nweb_->ClearMatches();
424 }
425
FindNext(const bool forward)426 void ArkWebNWebWrapper::FindNext(const bool forward)
427 {
428 ark_web_nweb_->FindNext(forward);
429 }
430
StoreWebArchive(const std::string & base_name,bool auto_name,std::shared_ptr<OHOS::NWeb::NWebStringValueCallback> callback)431 void ArkWebNWebWrapper::StoreWebArchive(
432 const std::string& base_name, bool auto_name, std::shared_ptr<OHOS::NWeb::NWebStringValueCallback> callback)
433 {
434 ArkWebString stName = ArkWebStringClassToStruct(base_name);
435
436 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
437 ark_web_nweb_->StoreWebArchive(stName, auto_name, nullptr);
438 } else {
439 ark_web_nweb_->StoreWebArchive(stName, auto_name, new ArkWebStringValueCallbackImpl(callback));
440 }
441
442 ArkWebStringStructRelease(stName);
443 }
444
CreateWebMessagePorts()445 std::vector<std::string> ArkWebNWebWrapper::CreateWebMessagePorts()
446 {
447 ArkWebStringVector stPorts = ark_web_nweb_->CreateWebMessagePorts();
448
449 std::vector<std::string> objPorts = ArkWebStringVectorStructToClass(stPorts);
450
451 ArkWebStringVectorStructRelease(stPorts);
452 return objPorts;
453 }
454
PostWebMessage(const std::string & message,const std::vector<std::string> & ports,const std::string & target_uri)455 void ArkWebNWebWrapper::PostWebMessage(
456 const std::string& message, const std::vector<std::string>& ports, const std::string& target_uri)
457 {
458 ArkWebString stMessage = ArkWebStringClassToStruct(message);
459 ArkWebString stTargetUrl = ArkWebStringClassToStruct(target_uri);
460 ArkWebStringVector stPorts = ArkWebStringVectorClassToStruct(ports);
461
462 ark_web_nweb_->PostWebMessage(stMessage, stPorts, stTargetUrl);
463
464 ArkWebStringStructRelease(stMessage);
465 ArkWebStringStructRelease(stTargetUrl);
466 ArkWebStringVectorStructRelease(stPorts);
467 }
468
ClosePort(const std::string & port_handle)469 void ArkWebNWebWrapper::ClosePort(const std::string& port_handle)
470 {
471 ArkWebString stPort = ArkWebStringClassToStruct(port_handle);
472
473 ark_web_nweb_->ClosePort(stPort);
474
475 ArkWebStringStructRelease(stPort);
476 }
477
PostPortMessage(const std::string & port_handle,std::shared_ptr<OHOS::NWeb::NWebMessage> data)478 void ArkWebNWebWrapper::PostPortMessage(const std::string& port_handle, std::shared_ptr<OHOS::NWeb::NWebMessage> data)
479 {
480 ArkWebString stPort = ArkWebStringClassToStruct(port_handle);
481
482 ArkWebMessage ark_web_message;
483 ark_web_message.nweb_message = data;
484 ark_web_nweb_->PostPortMessage(stPort, ark_web_message);
485
486 ArkWebStringStructRelease(stPort);
487 }
488
SetPortMessageCallback(const std::string & port_handle,std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback)489 void ArkWebNWebWrapper::SetPortMessageCallback(
490 const std::string& port_handle, std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback)
491 {
492 ArkWebString stPort = ArkWebStringClassToStruct(port_handle);
493
494 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
495 ark_web_nweb_->SetPortMessageCallback(stPort, nullptr);
496 } else {
497 ark_web_nweb_->SetPortMessageCallback(stPort, new ArkWebMessageValueCallbackImpl(callback));
498 }
499
500 ArkWebStringStructRelease(stPort);
501 }
502
SendDragEvent(std::shared_ptr<OHOS::NWeb::NWebDragEvent> drag_event)503 void ArkWebNWebWrapper::SendDragEvent(std::shared_ptr<OHOS::NWeb::NWebDragEvent> drag_event)
504 {
505 if (CHECK_SHARED_PTR_IS_NULL(drag_event)) {
506 ark_web_nweb_->SendDragEvent(nullptr);
507 return;
508 }
509
510 ark_web_nweb_->SendDragEvent(new ArkWebDragEventImpl(drag_event));
511 }
512
ClearSslCache()513 void ArkWebNWebWrapper::ClearSslCache()
514 {
515 ark_web_nweb_->ClearSslCache();
516 }
517
GetUrl()518 std::string ArkWebNWebWrapper::GetUrl()
519 {
520 ArkWebString stUrl = ark_web_nweb_->GetUrl();
521
522 std::string objUrl = ArkWebStringStructToClass(stUrl);
523 ArkWebStringStructRelease(stUrl);
524 return objUrl;
525 }
526
ClearClientAuthenticationCache()527 void ArkWebNWebWrapper::ClearClientAuthenticationCache()
528 {
529 ark_web_nweb_->ClearClientAuthenticationCache();
530 }
531
UpdateLocale(const std::string & language,const std::string & region)532 void ArkWebNWebWrapper::UpdateLocale(const std::string& language, const std::string& region)
533 {
534 ArkWebString stRegion = ArkWebStringClassToStruct(region);
535 ArkWebString stLanguage = ArkWebStringClassToStruct(language);
536
537 ark_web_nweb_->UpdateLocale(stLanguage, stRegion);
538
539 ArkWebStringStructRelease(stRegion);
540 ArkWebStringStructRelease(stLanguage);
541 }
542
GetOriginalUrl()543 const std::string ArkWebNWebWrapper::GetOriginalUrl()
544 {
545 ArkWebString stUrl = ark_web_nweb_->GetOriginalUrl();
546
547 std::string objUrl = ArkWebStringStructToClass(stUrl);
548 ArkWebStringStructRelease(stUrl);
549 return objUrl;
550 }
551
GetFavicon(const void ** data,size_t & width,size_t & height,ArkWebImageColorType & color_type,ArkWebImageAlphaType & alpha_type)552 bool ArkWebNWebWrapper::GetFavicon(const void** data, size_t& width, size_t& height, ArkWebImageColorType& color_type,
553 ArkWebImageAlphaType& alpha_type)
554 {
555 int enum_color_type = static_cast<int>(ArkWebImageColorType::COLOR_TYPE_UNKNOWN);
556 int enum_alpha_type = static_cast<int>(ArkWebImageAlphaType::ALPHA_TYPE_UNKNOWN);
557 bool result = ark_web_nweb_->GetFavicon(data, width, height, enum_color_type, enum_alpha_type);
558 color_type = static_cast<ArkWebImageColorType>(enum_color_type);
559 alpha_type = static_cast<ArkWebImageAlphaType>(enum_alpha_type);
560 return result;
561 }
562
PutNetworkAvailable(bool available)563 void ArkWebNWebWrapper::PutNetworkAvailable(bool available)
564 {
565 ark_web_nweb_->PutNetworkAvailable(available);
566 }
567
HasImages(std::shared_ptr<OHOS::NWeb::NWebBoolValueCallback> callback)568 void ArkWebNWebWrapper::HasImages(std::shared_ptr<OHOS::NWeb::NWebBoolValueCallback> callback)
569 {
570 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
571 ark_web_nweb_->HasImages(nullptr);
572 return;
573 }
574
575 ark_web_nweb_->HasImages(new ArkWebBoolValueCallbackImpl(callback));
576 }
577
RemoveCache(bool include_disk_files)578 void ArkWebNWebWrapper::RemoveCache(bool include_disk_files)
579 {
580 ark_web_nweb_->RemoveCache(include_disk_files);
581 }
582
GetHistoryList()583 std::shared_ptr<OHOS::NWeb::NWebHistoryList> ArkWebNWebWrapper::GetHistoryList()
584 {
585 ArkWebRefPtr<ArkWebHistoryList> ark_web_history_list = ark_web_nweb_->GetHistoryList();
586 if (CHECK_REF_PTR_IS_NULL(ark_web_history_list)) {
587 return nullptr;
588 }
589
590 return std::make_shared<ArkWebHistoryListWrapper>(ark_web_history_list);
591 }
592
PutReleaseSurfaceCallback(std::shared_ptr<OHOS::NWeb::NWebReleaseSurfaceCallback> release_surface_listener)593 void ArkWebNWebWrapper::PutReleaseSurfaceCallback(
594 std::shared_ptr<OHOS::NWeb::NWebReleaseSurfaceCallback> release_surface_listener)
595 {
596 if (CHECK_SHARED_PTR_IS_NULL(release_surface_listener)) {
597 ark_web_nweb_->PutReleaseSurfaceCallback(nullptr);
598 return;
599 }
600
601 ark_web_nweb_->PutReleaseSurfaceCallback(new ArkWebReleaseSurfaceCallbackImpl(release_surface_listener));
602 }
603
SerializeWebState()604 std::vector<uint8_t> ArkWebNWebWrapper::SerializeWebState()
605 {
606 ArkWebUint8Vector stState = ark_web_nweb_->SerializeWebState();
607
608 std::vector<uint8_t> objState = ArkWebBasicVectorStructToClass<uint8_t, ArkWebUint8Vector>(stState);
609 ArkWebBasicVectorStructRelease<ArkWebUint8Vector>(stState);
610 return objState;
611 }
612
RestoreWebState(const std::vector<uint8_t> & state)613 bool ArkWebNWebWrapper::RestoreWebState(const std::vector<uint8_t>& state)
614 {
615 ArkWebUint8Vector stState = ArkWebBasicVectorClassToStruct<uint8_t, ArkWebUint8Vector>(state);
616
617 bool flag = ark_web_nweb_->RestoreWebState(stState);
618
619 ArkWebBasicVectorStructRelease<ArkWebUint8Vector>(stState);
620 return flag;
621 }
622
PageUp(bool top)623 void ArkWebNWebWrapper::PageUp(bool top)
624 {
625 ark_web_nweb_->PageUp(top);
626 }
627
PageDown(bool bottom)628 void ArkWebNWebWrapper::PageDown(bool bottom)
629 {
630 ark_web_nweb_->PageDown(bottom);
631 }
632
ScrollTo(float x,float y)633 void ArkWebNWebWrapper::ScrollTo(float x, float y)
634 {
635 ark_web_nweb_->ScrollTo(x, y);
636 }
637
ScrollBy(float delta_x,float delta_y)638 void ArkWebNWebWrapper::ScrollBy(float delta_x, float delta_y)
639 {
640 ark_web_nweb_->ScrollBy(delta_x, delta_y);
641 }
642
SlideScroll(float vx,float vy)643 void ArkWebNWebWrapper::SlideScroll(float vx, float vy)
644 {
645 ark_web_nweb_->SlideScroll(vx, vy);
646 }
647
GetCertChainDerData(std::vector<std::string> & cert_chain_data,bool is_single_cert)648 bool ArkWebNWebWrapper::GetCertChainDerData(std::vector<std::string>& cert_chain_data, bool is_single_cert)
649 {
650 ArkWebStringVector cert_chain_data_vector;
651 bool result = ark_web_nweb_->GetCertChainDerData(cert_chain_data_vector, is_single_cert);
652 cert_chain_data = ArkWebStringVectorStructToClass(cert_chain_data_vector);
653
654 ArkWebStringVectorStructRelease(cert_chain_data_vector);
655 return result;
656 }
657
SetScreenOffSet(double x,double y)658 void ArkWebNWebWrapper::SetScreenOffSet(double x, double y)
659 {
660 ark_web_nweb_->SetScreenOffSet(x, y);
661 }
662
SetAudioMuted(bool muted)663 void ArkWebNWebWrapper::SetAudioMuted(bool muted)
664 {
665 ark_web_nweb_->SetAudioMuted(muted);
666 }
667
SetShouldFrameSubmissionBeforeDraw(bool should)668 void ArkWebNWebWrapper::SetShouldFrameSubmissionBeforeDraw(bool should)
669 {
670 ark_web_nweb_->SetShouldFrameSubmissionBeforeDraw(should);
671 }
672
NotifyPopupWindowResult(bool result)673 void ArkWebNWebWrapper::NotifyPopupWindowResult(bool result)
674 {
675 ark_web_nweb_->NotifyPopupWindowResult(result);
676 }
677
SetAudioResumeInterval(int32_t resume_interval)678 void ArkWebNWebWrapper::SetAudioResumeInterval(int32_t resume_interval)
679 {
680 ark_web_nweb_->SetAudioResumeInterval(resume_interval);
681 }
682
SetAudioExclusive(bool audio_exclusive)683 void ArkWebNWebWrapper::SetAudioExclusive(bool audio_exclusive)
684 {
685 ark_web_nweb_->SetAudioExclusive(audio_exclusive);
686 }
687
RegisterScreenLockFunction(int32_t window_id,std::shared_ptr<OHOS::NWeb::NWebScreenLockCallback> callback)688 void ArkWebNWebWrapper::RegisterScreenLockFunction(
689 int32_t window_id, std::shared_ptr<OHOS::NWeb::NWebScreenLockCallback> callback)
690 {
691 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
692 ark_web_nweb_->RegisterScreenLockFunction(window_id, nullptr);
693 return;
694 }
695
696 ark_web_nweb_->RegisterScreenLockFunction(window_id, new ArkWebScreenLockCallbackImpl(callback));
697 }
698
UnRegisterScreenLockFunction(int32_t window_id)699 void ArkWebNWebWrapper::UnRegisterScreenLockFunction(int32_t window_id)
700 {
701 ark_web_nweb_->UnRegisterScreenLockFunction(window_id);
702 }
703
NotifyMemoryLevel(int32_t level)704 void ArkWebNWebWrapper::NotifyMemoryLevel(int32_t level)
705 {
706 ark_web_nweb_->NotifyMemoryLevel(level);
707 }
708
OnWebviewHide()709 void ArkWebNWebWrapper::OnWebviewHide()
710 {
711 ark_web_nweb_->OnWebviewHide();
712 }
713
OnWebviewShow()714 void ArkWebNWebWrapper::OnWebviewShow()
715 {
716 ark_web_nweb_->OnWebviewShow();
717 }
718
GetOrCreateDragData()719 std::shared_ptr<OHOS::NWeb::NWebDragData> ArkWebNWebWrapper::GetOrCreateDragData()
720 {
721 ArkWebRefPtr<ArkWebDragData> ark_web_drag_data = ark_web_nweb_->GetOrCreateDragData();
722 if (CHECK_REF_PTR_IS_NULL(ark_web_drag_data)) {
723 return nullptr;
724 }
725
726 return std::make_shared<ArkWebDragDataWrapper>(ark_web_drag_data);
727 }
728
PrefetchPage(const std::string & url,const std::map<std::string,std::string> & additional_http_headers)729 void ArkWebNWebWrapper::PrefetchPage(
730 const std::string& url, const std::map<std::string, std::string>& additional_http_headers)
731 {
732 ArkWebString stUrl = ArkWebStringClassToStruct(url);
733 ArkWebStringMap stHeaders = ArkWebStringMapClassToStruct(additional_http_headers);
734
735 ark_web_nweb_->PrefetchPage(stUrl, stHeaders);
736
737 ArkWebStringStructRelease(stUrl);
738 ArkWebStringMapStructRelease(stHeaders);
739 }
740
SetWindowId(uint32_t window_id)741 void ArkWebNWebWrapper::SetWindowId(uint32_t window_id)
742 {
743 ark_web_nweb_->SetWindowId(window_id);
744 }
745
OnOccluded()746 void ArkWebNWebWrapper::OnOccluded()
747 {
748 ark_web_nweb_->OnOccluded();
749 }
750
OnUnoccluded()751 void ArkWebNWebWrapper::OnUnoccluded()
752 {
753 ark_web_nweb_->OnUnoccluded();
754 }
755
SetToken(void * token)756 void ArkWebNWebWrapper::SetToken(void* token)
757 {
758 ark_web_nweb_->SetToken(token);
759 }
760
SetNestedScrollMode(const ArkWebNestedScrollMode & nested_scroll_mode)761 void ArkWebNWebWrapper::SetNestedScrollMode(const ArkWebNestedScrollMode& nested_scroll_mode)
762 {
763 ark_web_nweb_->SetNestedScrollMode(static_cast<int32_t>(nested_scroll_mode));
764 }
765
SetEnableLowerFrameRate(bool enabled)766 void ArkWebNWebWrapper::SetEnableLowerFrameRate(bool enabled)
767 {
768 ark_web_nweb_->SetEnableLowerFrameRate(enabled);
769 }
770
SetVirtualKeyBoardArg(int32_t width,int32_t height,double keyboard)771 void ArkWebNWebWrapper::SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard)
772 {
773 ark_web_nweb_->SetVirtualKeyBoardArg(width, height, keyboard);
774 }
775
ShouldVirtualKeyboardOverlay()776 bool ArkWebNWebWrapper::ShouldVirtualKeyboardOverlay()
777 {
778 return ark_web_nweb_->ShouldVirtualKeyboardOverlay();
779 }
780
SetDrawRect(int32_t x,int32_t y,int32_t width,int32_t height)781 void ArkWebNWebWrapper::SetDrawRect(int32_t x, int32_t y, int32_t width, int32_t height)
782 {
783 ark_web_nweb_->SetDrawRect(x, y, width, height);
784 }
785
SetDrawMode(int32_t mode)786 void ArkWebNWebWrapper::SetDrawMode(int32_t mode)
787 {
788 ark_web_nweb_->SetDrawMode(mode);
789 }
790
CreateWebPrintDocumentAdapter(const std::string & job_name)791 void* ArkWebNWebWrapper::CreateWebPrintDocumentAdapter(const std::string& job_name)
792 {
793 ArkWebString stObjName = ArkWebStringClassToStruct(job_name);
794
795 void* adapter = ark_web_nweb_->CreateWebPrintDocumentAdapter(stObjName);
796
797 ArkWebStringStructRelease(stObjName);
798 return adapter;
799 }
800
CreateWebPrintDocumentAdapterV2(const std::string & job_name)801 std::unique_ptr<OHOS::NWeb::NWebPrintDocumentAdapterAdapter> ArkWebNWebWrapper::CreateWebPrintDocumentAdapterV2(
802 const std::string& job_name)
803 {
804 ArkWebString stObjName = ArkWebStringClassToStruct(job_name);
805 ArkWebRefPtr<ArkWebPrintDocumentAdapterAdapter> adapter = ark_web_nweb_->CreateWebPrintDocumentAdapterV2(stObjName);
806 ArkWebStringStructRelease(stObjName);
807 if (CHECK_REF_PTR_IS_NULL(adapter)) {
808 return nullptr;
809 }
810 return std::make_unique<ArkWebPrintDocumentAdapterAdapterWrapper>(adapter);
811 }
812
PostUrl(const std::string & url,const std::vector<char> & post_data)813 int ArkWebNWebWrapper::PostUrl(const std::string& url, const std::vector<char>& post_data)
814 {
815 ArkWebString stUrl = ArkWebStringClassToStruct(url);
816 ArkWebCharVector stPostData = ArkWebBasicVectorClassToStruct<char, ArkWebCharVector>(post_data);
817
818 int code = ark_web_nweb_->PostUrl(stUrl, stPostData);
819
820 ArkWebStringStructRelease(stUrl);
821 ArkWebBasicVectorStructRelease<ArkWebCharVector>(stPostData);
822 return code;
823 }
824
JavaScriptOnDocumentStart(const std::map<std::string,std::vector<std::string>> & script_items)825 void ArkWebNWebWrapper::JavaScriptOnDocumentStart(const std::map<std::string, std::vector<std::string>>& script_items)
826 {
827 ArkWebStringVectorMap stScriptItems = ArkWebStringVectorMapClassToStruct(script_items);
828
829 ark_web_nweb_->JavaScriptOnDocumentStart(stScriptItems);
830
831 ArkWebStringVectorMapStructRelease(stScriptItems);
832 }
833
JavaScriptOnDocumentStartByOrder(const std::map<std::string,std::vector<std::string>> & script_items,const std::vector<std::string> & script_items_by_order)834 void ArkWebNWebWrapper::JavaScriptOnDocumentStartByOrder(
835 const std::map<std::string, std::vector<std::string>>& script_items,
836 const std::vector<std::string>& script_items_by_order)
837 {
838 ArkWebStringVectorMap stScriptItems = ArkWebStringVectorMapClassToStruct(script_items);
839 ArkWebStringVector stscript_items_by_order = ArkWebStringVectorClassToStruct(script_items_by_order);
840
841 ark_web_nweb_->JavaScriptOnDocumentStartByOrder(stScriptItems, stscript_items_by_order);
842
843 ArkWebStringVectorMapStructRelease(stScriptItems);
844 ArkWebStringVectorStructRelease(stscript_items_by_order);
845 }
846
JavaScriptOnDocumentEndByOrder(const std::map<std::string,std::vector<std::string>> & script_items,const std::vector<std::string> & script_items_by_order)847 void ArkWebNWebWrapper::JavaScriptOnDocumentEndByOrder(
848 const std::map<std::string, std::vector<std::string>>& script_items,
849 const std::vector<std::string>& script_items_by_order)
850 {
851 ArkWebStringVectorMap stScriptItems = ArkWebStringVectorMapClassToStruct(script_items);
852 ArkWebStringVector stscript_items_by_order = ArkWebStringVectorClassToStruct(script_items_by_order);
853
854 ark_web_nweb_->JavaScriptOnDocumentEndByOrder(stScriptItems, stscript_items_by_order);
855
856 ArkWebStringVectorMapStructRelease(stScriptItems);
857 ArkWebStringVectorStructRelease(stscript_items_by_order);
858 }
859
JavaScriptOnHeadReadyByOrder(const std::map<std::string,std::vector<std::string>> & script_items,const std::vector<std::string> & script_items_by_order)860 void ArkWebNWebWrapper::JavaScriptOnHeadReadyByOrder(
861 const std::map<std::string, std::vector<std::string>>& script_items,
862 const std::vector<std::string>& script_items_by_order)
863 {
864 ArkWebStringVectorMap stScriptItems = ArkWebStringVectorMapClassToStruct(script_items);
865 ArkWebStringVector stscript_items_by_order = ArkWebStringVectorClassToStruct(script_items_by_order);
866
867 ark_web_nweb_->JavaScriptOnHeadReadyByOrder(stScriptItems, stscript_items_by_order);
868
869 ArkWebStringVectorMapStructRelease(stScriptItems);
870 ArkWebStringVectorStructRelease(stscript_items_by_order);
871 }
872
ExecuteAction(int64_t accessibility_id,uint32_t action)873 void ArkWebNWebWrapper::ExecuteAction(int64_t accessibility_id, uint32_t action)
874 {
875 ark_web_nweb_->ExecuteAction(accessibility_id, action);
876 }
877
GetFocusedAccessibilityNodeInfo(int64_t accessibility_id,bool is_accessibility_focus)878 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> ArkWebNWebWrapper::GetFocusedAccessibilityNodeInfo(
879 int64_t accessibility_id, bool is_accessibility_focus)
880 {
881 ArkWebRefPtr<ArkWebAccessibilityNodeInfo> ark_web_accessibility_node_info =
882 ark_web_nweb_->GetFocusedAccessibilityNodeInfo(accessibility_id, is_accessibility_focus);
883 if (CHECK_REF_PTR_IS_NULL(ark_web_accessibility_node_info)) {
884 return nullptr;
885 }
886
887 return std::make_shared<ArkWebAccessibilityNodeInfoWrapper>(ark_web_accessibility_node_info);
888 }
889
GetAccessibilityNodeInfoById(int64_t accessibility_id)890 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> ArkWebNWebWrapper::GetAccessibilityNodeInfoById(
891 int64_t accessibility_id)
892 {
893 ArkWebRefPtr<ArkWebAccessibilityNodeInfo> ark_web_accessibility_node_info =
894 ark_web_nweb_->GetAccessibilityNodeInfoById(accessibility_id);
895 if (CHECK_REF_PTR_IS_NULL(ark_web_accessibility_node_info)) {
896 return nullptr;
897 }
898
899 return std::make_shared<ArkWebAccessibilityNodeInfoWrapper>(ark_web_accessibility_node_info);
900 }
901
GetAccessibilityNodeInfoByFocusMove(int64_t accessibility_id,int32_t direction)902 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> ArkWebNWebWrapper::GetAccessibilityNodeInfoByFocusMove(
903 int64_t accessibility_id, int32_t direction)
904 {
905 ArkWebRefPtr<ArkWebAccessibilityNodeInfo> ark_web_accessibility_node_info =
906 ark_web_nweb_->GetAccessibilityNodeInfoByFocusMove(accessibility_id, direction);
907 if (CHECK_REF_PTR_IS_NULL(ark_web_accessibility_node_info)) {
908 return nullptr;
909 }
910
911 return std::make_shared<ArkWebAccessibilityNodeInfoWrapper>(ark_web_accessibility_node_info);
912 }
913
SetAccessibilityState(bool state)914 void ArkWebNWebWrapper::SetAccessibilityState(bool state)
915 {
916 ark_web_nweb_->SetAccessibilityState(state);
917 }
918
NeedSoftKeyboard()919 bool ArkWebNWebWrapper::NeedSoftKeyboard()
920 {
921 return ark_web_nweb_->NeedSoftKeyboard();
922 }
923
Discard()924 bool ArkWebNWebWrapper::Discard()
925 {
926 return ark_web_nweb_->Discard();
927 }
928
Restore()929 bool ArkWebNWebWrapper::Restore()
930 {
931 return ark_web_nweb_->Restore();
932 }
933
GetSecurityLevel()934 int ArkWebNWebWrapper::GetSecurityLevel()
935 {
936 return ark_web_nweb_->GetSecurityLevel();
937 }
938
CallH5Function(int32_t routingId,int32_t h5ObjectId,const std::string & h5MethodName,const std::vector<std::shared_ptr<OHOS::NWeb::NWebValue>> & args)939 void ArkWebNWebWrapper::CallH5Function(int32_t routingId, int32_t h5ObjectId, const std::string& h5MethodName,
940 const std::vector<std::shared_ptr<OHOS::NWeb::NWebValue>>& args)
941 {
942 ArkWebString stName = ArkWebStringClassToStruct(h5MethodName);
943 ArkWebValueVector stArgs = ArkWebValueVectorClassToStruct(args);
944
945 ark_web_nweb_->CallH5Function(routingId, h5ObjectId, stName, stArgs);
946
947 ArkWebStringStructRelease(stName);
948 ArkWebValueVectorStructRelease(stArgs);
949 }
950
IsIncognitoMode()951 bool ArkWebNWebWrapper::IsIncognitoMode()
952 {
953 return ark_web_nweb_->IsIncognitoMode();
954 }
955
RegisterNativeArkJSFunction(const char * objName,const std::vector<std::shared_ptr<OHOS::NWeb::NWebJsProxyCallback>> & callbacks)956 void ArkWebNWebWrapper::RegisterNativeArkJSFunction(
957 const char* objName, const std::vector<std::shared_ptr<OHOS::NWeb::NWebJsProxyCallback>>& callbacks)
958 {
959 ArkWebJsProxyCallbackVector stJsProxyCallbackVector = ArkWebJsProxyCallbackVectorClassToStruct(callbacks);
960
961 ark_web_nweb_->RegisterNativeArkJSFunction(objName, stJsProxyCallbackVector);
962
963 ArkWebJsProxyCallbackVectorStructRelease(stJsProxyCallbackVector);
964 }
965
UnRegisterNativeArkJSFunction(const char * objName)966 void ArkWebNWebWrapper::UnRegisterNativeArkJSFunction(const char* objName)
967 {
968 ark_web_nweb_->UnRegisterNativeArkJSFunction(objName);
969 }
970
RegisterNativeValideCallback(const char * webName,const NativeArkWebOnValidCallback callback)971 void ArkWebNWebWrapper::RegisterNativeValideCallback(const char* webName, const NativeArkWebOnValidCallback callback)
972 {
973 ark_web_nweb_->RegisterNativeValideCallback(webName, callback);
974 }
975
RegisterNativeDestroyCallback(const char * webName,const NativeArkWebOnValidCallback callback)976 void ArkWebNWebWrapper::RegisterNativeDestroyCallback(const char* webName, const NativeArkWebOnValidCallback callback)
977 {
978 ark_web_nweb_->RegisterNativeDestroyCallback(webName, callback);
979 }
980
JavaScriptOnDocumentEnd(const std::map<std::string,std::vector<std::string>> & script_items)981 void ArkWebNWebWrapper::JavaScriptOnDocumentEnd(const std::map<std::string, std::vector<std::string>>& script_items)
982 {
983 ArkWebStringVectorMap stScriptItems = ArkWebStringVectorMapClassToStruct(script_items);
984
985 ark_web_nweb_->JavaScriptOnDocumentEnd(stScriptItems);
986
987 ArkWebStringVectorMapStructRelease(stScriptItems);
988 }
989
EnableSafeBrowsing(bool enable)990 void ArkWebNWebWrapper::EnableSafeBrowsing(bool enable)
991 {
992 ark_web_nweb_->EnableSafeBrowsing(enable);
993 }
994
IsSafeBrowsingEnabled()995 bool ArkWebNWebWrapper::IsSafeBrowsingEnabled()
996 {
997 return ark_web_nweb_->IsSafeBrowsingEnabled();
998 }
999
SetPrintBackground(bool enable)1000 void ArkWebNWebWrapper::SetPrintBackground(bool enable)
1001 {
1002 ark_web_nweb_->SetPrintBackground(enable);
1003 }
1004
GetPrintBackground()1005 bool ArkWebNWebWrapper::GetPrintBackground()
1006 {
1007 return ark_web_nweb_->GetPrintBackground();
1008 }
1009
CloseAllMediaPresentations()1010 void ArkWebNWebWrapper::CloseAllMediaPresentations()
1011 {
1012 ark_web_nweb_->CloseAllMediaPresentations();
1013 }
1014
StopAllMedia()1015 void ArkWebNWebWrapper::StopAllMedia()
1016 {
1017 ark_web_nweb_->StopAllMedia();
1018 }
1019
ResumeAllMedia()1020 void ArkWebNWebWrapper::ResumeAllMedia()
1021 {
1022 ark_web_nweb_->ResumeAllMedia();
1023 }
1024
PauseAllMedia()1025 void ArkWebNWebWrapper::PauseAllMedia()
1026 {
1027 ark_web_nweb_->PauseAllMedia();
1028 }
1029
GetMediaPlaybackState()1030 int ArkWebNWebWrapper::GetMediaPlaybackState()
1031 {
1032 return ark_web_nweb_->GetMediaPlaybackState();
1033 }
1034
EnableIntelligentTrackingPrevention(bool enable)1035 void ArkWebNWebWrapper::EnableIntelligentTrackingPrevention(bool enable)
1036 {
1037 ark_web_nweb_->EnableIntelligentTrackingPrevention(enable);
1038 }
1039
IsIntelligentTrackingPreventionEnabled() const1040 bool ArkWebNWebWrapper::IsIntelligentTrackingPreventionEnabled() const
1041 {
1042 return ark_web_nweb_->IsIntelligentTrackingPreventionEnabled();
1043 }
1044
StartCamera()1045 void ArkWebNWebWrapper::StartCamera()
1046 {
1047 ark_web_nweb_->StartCamera();
1048 }
1049
StopCamera()1050 void ArkWebNWebWrapper::StopCamera()
1051 {
1052 ark_web_nweb_->StopCamera();
1053 }
1054
CloseCamera()1055 void ArkWebNWebWrapper::CloseCamera()
1056 {
1057 ark_web_nweb_->CloseCamera();
1058 }
1059
GetLastJavascriptProxyCallingFrameUrl()1060 std::string ArkWebNWebWrapper::GetLastJavascriptProxyCallingFrameUrl()
1061 {
1062 return ArkWebStringStructToClass(ark_web_nweb_->GetLastJavascriptProxyCallingFrameUrl());
1063 }
1064
GetPendingSizeStatus()1065 bool ArkWebNWebWrapper::GetPendingSizeStatus()
1066 {
1067 return ark_web_nweb_->GetPendingSizeStatus();
1068 }
1069
ScrollByRefScreen(float delta_x,float delta_y,float vx,float vy)1070 void ArkWebNWebWrapper::ScrollByRefScreen(float delta_x, float delta_y, float vx, float vy)
1071 {
1072 ark_web_nweb_->ScrollByRefScreen(delta_x, delta_y, vx, vy);
1073 }
1074
ExecuteJavaScriptExt(const int fd,const size_t scriptLength,std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback,bool extention)1075 void ArkWebNWebWrapper::ExecuteJavaScriptExt(const int fd, const size_t scriptLength,
1076 std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback, bool extention)
1077 {
1078 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
1079 ark_web_nweb_->ExecuteJavaScriptExt(fd, scriptLength, nullptr, extention);
1080 } else {
1081 ark_web_nweb_->ExecuteJavaScriptExt(fd, scriptLength, new ArkWebMessageValueCallbackImpl(callback), extention);
1082 }
1083 }
1084
OnRenderToBackground()1085 void ArkWebNWebWrapper::OnRenderToBackground()
1086 {
1087 ark_web_nweb_->OnRenderToBackground();
1088 }
1089
OnRenderToForeground()1090 void ArkWebNWebWrapper::OnRenderToForeground()
1091 {
1092 ark_web_nweb_->OnRenderToForeground();
1093 }
1094
PrecompileJavaScript(const std::string & url,const std::string & script,std::shared_ptr<OHOS::NWeb::CacheOptions> & cacheOptions,std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback)1095 void ArkWebNWebWrapper::PrecompileJavaScript(const std::string& url, const std::string& script,
1096 std::shared_ptr<OHOS::NWeb::CacheOptions>& cacheOptions,
1097 std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback)
1098 {
1099 ArkWebString ark_url = ArkWebStringClassToStruct(url);
1100 ArkWebString ark_script = ArkWebStringClassToStruct(script);
1101 ArkWebRefPtr<ArkWebCacheOptions> options = new ArkWebCacheOptionsImpl(cacheOptions);
1102 ark_web_nweb_->PrecompileJavaScript(ark_url, ark_script, options, new ArkWebMessageValueCallbackImpl(callback));
1103 ArkWebStringStructRelease(ark_url);
1104 ArkWebStringStructRelease(ark_script);
1105 }
1106
OnCreateNativeMediaPlayer(std::shared_ptr<OHOS::NWeb::NWebCreateNativeMediaPlayerCallback> callback)1107 void ArkWebNWebWrapper::OnCreateNativeMediaPlayer(
1108 std::shared_ptr<OHOS::NWeb::NWebCreateNativeMediaPlayerCallback> callback)
1109 {
1110 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
1111 return;
1112 }
1113
1114 ark_web_nweb_->OnCreateNativeMediaPlayer(new ArkWebCreateNativeMediaPlayerCallbackImpl(callback));
1115 }
1116
SendTouchpadFlingEvent(double x,double y,double vx,double vy)1117 void ArkWebNWebWrapper::SendTouchpadFlingEvent(double x, double y, double vx, double vy)
1118 {
1119 ark_web_nweb_->SendTouchpadFlingEvent(x, y, vx, vy);
1120 }
1121
DragResize(uint32_t width,uint32_t height,uint32_t pre_height,uint32_t pre_width)1122 void ArkWebNWebWrapper::DragResize(uint32_t width, uint32_t height, uint32_t pre_height, uint32_t pre_width)
1123 {
1124 ark_web_nweb_->DragResize(width, height, pre_height, pre_width);
1125 }
1126
OnTouchCancelById(int32_t id,double x,double y,bool from_overlay)1127 void ArkWebNWebWrapper::OnTouchCancelById(int32_t id, double x, double y, bool from_overlay)
1128 {
1129 ark_web_nweb_->OnTouchCancelById(id, x, y, from_overlay);
1130 }
1131
InjectOfflineResource(const std::string & url,const std::string & origin,const std::vector<uint8_t> & resource,const std::map<std::string,std::string> & responseHeaders,const int type)1132 void ArkWebNWebWrapper::InjectOfflineResource(const std::string& url, const std::string& origin,
1133 const std::vector<uint8_t>& resource, const std::map<std::string, std::string>& responseHeaders, const int type)
1134 {
1135 ArkWebString arkUrl = ArkWebStringClassToStruct(url);
1136 ArkWebString arkOrigin = ArkWebStringClassToStruct(origin);
1137
1138 auto responseHeadersMap = ArkWebStringMapClassToStruct(responseHeaders);
1139
1140 ArkWebUint8Vector arkResource = ArkWebBasicVectorClassToStruct<uint8_t, ArkWebUint8Vector>(resource);
1141
1142 ark_web_nweb_->InjectOfflineResource(arkUrl, arkOrigin, arkResource, responseHeadersMap, type);
1143
1144 ArkWebStringStructRelease(arkUrl);
1145 ArkWebStringStructRelease(arkOrigin);
1146 ArkWebBasicVectorStructRelease<ArkWebUint8Vector>(arkResource);
1147 ArkWebStringMapStructRelease(responseHeadersMap);
1148 }
1149
RegisterArkJSfunction(const std::string & object_name,const std::vector<std::string> & method_list,const std::vector<std::string> & async_method_list,const int32_t object_id)1150 void ArkWebNWebWrapper::RegisterArkJSfunction(const std::string& object_name,
1151 const std::vector<std::string>& method_list, const std::vector<std::string>& async_method_list,
1152 const int32_t object_id)
1153 {
1154 ArkWebString stName = ArkWebStringClassToStruct(object_name);
1155 ArkWebStringVector stMethods = ArkWebStringVectorClassToStruct(method_list);
1156 ArkWebStringVector stAsyncMethods = ArkWebStringVectorClassToStruct(async_method_list);
1157
1158 ark_web_nweb_->RegisterArkJSfunction(stName, stMethods, stAsyncMethods, object_id);
1159
1160 ArkWebStringStructRelease(stName);
1161 ArkWebStringVectorStructRelease(stMethods);
1162 ArkWebStringVectorStructRelease(stAsyncMethods);
1163 }
1164
SetFitContentMode(int32_t mode)1165 void ArkWebNWebWrapper::SetFitContentMode(int32_t mode)
1166 {
1167 ark_web_nweb_->SetFitContentMode(mode);
1168 }
1169
TerminateRenderProcess()1170 bool ArkWebNWebWrapper::TerminateRenderProcess()
1171 {
1172 return ark_web_nweb_->TerminateRenderProcess();
1173 }
1174
GetSelectInfo()1175 std::string ArkWebNWebWrapper::GetSelectInfo()
1176 {
1177 return ArkWebStringStructToClass(ark_web_nweb_->GetSelectInfo());
1178 }
1179
OnOnlineRenderToForeground()1180 void ArkWebNWebWrapper::OnOnlineRenderToForeground()
1181 {
1182 ark_web_nweb_->OnOnlineRenderToForeground();
1183 }
1184
ScaleGestureChange(double scale,double centerX,double centerY)1185 int ArkWebNWebWrapper::ScaleGestureChange(double scale, double centerX, double centerY)
1186 {
1187 return ark_web_nweb_->ScaleGestureChange(scale, centerX, centerY);
1188 }
1189
SuggestionSelected(int32_t index)1190 void ArkWebNWebWrapper::SuggestionSelected(int32_t index)
1191 {
1192 ark_web_nweb_->SuggestionSelected(index);
1193 }
1194
OnSafeInsetsChange(int left,int top,int right,int bottom)1195 void ArkWebNWebWrapper::OnSafeInsetsChange(int left, int top, int right, int bottom)
1196 {
1197 ark_web_nweb_->OnSafeInsetsChange(left, top, right, bottom);
1198 }
1199
OnTextSelected()1200 void ArkWebNWebWrapper::OnTextSelected()
1201 {
1202 ark_web_nweb_->OnTextSelected();
1203 }
1204
NotifyForNextTouchEvent()1205 void ArkWebNWebWrapper::NotifyForNextTouchEvent()
1206 {
1207 ark_web_nweb_->NotifyForNextTouchEvent();
1208 }
1209
EnableAdsBlock(bool enable)1210 void ArkWebNWebWrapper::EnableAdsBlock(bool enable)
1211 {
1212 ark_web_nweb_->EnableAdsBlock(enable);
1213 }
1214
IsAdsBlockEnabled()1215 bool ArkWebNWebWrapper::IsAdsBlockEnabled()
1216 {
1217 return ark_web_nweb_->IsAdsBlockEnabled();
1218 }
1219
IsAdsBlockEnabledForCurPage()1220 bool ArkWebNWebWrapper::IsAdsBlockEnabledForCurPage()
1221 {
1222 return ark_web_nweb_->IsAdsBlockEnabledForCurPage();
1223 }
1224
WebPageSnapshot(const char * id,ArkPixelUnit type,int width,int height,const WebSnapshotCallback callback)1225 bool ArkWebNWebWrapper::WebPageSnapshot(const char* id,
1226 ArkPixelUnit type,
1227 int width,
1228 int height,
1229 const WebSnapshotCallback callback)
1230 {
1231 return ark_web_nweb_->WebPageSnapshot(id, static_cast<int>(type), width, height, callback);
1232 }
1233
OnConfigurationUpdated(std::shared_ptr<OHOS::NWeb::NWebSystemConfiguration> configuration)1234 void ArkWebNWebWrapper::OnConfigurationUpdated(std::shared_ptr<OHOS::NWeb::NWebSystemConfiguration> configuration)
1235 {
1236 if (CHECK_SHARED_PTR_IS_NULL(configuration)) {
1237 ark_web_nweb_->OnConfigurationUpdated(nullptr);
1238 return;
1239 }
1240
1241 ark_web_nweb_->OnConfigurationUpdated(new ArkWebSystemConfigurationImpl(configuration));
1242 }
1243
SetUrlTrustListWithErrMsg(const std::string & urlTrustList,std::string & detailErrMsg)1244 int ArkWebNWebWrapper::SetUrlTrustListWithErrMsg(
1245 const std::string& urlTrustList, std::string& detailErrMsg)
1246 {
1247 ArkWebString stUrlTrustList = ArkWebStringClassToStruct(urlTrustList);
1248 ArkWebString stDetailErrMsg = ark_web_string_default;
1249 int res = ark_web_nweb_->SetUrlTrustListWithErrMsg(stUrlTrustList, stDetailErrMsg);
1250 detailErrMsg = ArkWebStringStructToClass(stDetailErrMsg);
1251 ArkWebStringStructRelease(stUrlTrustList);
1252 ArkWebStringStructRelease(stDetailErrMsg);
1253 return res;
1254 }
1255
PutSpanstringConvertHtmlCallback(std::shared_ptr<OHOS::NWeb::NWebSpanstringConvertHtmlCallback> callback)1256 void ArkWebNWebWrapper::PutSpanstringConvertHtmlCallback(
1257 std::shared_ptr<OHOS::NWeb::NWebSpanstringConvertHtmlCallback> callback)
1258 {
1259 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
1260 ark_web_nweb_->PutSpanstringConvertHtmlCallback(nullptr);
1261 return;
1262 }
1263
1264 ark_web_nweb_->PutSpanstringConvertHtmlCallback(
1265 new ArkWebSpanstringConvertHtmlCallbackImpl(callback));
1266 }
1267
SetUrlTrustList(const std::string & urlTrustList)1268 int ArkWebNWebWrapper::SetUrlTrustList(const std::string& urlTrustList)
1269 {
1270 ArkWebString stUrlTrustList = ArkWebStringClassToStruct(urlTrustList);
1271 int res = ark_web_nweb_->SetUrlTrustList(stUrlTrustList);
1272 ArkWebStringStructRelease(stUrlTrustList);
1273 return res;
1274 }
1275
WebSendKeyEvent(int32_t key_code,int32_t key_action,const std::vector<int32_t> & pressedCodes)1276 bool ArkWebNWebWrapper::WebSendKeyEvent(int32_t key_code, int32_t key_action, const std::vector<int32_t>& pressedCodes)
1277 {
1278 ArkWebInt32Vector pCodes = ArkWebBasicVectorClassToStruct<int32_t, ArkWebInt32Vector>(pressedCodes);
1279
1280 bool result = ark_web_nweb_->WebSendKeyEvent(key_code, key_action, pCodes);
1281
1282 ArkWebBasicVectorStructRelease<ArkWebInt32Vector>(pCodes);
1283 return result;
1284 }
1285
SetPathAllowingUniversalAccess(const std::vector<std::string> & dirs,const std::vector<std::string> & moduleName,std::string & errorPath)1286 void ArkWebNWebWrapper::SetPathAllowingUniversalAccess(
1287 const std::vector<std::string>& dirs,
1288 const std::vector<std::string>& moduleName,
1289 std::string& errorPath)
1290 {
1291 ArkWebStringVector stDirs = ArkWebStringVectorClassToStruct(dirs);
1292 ArkWebStringVector stModuleName = ArkWebStringVectorClassToStruct(moduleName);
1293 ArkWebString stErrorPath = ark_web_string_default;
1294
1295 ark_web_nweb_->SetPathAllowingUniversalAccess(stDirs, stModuleName, stErrorPath);
1296
1297 errorPath = ArkWebStringStructToClass(stErrorPath);
1298 ArkWebStringVectorStructRelease(stDirs);
1299 ArkWebStringVectorStructRelease(stModuleName);
1300 ArkWebStringStructRelease(stErrorPath);
1301 }
1302
WebSendMouseWheelEvent(double x,double y,double delta_x,double delta_y,const std::vector<int32_t> & pressedCodes)1303 void ArkWebNWebWrapper::WebSendMouseWheelEvent(double x,
1304 double y,
1305 double delta_x,
1306 double delta_y,
1307 const std::vector<int32_t>& pressedCodes)
1308 {
1309 ArkWebInt32Vector pCodes = ArkWebBasicVectorClassToStruct<int32_t, ArkWebInt32Vector>(pressedCodes);
1310
1311 ark_web_nweb_->WebSendMouseWheelEvent(x, y, delta_x, delta_y, pCodes);
1312
1313 ArkWebBasicVectorStructRelease<ArkWebInt32Vector>(pCodes);
1314 }
1315
WebSendTouchpadFlingEvent(double x,double y,double vx,double vy,const std::vector<int32_t> & pressedCodes)1316 void ArkWebNWebWrapper::WebSendTouchpadFlingEvent(double x,
1317 double y,
1318 double vx,
1319 double vy,
1320 const std::vector<int32_t>& pressedCodes)
1321 {
1322 ArkWebInt32Vector pCodes = ArkWebBasicVectorClassToStruct<int32_t, ArkWebInt32Vector>(pressedCodes);
1323
1324 ark_web_nweb_->WebSendTouchpadFlingEvent(x, y, vx, vy, pCodes);
1325
1326 ArkWebBasicVectorStructRelease<ArkWebInt32Vector>(pCodes);
1327 }
1328
ResizeVisibleViewport(uint32_t width,uint32_t height,bool isKeyboard)1329 void ArkWebNWebWrapper::ResizeVisibleViewport(uint32_t width, uint32_t height, bool isKeyboard)
1330 {
1331 ark_web_nweb_->ResizeVisibleViewport(width, height, isKeyboard);
1332 }
1333
SetBackForwardCacheOptions(int32_t size,int32_t timeToLive)1334 void ArkWebNWebWrapper::SetBackForwardCacheOptions(int32_t size, int32_t timeToLive)
1335 {
1336 ark_web_nweb_->SetBackForwardCacheOptions(size, timeToLive);
1337 }
1338
RegisterArkJSfunction(const std::string & object_name,const std::vector<std::string> & method_list,const std::vector<std::string> & async_method_list,const int32_t object_id,const std::string & permission)1339 void ArkWebNWebWrapper::RegisterArkJSfunction(const std::string& object_name,
1340 const std::vector<std::string>& method_list, const std::vector<std::string>& async_method_list,
1341 const int32_t object_id,
1342 const std::string& permission)
1343 {
1344 ArkWebString stName = ArkWebStringClassToStruct(object_name);
1345 ArkWebStringVector stMethods = ArkWebStringVectorClassToStruct(method_list);
1346 ArkWebStringVector stAsyncMethods = ArkWebStringVectorClassToStruct(async_method_list);
1347 ArkWebString stPermission = ArkWebStringClassToStruct(permission);
1348
1349 ark_web_nweb_->RegisterArkJSfunction(stName, stMethods, stAsyncMethods, object_id, stPermission);
1350
1351 ArkWebStringStructRelease(stName);
1352 ArkWebStringVectorStructRelease(stMethods);
1353 ArkWebStringVectorStructRelease(stAsyncMethods);
1354 ArkWebStringStructRelease(stPermission);
1355 }
1356
SetAutofillCallback(std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback)1357 void ArkWebNWebWrapper::SetAutofillCallback(std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback)
1358 {
1359 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
1360 ark_web_nweb_->SetAutofillCallback(nullptr);
1361 } else {
1362 ark_web_nweb_->SetAutofillCallback(new ArkWebMessageValueCallbackImpl(callback));
1363 }
1364 }
1365
FillAutofillData(std::shared_ptr<OHOS::NWeb::NWebMessage> data)1366 void ArkWebNWebWrapper::FillAutofillData(std::shared_ptr<OHOS::NWeb::NWebMessage> data)
1367 {
1368 ArkWebMessage ark_web_message;
1369 ark_web_message.nweb_message = data;
1370 ark_web_nweb_->FillAutofillData(ark_web_message);
1371 }
1372
OnAutofillCancel(const std::string & fillContent)1373 void ArkWebNWebWrapper::OnAutofillCancel(const std::string& fillContent)
1374 {
1375 ArkWebString stFillContent = ArkWebStringClassToStruct(fillContent);
1376
1377 ark_web_nweb_->OnAutofillCancel(stFillContent);
1378
1379 ArkWebStringStructRelease(stFillContent);
1380 }
1381
PerformAction(int64_t accessibility_id,uint32_t action,const std::map<std::string,std::string> & actionArguments)1382 void ArkWebNWebWrapper::PerformAction(int64_t accessibility_id, uint32_t action,
1383 const std::map<std::string, std::string>& actionArguments)
1384 {
1385 ArkWebStringMap stArguments = ArkWebStringMapClassToStruct(actionArguments);
1386 ark_web_nweb_->PerformAction(accessibility_id, action, stArguments);
1387
1388 ArkWebStringMapStructRelease(stArguments);
1389 }
1390
SendAccessibilityHoverEvent(int32_t x,int32_t y)1391 void ArkWebNWebWrapper::SendAccessibilityHoverEvent(int32_t x, int32_t y)
1392 {
1393 ark_web_nweb_->SendAccessibilityHoverEvent(x, y);
1394 }
1395
GetScrollOffset(float * offset_x,float * offset_y)1396 void ArkWebNWebWrapper::GetScrollOffset(float* offset_x, float* offset_y)
1397 {
1398 ark_web_nweb_->GetScrollOffset(offset_x, offset_y);
1399 }
1400
ExecuteCreatePDFExt(std::shared_ptr<OHOS::NWeb::NWebPDFConfigArgs> pdfConfig,std::shared_ptr<OHOS::NWeb::NWebArrayBufferValueCallback> callback)1401 void ArkWebNWebWrapper::ExecuteCreatePDFExt(std::shared_ptr<OHOS::NWeb::NWebPDFConfigArgs> pdfConfig,
1402 std::shared_ptr<OHOS::NWeb::NWebArrayBufferValueCallback> callback)
1403 {
1404 if (CHECK_SHARED_PTR_IS_NULL(callback)) {
1405 ark_web_nweb_->ExecuteCreatePDFExt(
1406 new ArkWebPDFConfigArgsImpl(CHECK_SHARED_PTR_IS_NULL(pdfConfig) ? nullptr : pdfConfig), nullptr);
1407 } else {
1408 ark_web_nweb_->ExecuteCreatePDFExt(
1409 new ArkWebPDFConfigArgsImpl(CHECK_SHARED_PTR_IS_NULL(pdfConfig) ? nullptr : pdfConfig),
1410 new ArkWebArrayBufferValueCallbackImpl(callback));
1411 }
1412 }
1413
ScrollByWithResult(float delta_x,float delta_y)1414 bool ArkWebNWebWrapper::ScrollByWithResult(float delta_x, float delta_y)
1415 {
1416 return ark_web_nweb_->ScrollByWithResult(delta_x, delta_y);
1417 }
1418
OnDestroyImageAnalyzerOverlay()1419 void ArkWebNWebWrapper::OnDestroyImageAnalyzerOverlay()
1420 {
1421 ark_web_nweb_->OnDestroyImageAnalyzerOverlay();
1422 }
1423
ScrollToWithAnime(float x,float y,int32_t duration)1424 void ArkWebNWebWrapper::ScrollToWithAnime(float x, float y, int32_t duration)
1425 {
1426 ark_web_nweb_->ScrollToWithAnime(x, y, duration);
1427 }
1428
ScrollByWithAnime(float delta_x,float delta_y,int32_t duration)1429 void ArkWebNWebWrapper::ScrollByWithAnime(float delta_x, float delta_y, int32_t duration)
1430 {
1431 ark_web_nweb_->ScrollByWithAnime(delta_x, delta_y, duration);
1432 }
1433
SetPopupSurface(void * popupSurface)1434 void ArkWebNWebWrapper::SetPopupSurface(void* popupSurface)
1435 {
1436 ark_web_nweb_->SetPopupSurface(popupSurface);
1437 }
1438
WebSendMouseEvent(const std::shared_ptr<OHOS::NWeb::NWebMouseEvent> & mouseEvent)1439 void ArkWebNWebWrapper::WebSendMouseEvent(const std::shared_ptr<OHOS::NWeb::NWebMouseEvent>& mouseEvent)
1440 {
1441 if (CHECK_SHARED_PTR_IS_NULL(mouseEvent)) {
1442 ark_web_nweb_->WebSendMouseEvent(nullptr);
1443 return;
1444 }
1445
1446 ark_web_nweb_->WebSendMouseEvent(new ArkWebMouseEventImpl(mouseEvent));
1447 }
1448
GetAccessibilityVisible(int64_t accessibility_id)1449 bool ArkWebNWebWrapper::GetAccessibilityVisible(int64_t accessibility_id)
1450 {
1451 return ark_web_nweb_->GetAccessibilityVisible(accessibility_id);
1452 }
1453
SetTransformHint(uint32_t rotation)1454 void ArkWebNWebWrapper::SetTransformHint(uint32_t rotation)
1455 {
1456 return ark_web_nweb_->SetTransformHint(rotation);
1457 }
1458
WebComponentsBlur()1459 void ArkWebNWebWrapper::WebComponentsBlur()
1460 {
1461 ark_web_nweb_->WebComponentsBlur();
1462 }
1463
DumpGpuInfo()1464 float ArkWebNWebWrapper::DumpGpuInfo()
1465 {
1466 return ark_web_nweb_->DumpGpuInfo();
1467 }
1468
ScaleGestureChangeV2(int type,double scale,double originScale,double centerX,double centerY)1469 int ArkWebNWebWrapper::ScaleGestureChangeV2(int type,
1470 double scale,
1471 double originScale,
1472 double centerX,
1473 double centerY)
1474 {
1475 return ark_web_nweb_->ScaleGestureChangeV2(type, scale, originScale, centerX, centerY);
1476 }
1477
SendKeyboardEvent(const std::shared_ptr<OHOS::NWeb::NWebKeyboardEvent> & keyboardEvent)1478 bool ArkWebNWebWrapper::SendKeyboardEvent(const std::shared_ptr<OHOS::NWeb::NWebKeyboardEvent>& keyboardEvent)
1479 {
1480 if (CHECK_SHARED_PTR_IS_NULL(keyboardEvent)) {
1481 ark_web_nweb_->SendKeyboardEvent(nullptr);
1482 return false;
1483 }
1484
1485 return ark_web_nweb_->SendKeyboardEvent(new ArkWebKeyboardEventImpl(keyboardEvent));
1486 }
1487
PerformActionV2(int64_t accessibility_id,uint32_t action,const std::map<std::string,std::string> & actionArguments)1488 bool ArkWebNWebWrapper::PerformActionV2(int64_t accessibility_id, uint32_t action,
1489 const std::map<std::string, std::string>& actionArguments)
1490 {
1491 ArkWebStringMap stArguments = ArkWebStringMapClassToStruct(actionArguments);
1492 bool res = ark_web_nweb_->PerformActionV2(accessibility_id, action, stArguments);
1493
1494 ArkWebStringMapStructRelease(stArguments);
1495 return res;
1496 }
1497
IsActivePolicyDisable()1498 bool ArkWebNWebWrapper::IsActivePolicyDisable()
1499 {
1500 return ark_web_nweb_->IsActivePolicyDisable();
1501 }
1502
PutOptimizeParserBudgetEnabled(bool enable)1503 void ArkWebNWebWrapper::PutOptimizeParserBudgetEnabled(bool enable)
1504 {
1505 ark_web_nweb_->PutOptimizeParserBudgetEnabled(enable);
1506 }
1507
GetAccessibilityNodeRectById(int64_t accessibilityId,int32_t * width,int32_t * height,int32_t * offsetX,int32_t * offsetY)1508 bool ArkWebNWebWrapper::GetAccessibilityNodeRectById(
1509 int64_t accessibilityId, int32_t* width, int32_t* height, int32_t* offsetX, int32_t* offsetY)
1510 {
1511 return ark_web_nweb_->GetAccessibilityNodeRectById(accessibilityId, width, height, offsetX, offsetY);
1512 }
1513
GetLastHitTestResult()1514 std::shared_ptr<OHOS::NWeb::HitTestResult> ArkWebNWebWrapper::GetLastHitTestResult()
1515 {
1516 ArkWebRefPtr<ArkWebHitTestResult> ark_web_last_hit_test_result = ark_web_nweb_->GetLastHitTestResult();
1517 if (CHECK_REF_PTR_IS_NULL(ark_web_last_hit_test_result)) {
1518 return nullptr;
1519 }
1520
1521 return std::make_shared<ArkWebHitTestResultWrapper>(ark_web_last_hit_test_result);
1522 }
1523
GetCurrentLanguage()1524 std::string ArkWebNWebWrapper::GetCurrentLanguage()
1525 {
1526 return ArkWebStringStructToClass(ark_web_nweb_->GetCurrentLanguage());
1527 }
WebSendMouseWheelEventV2(double x,double y,double delta_x,double delta_y,const std::vector<int32_t> & pressedCodes,int32_t source)1528 bool ArkWebNWebWrapper::WebSendMouseWheelEventV2(
1529 double x, double y, double delta_x, double delta_y, const std::vector<int32_t> &pressedCodes, int32_t source)
1530 {
1531 ArkWebInt32Vector pCodes = ArkWebBasicVectorClassToStruct<int32_t, ArkWebInt32Vector>(pressedCodes);
1532
1533 bool result = ark_web_nweb_->WebSendMouseWheelEventV2(x, y, delta_x, delta_y, pCodes, source);
1534
1535 ArkWebBasicVectorStructRelease<ArkWebInt32Vector>(pCodes);
1536 return result;
1537 }
1538
IsNWebEx()1539 bool ArkWebNWebWrapper::IsNWebEx()
1540 {
1541 return ark_web_nweb_->IsNWebEx();
1542 }
1543
SetEnableHalfFrameRate(bool enabled)1544 void ArkWebNWebWrapper::SetEnableHalfFrameRate(bool enabled)
1545 {
1546 ark_web_nweb_->SetEnableHalfFrameRate(enabled);
1547 }
1548
MaximizeResize()1549 void ArkWebNWebWrapper::MaximizeResize()
1550 {
1551 ark_web_nweb_->MaximizeResize();
1552 }
1553
OnDragAttach()1554 void ArkWebNWebWrapper::OnDragAttach()
1555 {
1556 ark_web_nweb_->OnDragAttach();
1557 }
1558
SetFocusByPosition(float x,float y)1559 bool ArkWebNWebWrapper::SetFocusByPosition(float x, float y)
1560 {
1561 return ark_web_nweb_->SetFocusByPosition(x, y);
1562 }
1563
SetSurfaceDensity(const double & density)1564 void ArkWebNWebWrapper::SetSurfaceDensity(const double& density)
1565 {
1566 ark_web_nweb_->SetSurfaceDensity(density);
1567 }
1568
SetBorderRadiusFromWeb(double borderRadiusTopLeft,double borderRadiusTopRight,double borderRadiusBottomLeft,double borderRadiusBottomRight)1569 void ArkWebNWebWrapper::SetBorderRadiusFromWeb(double borderRadiusTopLeft, double borderRadiusTopRight,
1570 double borderRadiusBottomLeft, double borderRadiusBottomRight)
1571 {
1572 ark_web_nweb_->SetBorderRadiusFromWeb(
1573 borderRadiusTopLeft, borderRadiusTopRight, borderRadiusBottomLeft, borderRadiusBottomRight);
1574 }
1575
SetNativeInnerWeb(bool isInnerWeb)1576 void ArkWebNWebWrapper::SetNativeInnerWeb(bool isInnerWeb)
1577 {
1578 ark_web_nweb_->SetNativeInnerWeb(isInnerWeb);
1579 }
1580
SendAccessibilityHoverEventV2(int32_t x,int32_t y,bool isHoverEnter)1581 void ArkWebNWebWrapper::SendAccessibilityHoverEventV2(int32_t x, int32_t y, bool isHoverEnter)
1582 {
1583 ark_web_nweb_->SendAccessibilityHoverEventV2(x, y, isHoverEnter);
1584 }
1585
OnBrowserForeground()1586 void ArkWebNWebWrapper::OnBrowserForeground()
1587 {
1588 ark_web_nweb_->OnBrowserForeground();
1589 }
1590
OnBrowserBackground()1591 void ArkWebNWebWrapper::OnBrowserBackground()
1592 {
1593 ark_web_nweb_->OnBrowserBackground();
1594 }
1595
RegisterNativeJavaScriptProxy(const std::string & objName,const std::vector<std::string> & methodName,std::shared_ptr<OHOS::NWeb::NWebJsProxyMethod> data,bool isAsync,const std::string & permission)1596 void ArkWebNWebWrapper::RegisterNativeJavaScriptProxy(const std::string& objName,
1597 const std::vector<std::string>& methodName, std::shared_ptr<OHOS::NWeb::NWebJsProxyMethod> data,
1598 bool isAsync, const std::string& permission)
1599 {
1600 ArkWebString stObjName = ArkWebStringClassToStruct(objName);
1601 ArkWebStringVector stMethodName = ArkWebStringVectorClassToStruct(methodName);
1602 ArkWebString stPermission = ArkWebStringClassToStruct(permission);
1603
1604 if (CHECK_SHARED_PTR_IS_NULL(data)) {
1605 ark_web_nweb_->RegisterNativeJavaScriptProxy(stObjName,
1606 stMethodName,
1607 nullptr,
1608 isAsync,
1609 stPermission);
1610 } else {
1611 ark_web_nweb_->RegisterNativeJavaScriptProxy(stObjName,
1612 stMethodName,
1613 new ArkWebJsProxyMethodImpl(data),
1614 isAsync,
1615 stPermission);
1616 }
1617
1618 ArkWebStringStructRelease(stObjName);
1619 ArkWebStringVectorStructRelease(stMethodName);
1620 ArkWebStringStructRelease(stPermission);
1621 }
1622
SetFocusWindowId(uint32_t focus_window_id)1623 void ArkWebNWebWrapper::SetFocusWindowId(uint32_t focus_window_id)
1624 {
1625 ark_web_nweb_->SetFocusWindowId(focus_window_id);
1626 }
1627
RunDataDetectorJS()1628 void ArkWebNWebWrapper::RunDataDetectorJS()
1629 {
1630 ark_web_nweb_->RunDataDetectorJS();
1631 }
1632
SetDataDetectorEnable(bool enable)1633 void ArkWebNWebWrapper::SetDataDetectorEnable(bool enable)
1634 {
1635 ark_web_nweb_->SetDataDetectorEnable(enable);
1636 }
1637
OnDataDetectorSelectText()1638 void ArkWebNWebWrapper::OnDataDetectorSelectText()
1639 {
1640 ark_web_nweb_->OnDataDetectorSelectText();
1641 }
1642
OnDataDetectorCopy(const std::vector<std::string> & recordMix)1643 void ArkWebNWebWrapper::OnDataDetectorCopy(const std::vector<std::string>& recordMix)
1644 {
1645 ArkWebStringVector cRecordMix = ArkWebStringVectorClassToStruct(recordMix);
1646 ark_web_nweb_->OnDataDetectorCopy(cRecordMix);
1647 ArkWebStringVectorStructRelease(cRecordMix);
1648 }
1649
SetPipNativeWindow(int delegate_id,int child_id,int frame_routing_id,void * window)1650 void ArkWebNWebWrapper::SetPipNativeWindow(int delegate_id,
1651 int child_id,
1652 int frame_routing_id,
1653 void* window)
1654 {
1655 ark_web_nweb_->SetPipNativeWindow(delegate_id, child_id,
1656 frame_routing_id, window);
1657 }
1658
SendPipEvent(int delegate_id,int child_id,int frame_routing_id,int event)1659 void ArkWebNWebWrapper::SendPipEvent(int delegate_id,
1660 int child_id,
1661 int frame_routing_id,
1662 int event)
1663 {
1664 ark_web_nweb_->SendPipEvent(delegate_id, child_id,
1665 frame_routing_id, event);
1666 }
1667
SetBlanklessLoadingKey(const std::string & key)1668 void ArkWebNWebWrapper::SetBlanklessLoadingKey(const std::string& key)
1669 {
1670 ArkWebString stKey = ArkWebStringClassToStruct(key);
1671
1672 ark_web_nweb_->SetBlanklessLoadingKey(stKey);
1673
1674 ArkWebStringStructRelease(stKey);
1675 }
1676
SetPrivacyStatus(bool isPrivate)1677 void ArkWebNWebWrapper::SetPrivacyStatus(bool isPrivate)
1678 {
1679 ark_web_nweb_->SetPrivacyStatus(isPrivate);
1680 }
1681
GetSelectStartIndex()1682 int ArkWebNWebWrapper::GetSelectStartIndex()
1683 {
1684 return ark_web_nweb_->GetSelectStartIndex();
1685 }
1686
GetSelectEndIndex()1687 int ArkWebNWebWrapper::GetSelectEndIndex()
1688 {
1689 return ark_web_nweb_->GetSelectEndIndex();
1690 }
1691
GetAllTextInfo()1692 std::string ArkWebNWebWrapper::GetAllTextInfo()
1693 {
1694 ArkWebString allTextInfo = ark_web_nweb_->GetAllTextInfo();
1695 std::string allText = ArkWebStringStructToClass(allTextInfo);
1696 ArkWebStringStructRelease(allTextInfo);
1697 return allText;
1698 }
1699
SetAudioSessionType(int32_t audio_session_type)1700 void ArkWebNWebWrapper::SetAudioSessionType(int32_t audio_session_type)
1701 {
1702 ark_web_nweb_->SetAudioSessionType(audio_session_type);
1703 }
1704
GetWebAccessibilityIdByHtmlElementId(const std::string & htmlElementId)1705 int64_t ArkWebNWebWrapper::GetWebAccessibilityIdByHtmlElementId(const std::string& htmlElementId)
1706 {
1707 ArkWebString stHtmlElementId = ArkWebStringClassToStruct(htmlElementId);
1708 int64_t ark_web_accessibility_Id = ark_web_nweb_->GetWebAccessibilityIdByHtmlElementId(stHtmlElementId);
1709 ArkWebStringStructRelease(stHtmlElementId);
1710 return ark_web_accessibility_Id;
1711 }
1712
GetBlanklessInfoWithKey(const std::string & key,double * similarity,int32_t * loadingTime)1713 int32_t ArkWebNWebWrapper::GetBlanklessInfoWithKey(const std::string& key, double* similarity, int32_t* loadingTime)
1714 {
1715 ArkWebString stKey = ArkWebStringClassToStruct(key);
1716
1717 int32_t errCode = ark_web_nweb_->GetBlanklessInfoWithKey(stKey, similarity, loadingTime);
1718
1719 ArkWebStringStructRelease(stKey);
1720 return errCode;
1721 }
1722
SetBlanklessLoadingWithKey(const std::string & key,bool isStart)1723 int32_t ArkWebNWebWrapper::SetBlanklessLoadingWithKey(const std::string& key, bool isStart)
1724 {
1725 ArkWebString stKey = ArkWebStringClassToStruct(key);
1726
1727 int32_t errCode = ark_web_nweb_->SetBlanklessLoadingWithKey(stKey, isStart);
1728
1729 ArkWebStringStructRelease(stKey);
1730 return errCode;
1731 }
1732
UpdateSingleHandleVisible(bool isVisible)1733 void ArkWebNWebWrapper::UpdateSingleHandleVisible(bool isVisible)
1734 {
1735 ark_web_nweb_->UpdateSingleHandleVisible(isVisible);
1736 }
1737
SetTouchHandleExistState(bool touchHandleExist)1738 void ArkWebNWebWrapper::SetTouchHandleExistState(bool touchHandleExist)
1739 {
1740 ark_web_nweb_->SetTouchHandleExistState(touchHandleExist);
1741 }
1742
AvoidVisibleViewportBottom(int32_t avoidHeight)1743 void ArkWebNWebWrapper::AvoidVisibleViewportBottom(int32_t avoidHeight)
1744 {
1745 ark_web_nweb_->AvoidVisibleViewportBottom(avoidHeight);
1746 }
1747
GetVisibleViewportAvoidHeight()1748 int32_t ArkWebNWebWrapper::GetVisibleViewportAvoidHeight()
1749 {
1750 return ark_web_nweb_->GetVisibleViewportAvoidHeight();
1751 }
1752
TriggerBlanklessForUrl(const std::string & url)1753 bool ArkWebNWebWrapper::TriggerBlanklessForUrl(const std::string& url)
1754 {
1755 ArkWebString url_ = ArkWebStringClassToStruct(url);
1756 bool ret = ark_web_nweb_->TriggerBlanklessForUrl(url_);
1757 ArkWebStringStructRelease(url_);
1758 return ret;
1759 }
1760
SetVisibility(bool isVisible)1761 void ArkWebNWebWrapper::SetVisibility(bool isVisible)
1762 {
1763 ark_web_nweb_->SetVisibility(isVisible);
1764 }
1765
SetViewportScaleState()1766 void ArkWebNWebWrapper::SetViewportScaleState()
1767 {
1768 ark_web_nweb_->SetViewportScaleState();
1769 }
1770
GetPageOffset(float * offset_x,float * offset_y)1771 void ArkWebNWebWrapper::GetPageOffset(float* offset_x, float* offset_y)
1772 {
1773 ark_web_nweb_->GetPageOffset(offset_x, offset_y);
1774 }
1775
SetErrorPageEnabled(bool enable)1776 void ArkWebNWebWrapper::SetErrorPageEnabled(bool enable)
1777 {
1778 ark_web_nweb_->SetErrorPageEnabled(enable);
1779 }
1780
GetErrorPageEnabled()1781 bool ArkWebNWebWrapper::GetErrorPageEnabled()
1782 {
1783 return ark_web_nweb_->GetErrorPageEnabled();
1784 }
1785
GetWebDestroyMode()1786 ArkWebDestroyMode ArkWebNWebWrapper::GetWebDestroyMode()
1787 {
1788 int res = ark_web_nweb_->GetWebDestroyMode();
1789 return static_cast<ArkWebDestroyMode>(res);
1790 }
1791
CallH5FunctionV2(int32_t routing_id,int32_t h5_object_id,const std::string & h5_method_name,const std::vector<std::shared_ptr<OHOS::NWeb::NWebRomValue>> & args)1792 void ArkWebNWebWrapper::CallH5FunctionV2(int32_t routing_id, int32_t h5_object_id, const std::string& h5_method_name,
1793 const std::vector<std::shared_ptr<OHOS::NWeb::NWebRomValue>>& args)
1794 {
1795 ArkWebString stH5MethodName = ArkWebStringClassToStruct(h5_method_name);
1796 ArkWebRomValueVector stArgs = ArkWebRomValueVectorClassToStruct(args);
1797 ark_web_nweb_->CallH5FunctionV2(routing_id, h5_object_id, stH5MethodName, stArgs);
1798 ArkWebStringStructRelease(stH5MethodName);
1799 ArkWebRomValueVectorStructRelease(stArgs);
1800 }
1801
PostPortMessageV2(const std::string & portHandle,std::shared_ptr<OHOS::NWeb::NWebRomValue> data)1802 void ArkWebNWebWrapper::PostPortMessageV2(const std::string& portHandle, std::shared_ptr<OHOS::NWeb::NWebRomValue> data)
1803 {
1804 ArkWebString stPortHandle = ArkWebStringClassToStruct(portHandle);
1805 if (CHECK_SHARED_PTR_IS_NULL(data)) {
1806 ark_web_nweb_->PostPortMessageV2(stPortHandle, nullptr);
1807 } else {
1808 ark_web_nweb_->PostPortMessageV2(stPortHandle, new ArkWebRomValueImpl(data));
1809 }
1810 ArkWebStringStructRelease(stPortHandle);
1811 }
1812
FillAutofillDataV2(std::shared_ptr<OHOS::NWeb::NWebRomValue> data)1813 void ArkWebNWebWrapper::FillAutofillDataV2(std::shared_ptr<OHOS::NWeb::NWebRomValue> data)
1814 {
1815 if (CHECK_SHARED_PTR_IS_NULL(data)) {
1816 ark_web_nweb_->FillAutofillDataV2(nullptr);
1817 return;
1818 }
1819
1820 ark_web_nweb_->FillAutofillDataV2(new ArkWebRomValueImpl(data));
1821 }
1822 } // namespace OHOS::ArkWeb
1823