• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "core/interfaces/native/node/web_modifier.h"
16 
17 #include "bridge/common/utils/utils.h"
18 #include "core/components_ng/pattern/web/web_model_ng.h"
19 #include "core/interfaces/native/node/node_drag_modifier.h"
20 #include "core/pipeline_ng/pipeline_context.h"
21 
22 namespace OHOS::Ace::NG {
23 namespace {
24 constexpr bool DEFAULT_JS_ACCESS_ENABLED = true;
25 constexpr bool DEFAULT_FILE_ACCESS_ENABLED = false;
26 constexpr bool DEFAULT_DOM_STORAGE_ACCESS_ENABLED = false;
27 constexpr MixedModeContent DEFAULT_MIXED_MODE = MixedModeContent::MIXED_CONTENT_NEVER_ALLOW;
28 constexpr int32_t DEFAULT_ZOOM_ACCESS_ENABLED = true;
29 constexpr WebCacheMode DEFAULT_CACHE_MODE = WebCacheMode::DEFAULT;
30 constexpr WebDarkMode DEFAULT_DARK_MODE = WebDarkMode::Off;
31 constexpr int32_t DEFAULT_MULTIWINDOW_ACCESS_ENABLED = false;
32 constexpr int32_t DEFAULT_ALLOW_WINDOWOPEN_METHOD = false;
33 constexpr WebKeyboardAvoidMode DEFAULT_KEYBOARD_AVOID_MODE = WebKeyboardAvoidMode::RESIZE_VISUAL;
34 constexpr bool DEFAULT_VERTICAL_SCROLL_BAR_ACCESS_ENABLED = false;
35 constexpr bool DEFAULT_HORIZONTAL_SCROLL_BAR_ACCESS_ENABLED = false;
36 constexpr int32_t DEFAULT_TEXT_ZOOM_RATIO = 100;
37 constexpr float DEFAULT_INITIAL_SCALE = 100.0f;
38 constexpr bool DEFAULT_GEOLOCATION_ACCESS_ENABLED = false;
39 constexpr bool DEFAULT_DATABASE_ACCESS_ENABLED = false;
40 constexpr bool DEFAULT_OVERVIEW_MODE_ACCESS = false;
41 constexpr bool DEFAULT_FORCEDARK_ACCESS_ENABLED = false;
42 constexpr bool DEFAULT_PINCH_SMOOTH_ENABLED = false;
43 constexpr bool DEFAULT_META_VIEWPORT_ENABLED = true;
44 constexpr bool DEFAULT_ENABLE_FOLLOW_SYSTEM_FONT_WEIGHT = false;
45 constexpr bool DEFAULT_NATIVE_EMBED_MODE_ENABLE = false;
46 constexpr int32_t DEFAULT_MINFONT_SIZE = 8;
47 constexpr int32_t DEFAULT_DEFAULTFONT_SIZE = 16;
48 constexpr int32_t DEFAULT_DEFAULTFIXEDFONT_SIZE = 13;
49 constexpr int32_t DEFAULT_MINLOGICALFONT_SIZE = 8;
50 constexpr char DEFAULT_WEBSTANDARD_FONT[] = "sans serif";
51 constexpr char DEFAULT_WEBSERIF_FONT[] = "serif";
52 constexpr char DEFAULT_WEBSANSSERIF_FONT[] = "sans-serif";
53 constexpr char DEFAULT_WEBFIXED_FONT[] = "monospace";
54 constexpr char DEFAULT_WEBFANTASY_FONT[] = "fantasy";
55 constexpr char DEFAULT_WEBCURSIVE_FONT[] = "cursive";
56 constexpr WebLayoutMode DEFAULT_LAYOUT_MODE = WebLayoutMode::NONE;
57 constexpr bool DEFAULT_NATIVE_EMBED_OPTIONS = false;
58 constexpr bool DEFAULT_IMAGE_ACCESS_ENABLED = false;
59 constexpr bool DEFAULT_ONLINE_IMAGE_ACCESS_ENABLED = false;
60 constexpr bool MEDIA_PLAY_GESTURE_ACCESS_ENABLED = true;
61 constexpr bool DEFAULT_MEDIA_OPTIONS_ENABLED = true;
62 constexpr int32_t DEFAULT_RESUMEINTERVAL = 0;
63 constexpr CopyOptions DEFAULT_COPY_OPTIONS_VALUE = CopyOptions::Local;
64 constexpr bool DEFAULT_BLOCK_NETWORK_ENABLED = false;
65 constexpr OverScrollMode DEFAULT_OVERSCROLL_MODE = OverScrollMode::NEVER;
66 constexpr GestureFocusMode DEFAULT_GESTURE_FOCUS_MODE = GestureFocusMode::DEFAULT;
67 } // namespace
68 
SetJavaScriptAccess(ArkUINodeHandle node,ArkUI_Bool value)69 void SetJavaScriptAccess(ArkUINodeHandle node, ArkUI_Bool value)
70 {
71     auto* frameNode = reinterpret_cast<FrameNode*>(node);
72     CHECK_NULL_VOID(frameNode);
73     WebModelNG::SetJsEnabled(frameNode, value);
74 }
75 
ResetJavaScriptAccess(ArkUINodeHandle node)76 void ResetJavaScriptAccess(ArkUINodeHandle node)
77 {
78     auto* frameNode = reinterpret_cast<FrameNode*>(node);
79     CHECK_NULL_VOID(frameNode);
80     WebModelNG::SetJsEnabled(frameNode, DEFAULT_JS_ACCESS_ENABLED);
81 }
82 
SetFileAccessEnabled(ArkUINodeHandle node,ArkUI_Bool value)83 void SetFileAccessEnabled(ArkUINodeHandle node, ArkUI_Bool value)
84 {
85     auto* frameNode = reinterpret_cast<FrameNode*>(node);
86     CHECK_NULL_VOID(frameNode);
87     WebModelNG::SetFileAccessEnabled(frameNode, value);
88 }
89 
ResetFileAccessEnabled(ArkUINodeHandle node)90 void ResetFileAccessEnabled(ArkUINodeHandle node)
91 {
92     auto* frameNode = reinterpret_cast<FrameNode*>(node);
93     CHECK_NULL_VOID(frameNode);
94     WebModelNG::SetFileAccessEnabled(frameNode, DEFAULT_FILE_ACCESS_ENABLED);
95 }
96 
SetDomStorageAccessEnabled(ArkUINodeHandle node,ArkUI_Bool value)97 void SetDomStorageAccessEnabled(ArkUINodeHandle node, ArkUI_Bool value)
98 {
99     auto* frameNode = reinterpret_cast<FrameNode*>(node);
100     CHECK_NULL_VOID(frameNode);
101     WebModelNG::SetDomStorageAccessEnabled(frameNode, value);
102 }
103 
ResetDomStorageAccessEnabled(ArkUINodeHandle node)104 void ResetDomStorageAccessEnabled(ArkUINodeHandle node)
105 {
106     auto* frameNode = reinterpret_cast<FrameNode*>(node);
107     CHECK_NULL_VOID(frameNode);
108     WebModelNG::SetDomStorageAccessEnabled(frameNode, DEFAULT_DOM_STORAGE_ACCESS_ENABLED);
109 }
110 
SetMixedMode(ArkUINodeHandle node,ArkUI_Int32 value)111 void SetMixedMode(ArkUINodeHandle node, ArkUI_Int32 value)
112 {
113     auto* frameNode = reinterpret_cast<FrameNode*>(node);
114     CHECK_NULL_VOID(frameNode);
115     auto mixedContentMode = MixedModeContent::MIXED_CONTENT_NEVER_ALLOW;
116     switch (value) {
117         case 0:
118             mixedContentMode = MixedModeContent::MIXED_CONTENT_ALWAYS_ALLOW;
119             break;
120         case 1:
121             mixedContentMode = MixedModeContent::MIXED_CONTENT_COMPATIBILITY_MODE;
122             break;
123         default:
124             mixedContentMode = MixedModeContent::MIXED_CONTENT_NEVER_ALLOW;
125             break;
126     }
127     WebModelNG::SetMixedMode(frameNode, MixedModeContent(mixedContentMode));
128 }
129 
ResetMixedMode(ArkUINodeHandle node)130 void ResetMixedMode(ArkUINodeHandle node)
131 {
132     auto* frameNode = reinterpret_cast<FrameNode*>(node);
133     CHECK_NULL_VOID(frameNode);
134     WebModelNG::SetMixedMode(frameNode, DEFAULT_MIXED_MODE);
135 }
136 
SetZoomAccessEnabled(ArkUINodeHandle node,ArkUI_Bool value)137 void SetZoomAccessEnabled(ArkUINodeHandle node, ArkUI_Bool value)
138 {
139     auto* frameNode = reinterpret_cast<FrameNode*>(node);
140     CHECK_NULL_VOID(frameNode);
141     WebModelNG::SetZoomAccessEnabled(frameNode, value);
142 }
143 
ResetZoomAccessEnabled(ArkUINodeHandle node)144 void ResetZoomAccessEnabled(ArkUINodeHandle node)
145 {
146     auto* frameNode = reinterpret_cast<FrameNode*>(node);
147     CHECK_NULL_VOID(frameNode);
148     WebModelNG::SetZoomAccessEnabled(frameNode, DEFAULT_ZOOM_ACCESS_ENABLED);
149 }
150 
SetCacheMode(ArkUINodeHandle node,ArkUI_Int32 value)151 void SetCacheMode(ArkUINodeHandle node, ArkUI_Int32 value)
152 {
153     auto* frameNode = reinterpret_cast<FrameNode*>(node);
154     CHECK_NULL_VOID(frameNode);
155     WebModelNG::SetCacheMode(frameNode, WebCacheMode(value));
156 }
157 
ResetCacheMode(ArkUINodeHandle node)158 void ResetCacheMode(ArkUINodeHandle node)
159 {
160     auto* frameNode = reinterpret_cast<FrameNode*>(node);
161     CHECK_NULL_VOID(frameNode);
162     WebModelNG::SetCacheMode(frameNode, DEFAULT_CACHE_MODE);
163 }
164 
SetDarkMode(ArkUINodeHandle node,ArkUI_Int32 value)165 void SetDarkMode(ArkUINodeHandle node, ArkUI_Int32 value)
166 {
167     auto* frameNode = reinterpret_cast<FrameNode*>(node);
168     CHECK_NULL_VOID(frameNode);
169     WebModelNG::SetDarkMode(frameNode, WebDarkMode(value));
170 }
171 
ResetDarkMode(ArkUINodeHandle node)172 void ResetDarkMode(ArkUINodeHandle node)
173 {
174     auto* frameNode = reinterpret_cast<FrameNode*>(node);
175     CHECK_NULL_VOID(frameNode);
176     WebModelNG::SetDarkMode(frameNode, DEFAULT_DARK_MODE);
177 }
178 
SetMultiWindowAccessEnabled(ArkUINodeHandle node,ArkUI_Bool value)179 void SetMultiWindowAccessEnabled(ArkUINodeHandle node, ArkUI_Bool value)
180 {
181     auto* frameNode = reinterpret_cast<FrameNode*>(node);
182     CHECK_NULL_VOID(frameNode);
183     WebModelNG::SetMultiWindowAccessEnabled(frameNode, value);
184 }
185 
ResetMultiWindowAccessEnabled(ArkUINodeHandle node)186 void ResetMultiWindowAccessEnabled(ArkUINodeHandle node)
187 {
188     auto* frameNode = reinterpret_cast<FrameNode*>(node);
189     CHECK_NULL_VOID(frameNode);
190     WebModelNG::SetMultiWindowAccessEnabled(frameNode, DEFAULT_MULTIWINDOW_ACCESS_ENABLED);
191 }
192 
SetAllowWindowOpenMethod(ArkUINodeHandle node,ArkUI_Bool value)193 void SetAllowWindowOpenMethod(ArkUINodeHandle node, ArkUI_Bool value)
194 {
195     auto* frameNode = reinterpret_cast<FrameNode*>(node);
196     CHECK_NULL_VOID(frameNode);
197     WebModelNG::SetAllowWindowOpenMethod(frameNode, value);
198 }
199 
ResetAllowWindowOpenMethod(ArkUINodeHandle node)200 void ResetAllowWindowOpenMethod(ArkUINodeHandle node)
201 {
202     auto* frameNode = reinterpret_cast<FrameNode*>(node);
203     CHECK_NULL_VOID(frameNode);
204     WebModelNG::SetAllowWindowOpenMethod(frameNode, DEFAULT_ALLOW_WINDOWOPEN_METHOD);
205 }
206 
SetKeyboardAvoidMode(ArkUINodeHandle node,ArkUI_Int32 value)207 void SetKeyboardAvoidMode(ArkUINodeHandle node, ArkUI_Int32 value)
208 {
209     auto* frameNode = reinterpret_cast<FrameNode*>(node);
210     CHECK_NULL_VOID(frameNode);
211     WebModelNG::SetKeyboardAvoidMode(frameNode, WebKeyboardAvoidMode(value));
212 }
213 
ResetKeyboardAvoidMode(ArkUINodeHandle node)214 void ResetKeyboardAvoidMode(ArkUINodeHandle node)
215 {
216     auto* frameNode = reinterpret_cast<FrameNode*>(node);
217     CHECK_NULL_VOID(frameNode);
218     WebModelNG::SetKeyboardAvoidMode(frameNode, DEFAULT_KEYBOARD_AVOID_MODE);
219 }
220 
SetOnControllerAttached(ArkUINodeHandle node,void * extraParam)221 void SetOnControllerAttached(ArkUINodeHandle node, void* extraParam)
222 {
223     auto* frameNode = reinterpret_cast<FrameNode*>(node);
224     CHECK_NULL_VOID(frameNode);
225     if (extraParam) {
226         auto onControllerAttached = reinterpret_cast<std::function<void()>*>(extraParam);
227         WebModelNG::SetOnControllerAttached(frameNode, std::move(*onControllerAttached));
228     } else {
229         WebModelNG::SetOnControllerAttached(frameNode, nullptr);
230     }
231 }
232 
ResetOnControllerAttached(ArkUINodeHandle node)233 void ResetOnControllerAttached(ArkUINodeHandle node)
234 {
235     auto* frameNode = reinterpret_cast<FrameNode*>(node);
236     CHECK_NULL_VOID(frameNode);
237     WebModelNG::SetOnControllerAttached(frameNode, nullptr);
238 }
239 
SetVerticalScrollBarAccessEnabled(ArkUINodeHandle node,ArkUI_Bool value)240 void SetVerticalScrollBarAccessEnabled(ArkUINodeHandle node, ArkUI_Bool value)
241 {
242     auto* frameNode = reinterpret_cast<FrameNode*>(node);
243     CHECK_NULL_VOID(frameNode);
244     WebModelNG::SetVerticalScrollBarAccessEnabled(frameNode, value);
245 }
246 
ResetVerticalScrollBarAccessEnabled(ArkUINodeHandle node)247 void ResetVerticalScrollBarAccessEnabled(ArkUINodeHandle node)
248 {
249     auto* frameNode = reinterpret_cast<FrameNode*>(node);
250     CHECK_NULL_VOID(frameNode);
251     WebModelNG::SetVerticalScrollBarAccessEnabled(frameNode, DEFAULT_VERTICAL_SCROLL_BAR_ACCESS_ENABLED);
252 }
253 
SetHorizontalScrollBarAccessEnabled(ArkUINodeHandle node,ArkUI_Bool value)254 void SetHorizontalScrollBarAccessEnabled(ArkUINodeHandle node, ArkUI_Bool value)
255 {
256     auto* frameNode = reinterpret_cast<FrameNode*>(node);
257     CHECK_NULL_VOID(frameNode);
258     WebModelNG::SetHorizontalScrollBarAccessEnabled(frameNode, value);
259 }
260 
ResetHorizontalScrollBarAccessEnabled(ArkUINodeHandle node)261 void ResetHorizontalScrollBarAccessEnabled(ArkUINodeHandle node)
262 {
263     auto* frameNode = reinterpret_cast<FrameNode*>(node);
264     CHECK_NULL_VOID(frameNode);
265     WebModelNG::SetHorizontalScrollBarAccessEnabled(frameNode, DEFAULT_HORIZONTAL_SCROLL_BAR_ACCESS_ENABLED);
266 }
267 
SetTextZoomRatio(ArkUINodeHandle node,ArkUI_Int32 value)268 void SetTextZoomRatio(ArkUINodeHandle node, ArkUI_Int32 value)
269 {
270     auto* frameNode = reinterpret_cast<FrameNode*>(node);
271     CHECK_NULL_VOID(frameNode);
272     WebModelNG::SetTextZoomRatio(frameNode, value);
273 }
274 
ResetTextZoomRatio(ArkUINodeHandle node)275 void ResetTextZoomRatio(ArkUINodeHandle node)
276 {
277     auto* frameNode = reinterpret_cast<FrameNode*>(node);
278     CHECK_NULL_VOID(frameNode);
279     WebModelNG::SetTextZoomRatio(frameNode, DEFAULT_TEXT_ZOOM_RATIO);
280 }
281 
SetInitialScale(ArkUINodeHandle node,ArkUI_Float32 value)282 void SetInitialScale(ArkUINodeHandle node, ArkUI_Float32 value)
283 {
284     auto* frameNode = reinterpret_cast<FrameNode*>(node);
285     CHECK_NULL_VOID(frameNode);
286     WebModelNG::InitialScale(frameNode, value);
287 }
288 
ResetInitialScale(ArkUINodeHandle node)289 void ResetInitialScale(ArkUINodeHandle node)
290 {
291     auto* frameNode = reinterpret_cast<FrameNode*>(node);
292     CHECK_NULL_VOID(frameNode);
293     WebModelNG::InitialScale(frameNode, DEFAULT_INITIAL_SCALE);
294 }
295 
SetOnScrollCallBack(ArkUINodeHandle node,void * extraParam)296 void SetOnScrollCallBack(ArkUINodeHandle node, void* extraParam)
297 {
298     auto* frameNode = reinterpret_cast<FrameNode*>(node);
299     CHECK_NULL_VOID(frameNode);
300     if (extraParam) {
301         auto* onScrollPtr = reinterpret_cast<std::function<void(WebOnScrollEvent&)>*>(extraParam);
302         CHECK_NULL_VOID(onScrollPtr);
303         auto callback = [onScrollCallback = *onScrollPtr](const BaseEventInfo* event) {
304             if (auto scrollEvent = static_cast<const WebOnScrollEvent*>(event)) {
305                 auto& nonConstEvent = const_cast<WebOnScrollEvent&>(*scrollEvent);
306                 onScrollCallback(nonConstEvent);
307             }
308         };
309         WebModelNG::SetOnScroll(frameNode, std::move(callback));
310     } else {
311         WebModelNG::SetOnScroll(frameNode, nullptr);
312     }
313 }
314 
ResetOnScrollCallBack(ArkUINodeHandle node)315 void ResetOnScrollCallBack(ArkUINodeHandle node)
316 {
317     auto* frameNode = reinterpret_cast<FrameNode*>(node);
318     CHECK_NULL_VOID(frameNode);
319     WebModelNG::SetOnScroll(frameNode, nullptr);
320 }
321 
SetOnOverScrollCallBack(ArkUINodeHandle node,void * extraParam)322 void SetOnOverScrollCallBack(ArkUINodeHandle node, void* extraParam)
323 {
324     auto* frameNode = reinterpret_cast<FrameNode*>(node);
325     CHECK_NULL_VOID(frameNode);
326     if (extraParam) {
327         auto* onOverScrollkPtr = reinterpret_cast<std::function<void(WebOnOverScrollEvent&)>*>(extraParam);
328         CHECK_NULL_VOID(onOverScrollkPtr);
329         auto callback = [onOverScrollkCallback = *onOverScrollkPtr](const BaseEventInfo* event) {
330             if (auto overScrollEvent = static_cast<const WebOnOverScrollEvent*>(event)) {
331                 auto& nonConstEvent = const_cast<WebOnOverScrollEvent&>(*overScrollEvent);
332                 onOverScrollkCallback(nonConstEvent);
333             }
334         };
335         WebModelNG::SetOnOverScroll(frameNode, std::move(callback));
336     } else {
337         WebModelNG::SetOnOverScroll(frameNode, nullptr);
338     }
339 }
340 
ResetOnOverScrollCallBack(ArkUINodeHandle node)341 void ResetOnOverScrollCallBack(ArkUINodeHandle node)
342 {
343     auto* frameNode = reinterpret_cast<FrameNode*>(node);
344     CHECK_NULL_VOID(frameNode);
345     WebModelNG::SetOnOverScroll(frameNode, nullptr);
346 }
347 
SetOnScaleChangeCallBack(ArkUINodeHandle node,void * extraParam)348 void SetOnScaleChangeCallBack(ArkUINodeHandle node, void* extraParam)
349 {
350     auto* frameNode = reinterpret_cast<FrameNode*>(node);
351     CHECK_NULL_VOID(frameNode);
352     if (extraParam) {
353         auto* scaleChangePtr = reinterpret_cast<std::function<void(ScaleChangeEvent&)>*>(extraParam);
354         CHECK_NULL_VOID(scaleChangePtr);
355         auto callback = [scaleChangeCallback = *scaleChangePtr](const BaseEventInfo* event) {
356             if (auto scaleChangeEvent = static_cast<const ScaleChangeEvent*>(event)) {
357                 auto& nonConstEvent = const_cast<ScaleChangeEvent&>(*scaleChangeEvent);
358                 scaleChangeCallback(nonConstEvent);
359             }
360         };
361         WebModelNG::SetOnScaleChange(frameNode, std::move(callback));
362     } else {
363         WebModelNG::SetOnScaleChange(frameNode, nullptr);
364     }
365 }
366 
ResetOnScaleChangeCallBack(ArkUINodeHandle node)367 void ResetOnScaleChangeCallBack(ArkUINodeHandle node)
368 {
369     auto* frameNode = reinterpret_cast<FrameNode*>(node);
370     CHECK_NULL_VOID(frameNode);
371     WebModelNG::SetOnScaleChange(frameNode, nullptr);
372 }
373 
SetOnRequestSelectedCallBack(ArkUINodeHandle node,void * extraParam)374 void SetOnRequestSelectedCallBack(ArkUINodeHandle node, void* extraParam)
375 {
376     auto* frameNode = reinterpret_cast<FrameNode*>(node);
377     CHECK_NULL_VOID(frameNode);
378     if (extraParam) {
379         auto* originalCallbackPtr = reinterpret_cast<std::function<void()>*>(extraParam);
380         CHECK_NULL_VOID(originalCallbackPtr);
381         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo*) { originalCallback(); };
382         WebModelNG::SetOnRequestFocus(frameNode, std::move(callback));
383     } else {
384         WebModelNG::SetOnRequestFocus(frameNode, nullptr);
385     }
386 }
387 
ResetOnRequestSelectedCallBack(ArkUINodeHandle node)388 void ResetOnRequestSelectedCallBack(ArkUINodeHandle node)
389 {
390     auto* frameNode = reinterpret_cast<FrameNode*>(node);
391     CHECK_NULL_VOID(frameNode);
392     WebModelNG::SetOnRequestFocus(frameNode, nullptr);
393 }
394 
SetOnContextMenuHideCallBack(ArkUINodeHandle node,void * extraParam)395 void SetOnContextMenuHideCallBack(ArkUINodeHandle node, void* extraParam)
396 {
397     auto* frameNode = reinterpret_cast<FrameNode*>(node);
398     CHECK_NULL_VOID(frameNode);
399     if (extraParam) {
400         auto* originalCallbackPtr = reinterpret_cast<std::function<void()>*>(extraParam);
401         CHECK_NULL_VOID(originalCallbackPtr);
402         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo*) { originalCallback(); };
403         WebModelNG::SetOnContextMenuHide(frameNode, std::move(callback));
404     } else {
405         WebModelNG::SetOnContextMenuHide(frameNode, nullptr);
406     }
407 }
408 
ResetOnContextMenuHideCallBack(ArkUINodeHandle node)409 void ResetOnContextMenuHideCallBack(ArkUINodeHandle node)
410 {
411     auto* frameNode = reinterpret_cast<FrameNode*>(node);
412     CHECK_NULL_VOID(frameNode);
413     WebModelNG::SetOnContextMenuHide(frameNode, nullptr);
414 }
415 
SetGeolocationAccess(ArkUINodeHandle node,ArkUI_Bool value)416 void SetGeolocationAccess(ArkUINodeHandle node, ArkUI_Bool value)
417 {
418     auto* frameNode = reinterpret_cast<FrameNode*>(node);
419     CHECK_NULL_VOID(frameNode);
420     WebModelNG::SetGeolocationAccessEnabled(frameNode, value);
421 }
422 
ResetGeolocationAccess(ArkUINodeHandle node)423 void ResetGeolocationAccess(ArkUINodeHandle node)
424 {
425     auto* frameNode = reinterpret_cast<FrameNode*>(node);
426     CHECK_NULL_VOID(frameNode);
427     WebModelNG::SetGeolocationAccessEnabled(frameNode, DEFAULT_GEOLOCATION_ACCESS_ENABLED);
428 }
429 
SetOnGeolocationShow(ArkUINodeHandle node,void * extraParam)430 void SetOnGeolocationShow(ArkUINodeHandle node, void* extraParam)
431 {
432     auto* frameNode = reinterpret_cast<FrameNode*>(node);
433     CHECK_NULL_VOID(frameNode);
434     if (extraParam) {
435         auto* originalCallbackPtr = reinterpret_cast<std::function<void(LoadWebGeolocationShowEvent&)>*>(extraParam);
436         std::function<void(const BaseEventInfo*)> adaptedCallback;
437         if (originalCallbackPtr) {
438             adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
439                 if (auto geoLocationEvent = static_cast<const LoadWebGeolocationShowEvent*>(event)) {
440                     auto& onGeolocationShow = const_cast<LoadWebGeolocationShowEvent&>(*geoLocationEvent);
441                     originalCallback(onGeolocationShow);
442                 }
443             };
444         }
445         WebModelNG::SetOnGeolocationShow(frameNode, std::move(adaptedCallback));
446     } else {
447         WebModelNG::SetOnGeolocationShow(frameNode, nullptr);
448     }
449 }
450 
ResetOnGeolocationShow(ArkUINodeHandle node)451 void ResetOnGeolocationShow(ArkUINodeHandle node)
452 {
453     auto* frameNode = reinterpret_cast<FrameNode*>(node);
454     CHECK_NULL_VOID(frameNode);
455     WebModelNG::SetOnGeolocationShow(frameNode, nullptr);
456 }
457 
SetDatabaseAccess(ArkUINodeHandle node,ArkUI_Bool value)458 void SetDatabaseAccess(ArkUINodeHandle node, ArkUI_Bool value)
459 {
460     auto* frameNode = reinterpret_cast<FrameNode*>(node);
461     CHECK_NULL_VOID(frameNode);
462     WebModelNG::SetDatabaseAccessEnabled(frameNode, value);
463 }
464 
ResetDatabaseAccess(ArkUINodeHandle node)465 void ResetDatabaseAccess(ArkUINodeHandle node)
466 {
467     auto* frameNode = reinterpret_cast<FrameNode*>(node);
468     CHECK_NULL_VOID(frameNode);
469     WebModelNG::SetDatabaseAccessEnabled(frameNode, DEFAULT_DATABASE_ACCESS_ENABLED);
470 }
471 
SetOverviewModeAccess(ArkUINodeHandle node,ArkUI_Bool value)472 void SetOverviewModeAccess(ArkUINodeHandle node, ArkUI_Bool value)
473 {
474     auto* frameNode = reinterpret_cast<FrameNode*>(node);
475     CHECK_NULL_VOID(frameNode);
476     WebModelNG::SetOverviewModeAccessEnabled(frameNode, value);
477 }
478 
ResetOverviewModeAccess(ArkUINodeHandle node)479 void ResetOverviewModeAccess(ArkUINodeHandle node)
480 {
481     auto* frameNode = reinterpret_cast<FrameNode*>(node);
482     CHECK_NULL_VOID(frameNode);
483     WebModelNG::SetOverviewModeAccessEnabled(frameNode, DEFAULT_OVERVIEW_MODE_ACCESS);
484 }
485 
SetForceDarkAccess(ArkUINodeHandle node,ArkUI_Bool value)486 void SetForceDarkAccess(ArkUINodeHandle node, ArkUI_Bool value)
487 {
488     auto* frameNode = reinterpret_cast<FrameNode*>(node);
489     CHECK_NULL_VOID(frameNode);
490     WebModelNG::SetForceDarkAccess(frameNode, value);
491 }
492 
ResetForceDarkAccess(ArkUINodeHandle node)493 void ResetForceDarkAccess(ArkUINodeHandle node)
494 {
495     auto* frameNode = reinterpret_cast<FrameNode*>(node);
496     CHECK_NULL_VOID(frameNode);
497     WebModelNG::SetForceDarkAccess(frameNode, DEFAULT_FORCEDARK_ACCESS_ENABLED);
498 }
499 
SetPinchSmooth(ArkUINodeHandle node,ArkUI_Bool value)500 void SetPinchSmooth(ArkUINodeHandle node, ArkUI_Bool value)
501 {
502     auto* frameNode = reinterpret_cast<FrameNode*>(node);
503     CHECK_NULL_VOID(frameNode);
504     WebModelNG::SetPinchSmoothModeEnabled(frameNode, value);
505 }
506 
ResetPinchSmooth(ArkUINodeHandle node)507 void ResetPinchSmooth(ArkUINodeHandle node)
508 {
509     auto* frameNode = reinterpret_cast<FrameNode*>(node);
510     CHECK_NULL_VOID(frameNode);
511     WebModelNG::SetPinchSmoothModeEnabled(frameNode, DEFAULT_PINCH_SMOOTH_ENABLED);
512 }
513 
SetMetaViewport(ArkUINodeHandle node,ArkUI_Bool value)514 void SetMetaViewport(ArkUINodeHandle node, ArkUI_Bool value)
515 {
516     auto* frameNode = reinterpret_cast<FrameNode*>(node);
517     CHECK_NULL_VOID(frameNode);
518     WebModelNG::SetMetaViewport(frameNode, value);
519 }
520 
ResetMetaViewport(ArkUINodeHandle node)521 void ResetMetaViewport(ArkUINodeHandle node)
522 {
523     auto* frameNode = reinterpret_cast<FrameNode*>(node);
524     CHECK_NULL_VOID(frameNode);
525     WebModelNG::SetMetaViewport(frameNode, DEFAULT_META_VIEWPORT_ENABLED);
526 }
527 
SetEnableFollowSystemFontWeight(ArkUINodeHandle node,ArkUI_Bool value)528 void SetEnableFollowSystemFontWeight(ArkUINodeHandle node, ArkUI_Bool value)
529 {
530     auto* frameNode = reinterpret_cast<FrameNode*>(node);
531     CHECK_NULL_VOID(frameNode);
532     WebModelNG::SetEnableFollowSystemFontWeight(frameNode, value);
533 }
534 
ResetEnableFollowSystemFontWeight(ArkUINodeHandle node)535 void ResetEnableFollowSystemFontWeight(ArkUINodeHandle node)
536 {
537     auto* frameNode = reinterpret_cast<FrameNode*>(node);
538     CHECK_NULL_VOID(frameNode);
539     WebModelNG::SetEnableFollowSystemFontWeight(frameNode, DEFAULT_ENABLE_FOLLOW_SYSTEM_FONT_WEIGHT);
540 }
541 
SetEnableNativeEmbedMode(ArkUINodeHandle node,ArkUI_Bool value)542 void SetEnableNativeEmbedMode(ArkUINodeHandle node, ArkUI_Bool value)
543 {
544     auto* frameNode = reinterpret_cast<FrameNode*>(node);
545     CHECK_NULL_VOID(frameNode);
546     WebModelNG::SetNativeEmbedModeEnabled(frameNode, value);
547 }
548 
ResetEnableNativeEmbedMode(ArkUINodeHandle node)549 void ResetEnableNativeEmbedMode(ArkUINodeHandle node)
550 {
551     auto* frameNode = reinterpret_cast<FrameNode*>(node);
552     CHECK_NULL_VOID(frameNode);
553     WebModelNG::SetNativeEmbedModeEnabled(frameNode, DEFAULT_NATIVE_EMBED_MODE_ENABLE);
554 }
555 
SetMinFontSize(ArkUINodeHandle node,ArkUI_Int32 value)556 void SetMinFontSize(ArkUINodeHandle node, ArkUI_Int32 value)
557 {
558     auto* frameNode = reinterpret_cast<FrameNode*>(node);
559     CHECK_NULL_VOID(frameNode);
560     WebModelNG::SetMinFontSize(frameNode, value);
561 }
562 
ResetMinFontSize(ArkUINodeHandle node)563 void ResetMinFontSize(ArkUINodeHandle node)
564 {
565     auto* frameNode = reinterpret_cast<FrameNode*>(node);
566     CHECK_NULL_VOID(frameNode);
567     WebModelNG::SetMinFontSize(frameNode, DEFAULT_MINFONT_SIZE);
568 }
569 
SetDefaultFontSize(ArkUINodeHandle node,ArkUI_Int32 value)570 void SetDefaultFontSize(ArkUINodeHandle node, ArkUI_Int32 value)
571 {
572     auto* frameNode = reinterpret_cast<FrameNode*>(node);
573     CHECK_NULL_VOID(frameNode);
574     WebModelNG::SetDefaultFontSize(frameNode, value);
575 }
576 
ResetDefaultFontSize(ArkUINodeHandle node)577 void ResetDefaultFontSize(ArkUINodeHandle node)
578 {
579     auto* frameNode = reinterpret_cast<FrameNode*>(node);
580     CHECK_NULL_VOID(frameNode);
581     WebModelNG::SetDefaultFontSize(frameNode, DEFAULT_DEFAULTFONT_SIZE);
582 }
583 
SetDefaultFixedFontSize(ArkUINodeHandle node,ArkUI_Int32 value)584 void SetDefaultFixedFontSize(ArkUINodeHandle node, ArkUI_Int32 value)
585 {
586     auto* frameNode = reinterpret_cast<FrameNode*>(node);
587     CHECK_NULL_VOID(frameNode);
588     WebModelNG::SetDefaultFixedFontSize(frameNode, value);
589 }
590 
ResetDefaultFixedFontSize(ArkUINodeHandle node)591 void ResetDefaultFixedFontSize(ArkUINodeHandle node)
592 {
593     auto* frameNode = reinterpret_cast<FrameNode*>(node);
594     CHECK_NULL_VOID(frameNode);
595     WebModelNG::SetDefaultFixedFontSize(frameNode, DEFAULT_DEFAULTFIXEDFONT_SIZE);
596 }
597 
SetMinLogicalFontSize(ArkUINodeHandle node,ArkUI_Int32 value)598 void SetMinLogicalFontSize(ArkUINodeHandle node, ArkUI_Int32 value)
599 {
600     auto* frameNode = reinterpret_cast<FrameNode*>(node);
601     CHECK_NULL_VOID(frameNode);
602     WebModelNG::SetMinLogicalFontSize(frameNode, value);
603 }
604 
ResetMinLogicalFontSize(ArkUINodeHandle node)605 void ResetMinLogicalFontSize(ArkUINodeHandle node)
606 {
607     auto* frameNode = reinterpret_cast<FrameNode*>(node);
608     CHECK_NULL_VOID(frameNode);
609     WebModelNG::SetMinLogicalFontSize(frameNode, DEFAULT_MINLOGICALFONT_SIZE);
610 }
611 
SetWebStandardFont(ArkUINodeHandle node,ArkUI_CharPtr value)612 void SetWebStandardFont(ArkUINodeHandle node, ArkUI_CharPtr value)
613 {
614     auto* frameNode = reinterpret_cast<FrameNode*>(node);
615     CHECK_NULL_VOID(frameNode);
616     WebModelNG::SetWebStandardFont(frameNode, std::string(value));
617 }
618 
ResetWebStandardFont(ArkUINodeHandle node)619 void ResetWebStandardFont(ArkUINodeHandle node)
620 {
621     auto* frameNode = reinterpret_cast<FrameNode*>(node);
622     CHECK_NULL_VOID(frameNode);
623     WebModelNG::SetWebStandardFont(frameNode, DEFAULT_WEBSTANDARD_FONT);
624 }
625 
SetWebSerifFont(ArkUINodeHandle node,ArkUI_CharPtr value)626 void SetWebSerifFont(ArkUINodeHandle node, ArkUI_CharPtr value)
627 {
628     auto* frameNode = reinterpret_cast<FrameNode*>(node);
629     CHECK_NULL_VOID(frameNode);
630     WebModelNG::SetWebSerifFont(frameNode, std::string(value));
631 }
632 
ResetWebSerifFont(ArkUINodeHandle node)633 void ResetWebSerifFont(ArkUINodeHandle node)
634 {
635     auto* frameNode = reinterpret_cast<FrameNode*>(node);
636     CHECK_NULL_VOID(frameNode);
637     WebModelNG::SetWebSerifFont(frameNode, DEFAULT_WEBSERIF_FONT);
638 }
639 
SetWebSansSerifFont(ArkUINodeHandle node,ArkUI_CharPtr value)640 void SetWebSansSerifFont(ArkUINodeHandle node, ArkUI_CharPtr value)
641 {
642     auto* frameNode = reinterpret_cast<FrameNode*>(node);
643     CHECK_NULL_VOID(frameNode);
644     WebModelNG::SetWebSansSerifFont(frameNode, std::string(value));
645 }
646 
ResetWebSansSerifFont(ArkUINodeHandle node)647 void ResetWebSansSerifFont(ArkUINodeHandle node)
648 {
649     auto* frameNode = reinterpret_cast<FrameNode*>(node);
650     CHECK_NULL_VOID(frameNode);
651     WebModelNG::SetWebSansSerifFont(frameNode, DEFAULT_WEBSANSSERIF_FONT);
652 }
653 
SetWebFixedFont(ArkUINodeHandle node,ArkUI_CharPtr value)654 void SetWebFixedFont(ArkUINodeHandle node, ArkUI_CharPtr value)
655 {
656     auto* frameNode = reinterpret_cast<FrameNode*>(node);
657     CHECK_NULL_VOID(frameNode);
658     WebModelNG::SetWebFixedFont(frameNode, std::string(value));
659 }
660 
ResetWebFixedFont(ArkUINodeHandle node)661 void ResetWebFixedFont(ArkUINodeHandle node)
662 {
663     auto* frameNode = reinterpret_cast<FrameNode*>(node);
664     CHECK_NULL_VOID(frameNode);
665     WebModelNG::SetWebFixedFont(frameNode, DEFAULT_WEBFIXED_FONT);
666 }
667 
SetWebFantasyFont(ArkUINodeHandle node,ArkUI_CharPtr value)668 void SetWebFantasyFont(ArkUINodeHandle node, ArkUI_CharPtr value)
669 {
670     auto* frameNode = reinterpret_cast<FrameNode*>(node);
671     CHECK_NULL_VOID(frameNode);
672     WebModelNG::SetWebFantasyFont(frameNode, std::string(value));
673 }
674 
ResetWebFantasyFont(ArkUINodeHandle node)675 void ResetWebFantasyFont(ArkUINodeHandle node)
676 {
677     auto* frameNode = reinterpret_cast<FrameNode*>(node);
678     CHECK_NULL_VOID(frameNode);
679     WebModelNG::SetWebFantasyFont(frameNode, DEFAULT_WEBFANTASY_FONT);
680 }
681 
SetWebCursiveFont(ArkUINodeHandle node,ArkUI_CharPtr value)682 void SetWebCursiveFont(ArkUINodeHandle node, ArkUI_CharPtr value)
683 {
684     auto* frameNode = reinterpret_cast<FrameNode*>(node);
685     CHECK_NULL_VOID(frameNode);
686     WebModelNG::SetWebCursiveFont(frameNode, std::string(value));
687 }
688 
ResetWebCursiveFont(ArkUINodeHandle node)689 void ResetWebCursiveFont(ArkUINodeHandle node)
690 {
691     auto* frameNode = reinterpret_cast<FrameNode*>(node);
692     CHECK_NULL_VOID(frameNode);
693     WebModelNG::SetWebCursiveFont(frameNode, DEFAULT_WEBCURSIVE_FONT);
694 }
695 
SetLayoutMode(ArkUINodeHandle node,ArkUI_Int32 value)696 void SetLayoutMode(ArkUINodeHandle node, ArkUI_Int32 value)
697 {
698     auto* frameNode = reinterpret_cast<FrameNode*>(node);
699     CHECK_NULL_VOID(frameNode);
700     WebModelNG::SetLayoutMode(frameNode, WebLayoutMode(value));
701 }
702 
ResetLayoutMode(ArkUINodeHandle node)703 void ResetLayoutMode(ArkUINodeHandle node)
704 {
705     auto* frameNode = reinterpret_cast<FrameNode*>(node);
706     CHECK_NULL_VOID(frameNode);
707     WebModelNG::SetLayoutMode(frameNode, DEFAULT_LAYOUT_MODE);
708 }
709 
SetOnNativeEmbedLifecycleChange(ArkUINodeHandle node,void * extraParam)710 void SetOnNativeEmbedLifecycleChange(ArkUINodeHandle node, void* extraParam)
711 {
712     auto* frameNode = reinterpret_cast<FrameNode*>(node);
713     CHECK_NULL_VOID(frameNode);
714     auto* originalCallbackPtr = reinterpret_cast<std::function<void(NativeEmbedDataInfo&)>*>(extraParam);
715     CHECK_NULL_VOID(originalCallbackPtr);
716     if (extraParam) {
717         auto adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
718             if (auto changeEvent = static_cast<const NativeEmbedDataInfo*>(event)) {
719                 auto& onNativeEmbedLifecycleChange = const_cast<NativeEmbedDataInfo&>(*changeEvent);
720                 originalCallback(onNativeEmbedLifecycleChange);
721             }
722         };
723         WebModelNG::SetNativeEmbedLifecycleChangeId(frameNode, std::move(adaptedCallback));
724     } else {
725         WebModelNG::SetNativeEmbedLifecycleChangeId(frameNode, nullptr);
726     }
727 }
728 
ResetOnNativeEmbedLifecycleChange(ArkUINodeHandle node)729 void ResetOnNativeEmbedLifecycleChange(ArkUINodeHandle node)
730 {
731     auto* frameNode = reinterpret_cast<FrameNode*>(node);
732     CHECK_NULL_VOID(frameNode);
733     WebModelNG::SetNativeEmbedLifecycleChangeId(frameNode, nullptr);
734 }
735 
SetOnNativeEmbedGestureEvent(ArkUINodeHandle node,void * extraParam)736 void SetOnNativeEmbedGestureEvent(ArkUINodeHandle node, void* extraParam)
737 {
738     auto* frameNode = reinterpret_cast<FrameNode*>(node);
739     CHECK_NULL_VOID(frameNode);
740     auto* originalCallbackPtr = reinterpret_cast<std::function<void(NativeEmbeadTouchInfo&)>*>(extraParam);
741     CHECK_NULL_VOID(originalCallbackPtr);
742     if (extraParam) {
743         auto adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
744             if (auto gestureEvent = static_cast<const NativeEmbeadTouchInfo*>(event)) {
745                 auto& onNativeEmbedGesture = const_cast<NativeEmbeadTouchInfo&>(*gestureEvent);
746                 originalCallback(onNativeEmbedGesture);
747             }
748         };
749         WebModelNG::SetNativeEmbedGestureEventId(frameNode, std::move(adaptedCallback));
750     } else {
751         WebModelNG::SetNativeEmbedGestureEventId(frameNode, nullptr);
752     }
753 }
754 
ResetOnNativeEmbedGestureEvent(ArkUINodeHandle node)755 void ResetOnNativeEmbedGestureEvent(ArkUINodeHandle node)
756 {
757     auto* frameNode = reinterpret_cast<FrameNode*>(node);
758     CHECK_NULL_VOID(frameNode);
759     WebModelNG::SetNativeEmbedGestureEventId(frameNode, nullptr);
760 }
761 
SetRegisterNativeEmbedRule(ArkUINodeHandle node,ArkUI_CharPtr tag,ArkUI_CharPtr type)762 void SetRegisterNativeEmbedRule(ArkUINodeHandle node, ArkUI_CharPtr tag, ArkUI_CharPtr type)
763 {
764     auto* frameNode = reinterpret_cast<FrameNode*>(node);
765     CHECK_NULL_VOID(frameNode);
766     WebModelNG::RegisterNativeEmbedRule(frameNode, tag, type);
767 }
768 
ResetRegisterNativeEmbedRule(ArkUINodeHandle node)769 void ResetRegisterNativeEmbedRule(ArkUINodeHandle node)
770 {
771     auto* frameNode = reinterpret_cast<FrameNode*>(node);
772     CHECK_NULL_VOID(frameNode);
773     WebModelNG::RegisterNativeEmbedRule(frameNode, nullptr, nullptr);
774 }
775 
SetNativeEmbedOptions(ArkUINodeHandle node,ArkUI_Bool value)776 void SetNativeEmbedOptions(ArkUINodeHandle node, ArkUI_Bool value)
777 {
778     auto* frameNode = reinterpret_cast<FrameNode*>(node);
779     CHECK_NULL_VOID(frameNode);
780     WebModelNG::SetIntrinsicSizeEnabled(frameNode, value);
781 }
782 
ResetNativeEmbedOptions(ArkUINodeHandle node)783 void ResetNativeEmbedOptions(ArkUINodeHandle node)
784 {
785     auto* frameNode = reinterpret_cast<FrameNode*>(node);
786     CHECK_NULL_VOID(frameNode);
787     WebModelNG::SetIntrinsicSizeEnabled(frameNode, DEFAULT_NATIVE_EMBED_OPTIONS);
788 }
789 
SetOnFirstContentfulPaint(ArkUINodeHandle node,void * extraParam)790 void SetOnFirstContentfulPaint(ArkUINodeHandle node, void* extraParam)
791 {
792     auto* frameNode = reinterpret_cast<FrameNode*>(node);
793     CHECK_NULL_VOID(frameNode);
794     auto* originalCallbackPtr = reinterpret_cast<std::function<void(AudioStateChangedEvent&)>*>(extraParam);
795     CHECK_NULL_VOID(originalCallbackPtr);
796     if (extraParam) {
797         auto adaptedCallback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
798             auto* onFirstContentfulPaint = static_cast<AudioStateChangedEvent*>(event.get());
799             if (onFirstContentfulPaint != nullptr) {
800                 originalCallback(*onFirstContentfulPaint);
801             }
802         };
803         WebModelNG::SetFirstContentfulPaintId(frameNode, std::move(adaptedCallback));
804     } else {
805         WebModelNG::SetFirstContentfulPaintId(frameNode, nullptr);
806     }
807 }
808 
ResetOnFirstContentfulPaint(ArkUINodeHandle node)809 void ResetOnFirstContentfulPaint(ArkUINodeHandle node)
810 {
811     auto* frameNode = reinterpret_cast<FrameNode*>(node);
812     CHECK_NULL_VOID(frameNode);
813     WebModelNG::SetFirstContentfulPaintId(frameNode, nullptr);
814 }
815 
SetOnAudioStateChanged(ArkUINodeHandle node,void * extraParam)816 void SetOnAudioStateChanged(ArkUINodeHandle node, void* extraParam)
817 {
818     auto* frameNode = reinterpret_cast<FrameNode*>(node);
819     CHECK_NULL_VOID(frameNode);
820     auto* originalCallbackPtr = reinterpret_cast<std::function<void(AudioStateChangedEvent&)>*>(extraParam);
821     CHECK_NULL_VOID(originalCallbackPtr);
822     if (extraParam) {
823         auto adaptedCallback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
824             auto* onAudioStateChanged = static_cast<AudioStateChangedEvent*>(event.get());
825             if (onAudioStateChanged != nullptr) {
826                 originalCallback(*onAudioStateChanged);
827             }
828         };
829         WebModelNG::SetAudioStateChangedId(frameNode, std::move(adaptedCallback));
830     } else {
831         WebModelNG::SetAudioStateChangedId(frameNode, nullptr);
832     }
833 }
834 
ResetOnAudioStateChanged(ArkUINodeHandle node)835 void ResetOnAudioStateChanged(ArkUINodeHandle node)
836 {
837     auto* frameNode = reinterpret_cast<FrameNode*>(node);
838     CHECK_NULL_VOID(frameNode);
839     WebModelNG::SetAudioStateChangedId(frameNode, nullptr);
840 }
841 
SetOnFullScreenExit(ArkUINodeHandle node,void * extraParam)842 void SetOnFullScreenExit(ArkUINodeHandle node, void* extraParam)
843 {
844     auto* frameNode = reinterpret_cast<FrameNode*>(node);
845     CHECK_NULL_VOID(frameNode);
846     if (extraParam) {
847         auto* originalCallbackPtr = reinterpret_cast<std::function<void()>*>(extraParam);
848         CHECK_NULL_VOID(originalCallbackPtr);
849         auto adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo*) { originalCallback(); };
850         WebModelNG::SetOnFullScreenExit(frameNode, std::move(adaptedCallback));
851     } else {
852         WebModelNG::SetOnFullScreenExit(frameNode, nullptr);
853     }
854 }
855 
856 
ResetOnFullScreenExit(ArkUINodeHandle node)857 void ResetOnFullScreenExit(ArkUINodeHandle node)
858 {
859     auto* frameNode = reinterpret_cast<FrameNode*>(node);
860     CHECK_NULL_VOID(frameNode);
861     WebModelNG::SetOnFullScreenExit(frameNode, nullptr);
862 }
863 
SetImageAccess(ArkUINodeHandle node,ArkUI_Bool value)864 void SetImageAccess(ArkUINodeHandle node, ArkUI_Bool value)
865 {
866     auto* frameNode = reinterpret_cast<FrameNode*>(node);
867     CHECK_NULL_VOID(frameNode);
868     WebModelNG::SetImageAccessEnabled(frameNode, value);
869 }
870 
ResetImageAccess(ArkUINodeHandle node)871 void ResetImageAccess(ArkUINodeHandle node)
872 {
873     auto* frameNode = reinterpret_cast<FrameNode*>(node);
874     CHECK_NULL_VOID(frameNode);
875     WebModelNG::SetImageAccessEnabled(frameNode, DEFAULT_IMAGE_ACCESS_ENABLED);
876 }
877 
SetOnlineImageAccess(ArkUINodeHandle node,ArkUI_Bool value)878 void SetOnlineImageAccess(ArkUINodeHandle node, ArkUI_Bool value)
879 {
880     auto* frameNode = reinterpret_cast<FrameNode*>(node);
881     CHECK_NULL_VOID(frameNode);
882     WebModelNG::SetOnLineImageAccessEnabled(frameNode, value);
883 }
884 
ResetOnlineImageAccess(ArkUINodeHandle node)885 void ResetOnlineImageAccess(ArkUINodeHandle node)
886 {
887     auto* frameNode = reinterpret_cast<FrameNode*>(node);
888     CHECK_NULL_VOID(frameNode);
889     WebModelNG::SetOnLineImageAccessEnabled(frameNode, DEFAULT_ONLINE_IMAGE_ACCESS_ENABLED);
890 }
891 
SetMediaPlayGestureAccess(ArkUINodeHandle node,ArkUI_Bool value)892 void SetMediaPlayGestureAccess(ArkUINodeHandle node, ArkUI_Bool value)
893 {
894     auto* frameNode = reinterpret_cast<FrameNode*>(node);
895     CHECK_NULL_VOID(frameNode);
896     WebModelNG::SetMediaPlayGestureAccess(frameNode, value);
897 }
898 
ResetMediaPlayGestureAccess(ArkUINodeHandle node)899 void ResetMediaPlayGestureAccess(ArkUINodeHandle node)
900 {
901     auto* frameNode = reinterpret_cast<FrameNode*>(node);
902     CHECK_NULL_VOID(frameNode);
903     WebModelNG::SetMediaPlayGestureAccess(frameNode, MEDIA_PLAY_GESTURE_ACCESS_ENABLED);
904 }
905 
SetMediaOptions(ArkUINodeHandle node,ArkUI_Int32 resumeInterval,ArkUI_Bool audioExclusive)906 void SetMediaOptions(ArkUINodeHandle node, ArkUI_Int32 resumeInterval, ArkUI_Bool audioExclusive)
907 {
908     auto* frameNode = reinterpret_cast<FrameNode*>(node);
909     CHECK_NULL_VOID(frameNode);
910     WebModelNG::SetAudioResumeInterval(frameNode, resumeInterval);
911     WebModelNG::SetAudioExclusive(frameNode, audioExclusive);
912 }
913 
ResetMediaOptions(ArkUINodeHandle node)914 void ResetMediaOptions(ArkUINodeHandle node)
915 {
916     auto* frameNode = reinterpret_cast<FrameNode*>(node);
917     CHECK_NULL_VOID(frameNode);
918     WebModelNG::SetAudioResumeInterval(frameNode, DEFAULT_RESUMEINTERVAL);
919     WebModelNG::SetAudioExclusive(frameNode, DEFAULT_MEDIA_OPTIONS_ENABLED);
920 }
SetOnPageEnd(ArkUINodeHandle node,void * extraParam)921 void SetOnPageEnd(ArkUINodeHandle node, void* extraParam)
922 {
923     auto* frameNode = reinterpret_cast<FrameNode*>(node);
924     CHECK_NULL_VOID(frameNode);
925     auto* originalCallbackPtr = reinterpret_cast<std::function<void(LoadWebPageFinishEvent&)>*>(extraParam);
926     std::function<void(const BaseEventInfo*)> adaptedCallback;
927     if (extraParam) {
928         if (originalCallbackPtr) {
929         adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
930             if (auto changeEvent = static_cast<const LoadWebPageFinishEvent*>(event)) {
931                 auto& nativeEmbedEvent = const_cast<LoadWebPageFinishEvent&>(*changeEvent);
932                 originalCallback(nativeEmbedEvent);
933             }
934         };
935         }
936         WebModelNG::SetOnPageFinish(frameNode, std::move(adaptedCallback));
937     } else {
938         WebModelNG::SetOnPageFinish(frameNode, nullptr);
939     }
940 }
941 
ResetOnPageEnd(ArkUINodeHandle node)942 void ResetOnPageEnd(ArkUINodeHandle node)
943 {
944     auto* frameNode = reinterpret_cast<FrameNode*>(node);
945     CHECK_NULL_VOID(frameNode);
946     WebModelNG::SetOnPageFinish(frameNode, nullptr);
947 }
948 
SetOnPageBegin(ArkUINodeHandle node,void * extraParam)949 void SetOnPageBegin(ArkUINodeHandle node, void* extraParam)
950 {
951     auto* frameNode = reinterpret_cast<FrameNode*>(node);
952     CHECK_NULL_VOID(frameNode);
953     auto* originalCallbackPtr = reinterpret_cast<std::function<void(LoadWebPageStartEvent&)>*>(extraParam);
954     std::function<void(const BaseEventInfo*)> adaptedCallback;
955     if (extraParam) {
956         if (originalCallbackPtr) {
957         adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
958             if (auto changeEvent = static_cast<const LoadWebPageStartEvent*>(event)) {
959                 auto& nativeEmbedEvent = const_cast<LoadWebPageStartEvent&>(*changeEvent);
960                 originalCallback(nativeEmbedEvent);
961             }
962         };
963         }
964         WebModelNG::SetOnPageStart(frameNode, std::move(adaptedCallback));
965     } else {
966         WebModelNG::SetOnPageStart(frameNode, nullptr);
967     }
968 }
969 
ResetOnPageBegin(ArkUINodeHandle node)970 void ResetOnPageBegin(ArkUINodeHandle node)
971 {
972     auto* frameNode = reinterpret_cast<FrameNode*>(node);
973     CHECK_NULL_VOID(frameNode);
974     WebModelNG::SetOnPageStart(frameNode, nullptr);
975 }
976 
SetOnProgressChange(ArkUINodeHandle node,void * extraParam)977 void SetOnProgressChange(ArkUINodeHandle node, void* extraParam)
978 {
979     auto* frameNode = reinterpret_cast<FrameNode*>(node);
980     CHECK_NULL_VOID(frameNode);
981     auto* originalCallbackPtr = reinterpret_cast<std::function<void(LoadWebProgressChangeEvent&)>*>(extraParam);
982     std::function<void(const BaseEventInfo*)> adaptedCallback;
983     if (extraParam) {
984         if (originalCallbackPtr) {
985         adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
986             if (auto changeEvent = static_cast<const LoadWebProgressChangeEvent*>(event)) {
987                 auto& nativeEmbedEvent = const_cast<LoadWebProgressChangeEvent&>(*changeEvent);
988                 originalCallback(nativeEmbedEvent);
989             }
990         };
991         }
992         WebModelNG::SetOnProgressChange(frameNode, std::move(adaptedCallback));
993     } else {
994         WebModelNG::SetOnProgressChange(frameNode, nullptr);
995     }
996 }
997 
ResetOnProgressChange(ArkUINodeHandle node)998 void ResetOnProgressChange(ArkUINodeHandle node)
999 {
1000     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1001     CHECK_NULL_VOID(frameNode);
1002     WebModelNG::SetOnProgressChange(frameNode, nullptr);
1003 }
1004 
SetOnTitleReceive(ArkUINodeHandle node,void * extraParam)1005 void SetOnTitleReceive(ArkUINodeHandle node, void* extraParam)
1006 {
1007     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1008     CHECK_NULL_VOID(frameNode);
1009     auto* originalCallbackPtr = reinterpret_cast<std::function<void(LoadWebTitleReceiveEvent&)>*>(extraParam);
1010     std::function<void(const BaseEventInfo*)> adaptedCallback;
1011     if (extraParam) {
1012         if (originalCallbackPtr) {
1013         adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1014             if (auto changeEvent = static_cast<const LoadWebTitleReceiveEvent*>(event)) {
1015                 auto& nativeEmbedEvent = const_cast<LoadWebTitleReceiveEvent&>(*changeEvent);
1016                 originalCallback(nativeEmbedEvent);
1017             }
1018         };
1019         }
1020         WebModelNG::SetOnTitleReceive(frameNode, std::move(adaptedCallback));
1021     } else {
1022         WebModelNG::SetOnTitleReceive(frameNode, nullptr);
1023     }
1024 }
1025 
ResetOnTitleReceive(ArkUINodeHandle node)1026 void ResetOnTitleReceive(ArkUINodeHandle node)
1027 {
1028     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1029     CHECK_NULL_VOID(frameNode);
1030     WebModelNG::SetOnTitleReceive(frameNode, nullptr);
1031 }
1032 
SetOnDownloadStart(ArkUINodeHandle node,void * extraParam)1033 void SetOnDownloadStart(ArkUINodeHandle node, void* extraParam)
1034 {
1035     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1036     CHECK_NULL_VOID(frameNode);
1037     auto* originalCallbackPtr = reinterpret_cast<std::function<void(DownloadStartEvent&)>*>(extraParam);
1038     std::function<void(const BaseEventInfo*)> adaptedCallback;
1039     if (extraParam) {
1040         if (originalCallbackPtr) {
1041         adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1042             if (auto changeEvent = static_cast<const DownloadStartEvent*>(event)) {
1043                 auto& nativeEmbedEvent = const_cast<DownloadStartEvent&>(*changeEvent);
1044                 originalCallback(nativeEmbedEvent);
1045             }
1046         };
1047         }
1048         WebModelNG::SetOnDownloadStart(frameNode, std::move(adaptedCallback));
1049     } else {
1050         WebModelNG::SetOnDownloadStart(frameNode, nullptr);
1051     }
1052 }
1053 
ResetOnDownloadStart(ArkUINodeHandle node)1054 void ResetOnDownloadStart(ArkUINodeHandle node)
1055 {
1056     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1057     CHECK_NULL_VOID(frameNode);
1058     WebModelNG::SetOnDownloadStart(frameNode, nullptr);
1059 }
1060 
SetJavaScriptOnDocumentStart(ArkUINodeHandle node,ArkUI_ScriptItemArray * values,ArkUI_Int32 size)1061 void SetJavaScriptOnDocumentStart(ArkUINodeHandle node, ArkUI_ScriptItemArray* values, ArkUI_Int32 size)
1062 {
1063     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1064     CHECK_NULL_VOID(frameNode);
1065     if (size <= 0) {
1066         return;
1067     }
1068     ScriptItems scriptInfos;
1069     for (int32_t i = 0; i < size; ++i) {
1070         std::string script;
1071         ScriptItemsByOrder scriptRules;
1072         std::string scriptStr(values[i].script);
1073         script = scriptStr;
1074         auto scriptRulesChar = values[i].scriptRules;
1075         auto scriptRulesSize = values[i].scriptRulesSize;
1076         ScriptItemsByOrder tmp;
1077         for (int32_t j = 0; j < scriptRulesSize; ++j) {
1078             std::string sc(scriptRulesChar[j]);
1079             tmp.push_back(sc);
1080         }
1081         scriptRules = tmp;
1082         scriptInfos.insert(std::make_pair(script, scriptRules));
1083     }
1084     WebModelNG::JavaScriptOnDocumentStart(frameNode, scriptInfos);
1085 }
1086 
ResetJavaScriptOnDocumentStart(ArkUINodeHandle node)1087 void ResetJavaScriptOnDocumentStart(ArkUINodeHandle node)
1088 {
1089     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1090     CHECK_NULL_VOID(frameNode);
1091     WebModelNG::JavaScriptOnDocumentStart(frameNode ,ScriptItems());
1092 }
1093 
SetJavaScriptOnDocumentEnd(ArkUINodeHandle node,ArkUI_ScriptItemArray * values,ArkUI_Int32 size)1094 void SetJavaScriptOnDocumentEnd(ArkUINodeHandle node, ArkUI_ScriptItemArray* values, ArkUI_Int32 size)
1095 {
1096     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1097     CHECK_NULL_VOID(frameNode);
1098     if (size <= 0) {
1099         return;
1100     }
1101     ScriptItems scriptInfos;
1102     for (int32_t i = 0; i < size; ++i) {
1103         std::string script;
1104         ScriptItemsByOrder scriptRules;
1105         std::string scriptStr(values[i].script);
1106         script = scriptStr;
1107         auto scriptRulesChar = values[i].scriptRules;
1108         auto scriptRulesSize = values[i].scriptRulesSize;
1109         ScriptItemsByOrder tmp;
1110         for (int32_t j = 0; j < scriptRulesSize; ++j) {
1111             std::string sc(scriptRulesChar[j]);
1112             tmp.push_back(sc);
1113         }
1114         scriptRules = tmp;
1115         scriptInfos.insert(std::make_pair(script, scriptRules));
1116     }
1117     WebModelNG::JavaScriptOnDocumentEnd(frameNode, scriptInfos);
1118 }
1119 
ResetJavaScriptOnDocumentEnd(ArkUINodeHandle node)1120 void ResetJavaScriptOnDocumentEnd(ArkUINodeHandle node)
1121 {
1122     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1123     CHECK_NULL_VOID(frameNode);
1124     WebModelNG::JavaScriptOnDocumentEnd(frameNode ,ScriptItems());
1125 }
1126 
SetCopyOptionMode(ArkUINodeHandle node,ArkUI_Int32 value)1127 void SetCopyOptionMode(ArkUINodeHandle node, ArkUI_Int32 value)
1128 {
1129     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1130     CHECK_NULL_VOID(frameNode);
1131     auto copyOptions = CopyOptions::Local;
1132     copyOptions = static_cast<CopyOptions>(value);
1133     WebModelNG::SetCopyOptionMode(frameNode, static_cast<CopyOptions>(copyOptions));
1134 }
1135 
ResetCopyOptionMode(ArkUINodeHandle node)1136 void ResetCopyOptionMode(ArkUINodeHandle node)
1137 {
1138     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1139     CHECK_NULL_VOID(frameNode);
1140     WebModelNG::SetCopyOptionMode(frameNode, DEFAULT_COPY_OPTIONS_VALUE);
1141 }
1142 
SetRenderProcessNotResponding(ArkUINodeHandle node,void * extraParam)1143 void SetRenderProcessNotResponding(ArkUINodeHandle node, void* extraParam)
1144 {
1145     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1146     CHECK_NULL_VOID(frameNode);
1147     auto* originalCallbackPtr = reinterpret_cast<std::function<void(RenderProcessNotRespondingEvent&)>*>(extraParam);
1148     std::function<void(const BaseEventInfo*)> adaptedCallback;
1149     if (extraParam) {
1150         if (originalCallbackPtr) {
1151         adaptedCallback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1152             if (auto changeEvent = static_cast<const RenderProcessNotRespondingEvent*>(event)) {
1153                 auto& nativeEmbedEvent = const_cast<RenderProcessNotRespondingEvent&>(*changeEvent);
1154                 originalCallback(nativeEmbedEvent);
1155             }
1156         };
1157         }
1158         WebModelNG::SetRenderProcessNotRespondingId(frameNode, std::move(adaptedCallback));
1159     } else {
1160         WebModelNG::SetRenderProcessNotRespondingId(frameNode, nullptr);
1161     }
1162 }
1163 
ResetRenderProcessNotResponding(ArkUINodeHandle node)1164 void ResetRenderProcessNotResponding(ArkUINodeHandle node)
1165 {
1166     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1167     CHECK_NULL_VOID(frameNode);
1168     WebModelNG::SetRenderProcessNotRespondingId(frameNode, nullptr);
1169 }
1170 
SetOnPageVisibleCallBack(ArkUINodeHandle node,void * extraParam)1171 void SetOnPageVisibleCallBack(ArkUINodeHandle node, void* extraParam)
1172 {
1173     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1174     CHECK_NULL_VOID(frameNode);
1175     if (extraParam) {
1176         auto* originalCallbackPtr = reinterpret_cast<std::function<void(PageVisibleEvent&)>*>(extraParam);
1177         CHECK_NULL_VOID(originalCallbackPtr);
1178         auto callback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
1179             auto* concreteEvent = static_cast<PageVisibleEvent*>(event.get());
1180             CHECK_NULL_VOID(originalCallback);
1181             originalCallback(*concreteEvent);
1182         };
1183         WebModelNG::SetOnPageVisible(frameNode, std::move(callback));
1184     } else {
1185         WebModelNG::SetOnPageVisible(frameNode, nullptr);
1186     }
1187 }
1188 
ResetOnPageVisibleCallBack(ArkUINodeHandle node)1189 void ResetOnPageVisibleCallBack(ArkUINodeHandle node)
1190 {
1191     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1192     CHECK_NULL_VOID(frameNode);
1193     WebModelNG::SetOnPageVisible(frameNode, nullptr);
1194 }
1195 
SetOnRenderExitedCallBack(ArkUINodeHandle node,void * extraParam)1196 void SetOnRenderExitedCallBack(ArkUINodeHandle node, void* extraParam)
1197 {
1198     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1199     CHECK_NULL_VOID(frameNode);
1200     if (extraParam) {
1201         auto* renderExitedPtr = reinterpret_cast<std::function<void(RenderExitedEvent&)>*>(extraParam);
1202         std::function<void(const BaseEventInfo*)> callback;
1203         CHECK_NULL_VOID(renderExitedPtr);
1204         callback = [renderExitedPtrCallback = *renderExitedPtr](const BaseEventInfo* event) {
1205             if (auto renderExitedEvent = static_cast<const RenderExitedEvent*>(event)) {
1206                 auto& nonConstEvent = const_cast<RenderExitedEvent&>(*renderExitedEvent);
1207                 renderExitedPtrCallback(nonConstEvent);
1208             }
1209         };
1210         WebModelNG::SetOnRenderExited(frameNode, std::move(callback));
1211     } else {
1212         WebModelNG::SetOnRenderExited(frameNode, nullptr);
1213     }
1214 }
1215 
ResetOnRenderExitedCallBack(ArkUINodeHandle node)1216 void ResetOnRenderExitedCallBack(ArkUINodeHandle node)
1217 {
1218     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1219     CHECK_NULL_VOID(frameNode);
1220     WebModelNG::SetOnRenderExited(frameNode, nullptr);
1221 }
1222 
SetBlockNetwork(ArkUINodeHandle node,ArkUI_Bool value)1223 void SetBlockNetwork(ArkUINodeHandle node, ArkUI_Bool value)
1224 {
1225     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1226     CHECK_NULL_VOID(frameNode);
1227     WebModelNG::SetBlockNetwork(frameNode, value);
1228 }
1229 
ResetBlockNetwork(ArkUINodeHandle node)1230 void ResetBlockNetwork(ArkUINodeHandle node)
1231 {
1232     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1233     CHECK_NULL_VOID(frameNode);
1234     WebModelNG::SetBlockNetwork(frameNode, DEFAULT_BLOCK_NETWORK_ENABLED);
1235 }
1236 
SetOnResourceLoadCallBack(ArkUINodeHandle node,void * extraParam)1237 void SetOnResourceLoadCallBack(ArkUINodeHandle node, void* extraParam)
1238 {
1239     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1240     CHECK_NULL_VOID(frameNode);
1241     if (extraParam) {
1242         auto* resourceLoadPtr = reinterpret_cast<std::function<void(ResourceLoadEvent&)>*>(extraParam);
1243         CHECK_NULL_VOID(resourceLoadPtr);
1244         auto callback = [resourceLoadCallback = *resourceLoadPtr](const BaseEventInfo* event) {
1245             if (auto scrollEvent = static_cast<const ResourceLoadEvent*>(event)) {
1246                 auto& nonConstEvent = const_cast<ResourceLoadEvent&>(*scrollEvent);
1247                 resourceLoadCallback(nonConstEvent);
1248             }
1249         };
1250         WebModelNG::SetOnResourceLoad(frameNode, std::move(callback));
1251     } else {
1252         WebModelNG::SetOnResourceLoad(frameNode, nullptr);
1253     }
1254 }
1255 
ResetOnResourceLoadCallBack(ArkUINodeHandle node)1256 void ResetOnResourceLoadCallBack(ArkUINodeHandle node)
1257 {
1258     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1259     CHECK_NULL_VOID(frameNode);
1260     WebModelNG::SetOnResourceLoad(frameNode, nullptr);
1261 }
1262 
SetOnRefreshAccessedHistoryCallBack(ArkUINodeHandle node,void * extraParam)1263 void SetOnRefreshAccessedHistoryCallBack(ArkUINodeHandle node, void* extraParam)
1264 {
1265     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1266     CHECK_NULL_VOID(frameNode);
1267     if (extraParam) {
1268         auto* refreshAccessedHistoryPtr =
1269             reinterpret_cast<std::function<void(RefreshAccessedHistoryEvent&)>*>(extraParam);
1270         CHECK_NULL_VOID(refreshAccessedHistoryPtr);
1271         auto callback = [refreshAccessedHistoryCallback = *refreshAccessedHistoryPtr](const BaseEventInfo* event) {
1272             if (auto scrollEvent = static_cast<const RefreshAccessedHistoryEvent*>(event)) {
1273                 auto& nonConstEvent = const_cast<RefreshAccessedHistoryEvent&>(*scrollEvent);
1274                 refreshAccessedHistoryCallback(nonConstEvent);
1275             }
1276         };
1277         WebModelNG::SetOnRefreshAccessedHistory(frameNode, std::move(callback));
1278     } else {
1279         WebModelNG::SetOnRefreshAccessedHistory(frameNode, nullptr);
1280     }
1281 }
1282 
ResetOnRefreshAccessedHistoryCallBack(ArkUINodeHandle node)1283 void ResetOnRefreshAccessedHistoryCallBack(ArkUINodeHandle node)
1284 {
1285     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1286     CHECK_NULL_VOID(frameNode);
1287     WebModelNG::SetOnRefreshAccessedHistory(frameNode, nullptr);
1288 }
1289 
SetOnNavigationEntryCommittedCallBack(ArkUINodeHandle node,void * extraParam)1290 void SetOnNavigationEntryCommittedCallBack(ArkUINodeHandle node, void* extraParam)
1291 {
1292     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1293     CHECK_NULL_VOID(frameNode);
1294     if (extraParam) {
1295         auto* originalCallbackPtr = reinterpret_cast<std::function<void(NavigationEntryCommittedEvent&)>*>(extraParam);
1296         CHECK_NULL_VOID(originalCallbackPtr);
1297         auto callback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
1298             auto* concreteEvent = static_cast<NavigationEntryCommittedEvent*>(event.get());
1299             CHECK_NULL_VOID(originalCallback);
1300             originalCallback(*concreteEvent);
1301         };
1302         WebModelNG::SetOnNavigationEntryCommitted(frameNode, std::move(callback));
1303     } else {
1304         WebModelNG::SetOnNavigationEntryCommitted(frameNode, nullptr);
1305     }
1306 }
1307 
ResetOnNavigationEntryCommittedCallBack(ArkUINodeHandle node)1308 void ResetOnNavigationEntryCommittedCallBack(ArkUINodeHandle node)
1309 {
1310     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1311     CHECK_NULL_VOID(frameNode);
1312     WebModelNG::SetOnNavigationEntryCommitted(frameNode, nullptr);
1313 }
1314 
SetOnSearchResultReceiveCallBack(ArkUINodeHandle node,void * extraParam)1315 void SetOnSearchResultReceiveCallBack(ArkUINodeHandle node, void* extraParam)
1316 {
1317     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1318     CHECK_NULL_VOID(frameNode);
1319     if (extraParam) {
1320         auto* searchResultReceivePtr = reinterpret_cast<std::function<void(SearchResultReceiveEvent&)>*>(extraParam);
1321         CHECK_NULL_VOID(searchResultReceivePtr);
1322         auto callback = [searchResultReceiveCallback = *searchResultReceivePtr](const BaseEventInfo* event) {
1323             if (auto scrollEvent = static_cast<const SearchResultReceiveEvent*>(event)) {
1324                 auto& nonConstEvent = const_cast<SearchResultReceiveEvent&>(*scrollEvent);
1325                 searchResultReceiveCallback(nonConstEvent);
1326             }
1327         };
1328         WebModelNG::SetOnSearchResultReceive(frameNode, std::move(callback));
1329     } else {
1330         WebModelNG::SetOnSearchResultReceive(frameNode, nullptr);
1331     }
1332 }
1333 
ResetOnSearchResultReceiveCallBack(ArkUINodeHandle node)1334 void ResetOnSearchResultReceiveCallBack(ArkUINodeHandle node)
1335 {
1336     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1337     CHECK_NULL_VOID(frameNode);
1338     WebModelNG::SetOnSearchResultReceive(frameNode, nullptr);
1339 }
1340 
1341 
SetOverScrollMode(ArkUINodeHandle node,ArkUI_Int32 value)1342 void SetOverScrollMode(ArkUINodeHandle node, ArkUI_Int32 value)
1343 {
1344     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1345     CHECK_NULL_VOID(frameNode);
1346     WebModelNG::SetOverScrollMode(frameNode, OverScrollMode(value));
1347 }
1348 
ResetOverScrollMode(ArkUINodeHandle node)1349 void ResetOverScrollMode(ArkUINodeHandle node)
1350 {
1351     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1352     CHECK_NULL_VOID(frameNode);
1353     WebModelNG::SetOverScrollMode(frameNode, DEFAULT_OVERSCROLL_MODE);
1354 }
1355 
SetOnTouchIconUrlReceivedCallBack(ArkUINodeHandle node,void * extraParam)1356 void SetOnTouchIconUrlReceivedCallBack(ArkUINodeHandle node, void* extraParam)
1357 {
1358     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1359     CHECK_NULL_VOID(frameNode);
1360     if (extraParam) {
1361         auto* originalCallbackPtr = reinterpret_cast<std::function<void(TouchIconUrlEvent&)>*>(extraParam);
1362         CHECK_NULL_VOID(originalCallbackPtr);
1363         auto callback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
1364             auto* concreteEvent = static_cast<TouchIconUrlEvent*>(event.get());
1365             CHECK_NULL_VOID(originalCallback);
1366             originalCallback(*concreteEvent);
1367         };
1368         WebModelNG::SetOnTouchIconUrlReceived(frameNode, std::move(callback));
1369     } else {
1370         WebModelNG::SetOnTouchIconUrlReceived(frameNode, nullptr);
1371     }
1372 }
1373 
ResetOnTouchIconUrlReceivedCallBack(ArkUINodeHandle node)1374 void ResetOnTouchIconUrlReceivedCallBack(ArkUINodeHandle node)
1375 {
1376     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1377     CHECK_NULL_VOID(frameNode);
1378     WebModelNG::SetOnTouchIconUrlReceived(frameNode, nullptr);
1379 }
1380 
SetOnRenderProcessRespondingCallBack(ArkUINodeHandle node,void * extraParam)1381 void SetOnRenderProcessRespondingCallBack(ArkUINodeHandle node, void* extraParam)
1382 {
1383     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1384     CHECK_NULL_VOID(frameNode);
1385     if (extraParam) {
1386         auto* originalCallbackPtr = reinterpret_cast<std::function<void()>*>(extraParam);
1387         CHECK_NULL_VOID(originalCallbackPtr);
1388         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo*) { originalCallback(); };
1389         WebModelNG::SetOnRenderProcessResponding(frameNode, std::move(callback));
1390     } else {
1391         WebModelNG::SetOnRenderProcessResponding(frameNode, nullptr);
1392     }
1393 }
1394 
ResetOnRenderProcessRespondingCallBack(ArkUINodeHandle node)1395 void ResetOnRenderProcessRespondingCallBack(ArkUINodeHandle node)
1396 {
1397     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1398     CHECK_NULL_VOID(frameNode);
1399     WebModelNG::SetOnRenderProcessResponding(frameNode, nullptr);
1400 }
1401 
SetOnWindowNew(ArkUINodeHandle node,void * extraParam)1402 void SetOnWindowNew(ArkUINodeHandle node, void* extraParam)
1403 {
1404     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1405     CHECK_NULL_VOID(frameNode);
1406     auto* originalCallbackPtr = reinterpret_cast<std::function<void(WebWindowNewEvent&)>*>(extraParam);
1407     CHECK_NULL_VOID(originalCallbackPtr);
1408     if (extraParam) {
1409         auto adaptedCallback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
1410             auto* onWindowNew = static_cast<WebWindowNewEvent*>(event.get());
1411             if (onWindowNew != nullptr) {
1412                 originalCallback(*onWindowNew);
1413             }
1414         };
1415         WebModelNG::SetWindowNewEvent(frameNode, std::move(adaptedCallback));
1416     } else {
1417         WebModelNG::SetWindowNewEvent(frameNode, nullptr);
1418     }
1419 }
1420 
ResetOnWindowNew(ArkUINodeHandle node)1421 void ResetOnWindowNew(ArkUINodeHandle node)
1422 {
1423     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1424     CHECK_NULL_VOID(frameNode);
1425     WebModelNG::SetWindowNewEvent(frameNode, nullptr);
1426 }
1427 
SetOnPermissionRequest(ArkUINodeHandle node,void * extraParam)1428 void SetOnPermissionRequest(ArkUINodeHandle node, void* extraParam)
1429 {
1430     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1431     CHECK_NULL_VOID(frameNode);
1432     if (extraParam) {
1433         auto* eventPtr = reinterpret_cast<std::function<void(WebPermissionRequestEvent&)>*>(extraParam);
1434         CHECK_NULL_VOID(eventPtr);
1435         auto callback = [webPermissionRequestEventCallback = *eventPtr](const BaseEventInfo* event) {
1436             if (auto webPermissionRequestEvent = static_cast<const WebPermissionRequestEvent*>(event)) {
1437                 auto& nonConstEvent = const_cast<WebPermissionRequestEvent&>(*webPermissionRequestEvent);
1438                 webPermissionRequestEventCallback(nonConstEvent);
1439             }
1440         };
1441         WebModelNG::SetPermissionRequestEventId(frameNode, std::move(callback));
1442     } else {
1443         WebModelNG::SetPermissionRequestEventId(frameNode, nullptr);
1444     }
1445 }
1446 
ResetOnPermissionRequest(ArkUINodeHandle node)1447 void ResetOnPermissionRequest(ArkUINodeHandle node)
1448 {
1449     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1450     CHECK_NULL_VOID(frameNode);
1451     WebModelNG::SetPermissionRequestEventId(frameNode, nullptr);
1452 }
1453 
SetOnScreenCaptureRequest(ArkUINodeHandle node,void * extraParam)1454 void SetOnScreenCaptureRequest(ArkUINodeHandle node, void* extraParam)
1455 {
1456     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1457     CHECK_NULL_VOID(frameNode);
1458     if (extraParam) {
1459         auto* eventPtr = reinterpret_cast<std::function<void(WebScreenCaptureRequestEvent&)>*>(extraParam);
1460         CHECK_NULL_VOID(eventPtr);
1461         auto callback = [webScreenCaptureRequestEventCallback = *eventPtr](const BaseEventInfo* event) {
1462             if (auto webPermissionRequestEvent = static_cast<const WebScreenCaptureRequestEvent*>(event)) {
1463                 auto& nonConstEvent = const_cast<WebScreenCaptureRequestEvent&>(*webPermissionRequestEvent);
1464                 webScreenCaptureRequestEventCallback(nonConstEvent);
1465             }
1466         };
1467         WebModelNG::SetScreenCaptureRequestEventId(frameNode, std::move(callback));
1468     } else {
1469         WebModelNG::SetScreenCaptureRequestEventId(frameNode, nullptr);
1470     }
1471 }
1472 
ResetOnScreenCaptureRequest(ArkUINodeHandle node)1473 void ResetOnScreenCaptureRequest(ArkUINodeHandle node)
1474 {
1475     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1476     CHECK_NULL_VOID(frameNode);
1477     WebModelNG::SetScreenCaptureRequestEventId(frameNode, nullptr);
1478 }
1479 
SetOnFullScreenEnter(ArkUINodeHandle node,void * extraParam)1480 void SetOnFullScreenEnter(ArkUINodeHandle node, void* extraParam)
1481 {
1482     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1483     CHECK_NULL_VOID(frameNode);
1484     if (extraParam) {
1485         auto* originalCallbackPtr = reinterpret_cast<std::function<void(FullScreenEnterEvent&)>*>(extraParam);
1486         CHECK_NULL_VOID(originalCallbackPtr);
1487         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1488             if (auto scrollEvent = static_cast<const FullScreenEnterEvent*>(event)) {
1489                 auto& nonConstEvent = const_cast<FullScreenEnterEvent&>(*scrollEvent);
1490                 originalCallback(nonConstEvent);
1491                 return true;
1492             }
1493             return false;
1494         };
1495         WebModelNG::SetOnFullScreenEnter(frameNode, std::move(callback));
1496     } else {
1497         WebModelNG::SetOnFullScreenEnter(frameNode, nullptr);
1498     }
1499 }
1500 
ResetOnFullScreenEnter(ArkUINodeHandle node)1501 void ResetOnFullScreenEnter(ArkUINodeHandle node)
1502 {
1503     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1504     CHECK_NULL_VOID(frameNode);
1505     WebModelNG::SetOnFullScreenEnter(frameNode, nullptr);
1506 }
1507 
SetOnWindowExit(ArkUINodeHandle node,void * extraParam)1508 void SetOnWindowExit(ArkUINodeHandle node, void* extraParam)
1509 {
1510     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1511     CHECK_NULL_VOID(frameNode);
1512     if (extraParam) {
1513         auto* OnWindowExit = reinterpret_cast<std::function<void()>*>(extraParam);
1514         std::function<void(const BaseEventInfo*)> adaptedCallback;
1515         if (OnWindowExit) {
1516             adaptedCallback = [originalCallback = *OnWindowExit](const BaseEventInfo*) { originalCallback(); };
1517         }
1518         WebModelNG::SetWindowExitEventId(frameNode, std::move(adaptedCallback));
1519     } else {
1520         WebModelNG::SetWindowExitEventId(frameNode, nullptr);
1521     }
1522 }
1523 
ResetOnWindowExit(ArkUINodeHandle node)1524 void ResetOnWindowExit(ArkUINodeHandle node)
1525 {
1526     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1527     CHECK_NULL_VOID(frameNode);
1528     WebModelNG::SetWindowExitEventId(frameNode, nullptr);
1529 }
1530 
SetOnAlertlCallBack(ArkUINodeHandle node,void * extraParam)1531 void SetOnAlertlCallBack(ArkUINodeHandle node, void* extraParam)
1532 {
1533     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1534     CHECK_NULL_VOID(frameNode);
1535     if (extraParam) {
1536         auto* webDialogEventPtr = reinterpret_cast<std::function<bool(WebDialogEvent&)>*>(extraParam);
1537         CHECK_NULL_VOID(webDialogEventPtr);
1538         auto callback = [webDialogEventCallback = *webDialogEventPtr](const BaseEventInfo* event) {
1539             CHECK_NULL_RETURN(event, false);
1540             if (auto webDialogEvent = static_cast<const WebDialogEvent*>(event)) {
1541                 auto& nonConstEvent = const_cast<WebDialogEvent&>(*webDialogEvent);
1542                 return webDialogEventCallback(nonConstEvent);
1543             }
1544             return false;
1545         };
1546         WebModelNG::SetOnAlert(frameNode, std::move(callback), DialogEventType::DIALOG_EVENT_ALERT);
1547     } else {
1548         WebModelNG::SetOnAlert(frameNode, nullptr, DialogEventType::DIALOG_EVENT_ALERT);
1549     }
1550 }
1551 
ResetOnAlertlCallBack(ArkUINodeHandle node)1552 void ResetOnAlertlCallBack(ArkUINodeHandle node)
1553 {
1554     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1555     CHECK_NULL_VOID(frameNode);
1556     WebModelNG::SetOnAlert(frameNode, nullptr, DialogEventType::DIALOG_EVENT_ALERT);
1557 }
1558 
SetOnConfirmCallBack(ArkUINodeHandle node,void * extraParam)1559 void SetOnConfirmCallBack(ArkUINodeHandle node, void* extraParam)
1560 {
1561     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1562     CHECK_NULL_VOID(frameNode);
1563     if (extraParam) {
1564         auto* webDialogEventPtr = reinterpret_cast<std::function<bool(WebDialogEvent&)>*>(extraParam);
1565         CHECK_NULL_VOID(webDialogEventPtr);
1566         auto callback = [webDialogEventCallback = *webDialogEventPtr](const BaseEventInfo* event) {
1567             CHECK_NULL_RETURN(event, false);
1568             if (auto webDialogEvent = static_cast<const WebDialogEvent*>(event)) {
1569                 auto& nonConstEvent = const_cast<WebDialogEvent&>(*webDialogEvent);
1570                 return webDialogEventCallback(nonConstEvent);
1571                 // return true;
1572             }
1573             return false;
1574         };
1575         WebModelNG::SetOnConfirm(frameNode, std::move(callback), DialogEventType::DIALOG_EVENT_CONFIRM);
1576     } else {
1577         WebModelNG::SetOnConfirm(frameNode, nullptr, DialogEventType::DIALOG_EVENT_CONFIRM);
1578     }
1579 }
1580 
ResetOnConfirmCallBack(ArkUINodeHandle node)1581 void ResetOnConfirmCallBack(ArkUINodeHandle node)
1582 {
1583     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1584     CHECK_NULL_VOID(frameNode);
1585     WebModelNG::SetOnConfirm(frameNode, nullptr, DialogEventType::DIALOG_EVENT_CONFIRM);
1586 }
1587 
SetOnPromptCallBack(ArkUINodeHandle node,void * extraParam)1588 void SetOnPromptCallBack(ArkUINodeHandle node, void* extraParam)
1589 {
1590     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1591     CHECK_NULL_VOID(frameNode);
1592     if (extraParam) {
1593         auto* webDialogEventPtr = reinterpret_cast<std::function<bool(WebDialogEvent&)>*>(extraParam);
1594         CHECK_NULL_VOID(webDialogEventPtr);
1595         auto callback = [webDialogEventCallback = *webDialogEventPtr](const BaseEventInfo* event) {
1596             CHECK_NULL_RETURN(event, false);
1597             auto webDialogEvent = static_cast<const WebDialogEvent*>(event);
1598             if (webDialogEvent) {
1599                 auto& nonConstEvent = const_cast<WebDialogEvent&>(*webDialogEvent);
1600                 return webDialogEventCallback(nonConstEvent);
1601             }
1602             return false;
1603         };
1604         WebModelNG::SetOnPrompt(frameNode, std::move(callback), DialogEventType::DIALOG_EVENT_PROMPT);
1605     } else {
1606         WebModelNG::SetOnPrompt(frameNode, nullptr, DialogEventType::DIALOG_EVENT_PROMPT);
1607     }
1608 }
1609 
ResetOnPromptCallBack(ArkUINodeHandle node)1610 void ResetOnPromptCallBack(ArkUINodeHandle node)
1611 {
1612     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1613     CHECK_NULL_VOID(frameNode);
1614     WebModelNG::SetOnPrompt(frameNode, nullptr, DialogEventType::DIALOG_EVENT_PROMPT);
1615 }
1616 
SetOnShowFileSelector(ArkUINodeHandle node,void * extraParam)1617 void SetOnShowFileSelector(ArkUINodeHandle node, void* extraParam)
1618 {
1619     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1620     CHECK_NULL_VOID(frameNode);
1621     if (extraParam) {
1622         auto* fileSelectorPtr = reinterpret_cast<std::function<bool(FileSelectorEvent&)>*>(extraParam);
1623         CHECK_NULL_VOID(fileSelectorPtr);
1624         auto callback = [fileSelectorCallback = *fileSelectorPtr](const BaseEventInfo* event) {
1625             if (auto scrollEvent = static_cast<const FileSelectorEvent*>(event)) {
1626                 auto& nonConstEvent = const_cast<FileSelectorEvent&>(*scrollEvent);
1627                 auto ret = fileSelectorCallback(nonConstEvent);
1628                 return ret;
1629             }
1630             return false;
1631         };
1632         WebModelNG::SetOnShowFileSelector(frameNode, std::move(callback));
1633     } else {
1634         WebModelNG::SetOnShowFileSelector(frameNode, nullptr);
1635     }
1636 }
1637 
ResetOnShowFileSelector(ArkUINodeHandle node)1638 void ResetOnShowFileSelector(ArkUINodeHandle node)
1639 {
1640     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1641     CHECK_NULL_VOID(frameNode);
1642     WebModelNG::SetOnShowFileSelector(frameNode, nullptr);
1643 }
1644 
SetOnContextMenuShow(ArkUINodeHandle node,void * extraParam)1645 void SetOnContextMenuShow(ArkUINodeHandle node, void* extraParam)
1646 {
1647     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1648     CHECK_NULL_VOID(frameNode);
1649     if (extraParam) {
1650         auto* contextMenuShowPtr = reinterpret_cast<std::function<bool(ContextMenuEvent&)>*>(extraParam);
1651         CHECK_NULL_VOID(contextMenuShowPtr);
1652         auto callback = [contextMenuShowCallback = *contextMenuShowPtr](const BaseEventInfo* event) {
1653             if (auto scrollEvent = static_cast<const ContextMenuEvent*>(event)) {
1654                 auto& nonConstEvent = const_cast<ContextMenuEvent&>(*scrollEvent);
1655                 return contextMenuShowCallback(nonConstEvent);
1656             }
1657             return false;
1658         };
1659         WebModelNG::SetOnContextMenuShow(frameNode, std::move(callback));
1660     } else {
1661         WebModelNG::SetOnContextMenuShow(frameNode, nullptr);
1662     }
1663 }
1664 
ResetOnContextMenuShow(ArkUINodeHandle node)1665 void ResetOnContextMenuShow(ArkUINodeHandle node)
1666 {
1667     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1668     CHECK_NULL_VOID(frameNode);
1669     WebModelNG::SetOnContextMenuShow(frameNode, nullptr);
1670 }
1671 
SetOnSafeBrowsingCheckResultCallBack(ArkUINodeHandle node,void * extraParam)1672 void SetOnSafeBrowsingCheckResultCallBack(ArkUINodeHandle node, void* extraParam)
1673 {
1674     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1675     CHECK_NULL_VOID(frameNode);
1676     if (extraParam) {
1677         auto* originalCallbackPtr = reinterpret_cast<std::function<void(SafeBrowsingCheckResultEvent&)>*>(extraParam);
1678         CHECK_NULL_VOID(originalCallbackPtr);
1679         auto callback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
1680             auto* concreteEvent = static_cast<SafeBrowsingCheckResultEvent*>(event.get());
1681             CHECK_NULL_VOID(originalCallback);
1682             originalCallback(*concreteEvent);
1683         };
1684         WebModelNG::SetOnSafeBrowsingCheckResult(frameNode, std::move(callback));
1685     } else {
1686         WebModelNG::SetOnSafeBrowsingCheckResult(frameNode, nullptr);
1687     }
1688 }
1689 
ResetOnSafeBrowsingCheckResultCallBack(ArkUINodeHandle node)1690 void ResetOnSafeBrowsingCheckResultCallBack(ArkUINodeHandle node)
1691 {
1692     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1693     CHECK_NULL_VOID(frameNode);
1694     WebModelNG::SetOnSafeBrowsingCheckResult(frameNode, nullptr);
1695 }
1696 
SetWebNestedScrollExt(ArkUINodeHandle node,ArkUI_Int32 scrollUp,ArkUI_Int32 scrollDown,ArkUI_Int32 scrollLeft,ArkUI_Int32 scrollRight)1697 void SetWebNestedScrollExt(
1698     ArkUINodeHandle node, ArkUI_Int32 scrollUp, ArkUI_Int32 scrollDown, ArkUI_Int32 scrollLeft, ArkUI_Int32 scrollRight)
1699 {
1700     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1701     CHECK_NULL_VOID(frameNode);
1702     NestedScrollOptionsExt nestedOpt = {
1703         .scrollUp = NestedScrollMode::SELF_FIRST,
1704         .scrollDown = NestedScrollMode::SELF_FIRST,
1705         .scrollLeft = NestedScrollMode::SELF_FIRST,
1706         .scrollRight = NestedScrollMode::SELF_FIRST,
1707     };
1708     nestedOpt.scrollUp = static_cast<NestedScrollMode>(scrollUp);
1709     nestedOpt.scrollDown = static_cast<NestedScrollMode>(scrollDown);
1710     nestedOpt.scrollLeft = static_cast<NestedScrollMode>(scrollLeft);
1711     nestedOpt.scrollRight = static_cast<NestedScrollMode>(scrollRight);
1712     WebModelNG::SetNestedScrollExt(frameNode, nestedOpt);
1713 }
1714 
ResetWebNestedScrollExt(ArkUINodeHandle node)1715 void ResetWebNestedScrollExt(ArkUINodeHandle node)
1716 {
1717     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1718     CHECK_NULL_VOID(frameNode);
1719     const NestedScrollOptionsExt nestedOpt = {
1720         .scrollUp = NestedScrollMode::SELF_FIRST,
1721         .scrollDown = NestedScrollMode::SELF_FIRST,
1722         .scrollLeft = NestedScrollMode::SELF_FIRST,
1723         .scrollRight = NestedScrollMode::SELF_FIRST,
1724     };
1725     WebModelNG::SetNestedScrollExt(frameNode, nestedOpt);
1726 }
1727 
SetOnInterceptKeyEventCallBack(ArkUINodeHandle node,void * callback)1728 void SetOnInterceptKeyEventCallBack(ArkUINodeHandle node, void* callback)
1729 {
1730     auto* eventFunc = reinterpret_cast<std::function<bool(KeyEventInfo&)>*>(callback);
1731     auto frameNode = reinterpret_cast<FrameNode*>(node);
1732     WeakPtr<NG::FrameNode> weak = AceType::WeakClaim(frameNode);
1733     auto onKeyEvent = [func = *eventFunc, weak](KeyEventInfo& keyEventInfo) -> bool {
1734         auto frameNode = weak.Upgrade();
1735         int32_t instanceId = INSTANCE_ID_UNDEFINED;
1736         if (frameNode) {
1737             instanceId = frameNode->GetInstanceId();
1738         } else {
1739             instanceId = Container::CurrentIdSafely();
1740         }
1741 
1742         ContainerScope scope(instanceId);
1743         auto context = PipelineBase::GetCurrentContext();
1744         bool result = false;
1745         CHECK_NULL_RETURN(context, result);
1746 
1747         context->PostSyncEvent(
1748             [func, &keyEventInfo, &result]() { result = func(keyEventInfo); }, "ArkUIWebInterceptKeyEventCallback");
1749         return result;
1750     };
1751     WebModelNG::SetOnInterceptKeyEvent(frameNode, std::move(onKeyEvent));
1752 }
1753 
ResetOnInterceptKeyEventCallBack(ArkUINodeHandle node)1754 void ResetOnInterceptKeyEventCallBack(ArkUINodeHandle node)
1755 {
1756     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1757     CHECK_NULL_VOID(frameNode);
1758     WebModelNG::SetOnInterceptKeyEvent(frameNode, nullptr);
1759 }
1760 
SetOnErrorReceive(ArkUINodeHandle node,void * extraParam)1761 void SetOnErrorReceive(ArkUINodeHandle node, void* extraParam)
1762 {
1763     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1764     CHECK_NULL_VOID(frameNode);
1765     if (extraParam) {
1766         auto* originalCallbackPtr = reinterpret_cast<std::function<void(ReceivedErrorEvent&)>*>(extraParam);
1767         CHECK_NULL_VOID(originalCallbackPtr);
1768         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1769             if (auto scrollEvent = static_cast<const ReceivedErrorEvent*>(event)) {
1770                 auto& nonConstEvent = const_cast<ReceivedErrorEvent&>(*scrollEvent);
1771                 originalCallback(nonConstEvent);
1772                 return true;
1773             }
1774             return false;
1775         };
1776         WebModelNG::SetOnErrorReceive(frameNode, std::move(callback));
1777     } else {
1778         WebModelNG::SetOnErrorReceive(frameNode, nullptr);
1779     }
1780 }
1781 
ResetOnErrorReceive(ArkUINodeHandle node)1782 void ResetOnErrorReceive(ArkUINodeHandle node)
1783 {
1784     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1785     CHECK_NULL_VOID(frameNode);
1786     WebModelNG::SetOnErrorReceive(frameNode, nullptr);
1787 }
1788 
SetOnLoadIntercept(ArkUINodeHandle node,void * extraParam)1789 void SetOnLoadIntercept(ArkUINodeHandle node, void* extraParam)
1790 {
1791     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1792     CHECK_NULL_VOID(frameNode);
1793     if (extraParam) {
1794         auto* originalCallbackPtr = reinterpret_cast<std::function<bool(LoadInterceptEvent&)>*>(extraParam);
1795         CHECK_NULL_VOID(originalCallbackPtr);
1796         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1797             if (auto scrollEvent = static_cast<const LoadInterceptEvent*>(event)) {
1798                 auto& nonConstEvent = const_cast<LoadInterceptEvent&>(*scrollEvent);
1799                 return originalCallback(nonConstEvent);
1800             }
1801             return false;
1802         };
1803         WebModelNG::SetOnLoadIntercept(frameNode, std::move(callback));
1804     } else {
1805         WebModelNG::SetOnLoadIntercept(frameNode, nullptr);
1806     }
1807 }
1808 
ResetOnLoadIntercept(ArkUINodeHandle node)1809 void ResetOnLoadIntercept(ArkUINodeHandle node)
1810 {
1811     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1812     CHECK_NULL_VOID(frameNode);
1813     WebModelNG::SetOnLoadIntercept(frameNode, nullptr);
1814 }
1815 
SetOnHttpErrorReceive(ArkUINodeHandle node,void * extraParam)1816 void SetOnHttpErrorReceive(ArkUINodeHandle node, void* extraParam)
1817 {
1818     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1819     CHECK_NULL_VOID(frameNode);
1820     if (extraParam) {
1821         auto* originalCallbackPtr = reinterpret_cast<std::function<void(ReceivedHttpErrorEvent&)>*>(extraParam);
1822         CHECK_NULL_VOID(originalCallbackPtr);
1823         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1824             if (auto scrollEvent = static_cast<const ReceivedHttpErrorEvent*>(event)) {
1825                 auto& nonConstEvent = const_cast<ReceivedHttpErrorEvent&>(*scrollEvent);
1826                 originalCallback(nonConstEvent);
1827                 return true;
1828             }
1829             return false;
1830         };
1831         WebModelNG::SetOnHttpErrorReceive(frameNode, std::move(callback));
1832     } else {
1833         WebModelNG::SetOnHttpErrorReceive(frameNode, nullptr);
1834     }
1835 }
1836 
ResetOnHttpErrorReceive(ArkUINodeHandle node)1837 void ResetOnHttpErrorReceive(ArkUINodeHandle node)
1838 {
1839     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1840     CHECK_NULL_VOID(frameNode);
1841     WebModelNG::SetOnHttpErrorReceive(frameNode, nullptr);
1842 }
1843 
SetOnOverrideUrlLoading(ArkUINodeHandle node,void * extraParam)1844 void SetOnOverrideUrlLoading(ArkUINodeHandle node, void* extraParam)
1845 {
1846     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1847     CHECK_NULL_VOID(frameNode);
1848     if (extraParam) {
1849         auto* originalCallbackPtr = reinterpret_cast<std::function<bool(LoadOverrideEvent&)>*>(extraParam);
1850         CHECK_NULL_VOID(originalCallbackPtr);
1851         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1852             if (auto scrollEvent = static_cast<const LoadOverrideEvent*>(event)) {
1853                 auto& nonConstEvent = const_cast<LoadOverrideEvent&>(*scrollEvent);
1854                 return originalCallback(nonConstEvent);
1855             }
1856             return false;
1857         };
1858         WebModelNG::SetOnOverrideUrlLoading(frameNode, std::move(callback));
1859     } else {
1860         WebModelNG::SetOnOverrideUrlLoading(frameNode, nullptr);
1861     }
1862 }
1863 
ResetOnOverrideUrlLoading(ArkUINodeHandle node)1864 void ResetOnOverrideUrlLoading(ArkUINodeHandle node)
1865 {
1866     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1867     CHECK_NULL_VOID(frameNode);
1868     WebModelNG::SetOnOverrideUrlLoading(frameNode, nullptr);
1869 }
1870 
SetOnHttpAuthRequest(ArkUINodeHandle node,void * extraParam)1871 void SetOnHttpAuthRequest(ArkUINodeHandle node, void* extraParam)
1872 {
1873     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1874     CHECK_NULL_VOID(frameNode);
1875     if (extraParam) {
1876         auto* originalCallbackPtr = reinterpret_cast<std::function<bool(WebHttpAuthEvent&)>*>(extraParam);
1877         CHECK_NULL_VOID(originalCallbackPtr);
1878         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
1879             if (auto scrollEvent = static_cast<const WebHttpAuthEvent*>(event)) {
1880                 auto& nonConstEvent = const_cast<WebHttpAuthEvent&>(*scrollEvent);
1881                 return originalCallback(nonConstEvent);
1882             }
1883             return false;
1884         };
1885         WebModelNG::SetOnHttpAuthRequest(frameNode, std::move(callback));
1886     } else {
1887         WebModelNG::SetOnHttpAuthRequest(frameNode, nullptr);
1888     }
1889 }
1890 
ResetOnHttpAuthRequest(ArkUINodeHandle node)1891 void ResetOnHttpAuthRequest(ArkUINodeHandle node)
1892 {
1893     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1894     CHECK_NULL_VOID(frameNode);
1895     WebModelNG::SetOnHttpAuthRequest(frameNode, nullptr);
1896 }
1897 
SetOnConsole(ArkUINodeHandle node,void * extraParam)1898 void SetOnConsole(ArkUINodeHandle node, void* extraParam)
1899 {
1900     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1901     CHECK_NULL_VOID(frameNode);
1902     if (extraParam) {
1903         auto* loadWebConsoleLogEventPtr = reinterpret_cast<std::function<bool(LoadWebConsoleLogEvent&)>*>(extraParam);
1904         CHECK_NULL_VOID(loadWebConsoleLogEventPtr);
1905         auto callback = [loadWebConsoleLogEventCallback = *loadWebConsoleLogEventPtr](const BaseEventInfo* event) {
1906             CHECK_NULL_RETURN(event, false);
1907             auto loadWebConsoleLogEvent = static_cast<const LoadWebConsoleLogEvent*>(event);
1908             if (loadWebConsoleLogEvent) {
1909                 auto& nonConstEvent = const_cast<LoadWebConsoleLogEvent&>(*loadWebConsoleLogEvent);
1910                 return loadWebConsoleLogEventCallback(nonConstEvent);
1911             }
1912             return false;
1913         };
1914         WebModelNG::SetOnConsole(frameNode, std::move(callback));
1915     } else {
1916         WebModelNG::SetOnConsole(frameNode, nullptr);
1917     }
1918 }
1919 
ResetOnConsole(ArkUINodeHandle node)1920 void ResetOnConsole(ArkUINodeHandle node)
1921 {
1922     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1923     CHECK_NULL_VOID(frameNode);
1924     WebModelNG::SetOnConsole(frameNode, nullptr);
1925 }
1926 
SetOnSslErrorEvent(ArkUINodeHandle node,void * extraParam)1927 void SetOnSslErrorEvent(ArkUINodeHandle node, void* extraParam)
1928 {
1929     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1930     CHECK_NULL_VOID(frameNode);
1931     if (extraParam) {
1932         auto* originalCallback = static_cast<std::function<void(WebAllSslErrorEvent&)>*>(extraParam);
1933         CHECK_NULL_VOID(originalCallback);
1934 
1935         auto callback = [originalFunc = *originalCallback](const BaseEventInfo* event) -> bool {
1936             CHECK_NULL_RETURN(event, false);
1937             auto* sslEvent = static_cast<const WebAllSslErrorEvent*>(event);
1938             originalFunc(const_cast<WebAllSslErrorEvent&>(*sslEvent));
1939             return true;
1940         };
1941         WebModelNG::SetOnSslErrorEvent(frameNode, std::move(callback));
1942     } else {
1943         WebModelNG::SetOnSslErrorEvent(frameNode, nullptr);
1944     }
1945 }
1946 
ResetOnSslErrorEvent(ArkUINodeHandle node)1947 void ResetOnSslErrorEvent(ArkUINodeHandle node)
1948 {
1949     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1950     CHECK_NULL_VOID(frameNode);
1951     WebModelNG::SetOnSslErrorEvent(frameNode, nullptr);
1952 }
1953 
SetOnDataResubmitted(ArkUINodeHandle node,void * extraParam)1954 void SetOnDataResubmitted(ArkUINodeHandle node, void* extraParam)
1955 {
1956     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1957     CHECK_NULL_VOID(frameNode);
1958     if (extraParam) {
1959         auto* originalCallbackPtr = reinterpret_cast<std::function<void(DataResubmittedEvent&)>*>(extraParam);
1960         CHECK_NULL_VOID(originalCallbackPtr);
1961         auto callback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
1962             auto* concreteEvent = static_cast<DataResubmittedEvent*>(event.get());
1963             CHECK_NULL_VOID(originalCallback);
1964             originalCallback(*concreteEvent);
1965         };
1966         WebModelNG::SetOnDataResubmitted(frameNode, std::move(callback));
1967     } else {
1968         WebModelNG::SetOnDataResubmitted(frameNode, nullptr);
1969     }
1970 }
1971 
ResetOnDataResubmitted(ArkUINodeHandle node)1972 void ResetOnDataResubmitted(ArkUINodeHandle node)
1973 {
1974     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1975     CHECK_NULL_VOID(frameNode);
1976     WebModelNG::SetOnDataResubmitted(frameNode, nullptr);
1977 }
1978 
SetGestureFocusMode(ArkUINodeHandle node,ArkUI_Int32 value)1979 void SetGestureFocusMode(ArkUINodeHandle node, ArkUI_Int32 value)
1980 {
1981     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1982     CHECK_NULL_VOID(frameNode);
1983     WebModelNG::SetGestureFocusMode(frameNode, GestureFocusMode(value));
1984 }
1985 
ResetGestureFocusMode(ArkUINodeHandle node)1986 void ResetGestureFocusMode(ArkUINodeHandle node)
1987 {
1988     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1989     CHECK_NULL_VOID(frameNode);
1990     WebModelNG::SetGestureFocusMode(frameNode, DEFAULT_GESTURE_FOCUS_MODE);
1991 }
1992 
SetOnSslErrorEventReceive(ArkUINodeHandle node,void * extraParam)1993 void SetOnSslErrorEventReceive(ArkUINodeHandle node, void* extraParam)
1994 {
1995     auto* frameNode = reinterpret_cast<FrameNode*>(node);
1996     CHECK_NULL_VOID(frameNode);
1997     if (extraParam) {
1998         auto* webSslErrorEventPtr = reinterpret_cast<std::function<bool(WebSslErrorEvent&)>*>(extraParam);
1999         CHECK_NULL_VOID(webSslErrorEventPtr);
2000         auto webSslErrorEventCallback = *webSslErrorEventPtr;
2001         auto callback = [webSslErrorEventCallback](const BaseEventInfo* event) {
2002             CHECK_NULL_RETURN(event, false);
2003             auto webSslErrorEvent = static_cast<const WebSslErrorEvent*>(event);
2004             if (webSslErrorEvent) {
2005                 auto& nonConstEvent = const_cast<WebSslErrorEvent&>(*webSslErrorEvent);
2006                 return webSslErrorEventCallback(nonConstEvent);
2007             }
2008             return false;
2009         };
2010         WebModelNG::SetOnSslErrorRequest(frameNode, std::move(callback));
2011     } else {
2012         WebModelNG::SetOnSslErrorRequest(frameNode, nullptr);
2013     }
2014 }
2015 
ResetOnSslErrorEventReceive(ArkUINodeHandle node)2016 void ResetOnSslErrorEventReceive(ArkUINodeHandle node)
2017 {
2018     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2019     CHECK_NULL_VOID(frameNode);
2020     WebModelNG::SetOnSslErrorRequest(frameNode, nullptr);
2021 }
2022 
SetOnClientAuthenticationRequest(ArkUINodeHandle node,void * extraParam)2023 void SetOnClientAuthenticationRequest(ArkUINodeHandle node, void* extraParam)
2024 {
2025     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2026     CHECK_NULL_VOID(frameNode);
2027     if (extraParam) {
2028         auto* webSslSelectCertEventPtr = reinterpret_cast<std::function<bool(WebSslSelectCertEvent&)>*>(extraParam);
2029         CHECK_NULL_VOID(webSslSelectCertEventPtr);
2030         auto callback = [webSslSelectCertEventCallback = *webSslSelectCertEventPtr](const BaseEventInfo* event) {
2031             CHECK_NULL_RETURN(event, false);
2032             auto webSslSelectCertEvent = static_cast<const WebSslSelectCertEvent*>(event);
2033             if (webSslSelectCertEvent) {
2034                 auto& nonConstEvent = const_cast<WebSslSelectCertEvent&>(*webSslSelectCertEvent);
2035                 return webSslSelectCertEventCallback(nonConstEvent);
2036             }
2037             return false;
2038         };
2039         WebModelNG::SetOnClientAuthenticationRequest(frameNode, std::move(callback));
2040     } else {
2041         WebModelNG::SetOnClientAuthenticationRequest(frameNode, nullptr);
2042     }
2043 }
2044 
ResetOnClientAuthenticationRequest(ArkUINodeHandle node)2045 void ResetOnClientAuthenticationRequest(ArkUINodeHandle node)
2046 {
2047     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2048     CHECK_NULL_VOID(frameNode);
2049     WebModelNG::SetOnClientAuthenticationRequest(frameNode, nullptr);
2050 }
2051 
SetOnInterceptRequest(ArkUINodeHandle node,void * extraParam)2052 void SetOnInterceptRequest(ArkUINodeHandle node, void* extraParam)
2053 {
2054     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2055     CHECK_NULL_VOID(frameNode);
2056     if (extraParam) {
2057         auto* originalCallbackPtr =
2058             reinterpret_cast<std::function<RefPtr<WebResponse>(OnInterceptRequestEvent&)>*>(extraParam);
2059         CHECK_NULL_VOID(originalCallbackPtr);
2060         auto callback = [originalCallback = *originalCallbackPtr](const BaseEventInfo* event) {
2061             if (event == nullptr) {
2062                 return RefPtr<WebResponse>(nullptr);
2063             }
2064             if (auto scrollEvent = static_cast<const OnInterceptRequestEvent*>(event)) {
2065                 auto& nonConstEvent = const_cast<OnInterceptRequestEvent&>(*scrollEvent);
2066                 return originalCallback(nonConstEvent);
2067             }
2068             return RefPtr<WebResponse>(nullptr);
2069         };
2070         WebModelNG::SetOnInterceptRequest(frameNode, std::move(callback));
2071     } else {
2072         WebModelNG::SetOnInterceptRequest(frameNode, nullptr);
2073     }
2074 }
2075 
ResetOnInterceptRequest(ArkUINodeHandle node)2076 void ResetOnInterceptRequest(ArkUINodeHandle node)
2077 {
2078     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2079     CHECK_NULL_VOID(frameNode);
2080     WebModelNG::SetOnInterceptRequest(frameNode, nullptr);
2081 }
2082 
SetOnFaviconReceived(ArkUINodeHandle node,void * extraParam)2083 void SetOnFaviconReceived(ArkUINodeHandle node, void* extraParam)
2084 {
2085     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2086     CHECK_NULL_VOID(frameNode);
2087     if (extraParam) {
2088         auto* originalCallbackPtr = reinterpret_cast<std::function<void(FaviconReceivedEvent&)>*>(extraParam);
2089         CHECK_NULL_VOID(originalCallbackPtr);
2090         auto adaptedCallback = [originalCallback = *originalCallbackPtr](const std::shared_ptr<BaseEventInfo>& event) {
2091             auto* onFaviconReceived = static_cast<FaviconReceivedEvent*>(event.get());
2092             if (onFaviconReceived != nullptr) {
2093                 originalCallback(*onFaviconReceived);
2094             }
2095         };
2096         WebModelNG::SetFaviconReceivedId(frameNode, std::move(adaptedCallback));
2097     } else {
2098         WebModelNG::SetFaviconReceivedId(frameNode, nullptr);
2099     }
2100 }
2101 
ResetOnFaviconReceived(ArkUINodeHandle node)2102 void ResetOnFaviconReceived(ArkUINodeHandle node)
2103 {
2104     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2105     CHECK_NULL_VOID(frameNode);
2106     WebModelNG::SetFaviconReceivedId(frameNode, nullptr);
2107 }
2108 
SetOnBeforeUnload(ArkUINodeHandle node,void * extraParam)2109 void SetOnBeforeUnload(ArkUINodeHandle node, void* extraParam)
2110 {
2111     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2112     CHECK_NULL_VOID(frameNode);
2113     if (extraParam) {
2114         auto* webDialogEventPtr = reinterpret_cast<std::function<bool(WebDialogEvent&)>*>(extraParam);
2115         CHECK_NULL_VOID(webDialogEventPtr);
2116         auto callback = [webDialogEventCallback = *webDialogEventPtr](const BaseEventInfo* event) {
2117             CHECK_NULL_RETURN(event, false);
2118             auto webDialogEvent = static_cast<const WebDialogEvent*>(event);
2119             if (webDialogEvent) {
2120                 auto& nonConstEvent = const_cast<WebDialogEvent&>(*webDialogEvent);
2121                 return webDialogEventCallback(nonConstEvent);
2122             }
2123             return false;
2124         };
2125         WebModelNG::SetOnBeforeUnload(frameNode, std::move(callback), DialogEventType::DIALOG_EVENT_BEFORE_UNLOAD);
2126     } else {
2127         WebModelNG::SetOnBeforeUnload(frameNode, nullptr, DialogEventType::DIALOG_EVENT_BEFORE_UNLOAD);
2128     }
2129 }
2130 
ResetOnBeforeUnload(ArkUINodeHandle node)2131 void ResetOnBeforeUnload(ArkUINodeHandle node)
2132 {
2133     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2134     CHECK_NULL_VOID(frameNode);
2135     WebModelNG::SetOnBeforeUnload(frameNode, nullptr, DialogEventType::DIALOG_EVENT_BEFORE_UNLOAD);
2136 }
2137 
SetJavaScriptProxy(ArkUINodeHandle node,void * extraParam)2138 void SetJavaScriptProxy(ArkUINodeHandle node, void* extraParam)
2139 {
2140     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2141     CHECK_NULL_VOID(frameNode);
2142     if (extraParam) {
2143         auto* jsProxyCallback = reinterpret_cast<std::function<void()>*>(extraParam);
2144         WebModelNG::SetJavaScriptProxy(frameNode, std::move(*jsProxyCallback));
2145     } else {
2146         WebModelNG::SetJavaScriptProxy(frameNode, nullptr);
2147     }
2148 }
2149 
ResetJavaScriptProxy(ArkUINodeHandle node)2150 void ResetJavaScriptProxy(ArkUINodeHandle node)
2151 {
2152     auto* frameNode = reinterpret_cast<FrameNode*>(node);
2153     CHECK_NULL_VOID(frameNode);
2154     WebModelNG::SetJavaScriptProxy(frameNode, nullptr);
2155 }
2156 
2157 namespace NodeModifier {
GetWebModifier()2158 const ArkUIWebModifier* GetWebModifier()
2159 {
2160     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2161     static const ArkUIWebModifier modifier = {
2162         .getWebController = nullptr,
2163         .getWebviewController = nullptr,
2164         .setWebOptions = nullptr,
2165         .setWebSrcResources = nullptr,
2166         .setJavaScriptAccess = SetJavaScriptAccess,
2167         .resetJavaScriptAccess = ResetJavaScriptAccess,
2168         .setFileAccessEnabled = SetFileAccessEnabled,
2169         .resetFileAccessEnabled = ResetFileAccessEnabled,
2170         .setDomStorageAccessEnabled = SetDomStorageAccessEnabled,
2171         .resetDomStorageAccessEnabled = ResetDomStorageAccessEnabled,
2172         .setMixedMode = SetMixedMode,
2173         .resetMixedMode = ResetMixedMode,
2174         .setZoomAccessEnabled = SetZoomAccessEnabled,
2175         .resetZoomAccessEnabled = ResetZoomAccessEnabled,
2176         .setCacheMode = SetCacheMode,
2177         .resetCacheMode = ResetCacheMode,
2178         .setDarkMode = SetDarkMode,
2179         .resetDarkMode = ResetDarkMode,
2180         .setMultiWindowAccessEnabled = SetMultiWindowAccessEnabled,
2181         .resetMultiWindowAccessEnabled = ResetMultiWindowAccessEnabled,
2182         .setAllowWindowOpenMethod = SetAllowWindowOpenMethod,
2183         .resetAllowWindowOpenMethod = ResetAllowWindowOpenMethod,
2184         .setKeyboardAvoidMode = SetKeyboardAvoidMode,
2185         .resetKeyboardAvoidMode = ResetKeyboardAvoidMode,
2186         .setOnControllerAttached = SetOnControllerAttached,
2187         .resetOnControllerAttached = ResetOnControllerAttached,
2188         .setVerticalScrollBarAccessEnabled = SetVerticalScrollBarAccessEnabled,
2189         .resetVerticalScrollBarAccessEnabled = ResetVerticalScrollBarAccessEnabled,
2190         .setHorizontalScrollBarAccessEnabled = SetHorizontalScrollBarAccessEnabled,
2191         .resetHorizontalScrollBarAccessEnabled = ResetHorizontalScrollBarAccessEnabled,
2192         .setTextZoomRatio = SetTextZoomRatio,
2193         .resetTextZoomRatio = ResetTextZoomRatio,
2194         .setInitialScale = SetInitialScale,
2195         .resetInitialScale = ResetInitialScale,
2196         .setOnScrollCallBack = SetOnScrollCallBack,
2197         .resetOnScrollCallBack = ResetOnScrollCallBack,
2198         .setOnOverScrollCallBack = SetOnOverScrollCallBack,
2199         .resetOnOverScrollCallBack = ResetOnOverScrollCallBack,
2200         .setOnScaleChangeCallBack = SetOnScaleChangeCallBack,
2201         .resetOnScaleChangeCallBack = ResetOnScaleChangeCallBack,
2202         .setOnRequestSelectedCallBack = SetOnRequestSelectedCallBack,
2203         .resetOnRequestSelectedCallBack = ResetOnRequestSelectedCallBack,
2204         .setOnContextMenuHideCallBack = SetOnContextMenuHideCallBack,
2205         .resetOnContextMenuHideCallBack = ResetOnContextMenuHideCallBack,
2206         .setGeolocationAccess = SetGeolocationAccess,
2207         .resetGeolocationAccess = ResetGeolocationAccess,
2208         .setDatabaseAccess = SetDatabaseAccess,
2209         .resetDatabaseAccess = ResetDatabaseAccess,
2210         .setOverviewModeAccess = SetOverviewModeAccess,
2211         .resetOverviewModeAccess = ResetOverviewModeAccess,
2212         .setForceDarkAccess = SetForceDarkAccess,
2213         .resetForceDarkAccess = ResetForceDarkAccess,
2214         .setPinchSmooth = SetPinchSmooth,
2215         .resetPinchSmooth = ResetPinchSmooth,
2216         .setMetaViewport = SetMetaViewport,
2217         .resetMetaViewport = ResetMetaViewport,
2218         .setEnableFollowSystemFontWeight = SetEnableFollowSystemFontWeight,
2219         .resetEnableFollowSystemFontWeight = ResetEnableFollowSystemFontWeight,
2220         .setEnableNativeEmbedMode = SetEnableNativeEmbedMode,
2221         .resetEnableNativeEmbedMode = ResetEnableNativeEmbedMode,
2222         .setMinFontSize = SetMinFontSize,
2223         .resetMinFontSize = ResetMinFontSize,
2224         .setDefaultFontSize = SetDefaultFontSize,
2225         .resetDefaultFontSize = ResetDefaultFontSize,
2226         .setDefaultFixedFontSize = SetDefaultFixedFontSize,
2227         .resetDefaultFixedFontSize = ResetDefaultFixedFontSize,
2228         .setMinLogicalFontSize = SetMinLogicalFontSize,
2229         .resetMinLogicalFontSize = ResetMinLogicalFontSize,
2230         .setWebStandardFont = SetWebStandardFont,
2231         .resetWebStandardFont = ResetWebStandardFont,
2232         .setWebSerifFont = SetWebSerifFont,
2233         .resetWebSerifFont = ResetWebSerifFont,
2234         .setWebSansSerifFont = SetWebSansSerifFont,
2235         .resetWebSansSerifFont = ResetWebSansSerifFont,
2236         .setWebFixedFont = SetWebFixedFont,
2237         .resetWebFixedFont = ResetWebFixedFont,
2238         .setWebFantasyFont = SetWebFantasyFont,
2239         .resetWebFantasyFont = ResetWebFantasyFont,
2240         .setWebCursiveFont = SetWebCursiveFont,
2241         .resetWebCursiveFont = ResetWebCursiveFont,
2242         .setLayoutMode = SetLayoutMode,
2243         .resetLayoutMode = ResetLayoutMode,
2244         .setOnNativeEmbedLifecycleChange = SetOnNativeEmbedLifecycleChange,
2245         .resetOnNativeEmbedLifecycleChange = ResetOnNativeEmbedLifecycleChange,
2246         .setOnNativeEmbedGestureEvent = SetOnNativeEmbedGestureEvent,
2247         .resetOnNativeEmbedGestureEvent = ResetOnNativeEmbedGestureEvent,
2248         .setRegisterNativeEmbedRule = SetRegisterNativeEmbedRule,
2249         .resetRegisterNativeEmbedRule = ResetRegisterNativeEmbedRule,
2250         .setNativeEmbedOptions = SetNativeEmbedOptions,
2251         .resetNativeEmbedOptions = ResetNativeEmbedOptions,
2252         .setOnFirstContentfulPaint = SetOnFirstContentfulPaint,
2253         .resetOnFirstContentfulPaint = ResetOnFirstContentfulPaint,
2254         .setOnAudioStateChanged = SetOnAudioStateChanged,
2255         .resetOnAudioStateChanged = ResetOnAudioStateChanged,
2256         .setOnFullScreenExit = SetOnFullScreenExit,
2257         .resetOnFullScreenExit = ResetOnFullScreenExit,
2258         .setImageAccess = SetImageAccess,
2259         .resetImageAccess = ResetImageAccess,
2260         .setOnlineImageAccess = SetOnlineImageAccess,
2261         .resetOnlineImageAccess = ResetOnlineImageAccess,
2262         .setMediaPlayGestureAccess = SetMediaPlayGestureAccess,
2263         .resetMediaPlayGestureAccess = ResetMediaPlayGestureAccess,
2264         .setMediaOptions = SetMediaOptions,
2265         .resetMediaOptions = ResetMediaOptions,
2266         .setOnPageEnd = SetOnPageEnd,
2267         .resetOnPageEnd = ResetOnPageEnd,
2268         .setOnPageBegin = SetOnPageBegin,
2269         .resetOnPageBegin = ResetOnPageBegin,
2270         .setOnProgressChange = SetOnProgressChange,
2271         .resetOnProgressChange = ResetOnProgressChange,
2272         .setOnTitleReceive = SetOnTitleReceive,
2273         .resetOnTitleReceive = ResetOnTitleReceive,
2274         .setOnDownloadStart = SetOnDownloadStart,
2275         .resetOnDownloadStart = ResetOnDownloadStart,
2276         .setJavaScriptOnDocumentStart = SetJavaScriptOnDocumentStart,
2277         .resetJavaScriptOnDocumentStart = ResetJavaScriptOnDocumentStart,
2278         .setJavaScriptOnDocumentEnd = SetJavaScriptOnDocumentEnd,
2279         .resetJavaScriptOnDocumentEnd = ResetJavaScriptOnDocumentEnd,
2280         .setCopyOptionMode = SetCopyOptionMode,
2281         .resetCopyOptionMode = ResetCopyOptionMode,
2282         .setRenderProcessNotResponding = SetRenderProcessNotResponding,
2283         .resetRenderProcessNotResponding = ResetRenderProcessNotResponding,
2284         .setOnPageVisibleCallBack = SetOnPageVisibleCallBack,
2285         .resetOnPageVisibleCallBack = ResetOnPageVisibleCallBack,
2286         .setOnRenderExitedCallBack = SetOnRenderExitedCallBack,
2287         .resetOnRenderExitedCallBack = ResetOnRenderExitedCallBack,
2288         .setBlockNetwork = SetBlockNetwork,
2289         .resetBlockNetwork = ResetBlockNetwork,
2290         .setOnResourceLoadCallBack = SetOnResourceLoadCallBack,
2291         .resetOnResourceLoadCallBack = ResetOnResourceLoadCallBack,
2292         .setOnRefreshAccessedHistoryCallBack = SetOnRefreshAccessedHistoryCallBack,
2293         .resetOnRefreshAccessedHistoryCallBack = ResetOnRefreshAccessedHistoryCallBack,
2294         .setOnNavigationEntryCommittedCallBack = SetOnNavigationEntryCommittedCallBack,
2295         .resetOnNavigationEntryCommittedCallBack = ResetOnNavigationEntryCommittedCallBack,
2296         .setOnSearchResultReceiveCallBack = SetOnSearchResultReceiveCallBack,
2297         .resetOnSearchResultReceiveCallBack = ResetOnSearchResultReceiveCallBack,
2298         .setOverScrollMode = SetOverScrollMode,
2299         .resetOverScrollMode = ResetOverScrollMode,
2300         .setOnTouchIconUrlReceivedCallBack = SetOnTouchIconUrlReceivedCallBack,
2301         .resetOnTouchIconUrlReceivedCallBack = ResetOnTouchIconUrlReceivedCallBack,
2302         .setOnRenderProcessRespondingCallBack = SetOnRenderProcessRespondingCallBack,
2303         .resetOnRenderProcessRespondingCallBack = ResetOnRenderProcessRespondingCallBack,
2304         .setOnWindowNew = SetOnWindowNew,
2305         .resetOnWindowNew = ResetOnWindowNew,
2306         .setOnGeolocationShow = SetOnGeolocationShow,
2307         .resetOnGeolocationShow = ResetOnGeolocationShow,
2308         .setOnPermissionRequest = SetOnPermissionRequest,
2309         .resetOnPermissionRequest = ResetOnPermissionRequest,
2310         .setOnScreenCaptureRequest = SetOnScreenCaptureRequest,
2311         .resetOnScreenCaptureRequest = ResetOnScreenCaptureRequest,
2312         .setOnFullScreenEnter = SetOnFullScreenEnter,
2313         .resetOnFullScreenEnter = ResetOnFullScreenEnter,
2314         .setOnWindowExit = SetOnWindowExit,
2315         .resetOnWindowExit = ResetOnWindowExit,
2316         .setOnAlertlCallBack = SetOnAlertlCallBack,
2317         .resetOnAlertlCallBack = ResetOnAlertlCallBack,
2318         .setOnConfirmCallBack = SetOnConfirmCallBack,
2319         .resetOnConfirmCallBack = ResetOnConfirmCallBack,
2320         .setOnPromptCallBack = SetOnPromptCallBack,
2321         .resetOnPromptCallBack = ResetOnPromptCallBack,
2322         .setOnShowFileSelector = SetOnShowFileSelector,
2323         .resetOnShowFileSelector = ResetOnShowFileSelector,
2324         .setOnContextMenuShow = SetOnContextMenuShow,
2325         .resetOnContextMenuShow = ResetOnContextMenuShow,
2326         .setOnSafeBrowsingCheckResultCallBack = SetOnSafeBrowsingCheckResultCallBack,
2327         .resetOnSafeBrowsingCheckResultCallBack = ResetOnSafeBrowsingCheckResultCallBack,
2328         .setWebNestedScrollExt = SetWebNestedScrollExt,
2329         .resetWebNestedScrollExt = ResetWebNestedScrollExt,
2330         .setOnInterceptKeyEventCallBack = SetOnInterceptKeyEventCallBack,
2331         .resetOnInterceptKeyEventCallBack = ResetOnInterceptKeyEventCallBack,
2332         .setOnErrorReceive = SetOnErrorReceive,
2333         .resetOnErrorReceive = ResetOnErrorReceive,
2334         .setOnLoadIntercept = SetOnLoadIntercept,
2335         .resetOnLoadIntercept = ResetOnLoadIntercept,
2336         .setOnHttpErrorReceive = SetOnHttpErrorReceive,
2337         .resetOnHttpErrorReceive = ResetOnHttpErrorReceive,
2338         .setOnOverrideUrlLoading = SetOnOverrideUrlLoading,
2339         .resetOnOverrideUrlLoading = ResetOnOverrideUrlLoading,
2340         .setOnHttpAuthRequest = SetOnHttpAuthRequest,
2341         .resetOnHttpAuthRequest = ResetOnHttpAuthRequest,
2342         .setOnConsole = SetOnConsole,
2343         .resetOnConsole = ResetOnConsole,
2344         .setOnSslErrorEvent = SetOnSslErrorEvent,
2345         .resetOnSslErrorEvent = ResetOnSslErrorEvent,
2346         .setOnDataResubmitted = SetOnDataResubmitted,
2347         .resetOnDataResubmitted = ResetOnDataResubmitted,
2348         .setGestureFocusMode = SetGestureFocusMode,
2349         .resetGestureFocusMode = ResetGestureFocusMode,
2350         .setOnSslErrorEventReceive = SetOnSslErrorEventReceive,
2351         .resetOnSslErrorEventReceive = ResetOnSslErrorEventReceive,
2352         .setOnClientAuthenticationRequest = SetOnClientAuthenticationRequest,
2353         .resetOnClientAuthenticationRequest = ResetOnClientAuthenticationRequest,
2354         .setOnInterceptRequest = SetOnInterceptRequest,
2355         .resetOnInterceptRequest = ResetOnInterceptRequest,
2356         .setOnFaviconReceived = SetOnFaviconReceived,
2357         .resetOnFaviconReceived = ResetOnFaviconReceived,
2358         .setOnBeforeUnload = SetOnBeforeUnload,
2359         .resetOnBeforeUnload = ResetOnBeforeUnload,
2360         .setJavaScriptProxy = SetJavaScriptProxy,
2361         .resetJavaScriptProxy = ResetJavaScriptProxy,
2362     };
2363     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2364     return &modifier;
2365 }
2366 
GetCJUIWebModifier()2367 const CJUIWebModifier* GetCJUIWebModifier()
2368 {
2369     CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line
2370     static const CJUIWebModifier modifier = {
2371         .getWebController = nullptr,
2372         .getWebviewController = nullptr,
2373         .setWebOptions = nullptr,
2374         .setWebSrcResources = nullptr,
2375         .setJavaScriptAccess = SetJavaScriptAccess,
2376         .resetJavaScriptAccess = ResetJavaScriptAccess,
2377         .setFileAccessEnabled = SetFileAccessEnabled,
2378         .resetFileAccessEnabled = ResetFileAccessEnabled,
2379         .setDomStorageAccessEnabled = SetDomStorageAccessEnabled,
2380         .resetDomStorageAccessEnabled = ResetDomStorageAccessEnabled,
2381         .setMixedMode = SetMixedMode,
2382         .resetMixedMode = ResetMixedMode,
2383         .setZoomAccessEnabled = SetZoomAccessEnabled,
2384         .resetZoomAccessEnabled = ResetZoomAccessEnabled,
2385         .setCacheMode = SetCacheMode,
2386         .resetCacheMode = ResetCacheMode,
2387         .setDarkMode = SetDarkMode,
2388         .resetDarkMode = ResetDarkMode,
2389         .setMultiWindowAccessEnabled = SetMultiWindowAccessEnabled,
2390         .resetMultiWindowAccessEnabled = ResetMultiWindowAccessEnabled,
2391         .setAllowWindowOpenMethod = SetAllowWindowOpenMethod,
2392         .resetAllowWindowOpenMethod = ResetAllowWindowOpenMethod,
2393         .setKeyboardAvoidMode = SetKeyboardAvoidMode,
2394         .resetKeyboardAvoidMode = ResetKeyboardAvoidMode,
2395         .setOnControllerAttached = SetOnControllerAttached,
2396         .resetOnControllerAttached = ResetOnControllerAttached,
2397         .setVerticalScrollBarAccessEnabled = SetVerticalScrollBarAccessEnabled,
2398         .resetVerticalScrollBarAccessEnabled = ResetVerticalScrollBarAccessEnabled,
2399         .setHorizontalScrollBarAccessEnabled = SetHorizontalScrollBarAccessEnabled,
2400         .resetHorizontalScrollBarAccessEnabled = ResetHorizontalScrollBarAccessEnabled,
2401         .setTextZoomRatio = SetTextZoomRatio,
2402         .resetTextZoomRatio = ResetTextZoomRatio,
2403         .setInitialScale = SetInitialScale,
2404         .resetInitialScale = ResetInitialScale,
2405         .setOnScrollCallBack = SetOnScrollCallBack,
2406         .resetOnScrollCallBack = ResetOnScrollCallBack,
2407         .setOnOverScrollCallBack = SetOnOverScrollCallBack,
2408         .resetOnOverScrollCallBack = ResetOnOverScrollCallBack,
2409         .setOnScaleChangeCallBack = SetOnScaleChangeCallBack,
2410         .resetOnScaleChangeCallBack = ResetOnScaleChangeCallBack,
2411         .setOnRequestSelectedCallBack = SetOnRequestSelectedCallBack,
2412         .resetOnRequestSelectedCallBack = ResetOnRequestSelectedCallBack,
2413         .setOnContextMenuHideCallBack = SetOnContextMenuHideCallBack,
2414         .resetOnContextMenuHideCallBack = ResetOnContextMenuHideCallBack,
2415         .setGeolocationAccess = SetGeolocationAccess,
2416         .resetGeolocationAccess = ResetGeolocationAccess,
2417         .setDatabaseAccess = SetDatabaseAccess,
2418         .resetDatabaseAccess = ResetDatabaseAccess,
2419         .setOverviewModeAccess = SetOverviewModeAccess,
2420         .resetOverviewModeAccess = ResetOverviewModeAccess,
2421         .setForceDarkAccess = SetForceDarkAccess,
2422         .resetForceDarkAccess = ResetForceDarkAccess,
2423         .setPinchSmooth = SetPinchSmooth,
2424         .resetPinchSmooth = ResetPinchSmooth,
2425         .setMetaViewport = SetMetaViewport,
2426         .resetMetaViewport = ResetMetaViewport,
2427         .setEnableFollowSystemFontWeight = SetEnableFollowSystemFontWeight,
2428         .resetEnableFollowSystemFontWeight = ResetEnableFollowSystemFontWeight,
2429         .setEnableNativeEmbedMode = SetEnableNativeEmbedMode,
2430         .resetEnableNativeEmbedMode = ResetEnableNativeEmbedMode,
2431         .setMinFontSize = SetMinFontSize,
2432         .resetMinFontSize = ResetMinFontSize,
2433         .setDefaultFontSize = SetDefaultFontSize,
2434         .resetDefaultFontSize = ResetDefaultFontSize,
2435         .setDefaultFixedFontSize = SetDefaultFixedFontSize,
2436         .resetDefaultFixedFontSize = ResetDefaultFixedFontSize,
2437         .setMinLogicalFontSize = SetMinLogicalFontSize,
2438         .resetMinLogicalFontSize = ResetMinLogicalFontSize,
2439         .setWebStandardFont = SetWebStandardFont,
2440         .resetWebStandardFont = ResetWebStandardFont,
2441         .setWebSerifFont = SetWebSerifFont,
2442         .resetWebSerifFont = ResetWebSerifFont,
2443         .setWebSansSerifFont = SetWebSansSerifFont,
2444         .resetWebSansSerifFont = ResetWebSansSerifFont,
2445         .setWebFixedFont = SetWebFixedFont,
2446         .resetWebFixedFont = ResetWebFixedFont,
2447         .setWebFantasyFont = SetWebFantasyFont,
2448         .resetWebFantasyFont = ResetWebFantasyFont,
2449         .setWebCursiveFont = SetWebCursiveFont,
2450         .resetWebCursiveFont = ResetWebCursiveFont,
2451         .setLayoutMode = SetLayoutMode,
2452         .resetLayoutMode = ResetLayoutMode,
2453         .setOnNativeEmbedLifecycleChange = SetOnNativeEmbedLifecycleChange,
2454         .resetOnNativeEmbedLifecycleChange = ResetOnNativeEmbedLifecycleChange,
2455         .setOnNativeEmbedGestureEvent = SetOnNativeEmbedGestureEvent,
2456         .resetOnNativeEmbedGestureEvent = ResetOnNativeEmbedGestureEvent,
2457         .setRegisterNativeEmbedRule = SetRegisterNativeEmbedRule,
2458         .resetRegisterNativeEmbedRule = ResetRegisterNativeEmbedRule,
2459         .setNativeEmbedOptions = SetNativeEmbedOptions,
2460         .resetNativeEmbedOptions = ResetNativeEmbedOptions,
2461         .setOnFirstContentfulPaint = SetOnFirstContentfulPaint,
2462         .resetOnFirstContentfulPaint = ResetOnFirstContentfulPaint,
2463         .setOnAudioStateChanged = SetOnAudioStateChanged,
2464         .resetOnAudioStateChanged = ResetOnAudioStateChanged,
2465         .setOnFullScreenExit = SetOnFullScreenExit,
2466         .resetOnFullScreenExit = ResetOnFullScreenExit,
2467         .setImageAccess = SetImageAccess,
2468         .resetImageAccess = ResetImageAccess,
2469         .setOnlineImageAccess = SetOnlineImageAccess,
2470         .resetOnlineImageAccess = ResetOnlineImageAccess,
2471         .setMediaPlayGestureAccess = SetMediaPlayGestureAccess,
2472         .resetMediaPlayGestureAccess = ResetMediaPlayGestureAccess,
2473         .setMediaOptions = SetMediaOptions,
2474         .resetMediaOptions = ResetMediaOptions,
2475         .setOnPageEnd = SetOnPageEnd,
2476         .resetOnPageEnd = ResetOnPageEnd,
2477         .setOnPageBegin = SetOnPageBegin,
2478         .resetOnPageBegin = ResetOnPageBegin,
2479         .setOnProgressChange = SetOnProgressChange,
2480         .resetOnProgressChange = ResetOnProgressChange,
2481         .setOnTitleReceive = SetOnTitleReceive,
2482         .resetOnTitleReceive = ResetOnTitleReceive,
2483         .setOnDownloadStart = SetOnDownloadStart,
2484         .resetOnDownloadStart = ResetOnDownloadStart,
2485         .setJavaScriptOnDocumentStart = SetJavaScriptOnDocumentStart,
2486         .resetJavaScriptOnDocumentStart = ResetJavaScriptOnDocumentStart,
2487         .setJavaScriptOnDocumentEnd = SetJavaScriptOnDocumentEnd,
2488         .resetJavaScriptOnDocumentEnd = ResetJavaScriptOnDocumentEnd,
2489         .setCopyOptionMode = SetCopyOptionMode,
2490         .resetCopyOptionMode = ResetCopyOptionMode,
2491         .setRenderProcessNotResponding = SetRenderProcessNotResponding,
2492         .resetRenderProcessNotResponding = ResetRenderProcessNotResponding,
2493         .setOnPageVisibleCallBack = SetOnPageVisibleCallBack,
2494         .resetOnPageVisibleCallBack = ResetOnPageVisibleCallBack,
2495         .setOnRenderExitedCallBack = SetOnRenderExitedCallBack,
2496         .resetOnRenderExitedCallBack = ResetOnRenderExitedCallBack,
2497         .setBlockNetwork = SetBlockNetwork,
2498         .resetBlockNetwork = ResetBlockNetwork,
2499         .setOnResourceLoadCallBack = SetOnResourceLoadCallBack,
2500         .resetOnResourceLoadCallBack = ResetOnResourceLoadCallBack,
2501         .setOnRefreshAccessedHistoryCallBack = SetOnRefreshAccessedHistoryCallBack,
2502         .resetOnRefreshAccessedHistoryCallBack = ResetOnRefreshAccessedHistoryCallBack,
2503         .setOnNavigationEntryCommittedCallBack = SetOnNavigationEntryCommittedCallBack,
2504         .resetOnNavigationEntryCommittedCallBack = ResetOnNavigationEntryCommittedCallBack,
2505         .setOnSearchResultReceiveCallBack = SetOnSearchResultReceiveCallBack,
2506         .resetOnSearchResultReceiveCallBack = ResetOnSearchResultReceiveCallBack,
2507         .setOverScrollMode = SetOverScrollMode,
2508         .resetOverScrollMode = ResetOverScrollMode,
2509         .setOnTouchIconUrlReceivedCallBack = SetOnTouchIconUrlReceivedCallBack,
2510         .resetOnTouchIconUrlReceivedCallBack = ResetOnTouchIconUrlReceivedCallBack,
2511         .setOnRenderProcessRespondingCallBack = SetOnRenderProcessRespondingCallBack,
2512         .resetOnRenderProcessRespondingCallBack = ResetOnRenderProcessRespondingCallBack,
2513         .setOnWindowNew = SetOnWindowNew,
2514         .resetOnWindowNew = ResetOnWindowNew,
2515         .setOnGeolocationShow = SetOnGeolocationShow,
2516         .resetOnGeolocationShow = ResetOnGeolocationShow,
2517         .setOnPermissionRequest = SetOnPermissionRequest,
2518         .resetOnPermissionRequest = ResetOnPermissionRequest,
2519         .setOnScreenCaptureRequest = SetOnScreenCaptureRequest,
2520         .resetOnScreenCaptureRequest = ResetOnScreenCaptureRequest,
2521         .setOnFullScreenEnter = SetOnFullScreenEnter,
2522         .resetOnFullScreenEnter = ResetOnFullScreenEnter,
2523         .setOnWindowExit = SetOnWindowExit,
2524         .resetOnWindowExit = ResetOnWindowExit,
2525         .setOnAlertlCallBack = SetOnAlertlCallBack,
2526         .resetOnAlertlCallBack = ResetOnAlertlCallBack,
2527         .setOnConfirmCallBack = SetOnConfirmCallBack,
2528         .resetOnConfirmCallBack = ResetOnConfirmCallBack,
2529         .setOnPromptCallBack = SetOnPromptCallBack,
2530         .resetOnPromptCallBack = ResetOnPromptCallBack,
2531         .setOnShowFileSelector = SetOnShowFileSelector,
2532         .resetOnShowFileSelector = ResetOnShowFileSelector,
2533         .setOnContextMenuShow = SetOnContextMenuShow,
2534         .resetOnContextMenuShow = ResetOnContextMenuShow,
2535         .setOnSafeBrowsingCheckResultCallBack = SetOnSafeBrowsingCheckResultCallBack,
2536         .resetOnSafeBrowsingCheckResultCallBack = ResetOnSafeBrowsingCheckResultCallBack,
2537         .setWebNestedScrollExt = SetWebNestedScrollExt,
2538         .resetWebNestedScrollExt = ResetWebNestedScrollExt,
2539         .setOnInterceptKeyEventCallBack = SetOnInterceptKeyEventCallBack,
2540         .resetOnInterceptKeyEventCallBack = ResetOnInterceptKeyEventCallBack,
2541         .setOnErrorReceive = SetOnErrorReceive,
2542         .resetOnErrorReceive = ResetOnErrorReceive,
2543         .setOnLoadIntercept = SetOnLoadIntercept,
2544         .resetOnLoadIntercept = ResetOnLoadIntercept,
2545         .setOnHttpErrorReceive = SetOnHttpErrorReceive,
2546         .resetOnHttpErrorReceive = ResetOnHttpErrorReceive,
2547         .setOnOverrideUrlLoading = SetOnOverrideUrlLoading,
2548         .resetOnOverrideUrlLoading = ResetOnOverrideUrlLoading,
2549         .setOnHttpAuthRequest = SetOnHttpAuthRequest,
2550         .resetOnHttpAuthRequest = ResetOnHttpAuthRequest,
2551         .setOnConsole = SetOnConsole,
2552         .resetOnConsole = ResetOnConsole,
2553         .setOnSslErrorEvent = SetOnSslErrorEvent,
2554         .resetOnSslErrorEvent = ResetOnSslErrorEvent,
2555         .setOnDataResubmitted = SetOnDataResubmitted,
2556         .resetOnDataResubmitted = ResetOnDataResubmitted,
2557         .setGestureFocusMode = SetGestureFocusMode,
2558         .resetGestureFocusMode = ResetGestureFocusMode,
2559         .setOnSslErrorEventReceive = SetOnSslErrorEventReceive,
2560         .resetOnSslErrorEventReceive = ResetOnSslErrorEventReceive,
2561         .setOnClientAuthenticationRequest = SetOnClientAuthenticationRequest,
2562         .resetOnClientAuthenticationRequest = ResetOnClientAuthenticationRequest,
2563         .setOnInterceptRequest = SetOnInterceptRequest,
2564         .resetOnInterceptRequest = ResetOnInterceptRequest,
2565         .setOnFaviconReceived = SetOnFaviconReceived,
2566         .resetOnFaviconReceived = ResetOnFaviconReceived,
2567         .setOnBeforeUnload = SetOnBeforeUnload,
2568         .resetOnBeforeUnload = ResetOnBeforeUnload,
2569         .setJavaScriptProxy = SetJavaScriptProxy,
2570         .resetJavaScriptProxy = ResetJavaScriptProxy,
2571     };
2572     CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line
2573     return &modifier;
2574 }
2575 } // namespace NodeModifier
2576 } // namespace OHOS::Ace::NG