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_nweb.h" 48 #include "ohos_nweb/include/ark_web_quick_menu_callback.h" 49 #include "ohos_nweb/include/ark_web_quick_menu_params.h" 50 #include "ohos_nweb/include/ark_web_screen_capture_access_request.h" 51 #include "ohos_nweb/include/ark_web_select_popup_menu_callback.h" 52 #include "ohos_nweb/include/ark_web_select_popup_menu_param.h" 53 #include "ohos_nweb/include/ark_web_string_vector_value_callback.h" 54 #include "ohos_nweb/include/ark_web_touch_handle_hot_zone.h" 55 #include "ohos_nweb/include/ark_web_touch_handle_state.h" 56 #include "ohos_nweb/include/ark_web_url_resource_error.h" 57 #include "ohos_nweb/include/ark_web_url_resource_request.h" 58 #include "ohos_nweb/include/ark_web_url_resource_response.h" 59 60 namespace OHOS::ArkWeb { 61 62 /*--ark web(source=webview)--*/ 63 class ArkWebHandler : public virtual ArkWebBaseRefCounted { 64 public: 65 /*--ark web()--*/ 66 virtual void SetNWeb(ArkWebRefPtr<ArkWebNWeb> nweb) = 0; 67 68 /** 69 * @brief Request display and focus for a new nweb. 70 * 71 */ 72 /*--ark web()--*/ 73 virtual bool OnFocus() = 0; 74 75 /*--ark web()--*/ 76 virtual void OnMessage(const ArkWebString& param) = 0; 77 78 /** 79 * @brief Notify the SDK that the nweb will load the resource specified by the 80 * given url. 81 * 82 * @param url The url of the resource. 83 */ 84 /*--ark web()--*/ 85 virtual void OnResource(const ArkWebString& url) = 0; 86 87 /** 88 * @brief Notify the SDK of a new favicon for the current web site. 89 * 90 * @param data The raw image data for the icon. 91 * @param width The width of the icon in pixel. 92 * @param height The height of the icon in pixel. 93 * @param color_type The color data encoding type. 94 * @param alpha_type The alpha value of any pixel. 95 */ 96 /*--ark web()--*/ 97 virtual void OnPageIcon(const void* data, size_t width, size_t height, int color_type, int alpha_type) = 0; 98 99 /** 100 * @brief Notify the SDK of the changed document title. 101 * 102 * @param title The document title. 103 */ 104 /*--ark web()--*/ 105 virtual void OnPageTitle(const ArkWebString& title) = 0; 106 107 /*--ark web()--*/ 108 virtual void OnProxyDied() = 0; 109 110 /** 111 * @brief Notify the SDK that an HTTP error has been received from the server 112 * while loading a resource. 113 * 114 * @param request The request information. 115 * @param error_response The error occurred. 116 */ 117 /*--ark web()--*/ 118 virtual void OnHttpError( 119 ArkWebRefPtr<ArkWebUrlResourceRequest> request, ArkWebRefPtr<ArkWebUrlResourceResponse> error_response) = 0; 120 121 /** 122 * @brief Report a JavaScript console message to the host application. 123 * 124 * @param message Details of the console message. 125 * 126 * @return Return true to stop the message from being output to the console. 127 */ 128 /*--ark web()--*/ 129 virtual bool OnConsoleLog(ArkWebRefPtr<ArkWebConsoleLog> message) = 0; 130 131 /*--ark web()--*/ 132 virtual void OnRouterPush(const ArkWebString& param) = 0; 133 134 /** 135 * @brief Notify the SDK that a web site has finished loading. This method is 136 * called only for main frame. 137 * 138 * @param http_status_code The status code for the http request. 139 * @param url The url of the web site. 140 */ 141 /*--ark web()--*/ 142 virtual void OnPageLoadEnd(int http_status_code, const ArkWebString& url) = 0; 143 144 /** 145 * @brief Notify the SDK that a web site has started loading. This method is 146 * called once for each main frame load. 147 * 148 * @param url The url to be loaded. 149 */ 150 /*--ark web()--*/ 151 virtual void OnPageLoadBegin(const ArkWebString& url) = 0; 152 153 /** 154 * @brief Report a load error to the SDK. 155 * 156 * @param error_code The error code. 157 * @param description The error description. 158 * @param failing_url The failed url. 159 */ 160 /*--ark web()--*/ 161 virtual void OnPageLoadError(int error_code, const ArkWebString& description, const ArkWebString& failing_url) = 0; 162 163 /** 164 * @brief Notify the SDK of the url for a touch icon. 165 * 166 * @param icon_url The icon url. 167 * @param precomposed The touch icon type. 168 */ 169 /*--ark web()--*/ 170 virtual void OnDesktopIconUrl(const ArkWebString& icon_url, bool precomposed) = 0; 171 172 /** 173 * @brief Notify the SDK the current progress of loading a web site. 174 * 175 * @param new_progress Loading progress, an integer between 0 and 100. 176 */ 177 /*--ark web()--*/ 178 virtual void OnLoadingProgress(int new_progress) = 0; 179 180 /** 181 * @brief Show prompt to ask for the geo location permission. 182 * 183 * @param origin String: the origin of the resource to get geo location 184 * @param callback GeolocationCallbackInterface: callback to report geo 185 * location 186 */ 187 /*--ark web()--*/ 188 virtual void OnGeolocationShow(const ArkWebString& origin, ArkWebRefPtr<ArkWebGeoLocationCallback> callback) = 0; 189 190 /** 191 * @brief Hide prompt to ask for the geolocation permission. 192 */ 193 /*--ark web()--*/ 194 virtual void OnGeolocationHide() = 0; 195 196 /** 197 * @brief inform application to show a file selector. 198 * 199 * @param callback the file list to select. 200 * @param params the params of file selector. 201 */ 202 /*--ark web()--*/ 203 virtual bool OnFileSelectorShow( 204 ArkWebRefPtr<ArkWebStringVectorValueCallback> callback, ArkWebRefPtr<ArkWebFileSelectorParams> params) = 0; 205 206 /** 207 * @brief Report web resource loading error to the SDK. These errors usually 208 * indicate inability to connect to the server. 209 * 210 * @param request The request information. 211 * @param error The error information. 212 */ 213 /*--ark web()--*/ 214 virtual void OnResourceLoadError( 215 ArkWebRefPtr<ArkWebUrlResourceRequest> request, ArkWebRefPtr<ArkWebUrlResourceError> error) = 0; 216 217 /** 218 * @brief Ask for the permission. 219 * 220 * @param request std::shared_ptr<NWebAccessRequest>: A request to ask for the 221 * permission. 222 */ 223 /*--ark web()--*/ 224 virtual void OnPermissionRequest(ArkWebRefPtr<ArkWebAccessRequest> request) = 0; 225 226 /*--ark web()--*/ 227 virtual void OnQuickMenuDismissed() = 0; 228 229 /*--ark web()--*/ 230 virtual void OnContextMenuDismissed() = 0; 231 232 /*--ark web()--*/ 233 virtual void OnTouchSelectionChanged(ArkWebRefPtr<ArkWebTouchHandleState> insert_handle, 234 ArkWebRefPtr<ArkWebTouchHandleState> start_selection_handle, 235 ArkWebRefPtr<ArkWebTouchHandleState> end_selection_handle) = 0; 236 237 /** 238 * @brief Notify the host application of a resource request and allow the 239 * application to return the data. 240 * 241 * @param request request information 242 * @param response response information 243 * 244 * @retval true if handle success, otherwise false. 245 */ 246 /*--ark web()--*/ 247 virtual bool OnHandleInterceptRequest( 248 ArkWebRefPtr<ArkWebUrlResourceRequest> request, ArkWebRefPtr<ArkWebUrlResourceResponse> response) = 0; 249 250 /** 251 * @brief inform application to update its visited links database. 252 * 253 * @param url the url being visited. 254 * @param is_reload true if the url is being reload. 255 */ 256 /*--ark web()--*/ 257 virtual void OnRefreshAccessedHistory(const ArkWebString& url, bool is_reload) = 0; 258 259 /** 260 * @brief Cancel the request to ask for the permission. 261 * 262 * @param request std::shared_ptr<NWebAccessRequest>: A request to ask for the 263 * permission. 264 */ 265 /*--ark web()--*/ 266 virtual void OnPermissionRequestCanceled(ArkWebRefPtr<ArkWebAccessRequest> request) = 0; 267 268 /** 269 * @brief Give the SDK a chance to decide whether to continue loading the url. 270 * 271 * @param url The url to be loaded. 272 * 273 * @return true to cancel the loading, false to continue the loading. 274 */ 275 /*--ark web()--*/ 276 virtual bool OnHandleInterceptUrlLoading(ArkWebRefPtr<ArkWebUrlResourceRequest> request) = 0; 277 278 /*--ark web()--*/ 279 virtual bool RunQuickMenu( 280 ArkWebRefPtr<ArkWebQuickMenuParams> params, ArkWebRefPtr<ArkWebQuickMenuCallback> callback) = 0; 281 282 /*--ark web()--*/ 283 virtual bool RunContextMenu( 284 ArkWebRefPtr<ArkWebContextMenuParams> params, ArkWebRefPtr<ArkWebContextMenuCallback> callback) = 0; 285 286 /*--ark web()--*/ 287 virtual void UpdateDragCursor(unsigned char op) = 0; 288 289 /*--ark web()--*/ 290 virtual bool FilterScrollEvent(const float x, const float y, const float x_velocity, const float y_velocity) = 0; 291 292 /** 293 * @brief Obtains a list of all visited history items, used for link coloring 294 * 295 * @return visited history 296 */ 297 /*--ark web()--*/ 298 virtual ArkWebStringVector VisitedUrlHistory() = 0; 299 300 /** 301 * @brief called when new window required. 302 * 303 * @param target_url URL to be loaded in the new window. 304 * @param is_alert dialog window or not. 305 * @param is_user_trigger triggered by User. 306 * @param handler set the new web object. 307 */ 308 /*--ark web()--*/ 309 virtual void OnWindowNewByJS(const ArkWebString& target_url, bool is_alert, bool is_user_trigger, 310 ArkWebRefPtr<ArkWebControllerHandler> handler) = 0; 311 312 /** 313 * @brief called when window exit. 314 */ 315 /*--ark web()--*/ 316 virtual void OnWindowExitByJS() = 0; 317 318 /** 319 * @brief Notify the host application that the web page wants to display a 320 * JavaScript alert() dialog. 321 * 322 * @param url String: The url of the page requesting the dialog. 323 * @param message String: The message of the dialog. 324 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 325 * confirm that the user closed the window. 326 * 327 * @return To show a custom dialog, the app should return true. 328 */ 329 /*--ark web()--*/ 330 virtual bool OnAlertDialogByJS( 331 const ArkWebString& url, const ArkWebString& message, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0; 332 333 /** 334 * @brief Notify the host application that the web page wants to handle 335 * JavaScript onbeforeunload. 336 * 337 * @param url String: The url of the page requesting. 338 * @param message String: The message of the dialog. 339 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 340 * confirm that the user closed the window. 341 * 342 * @return To show a custom dialog, the app should return true. 343 */ 344 /*--ark web()--*/ 345 virtual bool OnBeforeUnloadByJS( 346 const ArkWebString& url, const ArkWebString& message, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0; 347 348 /** 349 * @brief Notify the host application that the web page wants to display a 350 * JavaScript prompt() dialog. 351 * 352 * @param url String: The url of the page requesting the dialog. 353 * @param message String: The message of the dialog. 354 * @param default_value String: The default value of the input message. 355 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 356 * confirm that the user closed the window. 357 * 358 * @return To show a custom dialog, the app should return true. 359 */ 360 /*--ark web()--*/ 361 virtual bool OnPromptDialogByJS(const ArkWebString& url, const ArkWebString& message, 362 const ArkWebString& default_value, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0; 363 364 /** 365 * @brief Notify the host application that the web page wants to display a 366 * JavaScript Confirm() dialog. 367 * 368 * @param url String: The url of the page requesting the dialog. 369 * @param message String: The message of the dialog. 370 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 371 * confirm that the user closed the window. 372 * 373 * @return To show a custom dialog, the app should return true. 374 */ 375 /*--ark web()--*/ 376 virtual bool OnConfirmDialogByJS( 377 const ArkWebString& url, const ArkWebString& message, ArkWebRefPtr<ArkWebJsDialogResult> result) = 0; 378 379 /*--ark web()--*/ 380 virtual bool OnHttpAuthRequestByJS( 381 ArkWebRefPtr<ArkWebJsHttpAuthResult> result, const ArkWebString& host, const ArkWebString& realm) = 0; 382 383 /*--ark web()--*/ 384 virtual bool OnSslErrorRequestByJS(ArkWebRefPtr<ArkWebJsSslErrorResult> result, int error) = 0; 385 386 /*--ark web()--*/ 387 virtual bool OnSslSelectCertRequestByJS(ArkWebRefPtr<ArkWebJsSslSelectCertResult> result, const ArkWebString& host, 388 int port, const ArkWebStringVector& key_types, const ArkWebStringVector& issuers) = 0; 389 390 /*--ark web()--*/ 391 virtual void OnScroll(double x_offset, double y_offset) = 0; 392 393 /*--ark web()--*/ 394 virtual void OnOverScroll(float x_offset, float y_offset) = 0; 395 396 /*--ark web()--*/ 397 virtual void OnScrollState(bool scroll_state) = 0; 398 399 /** 400 * @brief called when the page being loaded is about to be made visible. 401 */ 402 /*--ark web()--*/ 403 virtual void OnPageVisible(const ArkWebString& url) = 0; 404 405 /** 406 * @brief Give the host application a chance to handle the key event 407 * synchronousl. 408 * 409 * @param event The key event. 410 * 411 * @return True if the host application wants to handle the key event itself, 412 * otherwise return false. 413 */ 414 /*--ark web()--*/ 415 virtual bool OnPreKeyEvent(ArkWebRefPtr<ArkWebKeyEvent> event) = 0; 416 417 /*--ark web()--*/ 418 virtual void OnScaleChanged(float old_scale_factor, float new_scale_factor) = 0; 419 420 /** 421 * @brief Called when the browser's cursor has changed. 422 * 423 * @param type Cursor type. 424 * @param info If |type| is CT_CUSTOM then |info| will be populated with the 425 * custom cursor information. 426 * 427 * @return True if the cursor change was handled or false for default 428 * handling. 429 */ 430 /*--ark web()--*/ 431 virtual bool OnCursorChange(const int32_t& type, ArkWebRefPtr<ArkWebCursorInfo> info) = 0; 432 433 /** 434 * @brief called when the render process exit. 435 * 436 * @param reason the detail reason why render process exit, the implementation 437 * of this callback should attempt to clean up the specific nweb that 438 * was set by SetNWeb interface. 439 */ 440 /*--ark web()--*/ 441 virtual void OnRenderExited(int reason) = 0; 442 443 /** 444 * @brief Called when resize not work. 445 */ 446 /*--ark web()--*/ 447 virtual void OnResizeNotWork() = 0; 448 449 /** 450 * @brief called when the page exit the full-screen mode. 451 */ 452 /*--ark web()--*/ 453 virtual void OnFullScreenExit() = 0; 454 455 /** 456 * @brief called when the page enter the full-screen mode. 457 * 458 * @param handler to exit full-screen mode. 459 */ 460 /*--ark web()--*/ 461 virtual void OnFullScreenEnter(ArkWebRefPtr<ArkWebFullScreenExitHandler> handler) = 0; 462 463 /*--ark web()--*/ 464 virtual bool OnDragAndDropData(const void* data, size_t len, ArkWebRefPtr<ArkWebImageOptions> opt) = 0; 465 466 /*--ark web()--*/ 467 virtual void OnSelectPopupMenu( 468 ArkWebRefPtr<ArkWebSelectPopupMenuParam> params, ArkWebRefPtr<ArkWebSelectPopupMenuCallback> callback) = 0; 469 470 /** 471 * @brief shows the repost form confirmation dialog box. 472 * 473 * @param handler sets whether to resend data. 474 */ 475 /*--ark web()--*/ 476 virtual void OnDataResubmission(ArkWebRefPtr<ArkWebDataResubmissionCallback> handler) = 0; 477 478 /*--ark web()--*/ 479 virtual void OnRootLayerChanged(int width, int height) = 0; 480 481 /** 482 * @brief Called when the audio playing state on web page changed. 483 * 484 * @param playing Whether the audio is playing or not. 485 */ 486 /*--ark web()--*/ 487 virtual void OnAudioStateChanged(bool playing) = 0; 488 489 /*--ark web()--*/ 490 virtual void OnOverScrollFlingEnd() = 0; 491 492 /** 493 * @brief Notify the host application that a key was not handled by the 494 * WebView. 495 * 496 * @param event The key event. 497 * 498 * @return True if the host application wants to handle the key event itself, 499 * otherwise return false. 500 */ 501 /*--ark web()--*/ 502 virtual bool OnUnProcessedKeyEvent(ArkWebRefPtr<ArkWebKeyEvent> event) = 0; 503 504 /*--ark web()--*/ 505 virtual bool OnDragAndDropDataUdmf(ArkWebRefPtr<ArkWebDragData> drag_data) = 0; 506 507 /** 508 * @brief Called when the first content rendering of web page. 509 * 510 * @param navigation_start_tick Absolute navigation start time, as TimeTicks. 511 * @param first_contentful_paint_ms Time to first contentful paint from 512 * navigation start. 513 */ 514 /*--ark web()--*/ 515 virtual void OnFirstContentfulPaint(int64_t navigation_start_tick, int64_t first_contentful_paint_ms) = 0; 516 517 /*--ark web()--*/ 518 virtual void OnDateTimeChooserPopup(ArkWebRefPtr<ArkWebDateTimeChooser> chooser, 519 const ArkWebDateTimeSuggestionVector& suggestions, ArkWebRefPtr<ArkWebDateTimeChooserCallback> callback) = 0; 520 521 /*--ark web()--*/ 522 virtual void OnDateTimeChooserClose() = 0; 523 524 /** 525 * @brief Ask for the screen capture permission. 526 * 527 * @param request std::shared_ptr<NWebScreenCaptureAccessRequest>: A request 528 * to ask for the screen capture permission. 529 */ 530 /*--ark web()--*/ 531 virtual void OnScreenCaptureRequest(ArkWebRefPtr<ArkWebScreenCaptureAccessRequest> request) = 0; 532 533 /** 534 * @brief Called when the media or form state on the web page changed. 535 * 536 * @param state state of the media or form. Refer to the enum class 537 * MediaPlayingState and FormState 538 * @param type it can be form, media, or audio 539 */ 540 /*--ark web()--*/ 541 virtual void OnActivityStateChanged(int state, int type) = 0; 542 543 /*--ark web()--*/ 544 virtual void OnGetTouchHandleHotZone(ArkWebRefPtr<ArkWebTouchHandleHotZone> hot_zone) = 0; 545 546 /** 547 * @brief Called when swap buffer completed with new size. 548 */ 549 /*--ark web()--*/ 550 virtual void OnCompleteSwapWithNewSize() = 0; 551 552 /*--ark web()--*/ 553 virtual void OnOverScrollFlingVelocity(float x_velocity, float y_velocity, bool is_fling) = 0; 554 555 /** 556 * @brief called when the navigation entry has been committed. 557 * 558 * @param details represents the details of a committed navigation entry. 559 */ 560 /*--ark web()--*/ 561 virtual void OnNavigationEntryCommitted(ArkWebRefPtr<ArkWebLoadCommittedDetails> details) = 0; 562 563 /*--ark web()--*/ 564 virtual void OnNativeEmbedLifecycleChange(ArkWebRefPtr<ArkWebNativeEmbedDataInfo> data_info) = 0; 565 566 /*--ark web()--*/ 567 virtual void OnNativeEmbedGestureEvent(ArkWebRefPtr<ArkWebNativeEmbedTouchEvent> touch_event) = 0; 568 569 /** 570 * @brief Called when received website security risk check result. 571 * 572 * @param threat_type The threat type of website. 573 */ 574 /*--ark web()--*/ 575 virtual void OnSafeBrowsingCheckResult(int threat_type) = 0; 576 577 /** 578 * @brief Called when tracker's cookie is prevented. 579 * 580 * @param website_host The host of website url. 581 * 582 * @param tracker_host The host of tracker url. 583 */ 584 /*--ark web()--*/ 585 virtual void OnIntelligentTrackingPreventionResult( 586 const ArkWebString& website_host, const ArkWebString& tracker_host) = 0; 587 588 /** 589 * @brief called when the page enter the full-screen mode. 590 * 591 * @param handler to exit full-screen mode. 592 * @param video_natural_width indicates the width of the <video> element 593 * entering full screen. 594 * @param video_natural_height indicates the height of the <video> element 595 * entering full screen. 596 */ 597 /*--ark web()--*/ 598 virtual void OnFullScreenEnterWithVideoSize( 599 ArkWebRefPtr<ArkWebFullScreenExitHandler> handler, int video_natural_width, int video_natural_height) = 0; 600 601 /** 602 * @brief Give the application a chance to decide whether to override loading the 603 * url. 604 * 605 * @param request The request information. 606 * @return true to abort loading the url, false to continue loading the url 607 * as usual. 608 */ 609 /*--ark web()--*/ 610 virtual bool OnHandleOverrideUrlLoading(ArkWebRefPtr<ArkWebUrlResourceRequest> request) = 0; 611 612 /*--ark web()--*/ 613 virtual void OnFirstMeaningfulPaint(ArkWebRefPtr<ArkWebFirstMeaningfulPaintDetails> details) = 0; 614 615 /*--ark web()--*/ 616 virtual void OnLargestContentfulPaint(ArkWebRefPtr<ArkWebLargestContentfulPaintDetails> details) = 0; 617 618 /*--ark web()--*/ 619 virtual bool OnAllSslErrorRequestByJS(ArkWebRefPtr<ArkWebJsAllSslErrorResult> result, int error, 620 const ArkWebString& url, const ArkWebString& originalUrl, const ArkWebString& referrer, bool isFatalError, 621 bool isMainFrame) = 0; 622 623 /*--ark web()--*/ 624 virtual void OnTooltip(const ArkWebString& tooltip) = 0; 625 626 /*--ark web()--*/ 627 virtual void ReleaseResizeHold() = 0; 628 629 /*--ark web()--*/ 630 virtual ArkWebCharVector GetWordSelection(const ArkWebString& text, int8_t offset) = 0; 631 632 /*--ark web()--*/ 633 virtual void UpdateClippedSelectionBounds(int x, int y, int w, int h) = 0; 634 635 /** 636 * @brief Called when the render process not responding. 637 * 638 * @param js_stack JavaScript stack info of webpage when render process not 639 * responding. 640 * @param pid Process id of the render process not responding. 641 * @param reason Reason of the render process not responding. 642 */ 643 /*--ark web()--*/ 644 virtual void OnRenderProcessNotResponding(const ArkWebString& js_stack, int pid, int reason) = 0; 645 646 /** 647 * @brief Called when the unresponding render process becomes responsive. 648 * 649 */ 650 /*--ark web()--*/ 651 virtual void OnRenderProcessResponding() = 0; 652 653 /*--ark web()--*/ 654 virtual bool OnOpenAppLink(const ArkWebString& url, ArkWebRefPtr<ArkWebAppLinkCallback> callback) = 0; 655 656 /*--ark web()--*/ 657 virtual void OnShowAutofillPopup( 658 const float offsetX, const float offsetY, const ArkWebStringVector& menu_items) = 0; 659 660 /*--ark web()--*/ 661 virtual void OnHideAutofillPopup() = 0; 662 663 /** 664 * @brief Called when the viewport-fit meta is detected for web page. 665 * 666 * @param viewportFit The type of the viewport-fit. 667 */ 668 /*--ark web()--*/ 669 virtual void OnViewportFitChange(int viewportFit) = 0; 670 671 /** 672 * @brief Request display and focus for a new nweb. 673 * 674 * @param source The Focus Source. 675 * @return Return true if request focus success, false if request focus fail. 676 */ 677 /*--ark web()--*/ 678 virtual bool OnFocus(int source) = 0; 679 680 /** 681 * @brief Called when the page is over scroll. 682 * 683 * @param xOffset The offset of x axis. 684 * @param yOffset The offset of y axis. 685 * @param xVelocity The velocity of x axis. 686 * @param yVelocity The velocity of y axis. 687 * @return Return true if value is consumed, false if value is unconsumed. 688 */ 689 /*--ark web()--*/ 690 virtual bool OnOverScroll(float xOffset, float yOffset, float xVelocity, float yVelocity) = 0; 691 692 /** 693 * @brief Called when creating overlay. 694 * 695 * @param data 696 * @param len 697 * @param width 698 * @param height 699 * @param offset_x 700 * @param offset_y 701 * @param rect_width 702 * @param rect_height 703 * @param point_x 704 * @param point_y 705 */ 706 /*--ark web()--*/ 707 virtual void CreateOverlay(void* data, size_t len, int width, int height, int offset_x, int offset_y, 708 int rect_width, int rect_height, int point_x, int point_y) = 0; 709 710 /** 711 * @brief Called when overlay state changed. 712 * 713 * @param offset_x 714 * @param offset_y 715 * @param rect_width 716 * @param rect_height 717 */ 718 /*--ark web()--*/ 719 virtual void OnOverlayStateChanged(int offset_x, int offset_y, int rect_width, int rect_height) = 0; 720 721 /** 722 * @brief Called when ads blocked. 723 * 724 * @param url the url of main frame. 725 * @param adsBlocked the url of ads. 726 */ 727 /*--ark web()--*/ 728 virtual void OnAdsBlocked(const ArkWebString& url, const ArkWebStringVector& adsBlocked) = 0; 729 730 /*--ark web()--*/ 731 virtual void OnInterceptKeyboardAttach(ArkWebRefPtr<ArkWebCustomKeyboardHandler> keyboardHandler, 732 const ArkWebStringMap &attributes, bool &useSystemKeyboard, int32_t &enterKeyType) = 0; 733 734 /*--ark web()--*/ 735 virtual void OnCustomKeyboardAttach() = 0; 736 737 /*--ark web()--*/ 738 virtual void OnCustomKeyboardClose() = 0; 739 740 /*--ark web()--*/ 741 virtual void KeyboardReDispatch(ArkWebRefPtr<ArkWebKeyEvent> event, bool isUsed) = 0; 742 743 /** 744 * @brief Called when you need to temporarily hide/restore the handle menu. 745 * 746 * @param hide hide. 747 */ 748 /*--ark web()--*/ 749 virtual void HideHandleAndQuickMenuIfNecessary(bool hide) = 0; 750 751 /** 752 * @brief called when the cursor info is updated. 753 * 754 * @param x, y relative coordinates within web components of the cursor 755 * @param width, height width and height of the cursor 756 */ 757 /*--ark web()--*/ 758 virtual void OnCursorUpdate(double x, double y, double width, double height) = 0; 759 760 /** 761 * @brief Called When you click on the selected area. 762 * 763 */ 764 /*--ark web()--*/ 765 virtual void ChangeVisibilityOfQuickMenu() = 0; 766 767 /** 768 * @brief Called when you need to start vibrator. 769 */ 770 /*--ark web()--*/ 771 virtual void StartVibraFeedback(const ArkWebString& vibratorType) = 0; 772 773 /*--ark web()--*/ 774 virtual void OnNativeEmbedVisibilityChange(const ArkWebString& embed_id, bool visibility) = 0; 775 776 /*--ark web()--*/ 777 virtual bool CloseImageOverlaySelection() = 0; 778 779 /** 780 * @brief Get the visible area relative to the web. 781 */ 782 /*--ark web()--*/ 783 virtual void GetVisibleRectToWeb(int& visibleX, int& visibleY, int& visibleWidth, int& visibleHeight) = 0; 784 785 /*--ark web()--*/ 786 virtual void OnScrollStart(const float x, const float y) = 0; 787 }; 788 789 } // namespace OHOS::ArkWeb 790 791 #endif // ARK_WEB_HANDLER_H_ 792