• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ARK_WEB_HANDLER_H_
17 #define ARK_WEB_HANDLER_H_
18 #pragma once
19 
20 #include "ohos_nweb/include/ark_web_access_request.h"
21 #include "ohos_nweb/include/ark_web_applink_callback.h"
22 #include "ohos_nweb/include/ark_web_console_log.h"
23 #include "ohos_nweb/include/ark_web_context_menu_callback.h"
24 #include "ohos_nweb/include/ark_web_context_menu_params.h"
25 #include "ohos_nweb/include/ark_web_controller_handler.h"
26 #include "ohos_nweb/include/ark_web_cursor_info.h"
27 #include "ohos_nweb/include/ark_web_custom_keyboard_handler.h"
28 #include "ohos_nweb/include/ark_web_data_resubmission_callback.h"
29 #include "ohos_nweb/include/ark_web_date_time_chooser.h"
30 #include "ohos_nweb/include/ark_web_date_time_chooser_callback.h"
31 #include "ohos_nweb/include/ark_web_date_time_suggestion_vector.h"
32 #include "ohos_nweb/include/ark_web_file_selector_params.h"
33 #include "ohos_nweb/include/ark_web_first_meaningful_paint_details.h"
34 #include "ohos_nweb/include/ark_web_full_screen_exit_handler.h"
35 #include "ohos_nweb/include/ark_web_geo_location_callback.h"
36 #include "ohos_nweb/include/ark_web_image_options.h"
37 #include "ohos_nweb/include/ark_web_js_all_ssl_error_result.h"
38 #include "ohos_nweb/include/ark_web_js_dialog_result.h"
39 #include "ohos_nweb/include/ark_web_js_http_auth_result.h"
40 #include "ohos_nweb/include/ark_web_js_ssl_error_result.h"
41 #include "ohos_nweb/include/ark_web_js_ssl_select_cert_result.h"
42 #include "ohos_nweb/include/ark_web_key_event.h"
43 #include "ohos_nweb/include/ark_web_largest_contentful_paint_details.h"
44 #include "ohos_nweb/include/ark_web_load_committed_details.h"
45 #include "ohos_nweb/include/ark_web_native_embed_data_info.h"
46 #include "ohos_nweb/include/ark_web_native_embed_touch_event.h"
47 #include "ohos_nweb/include/ark_web_native_embed_mouse_event.h"
48 #include "ohos_nweb/include/ark_web_nweb.h"
49 #include "ohos_nweb/include/ark_web_quick_menu_callback.h"
50 #include "ohos_nweb/include/ark_web_quick_menu_params.h"
51 #include "ohos_nweb/include/ark_web_screen_capture_access_request.h"
52 #include "ohos_nweb/include/ark_web_select_popup_menu_callback.h"
53 #include "ohos_nweb/include/ark_web_select_popup_menu_param.h"
54 #include "ohos_nweb/include/ark_web_string_vector_value_callback.h"
55 #include "ohos_nweb/include/ark_web_touch_handle_hot_zone.h"
56 #include "ohos_nweb/include/ark_web_touch_handle_state.h"
57 #include "ohos_nweb/include/ark_web_url_resource_error.h"
58 #include "ohos_nweb/include/ark_web_url_resource_request.h"
59 #include "ohos_nweb/include/ark_web_url_resource_response.h"
60 
61 namespace OHOS::ArkWeb {
62 
63 /*--ark web(source=webview)--*/
64 class ArkWebHandler : public virtual ArkWebBaseRefCounted {
65 public:
66     /*--ark web()--*/
67     virtual void SetNWeb(ArkWebRefPtr<ArkWebNWeb> nweb) = 0;
68 
69     /**
70      * @brief Request display and focus for a new nweb.
71      *
72      */
73     /*--ark web()--*/
74     virtual bool OnFocus() = 0;
75 
76     /*--ark web()--*/
77     virtual void OnMessage(const ArkWebString& param) = 0;
78 
79     /**
80      * @brief Notify the SDK that the nweb will load the resource specified by the
81      *        given url.
82      *
83      * @param url The url of the resource.
84      */
85     /*--ark web()--*/
86     virtual void OnResource(const ArkWebString& url) = 0;
87 
88     /**
89      * @brief Notify the SDK of a new favicon for the current web site.
90      *
91      * @param data The raw image data for the icon.
92      * @param width The width of the icon in pixel.
93      * @param height The height of the icon in pixel.
94      * @param color_type The color data encoding type.
95      * @param alpha_type The alpha value of any pixel.
96      */
97     /*--ark web()--*/
98     virtual void OnPageIcon(const void* data, size_t width, size_t height, int color_type, int alpha_type) = 0;
99 
100     /**
101      * @brief Notify the SDK of the changed document title.
102      *
103      * @param title The document title.
104      */
105     /*--ark web()--*/
106     virtual void OnPageTitle(const ArkWebString& title) = 0;
107 
108     /*--ark web()--*/
109     virtual void OnProxyDied() = 0;
110 
111     /**
112      * @brief Notify the SDK that an HTTP error has been received from the server
113      *        while loading a resource.
114      *
115      * @param request The request information.
116      * @param error_response The error occurred.
117      */
118     /*--ark web()--*/
119     virtual void OnHttpError(
120         ArkWebRefPtr<ArkWebUrlResourceRequest> request, ArkWebRefPtr<ArkWebUrlResourceResponse> error_response) = 0;
121 
122     /**
123      * @brief Report a JavaScript console message to the host application.
124      *
125      * @param message Details of the console message.
126      *
127      * @return Return true to stop the message from being output to the console.
128      */
129     /*--ark web()--*/
130     virtual bool OnConsoleLog(ArkWebRefPtr<ArkWebConsoleLog> message) = 0;
131 
132     /*--ark web()--*/
133     virtual void OnRouterPush(const ArkWebString& param) = 0;
134 
135     /**
136      * @brief Notify the SDK that a web site has finished loading. This method is
137      *        called only for main frame.
138      *
139      * @param http_status_code The status code for the http request.
140      * @param url The url of the web site.
141      */
142     /*--ark web()--*/
143     virtual void OnPageLoadEnd(int http_status_code, const ArkWebString& url) = 0;
144 
145     /**
146      * @brief Notify the SDK that a web site has started loading. This method is
147      *        called once for each main frame load.
148      *
149      * @param url The url to be loaded.
150      */
151     /*--ark web()--*/
152     virtual void OnPageLoadBegin(const ArkWebString& url) = 0;
153 
154     /**
155      * @brief Report a load error to the SDK.
156      *
157      * @param error_code The error code.
158      * @param description The error description.
159      * @param failing_url The failed url.
160      */
161     /*--ark web()--*/
162     virtual void OnPageLoadError(int error_code, const ArkWebString& description, const ArkWebString& failing_url) = 0;
163 
164     /**
165      * @brief Notify the SDK of the url for a touch icon.
166      *
167      * @param icon_url The icon url.
168      * @param precomposed The touch icon type.
169      */
170     /*--ark web()--*/
171     virtual void OnDesktopIconUrl(const ArkWebString& icon_url, bool precomposed) = 0;
172 
173     /**
174      * @brief Notify the SDK the current progress of loading a web site.
175      *
176      * @param new_progress Loading progress, an integer between 0 and 100.
177      */
178     /*--ark web()--*/
179     virtual void OnLoadingProgress(int new_progress) = 0;
180 
181     /**
182      * @brief Show prompt to ask for the geo location permission.
183      *
184      * @param origin String: the origin of the resource to get geo location
185      * @param callback GeolocationCallbackInterface: callback to report geo
186      *        location
187      */
188     /*--ark web()--*/
189     virtual void OnGeolocationShow(const ArkWebString& origin, ArkWebRefPtr<ArkWebGeoLocationCallback> callback) = 0;
190 
191     /**
192      * @brief Hide prompt to ask for the geolocation permission.
193      */
194     /*--ark web()--*/
195     virtual void OnGeolocationHide() = 0;
196 
197     /**
198      * @brief inform application to show a file selector.
199      *
200      * @param callback the file list to select.
201      * @param params the params of file selector.
202      */
203     /*--ark web()--*/
204     virtual bool OnFileSelectorShow(
205         ArkWebRefPtr<ArkWebStringVectorValueCallback> callback, ArkWebRefPtr<ArkWebFileSelectorParams> params) = 0;
206 
207     /**
208      * @brief Report web resource loading error to the SDK. These errors usually
209      *        indicate inability to connect to the server.
210      *
211      * @param request The request information.
212      * @param error The error information.
213      */
214     /*--ark web()--*/
215     virtual void OnResourceLoadError(
216         ArkWebRefPtr<ArkWebUrlResourceRequest> request, ArkWebRefPtr<ArkWebUrlResourceError> error) = 0;
217 
218     /**
219      * @brief Ask for the permission.
220      *
221      * @param request std::shared_ptr<NWebAccessRequest>: A request to ask for the
222      *        permission.
223      */
224     /*--ark web()--*/
225     virtual void OnPermissionRequest(ArkWebRefPtr<ArkWebAccessRequest> request) = 0;
226 
227     /*--ark web()--*/
228     virtual void OnQuickMenuDismissed() = 0;
229 
230     /*--ark web()--*/
231     virtual void OnContextMenuDismissed() = 0;
232 
233     /*--ark web()--*/
234     virtual void OnTouchSelectionChanged(ArkWebRefPtr<ArkWebTouchHandleState> insert_handle,
235         ArkWebRefPtr<ArkWebTouchHandleState> start_selection_handle,
236         ArkWebRefPtr<ArkWebTouchHandleState> end_selection_handle) = 0;
237 
238     /**
239      * @brief Notify the host application of a resource request and allow the
240      *        application to return the data.
241      *
242      * @param request request information
243      * @param response response information
244      *
245      * @retval true if handle success, otherwise false.
246      */
247     /*--ark web()--*/
248     virtual bool OnHandleInterceptRequest(
249         ArkWebRefPtr<ArkWebUrlResourceRequest> request, ArkWebRefPtr<ArkWebUrlResourceResponse> response) = 0;
250 
251     /**
252      * @brief inform application to update its visited links database.
253      *
254      * @param url the url being visited.
255      * @param is_reload true if the url is being reload.
256      */
257     /*--ark web()--*/
258     virtual void OnRefreshAccessedHistory(const ArkWebString& url, bool is_reload) = 0;
259 
260     /**
261      * @brief Cancel the request to ask for the permission.
262      *
263      * @param request std::shared_ptr<NWebAccessRequest>: A request to ask for the
264      *        permission.
265      */
266     /*--ark web()--*/
267     virtual void OnPermissionRequestCanceled(ArkWebRefPtr<ArkWebAccessRequest> request) = 0;
268 
269     /**
270      * @brief Give the SDK a chance to decide whether to continue loading the url.
271      *
272      * @param url The url to be loaded.
273      *
274      * @return true to cancel the loading, false to continue the loading.
275      */
276     /*--ark web()--*/
277     virtual bool OnHandleInterceptUrlLoading(ArkWebRefPtr<ArkWebUrlResourceRequest> request) = 0;
278 
279     /*--ark web()--*/
280     virtual bool RunQuickMenu(
281         ArkWebRefPtr<ArkWebQuickMenuParams> params, ArkWebRefPtr<ArkWebQuickMenuCallback> callback) = 0;
282 
283     /*--ark web()--*/
284     virtual bool RunContextMenu(
285         ArkWebRefPtr<ArkWebContextMenuParams> params, ArkWebRefPtr<ArkWebContextMenuCallback> callback) = 0;
286 
287     /*--ark web()--*/
288     virtual void UpdateDragCursor(unsigned char op) = 0;
289 
290     /*--ark web()--*/
291     virtual bool FilterScrollEvent(const float x, const float y, const float x_velocity, const float y_velocity) = 0;
292 
293     /**
294      * @brief Obtains a list of all visited history items, used for link coloring
295      *
296      * @return visited history
297      */
298     /*--ark web()--*/
299     virtual ArkWebStringVector VisitedUrlHistory() = 0;
300 
301     /**
302      * @brief called when new window required.
303      *
304      * @param target_url URL to be loaded in the new window.
305      * @param is_alert dialog window or not.
306      * @param is_user_trigger triggered by User.
307      * @param handler set the new web object.
308      */
309     /*--ark web()--*/
310     virtual void OnWindowNewByJS(const ArkWebString& target_url, bool is_alert, bool is_user_trigger,
311         ArkWebRefPtr<ArkWebControllerHandler> handler) = 0;
312 
313     /**
314      * @brief called when window exit.
315      */
316     /*--ark web()--*/
317     virtual void OnWindowExitByJS() = 0;
318 
319     /**
320      * @brief Notify the host application that the web page wants to display a
321      *        JavaScript alert() dialog.
322      *
323      * @param url String: The url of the page requesting the dialog.
324      * @param message String: The message of the dialog.
325      * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to
326      *        confirm that the user closed the window.
327      *
328      * @return To show a custom dialog, the app should return true.
329      */
330     /*--ark web()--*/
331     virtual bool OnAlertDialogByJS(
332         const ArkWebString& url, const ArkWebString& message, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0;
333 
334     /**
335      * @brief Notify the host application that the web page wants to handle
336      *        JavaScript onbeforeunload.
337      *
338      * @param url String: The url of the page requesting.
339      * @param message String: The message of the dialog.
340      * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to
341      *        confirm that the user closed the window.
342      *
343      * @return To show a custom dialog, the app should return true.
344      */
345     /*--ark web()--*/
346     virtual bool OnBeforeUnloadByJS(
347         const ArkWebString& url, const ArkWebString& message, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0;
348 
349     /**
350      * @brief Notify the host application that the web page wants to display a
351      *        JavaScript prompt() dialog.
352      *
353      * @param url String: The url of the page requesting the dialog.
354      * @param message String: The message of the dialog.
355      * @param default_value String: The default value of the input message.
356      * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to
357      *        confirm that the user closed the window.
358      *
359      * @return To show a custom dialog, the app should return true.
360      */
361     /*--ark web()--*/
362     virtual bool OnPromptDialogByJS(const ArkWebString& url, const ArkWebString& message,
363         const ArkWebString& default_value, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0;
364 
365     /**
366      * @brief Notify the host application that the web page wants to display a
367      *        JavaScript Confirm() dialog.
368      *
369      * @param url String: The url of the page requesting the dialog.
370      * @param message String: The message of the dialog.
371      * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to
372      *        confirm that the user closed the window.
373      *
374      * @return To show a custom dialog, the app should return true.
375      */
376     /*--ark web()--*/
377     virtual bool OnConfirmDialogByJS(
378         const ArkWebString& url, const ArkWebString& message, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0;
379 
380     /*--ark web()--*/
381     virtual bool OnHttpAuthRequestByJS(
382         ArkWebRefPtr<ArkWebJsHttpAuthResult> result, const ArkWebString& host, const ArkWebString& realm) = 0;
383 
384     /*--ark web()--*/
385     virtual bool OnSslErrorRequestByJS(ArkWebRefPtr<ArkWebJsSslErrorResult> result, int error) = 0;
386 
387     /*--ark web()--*/
388     virtual bool OnSslSelectCertRequestByJS(ArkWebRefPtr<ArkWebJsSslSelectCertResult> result, const ArkWebString& host,
389         int port, const ArkWebStringVector& key_types, const ArkWebStringVector& issuers) = 0;
390 
391     /*--ark web()--*/
392     virtual void OnScroll(double x_offset, double y_offset) = 0;
393 
394     /*--ark web()--*/
395     virtual void OnOverScroll(float x_offset, float y_offset) = 0;
396 
397     /*--ark web()--*/
398     virtual void OnScrollState(bool scroll_state) = 0;
399 
400     /**
401      * @brief called when the page being loaded is about to be made visible.
402      */
403     /*--ark web()--*/
404     virtual void OnPageVisible(const ArkWebString& url) = 0;
405 
406     /**
407      * @brief Give the host application a chance to handle the key event
408      *        synchronousl.
409      *
410      * @param event The key event.
411      *
412      * @return True if the host application wants to handle the key event itself,
413      *         otherwise return false.
414      */
415     /*--ark web()--*/
416     virtual bool OnPreKeyEvent(ArkWebRefPtr<ArkWebKeyEvent> event) = 0;
417 
418     /*--ark web()--*/
419     virtual void OnScaleChanged(float old_scale_factor, float new_scale_factor) = 0;
420 
421     /**
422      * @brief Called when the browser's cursor has changed.
423      *
424      * @param type Cursor type.
425      * @param info If |type| is CT_CUSTOM then |info| will be populated with the
426      *        custom cursor information.
427      *
428      * @return True if the cursor change was handled or false for default
429      *         handling.
430      */
431     /*--ark web()--*/
432     virtual bool OnCursorChange(const int32_t& type, ArkWebRefPtr<ArkWebCursorInfo> info) = 0;
433 
434     /**
435      * @brief called when the render process exit.
436      *
437      * @param reason the detail reason why render process exit, the implementation
438      *        of this callback should attempt to clean up the specific nweb that
439      *        was set by SetNWeb interface.
440      */
441     /*--ark web()--*/
442     virtual void OnRenderExited(int reason) = 0;
443 
444     /**
445      * @brief Called when resize not work.
446      */
447     /*--ark web()--*/
448     virtual void OnResizeNotWork() = 0;
449 
450     /**
451      * @brief called when the page exit the full-screen mode.
452      */
453     /*--ark web()--*/
454     virtual void OnFullScreenExit() = 0;
455 
456     /**
457      * @brief called when the page enter the full-screen mode.
458      *
459      * @param handler to exit full-screen mode.
460      */
461     /*--ark web()--*/
462     virtual void OnFullScreenEnter(ArkWebRefPtr<ArkWebFullScreenExitHandler> handler) = 0;
463 
464     /*--ark web()--*/
465     virtual bool OnDragAndDropData(const void* data, size_t len, ArkWebRefPtr<ArkWebImageOptions> opt) = 0;
466 
467     /*--ark web()--*/
468     virtual void OnSelectPopupMenu(
469         ArkWebRefPtr<ArkWebSelectPopupMenuParam> params, ArkWebRefPtr<ArkWebSelectPopupMenuCallback> callback) = 0;
470 
471     /**
472      * @brief shows the repost form confirmation dialog box.
473      *
474      * @param handler sets whether to resend data.
475      */
476     /*--ark web()--*/
477     virtual void OnDataResubmission(ArkWebRefPtr<ArkWebDataResubmissionCallback> handler) = 0;
478 
479     /*--ark web()--*/
480     virtual void OnRootLayerChanged(int width, int height) = 0;
481 
482     /**
483      * @brief Called when the audio playing state on web page changed.
484      *
485      * @param playing Whether the audio is playing or not.
486      */
487     /*--ark web()--*/
488     virtual void OnAudioStateChanged(bool playing) = 0;
489 
490     /*--ark web()--*/
491     virtual void OnOverScrollFlingEnd() = 0;
492 
493     /**
494      * @brief Notify the host application that a key was not handled by the
495      *        WebView.
496      *
497      * @param event The key event.
498      *
499      * @return True if the host application wants to handle the key event itself,
500      *         otherwise return false.
501      */
502     /*--ark web()--*/
503     virtual bool OnUnProcessedKeyEvent(ArkWebRefPtr<ArkWebKeyEvent> event) = 0;
504 
505     /*--ark web()--*/
506     virtual bool OnDragAndDropDataUdmf(ArkWebRefPtr<ArkWebDragData> drag_data) = 0;
507 
508     /**
509      * @brief Called when the first content rendering of web page.
510      *
511      * @param navigation_start_tick Absolute navigation start time, as TimeTicks.
512      * @param first_contentful_paint_ms Time to first contentful paint from
513      *        navigation start.
514      */
515     /*--ark web()--*/
516     virtual void OnFirstContentfulPaint(int64_t navigation_start_tick, int64_t first_contentful_paint_ms) = 0;
517 
518     /*--ark web()--*/
519     virtual void OnDateTimeChooserPopup(ArkWebRefPtr<ArkWebDateTimeChooser> chooser,
520         const ArkWebDateTimeSuggestionVector& suggestions, ArkWebRefPtr<ArkWebDateTimeChooserCallback> callback) = 0;
521 
522     /*--ark web()--*/
523     virtual void OnDateTimeChooserClose() = 0;
524 
525     /**
526      * @brief Ask for the screen capture permission.
527      *
528      * @param request std::shared_ptr<NWebScreenCaptureAccessRequest>: A request
529      *        to ask for the screen capture permission.
530      */
531     /*--ark web()--*/
532     virtual void OnScreenCaptureRequest(ArkWebRefPtr<ArkWebScreenCaptureAccessRequest> request) = 0;
533 
534     /**
535      * @brief Called when the media or form state on the web page changed.
536      *
537      * @param state state of the media or form. Refer to the enum class
538      *        MediaPlayingState and FormState
539      * @param type it can be form, media, or audio
540      */
541     /*--ark web()--*/
542     virtual void OnActivityStateChanged(int state, int type) = 0;
543 
544     /*--ark web()--*/
545     virtual void OnGetTouchHandleHotZone(ArkWebRefPtr<ArkWebTouchHandleHotZone> hot_zone) = 0;
546 
547     /**
548      * @brief Called when swap buffer completed with new size.
549      */
550     /*--ark web()--*/
551     virtual void OnCompleteSwapWithNewSize() = 0;
552 
553     /*--ark web()--*/
554     virtual void OnOverScrollFlingVelocity(float x_velocity, float y_velocity, bool is_fling) = 0;
555 
556     /**
557      * @brief called when the navigation entry has been committed.
558      *
559      * @param details represents the details of a committed navigation entry.
560      */
561     /*--ark web()--*/
562     virtual void OnNavigationEntryCommitted(ArkWebRefPtr<ArkWebLoadCommittedDetails> details) = 0;
563 
564     /*--ark web()--*/
565     virtual void OnNativeEmbedLifecycleChange(ArkWebRefPtr<ArkWebNativeEmbedDataInfo> data_info) = 0;
566 
567     /*--ark web()--*/
568     virtual void OnNativeEmbedGestureEvent(ArkWebRefPtr<ArkWebNativeEmbedTouchEvent> touch_event) = 0;
569 
570     /**
571      * @brief Called when received website security risk check result.
572      *
573      * @param threat_type The threat type of website.
574      */
575     /*--ark web()--*/
576     virtual void OnSafeBrowsingCheckResult(int threat_type) = 0;
577 
578     /**
579      * @brief Called when tracker's cookie is prevented.
580      *
581      * @param website_host The host of website url.
582      *
583      * @param tracker_host The host of tracker url.
584      */
585     /*--ark web()--*/
586     virtual void OnIntelligentTrackingPreventionResult(
587         const ArkWebString& website_host, const ArkWebString& tracker_host) = 0;
588 
589     /**
590      * @brief called when the page enter the full-screen mode.
591      *
592      * @param handler to exit full-screen mode.
593      * @param video_natural_width indicates the width of the <video> element
594      * entering full screen.
595      * @param video_natural_height indicates the height of the <video> element
596      * entering full screen.
597      */
598     /*--ark web()--*/
599     virtual void OnFullScreenEnterWithVideoSize(
600         ArkWebRefPtr<ArkWebFullScreenExitHandler> handler, int video_natural_width, int video_natural_height) = 0;
601 
602     /**
603      * @brief Give the application a chance to decide whether to override loading the
604      * url.
605      *
606      * @param request The request information.
607      * @return true to abort loading the url, false to continue loading the url
608      * as usual.
609      */
610     /*--ark web()--*/
611     virtual bool OnHandleOverrideUrlLoading(ArkWebRefPtr<ArkWebUrlResourceRequest> request) = 0;
612 
613     /*--ark web()--*/
614     virtual void OnFirstMeaningfulPaint(ArkWebRefPtr<ArkWebFirstMeaningfulPaintDetails> details) = 0;
615 
616     /*--ark web()--*/
617     virtual void OnLargestContentfulPaint(ArkWebRefPtr<ArkWebLargestContentfulPaintDetails> details) = 0;
618 
619     /*--ark web()--*/
620     virtual bool OnAllSslErrorRequestByJS(ArkWebRefPtr<ArkWebJsAllSslErrorResult> result, int error,
621         const ArkWebString& url, const ArkWebString& originalUrl, const ArkWebString& referrer, bool isFatalError,
622         bool isMainFrame) = 0;
623 
624     /*--ark web()--*/
625     virtual void OnTooltip(const ArkWebString& tooltip) = 0;
626 
627     /*--ark web()--*/
628     virtual void ReleaseResizeHold() = 0;
629 
630     /*--ark web()--*/
631     virtual void OnShowAutofillPopup(
632         const float offsetX, const float offsetY, const ArkWebStringVector& menu_items) = 0;
633 
634     /*--ark web()--*/
635     virtual void OnHideAutofillPopup() = 0;
636 
637     /*--ark web()--*/
638     virtual ArkWebCharVector GetWordSelection(const ArkWebString& text, int8_t offset) = 0;
639 
640     /*--ark web()--*/
641     virtual void UpdateClippedSelectionBounds(int x, int y, int w, int h) = 0;
642 
643     /*--ark web()--*/
644     virtual bool OnOpenAppLink(const ArkWebString& url, ArkWebRefPtr<ArkWebAppLinkCallback> callback) = 0;
645 
646     /**
647      * @brief Called when the render process not responding.
648      *
649      * @param js_stack Javascript stack info of webpage when render process not
650      * responding.
651      * @param pid Process id of the render process not responding.
652      * @param reason Reason of the render process not responding.
653      */
654     /*--ark web()--*/
655     virtual void OnRenderProcessNotResponding(const ArkWebString& js_stack, int pid, int reason) = 0;
656 
657     /**
658      * @brief Called when the unresponding render process becomes responsive.
659      *
660      */
661     /*--ark web()--*/
662     virtual void OnRenderProcessResponding() = 0;
663 
664     /**
665      * @brief Called when the viewport-fit meta is detected for web page.
666      *
667      * @param viewportFit The type of the viewport-fit.
668      */
669     /*--ark web()--*/
670     virtual void OnViewportFitChange(int viewportFit) = 0;
671 
672     /**
673      * @brief Called when creating overlay.
674      *
675      * @param data
676      * @param len
677      * @param width
678      * @param height
679      * @param offset_x
680      * @param offset_y
681      * @param rect_width
682      * @param rect_height
683      * @param point_x
684      * @param point_y
685      */
686     /*--ark web()--*/
687     virtual void CreateOverlay(void* data, size_t len, int width, int height, int offset_x, int offset_y,
688         int rect_width, int rect_height, int point_x, int point_y) = 0;
689 
690     /**
691      * @brief Called when overlay state changed.
692      *
693      * @param offset_x
694      * @param offset_y
695      * @param rect_width
696      * @param rect_height
697      */
698     /*--ark web()--*/
699     virtual void OnOverlayStateChanged(int offset_x, int offset_y, int rect_width, int rect_height) = 0;
700 
701     /**
702      * @brief Request display and focus for a new nweb.
703      *
704      * @param source The Focus Source.
705      * @return Return true if request focus success, false if request focus fail.
706      */
707     /*--ark web()--*/
708     virtual bool OnFocus(int source) = 0;
709 
710     /**
711      * @brief Called when the page is over scroll.
712      *
713      * @param xOffset The offset of x axis.
714      * @param yOffset The offset of y axis.
715      * @param xVelocity The velocity of x axis.
716      * @param yVelocity The velocity of y axis.
717      * @return Return true if value is consumed, false if value is unconsumed.
718      */
719     /*--ark web()--*/
720     virtual bool OnOverScroll(float xOffset, float yOffset, float xVelocity, float yVelocity) = 0;
721 
722     /**
723      * @brief Called when the key board redispatch.
724      *
725      * @param event Key information.
726      * @param isUsed Whether the key is used by the kernel.
727      */
728     /*--ark web()--*/
729     virtual void KeyboardReDispatch(ArkWebRefPtr<ArkWebKeyEvent> event, bool isUsed) = 0;
730 
731     /*--ark web()--*/
732     virtual void OnInterceptKeyboardAttach(ArkWebRefPtr<ArkWebCustomKeyboardHandler> keyboardHandler,
733         const ArkWebStringMap &attributes, bool &useSystemKeyboard, int32_t &enterKeyType) = 0;
734 
735     /*--ark web()--*/
736     virtual void OnCustomKeyboardAttach() = 0;
737 
738     /*--ark web()--*/
739     virtual void OnCustomKeyboardClose() = 0;
740     /**
741      * @brief Called when ads blocked.
742      *
743      * @param url the url of main frame.
744      * @param adsBlocked the url of ads.
745      */
746     /*--ark web()--*/
747     virtual void OnAdsBlocked(const ArkWebString &url, const ArkWebStringVector &adsBlocked) = 0;
748 
749     /**
750      * @brief called when the cursor info is updated.
751      *
752      * @param x, y relative coordinates within web components of the cursor
753      * @param width, height width and height of the cursor
754      */
755     /*--ark web()--*/
756     virtual void OnCursorUpdate(double x, double y, double width, double height) = 0;
757 
758     /**
759      * @brief Called when web occurs frame loss event.
760      *
761      * @param sceneId The id of event scene.
762      * @param isStart True if is start.
763      */
764     /*--ark web()--*/
765     virtual void ReportDynamicFrameLossEvent(const ArkWebString& sceneId, bool isStart) = 0;
766 
767     /**
768      * @brief Called when you need to temporarily hide/restore the handle menu.
769      *
770      * @param hide hide.
771      */
772     /*--ark web()--*/
773     virtual void HideHandleAndQuickMenuIfNecessary(bool hide) = 0;
774 
775     /**
776      * @brief Called When you click on the selected area.
777      *
778      */
779     /*--ark web()--*/
780     virtual void ChangeVisibilityOfQuickMenu() = 0;
781 
782     /**
783      * @brief Called when you need to start vibrator.
784      */
785     /*--ark web()--*/
786     virtual void StartVibraFeedback(const ArkWebString& vibratorType) = 0;
787 
788     /**
789      * @brief Called when a popup is shown with the given size.
790      *
791      * @param x The offset of the popup on the x coordinate axis.
792      * @param y The offset of the popup on the y coordinate axis.
793 	 * @param width The width of the popup.
794      * @param height The height of the popup.
795      *
796      */
797     /*--ark web()--*/
798     virtual void OnPopupSize(int x, int y, int width, int height) = 0;
799 
800     /**
801      * @brief Called when the popup is shown or hidden.
802      *
803      * @param show Whether the popup is shown or hidden.
804      *
805      */
806     /*--ark web()--*/
807     virtual void OnPopupShow(bool show) = 0;
808 
809     /*--ark web()--*/
810     virtual void OnNativeEmbedVisibilityChange(const ArkWebString& embed_id, bool visibility) = 0;
811 
812     /*--ark web()--*/
813     virtual bool CloseImageOverlaySelection() = 0;
814 
815     /**
816      * @Description: Called when web occurs ssl error event.
817      * @Input result: handler of result.
818      * @Input error: error code.
819      * @Input certChainData: cert chain data.
820      * @Return: true/false
821      */
822     /*--ark web()--*/
823     virtual bool OnSslErrorRequestByJSV2(ArkWebRefPtr<ArkWebJsSslErrorResult> result, int error,
824         const ArkWebStringVector& certChainData) = 0;
825 
826     /**
827      * @Description: Called when an accessibility event occurs.
828      * @Input accessibilityId: the accessibility id of the accessibility node of the accessibility event.
829      * @Input eventType: the event type of the accessibility event.
830      */
831     /*--ark web()--*/
832     virtual void OnAccessibilityEvent(int64_t accessibilityId, int32_t eventType) = 0;
833 
834     /**
835      * @Description: Web gets focus on the framework.
836      * @Return: true/false
837      */
838     /*--ark web()--*/
839     virtual bool IsCurrentFocus() = 0;
840 
841     /**
842      * @brief Get the visible area relative to the web.
843      */
844     /*--ark web()--*/
845     virtual void GetVisibleRectToWeb(int& visibleX, int& visibleY, int& visibleWidth, int& visibleHeight) = 0;
846 
847     /*--ark web()--*/
848     virtual void OnScrollStart(const float x, const float y) = 0;
849 
850     /*--ark web()--*/
851     virtual void OnShowAutofillPopupV2(
852         const float offsetX, const float offsetY, const float height, const float width,
853         const ArkWebStringVector& menu_items) = 0;
854 
855     /**
856      * @brief Restore web component renderfit.
857      */
858     /*--ark web()--*/
859     virtual void RestoreRenderFit() = 0;
860 
861     /**
862      * @Description: Called when an accessibility event occurs.
863      * @Input accessibilityId: the accessibility id of the accessibility node of the accessibility event.
864      * @Input eventType: the event type of the accessibility event.
865      * @Input argument: the argument of the accessibility event.
866      */
867     /*--ark web()--*/
868     virtual void OnAccessibilityEventV2(int64_t accessibilityId, int32_t eventType, const ArkWebString& argument) = 0;
869 
870     /*--ark web()--*/
871     virtual bool OnNestedScroll(float& x, float& y, float& xVelocity, float& yVelocity, bool& isAvailable) = 0;
872 
873     /*--ark web()--*/
874     virtual void EnableSecurityLayer(bool isNeedSecurityLayer) = 0;
875 
876     /**
877      * @brief Called When you click on the selected area.
878      */
879     /*--ark web()--*/
880     virtual bool ChangeVisibilityOfQuickMenuV2() = 0;
881 
882     /*--ark web()--*/
883     virtual void OnPip(int status,
884                        int delegate_id,
885                        int child_id,
886                        int frame_routing_id,
887                        int width,
888                        int height) = 0;
889 
890     /**
891      * @brief Notify the host application that the web page wants to handle
892      *        JavaScript onbeforeunload.
893      *
894      * @param url String: The url of the page requesting.
895      * @param message String: The message of the dialog.
896      * @param isReload bool: The isReload parameter is set to true when the page is refreshed;
897      *        otherwise, it remains false. Default is false.
898      * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to
899      *        confirm that the user closed the window.
900      * @return To show a custom dialog, the app should return true.
901      */
902     /*--ark web()--*/
903     virtual bool OnBeforeUnloadByJSV2(const ArkWebString& url, const ArkWebString& message, bool isReload,
904         ArkWebRefPtr<ArkWebJsDialogResult> result) = 0;
905 
906     /**
907      * @Description: Called when an mouse native event occurs on native embed area.
908      * @Input mouse_event: Mouse events that contain information about the same layer.
909      */
910     /*--ark web()--*/
911     virtual void OnNativeEmbedMouseEvent(ArkWebRefPtr<ArkWebNativeEmbedMouseEvent> mouse_event) = 0;
912 
913     /**
914      * @brief called when the web page is active for window.open called by other web component.
915      */
916     /*--ark web()--*/
917     virtual void OnActivateContentByJS() = 0;
918 
919     /**
920      * @Description Notify the SDK that a web site has started loading. This method is
921      * called once for each main frame load. Embedded frame changes, i.e. clicking
922      * a link whose target is an iframe and fragment navigations (navigations to
923      * #fragment_id) will not trigger this callback.
924      *
925      * @Input url The url to be loaded.
926      */
927     /*--ark web()--*/
928     virtual void OnLoadStarted(const ArkWebString& url) = 0;
929 
930     /**
931      * @Description Notify the SDK that a web site has finished loading. This method is
932      * called only for main frame. Different from onPageEnd, onLoadFinished is
933      * triggered only once if the mainframe is automatically redirected before the
934      * page is completely loaded. OnPageEnd is triggered every navigation.
935      * fragment navigation also triggers onLoadFinished.
936      *
937      * @Input url The url of the web site.
938      */
939     /*--ark web()--*/
940     virtual void OnLoadFinished(const ArkWebString& url) = 0;
941 
942     /**
943      * @Description Called when an SSL error occurs during the loading of resources (for the main frame and subframes).
944      * @Input result: handler of result.
945      * @Input error: error code.
946      * @Input url: request url
947      * @Input originalUrl: original url.
948      * @Input referrer: referrer url.
949      * @Input isFatalError: whether the error is a fatal error.
950      * @Input isMainFrame: whether the request is made for the main frame.
951      * @Input certChainData: cert chain data.
952      * @Return: true/false
953      */
954     /*--ark web()--*/
955     virtual bool OnAllSslErrorRequestByJSV2(ArkWebRefPtr<ArkWebJsAllSslErrorResult> result, int error,
956         const ArkWebString& url, const ArkWebString& originalUrl, const ArkWebString& referrer, bool isFatalError,
957         bool isMainFrame, const ArkWebStringVector& certChainData) = 0;
958 
959     /**
960      * @brief Called when you need to show magnifier.
961      */
962     /*--ark web()--*/
ShowMagnifier()963     virtual void ShowMagnifier() {}
964 
965     /**
966      * @brief Called when you need to hide magnifier.
967      */
968     /*--ark web()--*/
HideMagnifier()969     virtual void HideMagnifier() {}
970 
971     /**
972      * @brief Notify the SDK of the changed document title.
973      *
974      * @param title The document title.
975      * @param isRealTitle Mark the source of the title. If it is true, the title is derived from the H5 title element;
976      *        If it is false, it is calculated from the URL. By default, it is calculated from the URL.
977      */
978     /*--ark web()--*/
979     virtual void OnPageTitleV2(const ArkWebString& title, bool isRealTitle) = 0;
980 
981     /**
982      * @brief Notify the web client to do something for blankless.
983      *
984      * @param pathToFrame The file used to insert frame. If empty, means remove frame.
985      */
986     /*--ark web()--*/
987     virtual void OnInsertBlanklessFrame(const ArkWebString& pathToFrame) = 0;
988 
989     /**
990      * @brief Notify the web client to remove blankless frame.
991      *
992      * @param delayTime The delayTime for web client to remove blankless frame.
993      */
994     /*--ark web()--*/
995     virtual void OnRemoveBlanklessFrame(int delayTime) = 0;
996 
997     /**
998      * @brief Triggered when the web page's document resource error
999      *
1000      * @param request The request information.
1001      * @param error The error information.
1002      */
1003     /*--ark web()--*/
1004     virtual ArkWebString OnHandleOverrideErrorPage(
1005         ArkWebRefPtr<ArkWebUrlResourceRequest> request,
1006         ArkWebRefPtr<ArkWebUrlResourceError> error) = 0;
1007 
1008     /**
1009      * @brief Notify the web client pdf scroll at bottom.
1010      *
1011      * @param url The url of the pdf.
1012      */
1013     /*--ark web()--*/
1014     virtual void OnPdfScrollAtBottom(const ArkWebString& url) = 0;
1015 
1016     /**
1017      * @brief Notify the web client pdf load event.
1018      *
1019      * @param result The result of the pdf load.
1020      * @param url The url of the pdf.
1021      */
1022     /*--ark web()--*/
1023     virtual void OnPdfLoadEvent(int32_t result, const ArkWebString& url) = 0;
1024 
1025     /*--ark web()--*/
1026     virtual void OnTakeFocus(ArkWebRefPtr<ArkWebKeyEvent> event) = 0;
1027 };
1028 
1029 } // namespace OHOS::ArkWeb
1030 
1031 #endif // ARK_WEB_HANDLER_H_
1032