1 /* 2 * Copyright (c) 2022 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 NWEB_HANDLER_H 17 #define NWEB_HANDLER_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 23 #include "nweb.h" 24 #include "nweb_access_request.h" 25 #include "nweb_app_link_callback.h" 26 #include "nweb_console_log.h" 27 #include "nweb_context_menu_params.h" 28 #include "nweb_controller_handler.h" 29 #include "nweb_custom_keyboard_handler.h" 30 #include "nweb_data_resubmission_callback.h" 31 #include "nweb_date_time_chooser.h" 32 #include "nweb_drag_data.h" 33 #include "nweb_file_selector_params.h" 34 #include "nweb_first_meaningful_paint_details.h" 35 #include "nweb_full_screen_exit_handler.h" 36 #include "nweb_geolocation_callback_interface.h" 37 #include "nweb_gesture_event_result.h" 38 #include "nweb_mouse_event_result.h" 39 #include "nweb_js_dialog_result.h" 40 #include "nweb_js_http_auth_result.h" 41 #include "nweb_js_ssl_error_result.h" 42 #include "nweb_js_ssl_select_cert_result.h" 43 #include "nweb_key_event.h" 44 #include "nweb_largest_contentful_paint_details.h" 45 #include "nweb_load_committed_details.h" 46 #include "nweb_select_popup_menu.h" 47 #include "nweb_touch_handle_state.h" 48 #include "nweb_url_resource_error.h" 49 #include "nweb_url_resource_request.h" 50 #include "nweb_url_resource_response.h" 51 52 namespace OHOS::NWeb { 53 54 enum class RenderExitReason { 55 // Render process non-zero exit status 56 PROCESS_ABNORMAL_TERMINATION, 57 58 // SIGKILL or task manager kill 59 PROCESS_WAS_KILLED, 60 61 // Segmentation fault 62 PROCESS_CRASHED, 63 64 // Out of memory 65 PROCESS_OOM, 66 67 // Unknown reason 68 PROCESS_EXIT_UNKNOWN, 69 }; 70 71 enum class RenderProcessNotRespondingReason { 72 // Input ack from Render process timeout 73 INPUT_TIMEOUT, 74 75 // navigation commit ack from Render process timeout 76 NAVIGATION_COMMIT_TIMEOUT, 77 }; 78 79 enum class ViewportFit { 80 // No effect - the whole web page is viewable(default) 81 AUTO, 82 83 // The initial layout viewport and the visual viewport are set to the 84 // largest rectangle which is inscribed in the display of the device. 85 CONTAIN, 86 87 // The initial layout viewport and the visual viewport are set to the 88 // circumscribed rectangle of the physical screen of the device. 89 COVER, 90 }; 91 92 class NWebImageOptions { 93 public: 94 virtual ~NWebImageOptions() = default; 95 96 virtual ImageColorType GetColorType() = 0; 97 virtual ImageAlphaType GetAlphaType() = 0; 98 virtual size_t GetWidth() = 0; 99 virtual size_t GetHeight() = 0; 100 }; 101 102 enum class SslError { 103 // General error 104 INVALID, 105 106 // Hostname mismatch 107 HOSTMISMATCH, 108 109 // The certificate date is invalid 110 DATEINVALID, 111 112 // The certificate authority is not trusted 113 UNTRUSTED, 114 }; 115 116 // Cursor type values. 117 enum class CursorType : int32_t { 118 CT_POINTER = 0, 119 CT_CROSS, 120 CT_HAND, 121 CT_IBEAM, 122 CT_WAIT, 123 CT_HELP, 124 CT_EASTRESIZE, 125 CT_NORTHRESIZE, 126 CT_NORTHEASTRESIZE, 127 CT_NORTHWESTRESIZE, 128 CT_SOUTHRESIZE, 129 CT_SOUTHEASTRESIZE, 130 CT_SOUTHWESTRESIZE, 131 CT_WESTRESIZE, 132 CT_NORTHSOUTHRESIZE, 133 CT_EASTWESTRESIZE, 134 CT_NORTHEASTSOUTHWESTRESIZE, 135 CT_NORTHWESTSOUTHEASTRESIZE, 136 CT_COLUMNRESIZE, 137 CT_ROWRESIZE, 138 CT_MIDDLEPANNING, 139 CT_EASTPANNING, 140 CT_NORTHPANNING, 141 CT_NORTHEASTPANNING, 142 CT_NORTHWESTPANNING, 143 CT_SOUTHPANNING, 144 CT_SOUTHEASTPANNING, 145 CT_SOUTHWESTPANNING, 146 CT_WESTPANNING, 147 CT_MOVE, 148 CT_VERTICALTEXT, 149 CT_CELL, 150 CT_CONTEXTMENU, 151 CT_ALIAS, 152 CT_PROGRESS, 153 CT_NODROP, 154 CT_COPY, 155 CT_NONE, 156 CT_NOTALLOWED, 157 CT_ZOOMIN, 158 CT_ZOOMOUT, 159 CT_GRAB, 160 CT_GRABBING, 161 CT_MIDDLE_PANNING_VERTICAL, 162 CT_MIDDLE_PANNING_HORIZONTAL, 163 CT_CUSTOM, 164 CT_DND_NONE, 165 CT_DND_MOVE, 166 CT_DND_COPY, 167 CT_DND_LINK, 168 CT_LOCK, 169 CT_UNLOCK, 170 CT_MAX_VALUE, 171 }; 172 173 class NWebCursorInfo { 174 public: 175 virtual ~NWebCursorInfo() = default; 176 177 virtual int32_t GetX() = 0; 178 virtual int32_t GetY() = 0; 179 virtual uint8_t* GetBuff() = 0; 180 virtual float GetScale() = 0; 181 virtual int32_t GetWidth() = 0; 182 virtual int32_t GetHeight() = 0; 183 }; 184 185 class NWebTouchHandleHotZone { 186 public: 187 virtual ~NWebTouchHandleHotZone() = default; 188 189 virtual void SetWidth(double width) = 0; 190 virtual void SetHeight(double height) = 0; 191 }; 192 193 enum class MediaPlayingState { 194 // Media is playing 195 PLAYING, 196 197 // Media playing is paused 198 PAUSED, 199 200 // Media playing is end 201 END_OF_STREAM, 202 }; 203 204 enum class FormState { 205 kHadInteraction, 206 kNoInteraction, 207 }; 208 209 enum class ActivityType { 210 VIDEO = 0, 211 AUDIO, 212 FORM, 213 }; 214 215 enum class NativeEmbedStatus { 216 CREATE, 217 UPDATE, 218 DESTROY, 219 ENTER_BFCACHE, 220 LEAVE_BFCACHE, 221 VISIBLE, 222 HIDDEN, 223 }; 224 225 enum class NWebFocusSource { 226 FOCUS_SOURCE_DEFAULT = -1, 227 FOCUS_SOURCE_NAVIGATION = 0, 228 FOCUS_SOURCE_SYSTEM, 229 FOCUS_SOURCE_GESTURE, 230 }; 231 232 class NWebNativeEmbedInfo { 233 public: 234 virtual ~NWebNativeEmbedInfo() = default; 235 236 virtual int32_t GetWidth() = 0; 237 238 virtual int32_t GetHeight() = 0; 239 240 virtual std::string GetId() = 0; 241 242 virtual std::string GetSrc() = 0; 243 244 virtual std::string GetUrl() = 0; 245 246 virtual std::string GetType() = 0; 247 248 virtual std::string GetTag() = 0; 249 250 virtual std::map<std::string, std::string> GetParams() = 0; 251 252 virtual int32_t GetX() = 0; 253 254 virtual int32_t GetY() = 0; 255 }; 256 257 class NWebNativeEmbedDataInfo { 258 public: 259 virtual ~NWebNativeEmbedDataInfo() = default; 260 261 virtual NativeEmbedStatus GetStatus() = 0; 262 263 virtual std::string GetEmbedId() = 0; 264 265 virtual std::string GetSurfaceId() = 0; 266 267 virtual std::shared_ptr<NWebNativeEmbedInfo> GetNativeEmbedInfo() = 0; 268 }; 269 270 enum class TouchType : size_t { 271 DOWN = 0, 272 UP, 273 MOVE, 274 CANCEL, 275 }; 276 277 class NWebNativeEmbedTouchEvent { 278 public: 279 virtual ~NWebNativeEmbedTouchEvent() = default; 280 281 virtual float GetX() = 0; 282 283 virtual float GetY() = 0; 284 285 virtual int32_t GetId() = 0; 286 287 virtual TouchType GetType() = 0; 288 289 virtual float GetOffsetX() = 0; 290 291 virtual float GetOffsetY() = 0; 292 293 virtual float GetScreenX() = 0; 294 295 virtual float GetScreenY() = 0; 296 297 virtual std::string GetEmbedId() = 0; 298 299 virtual std::shared_ptr<NWebGestureEventResult> GetResult() = 0; 300 }; 301 302 enum class MouseType : size_t { 303 NONE = 0, 304 PRESS = 1, 305 RELEASE = 2, 306 MOVE = 3, 307 WINDOW_ENTER = 4, 308 WINDOW_LEAVE = 5, 309 HOVER, 310 HOVER_ENTER, 311 HOVER_MOVE, 312 HOVER_EXIT, 313 PULL_DOWN, 314 PULL_MOVE, 315 PULL_UP, 316 CANCEL 317 }; 318 319 enum class MouseButton : size_t { 320 NONE_BUTTON = 0, 321 LEFT_BUTTON = 1, 322 RIGHT_BUTTON = 2, 323 MIDDLE_BUTTON = 4, 324 BACK_BUTTON = 8, 325 FORWARD_BUTTON = 16, 326 SIDE_BUTTON = 32, 327 EXTRA_BUTTON = 64, 328 TASK_BUTTON = 128, 329 }; 330 331 class NWebNativeEmbedMouseEvent { 332 public: 333 virtual ~NWebNativeEmbedMouseEvent() = default; 334 335 virtual float GetX() = 0; 336 337 virtual float GetY() = 0; 338 339 virtual bool IsHitNativeArea() = 0; 340 341 virtual MouseType GetType() = 0; 342 343 virtual MouseButton GetButton() = 0; 344 345 virtual float GetOffsetX() = 0; 346 347 virtual float GetOffsetY() = 0; 348 349 virtual float GetScreenX() = 0; 350 351 virtual float GetScreenY() = 0; 352 353 virtual std::string GetEmbedId() = 0; 354 355 virtual std::shared_ptr<NWebMouseEventResult> GetResult() = 0; 356 }; 357 358 class OHOS_NWEB_EXPORT NWebHandler { 359 public: 360 NWebHandler() = default; 361 362 virtual ~NWebHandler() = default; 363 SetNWeb(std::shared_ptr<NWeb> nweb)364 virtual void SetNWeb(std::shared_ptr<NWeb> nweb) {} 365 OnProxyDied()366 virtual void OnProxyDied() {} 367 OnRouterPush(const std::string & param)368 virtual void OnRouterPush(const std::string& param) {} 369 OnMessage(const std::string & param)370 virtual void OnMessage(const std::string& param) {} 371 372 /** 373 * @brief Notify the SDK that a web site has finished loading. This method is 374 * called only for main frame. 375 * 376 * @param httpStatusCode The status code for the http request. 377 * @param url The url of the web site. 378 */ OnPageLoadEnd(int httpStatusCode,const std::string & url)379 virtual void OnPageLoadEnd(int httpStatusCode, const std::string& url) {} 380 381 /** 382 * @brief Notify the SDK that a web site has started loading. This method is 383 * called once for each main frame load. 384 * 385 * @param url The url to be loaded. 386 */ OnPageLoadBegin(const std::string & url)387 virtual void OnPageLoadBegin(const std::string& url) {} 388 389 /** 390 * @brief Report a load error to the SDK. 391 * 392 * @param errorCode The error code. 393 * @param description The error description. 394 * @param failingUrl The failed url. 395 */ OnPageLoadError(int errorCode,const std::string & description,const std::string & failingUrl)396 virtual void OnPageLoadError(int errorCode, const std::string& description, const std::string& failingUrl) {} 397 398 /** 399 * @brief Give the SDK a chance to decide whether to continue loading the 400 * url. 401 * 402 * @param url The url to be loaded. 403 * @return true to cancel the loading, false to continue the loading. 404 */ OnHandleInterceptUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request)405 virtual bool OnHandleInterceptUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request) 406 { 407 return false; 408 } 409 410 /** 411 * @brief Notify the SDK that the nweb will load the resource specified by 412 * the given url. 413 * 414 * @param url The url of the resource. 415 */ OnResource(const std::string & url)416 virtual void OnResource(const std::string& url) {} 417 418 /** 419 * @brief Notify the SDK of the changed document title. 420 * 421 * @param title The document title. 422 */ OnPageTitle(const std::string & title)423 virtual void OnPageTitle(const std::string& title) {} 424 425 /** 426 * @brief Notify the SDK the current progress of loading a web site. 427 * 428 * @param newProgress Loading progress, an integer between 0 and 100. 429 */ OnLoadingProgress(int newProgress)430 virtual void OnLoadingProgress(int newProgress) {} 431 432 /** 433 * @brief Request display and focus for a new nweb. 434 * 435 * @return Return true if request focus success, false if request focus fail. 436 */ OnFocus()437 virtual bool OnFocus() 438 { 439 return false; 440 } 441 442 /** 443 * @brief Obtains a list of all visited history items, used for link coloring 444 * 445 * @retval visited history 446 */ VisitedUrlHistory()447 virtual std::vector<std::string> VisitedUrlHistory() 448 { 449 return std::vector<std::string>(); 450 } 451 452 /** 453 * @brief Notify the host application of a resource request and allow the 454 * application to return the data. 455 * 456 * @param request request information 457 * @param response response information 458 * 459 * @retval true if handle success, otherwise false. 460 */ OnHandleInterceptRequest(std::shared_ptr<NWebUrlResourceRequest> request,std::shared_ptr<NWebUrlResourceResponse> response)461 virtual bool OnHandleInterceptRequest( 462 std::shared_ptr<NWebUrlResourceRequest> request, std::shared_ptr<NWebUrlResourceResponse> response) 463 { 464 return false; 465 } 466 467 /** 468 * @brief Report web resource loading error to the SDK. These errors usually 469 * indicate inability to connect to the server. 470 * 471 * @param request The request information. 472 * @param error The error information. 473 */ OnResourceLoadError(std::shared_ptr<NWebUrlResourceRequest> request,std::shared_ptr<NWebUrlResourceError> error)474 virtual void OnResourceLoadError( 475 std::shared_ptr<NWebUrlResourceRequest> request, std::shared_ptr<NWebUrlResourceError> error) 476 {} 477 478 /** 479 * @brief Notify the SDK that an HTTP error has been received from the server 480 * while loading a resource. 481 * 482 * @param request The request information. 483 * @param errorResponse The error occurred. 484 */ OnHttpError(std::shared_ptr<NWebUrlResourceRequest> request,std::shared_ptr<NWebUrlResourceResponse> errorResponse)485 virtual void OnHttpError( 486 std::shared_ptr<NWebUrlResourceRequest> request, std::shared_ptr<NWebUrlResourceResponse> errorResponse) 487 {} 488 489 /** 490 * @brief Notify the SDK of a new favicon for the current web site. 491 * 492 * @param data The raw image data for the icon. 493 * @param width The width of the icon in pixel. 494 * @param height The height of the icon in pixel. 495 * @param color_type The color data encoding type. 496 * @param alpha_type The alpha value of any pixel. 497 */ OnPageIcon(const void * data,size_t width,size_t height,ImageColorType color_type,ImageAlphaType alpha_type)498 virtual void OnPageIcon( 499 const void* data, size_t width, size_t height, ImageColorType color_type, ImageAlphaType alpha_type) 500 {} 501 502 /** 503 * @brief Notify the SDK of the url for a touch icon. 504 * 505 * @param icon_url The icon url. 506 * @param precomposed The touch icon type. 507 */ OnDesktopIconUrl(const std::string & icon_url,bool precomposed)508 virtual void OnDesktopIconUrl(const std::string& icon_url, bool precomposed) {} 509 510 /** 511 * @brief Report a JavaScript console message to the host application. 512 * 513 * @param console_log Details of the console message. 514 * @return Return true to stop the message from being output to the console. 515 */ OnConsoleLog(std::shared_ptr<NWebConsoleLog> console_log)516 virtual bool OnConsoleLog(std::shared_ptr<NWebConsoleLog> console_log) 517 { 518 return false; 519 } 520 521 /** 522 * @brief Show prompt to ask for the geolocation permission. 523 * 524 * @param origin String: the origin of the resource to get geolocation 525 * @param callback GeolocationCallbackInterface: callback to report 526 * geolocation 527 */ OnGeolocationShow(const std::string & origin,std::shared_ptr<NWebGeolocationCallbackInterface> callback)528 virtual void OnGeolocationShow( 529 const std::string& origin, std::shared_ptr<NWebGeolocationCallbackInterface> callback) 530 {} 531 532 /** 533 * @brief Notify the host application that the web page wants to display a 534 * JavaScript alert() dialog. 535 * 536 * @param url String: The url of the page requesting the dialog. 537 * @param message String: The message of the dialog. 538 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 539 * confirm that the user closed the window. 540 * @return To show a custom dialog, the app should return true. 541 */ OnAlertDialogByJS(const std::string & url,const std::string & message,std::shared_ptr<NWebJSDialogResult> result)542 virtual bool OnAlertDialogByJS( 543 const std::string& url, const std::string& message, std::shared_ptr<NWebJSDialogResult> result) 544 { 545 return false; 546 } 547 548 /** 549 * @brief Notify the host application that the web page wants to handle 550 * JavaScript onbeforeunload. 551 * 552 * @param url String: The url of the page requesting. 553 * @param message String: The message of the dialog. 554 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 555 * confirm that the user closed the window. 556 * @return To show a custom dialog, the app should return true. 557 */ OnBeforeUnloadByJS(const std::string & url,const std::string & message,std::shared_ptr<NWebJSDialogResult> result)558 virtual bool OnBeforeUnloadByJS( 559 const std::string& url, const std::string& message, std::shared_ptr<NWebJSDialogResult> result) 560 { 561 return false; 562 } 563 564 /** 565 * @brief Notify the host application that the web page wants to display a 566 * JavaScript prompt() dialog. 567 * 568 * @param url String: The url of the page requesting the dialog. 569 * @param message String: The message of the dialog. 570 * @param defaultValue String: The default value of the input message. 571 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 572 * confirm that the user closed the window. 573 * @return To show a custom dialog, the app should return true. 574 */ OnPromptDialogByJS(const std::string & url,const std::string & message,const std::string & defaultValue,std::shared_ptr<NWebJSDialogResult> result)575 virtual bool OnPromptDialogByJS(const std::string& url, const std::string& message, const std::string& defaultValue, 576 std::shared_ptr<NWebJSDialogResult> result) 577 { 578 return false; 579 } 580 581 /** 582 * @brief Notify the host application that the web page wants to display a 583 * JavaScript Confirm() dialog. 584 * 585 * @param url String: The url of the page requesting the dialog. 586 * @param message String: The message of the dialog. 587 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 588 * confirm that the user closed the window. 589 * @return To show a custom dialog, the app should return true. 590 */ OnConfirmDialogByJS(const std::string & url,const std::string & message,std::shared_ptr<NWebJSDialogResult> result)591 virtual bool OnConfirmDialogByJS( 592 const std::string& url, const std::string& message, std::shared_ptr<NWebJSDialogResult> result) 593 { 594 return false; 595 } 596 597 /** 598 * @brief Hide prompt to ask for the geolocation permission. 599 */ OnGeolocationHide()600 virtual void OnGeolocationHide() {} 601 602 /** 603 * @brief Ask for the permission. 604 * 605 * @param request std::shared_ptr<NWebAccessRequest>: A request to ask for the 606 * permission. 607 */ OnPermissionRequest(std::shared_ptr<NWebAccessRequest> request)608 virtual void OnPermissionRequest(std::shared_ptr<NWebAccessRequest> request) {} 609 610 /** 611 * @brief Cancel the request to ask for the permission. 612 * 613 * @param request std::shared_ptr<NWebAccessRequest>: A request to ask for the 614 * permission. 615 */ OnPermissionRequestCanceled(std::shared_ptr<NWebAccessRequest> request)616 virtual void OnPermissionRequestCanceled(std::shared_ptr<NWebAccessRequest> request) {} 617 618 /** 619 * @brief called when the render process exit. 620 * 621 * @param reason the detail reason why render process exit, the implementation of this callback 622 * should attempt to clean up the specific nweb that was set by SetNWeb interface. 623 */ OnRenderExited(RenderExitReason reason)624 virtual void OnRenderExited(RenderExitReason reason) {} 625 626 /** 627 * @brief inform application to update its visited links database. 628 * 629 * @param url the url being visited. 630 * @param isReload true if the url is being reload. 631 */ OnRefreshAccessedHistory(const std::string & url,bool isReload)632 virtual void OnRefreshAccessedHistory(const std::string& url, bool isReload) {} 633 634 /** 635 * @brief inform application to show a file selector. 636 * @param callback the file list to select. 637 * @param params the params of file selector. 638 */ OnFileSelectorShow(std::shared_ptr<NWebStringVectorValueCallback> callback,std::shared_ptr<NWebFileSelectorParams> params)639 virtual bool OnFileSelectorShow( 640 std::shared_ptr<NWebStringVectorValueCallback> callback, std::shared_ptr<NWebFileSelectorParams> params) 641 { 642 return false; 643 } 644 OnScaleChanged(float oldScaleFactor,float newScaleFactor)645 virtual void OnScaleChanged(float oldScaleFactor, float newScaleFactor) {} 646 RunContextMenu(std::shared_ptr<NWebContextMenuParams> params,std::shared_ptr<NWebContextMenuCallback> callback)647 virtual bool RunContextMenu( 648 std::shared_ptr<NWebContextMenuParams> params, std::shared_ptr<NWebContextMenuCallback> callback) 649 { 650 return false; 651 } 652 OnContextMenuDismissed()653 virtual void OnContextMenuDismissed() {} 654 RunQuickMenu(std::shared_ptr<NWebQuickMenuParams> params,std::shared_ptr<NWebQuickMenuCallback> callback)655 virtual bool RunQuickMenu( 656 std::shared_ptr<NWebQuickMenuParams> params, std::shared_ptr<NWebQuickMenuCallback> callback) 657 { 658 return false; 659 } 660 OnQuickMenuDismissed()661 virtual void OnQuickMenuDismissed() {} 662 OnTouchSelectionChanged(std::shared_ptr<NWebTouchHandleState> insertHandle,std::shared_ptr<NWebTouchHandleState> startSelectionHandle,std::shared_ptr<NWebTouchHandleState> endSelectionHandle)663 virtual void OnTouchSelectionChanged(std::shared_ptr<NWebTouchHandleState> insertHandle, 664 std::shared_ptr<NWebTouchHandleState> startSelectionHandle, 665 std::shared_ptr<NWebTouchHandleState> endSelectionHandle) 666 {} 667 OnHttpAuthRequestByJS(std::shared_ptr<NWebJSHttpAuthResult> result,const std::string & host,const std::string & realm)668 virtual bool OnHttpAuthRequestByJS( 669 std::shared_ptr<NWebJSHttpAuthResult> result, const std::string& host, const std::string& realm) 670 { 671 return false; 672 } 673 OnScroll(double xOffset,double yOffset)674 virtual void OnScroll(double xOffset, double yOffset) {} 675 OnDragAndDropData(const void * data,size_t len,std::shared_ptr<NWebImageOptions> opt)676 virtual bool OnDragAndDropData(const void* data, size_t len, std::shared_ptr<NWebImageOptions> opt) 677 { 678 return false; 679 } 680 OnSslErrorRequestByJS(std::shared_ptr<NWebJSSslErrorResult> result,SslError error)681 virtual bool OnSslErrorRequestByJS(std::shared_ptr<NWebJSSslErrorResult> result, SslError error) 682 { 683 return false; 684 } 685 OnSslSelectCertRequestByJS(std::shared_ptr<NWebJSSslSelectCertResult> result,const std::string & host,int port,const std::vector<std::string> & keyTypes,const std::vector<std::string> & issuers)686 virtual bool OnSslSelectCertRequestByJS(std::shared_ptr<NWebJSSslSelectCertResult> result, const std::string& host, 687 int port, const std::vector<std::string>& keyTypes, const std::vector<std::string>& issuers) 688 { 689 return false; 690 } 691 692 /** 693 * @brief called when the page enter the full-screen mode. 694 * @param handler to exit full-screen mode. 695 */ OnFullScreenEnter(std::shared_ptr<NWebFullScreenExitHandler> handler)696 virtual void OnFullScreenEnter(std::shared_ptr<NWebFullScreenExitHandler> handler) {} 697 698 /** 699 * @brief called when the page exit the full-screen mode. 700 */ OnFullScreenExit()701 virtual void OnFullScreenExit() {} 702 703 /** 704 * @brief called when new window required. 705 * 706 * @param targetUrl URL to be loaded in the new window. 707 * @param isAlert dialog window or not. 708 * @param isUserTrigger triggered by User. 709 * @param handler set the new web object. 710 */ OnWindowNewByJS(const std::string & targetUrl,bool isAlert,bool isUserTrigger,std::shared_ptr<NWebControllerHandler> handler)711 virtual void OnWindowNewByJS( 712 const std::string& targetUrl, bool isAlert, bool isUserTrigger, std::shared_ptr<NWebControllerHandler> handler) 713 {} 714 715 /** 716 * @brief called when window exit. 717 */ OnWindowExitByJS()718 virtual void OnWindowExitByJS() {} 719 720 /** 721 * @brief called when the page being loaded is about to be made visible. 722 */ OnPageVisible(const std::string & url)723 virtual void OnPageVisible(const std::string& url) {} 724 725 /** 726 * @brief shows the repost form confirmation dialog box. 727 * @param handler sets whether to resend data. 728 */ OnDataResubmission(std::shared_ptr<NWebDataResubmissionCallback> handler)729 virtual void OnDataResubmission(std::shared_ptr<NWebDataResubmissionCallback> handler) {} 730 731 /** 732 * @brief Give the host application a chance to handle the key event synchronousl. 733 * @param event The key event. 734 * @return True if the host application wants to handle the key event itself, otherwise return false. 735 */ OnPreKeyEvent(std::shared_ptr<NWebKeyEvent> event)736 virtual bool OnPreKeyEvent(std::shared_ptr<NWebKeyEvent> event) 737 { 738 return false; 739 } 740 741 /** 742 * @brief Notify the host application that a key was not handled by the WebView. 743 * @param event The key event. 744 * @return True if the host application wants to handle the key event itself, otherwise return false. 745 */ OnUnProcessedKeyEvent(std::shared_ptr<NWebKeyEvent> event)746 virtual bool OnUnProcessedKeyEvent(std::shared_ptr<NWebKeyEvent> event) 747 { 748 return false; 749 } 750 751 /** 752 * @brief Called when the browser's cursor has changed. 753 * @param type Cursor type. 754 * @param info If |type| is CT_CUSTOM then |info| will be populated with the custom cursor information. 755 * @return True if the cursor change was handled or false for default handling. 756 */ OnCursorChange(const CursorType & type,std::shared_ptr<NWebCursorInfo> info)757 virtual bool OnCursorChange(const CursorType& type, std::shared_ptr<NWebCursorInfo> info) 758 { 759 return false; 760 } 761 OnSelectPopupMenu(std::shared_ptr<NWebSelectPopupMenuParam> params,std::shared_ptr<NWebSelectPopupMenuCallback> callback)762 virtual void OnSelectPopupMenu( 763 std::shared_ptr<NWebSelectPopupMenuParam> params, std::shared_ptr<NWebSelectPopupMenuCallback> callback) 764 {} 765 766 /** 767 * @brief Called when the audio playing state on web page changed. 768 * @param playing Whether the audio is playing or not. 769 */ OnAudioStateChanged(bool playing)770 virtual void OnAudioStateChanged(bool playing) {} 771 772 /** 773 * @brief Called when the first content rendering of web page. 774 * @param navigationStartTick Absolute navigation start time, as TimeTicks. 775 * @param firstContentfulPaintMs Time to first contentful paint from 776 * navigation start. 777 */ OnFirstContentfulPaint(int64_t navigationStartTick,int64_t firstContentfulPaintMs)778 virtual void OnFirstContentfulPaint(int64_t navigationStartTick, int64_t firstContentfulPaintMs) {} 779 780 /** 781 * @brief Called when the first meaningful paint rendering of web page. 782 * @param details represents the details of first meaningful paint. 783 */ OnFirstMeaningfulPaint(std::shared_ptr<NWebFirstMeaningfulPaintDetails> details)784 virtual void OnFirstMeaningfulPaint(std::shared_ptr<NWebFirstMeaningfulPaintDetails> details) {} 785 786 /** 787 * @brief Called when the largest contentful paint rendering of web page. 788 * @param details represents the details of largest contentful paint. 789 */ OnLargestContentfulPaint(std::shared_ptr<NWebLargestContentfulPaintDetails> details)790 virtual void OnLargestContentfulPaint(std::shared_ptr<NWebLargestContentfulPaintDetails> details) {} 791 792 /** 793 * @brief Called when swap buffer completed with new size. 794 */ OnCompleteSwapWithNewSize()795 virtual void OnCompleteSwapWithNewSize() {} 796 797 /** 798 * @brief Called when resize not work. 799 */ OnResizeNotWork()800 virtual void OnResizeNotWork() {} 801 OnGetTouchHandleHotZone(std::shared_ptr<NWebTouchHandleHotZone> hotZone)802 virtual void OnGetTouchHandleHotZone(std::shared_ptr<NWebTouchHandleHotZone> hotZone) {} 803 OnDateTimeChooserPopup(std::shared_ptr<NWebDateTimeChooser> chooser,const std::vector<std::shared_ptr<NWebDateTimeSuggestion>> & suggestions,std::shared_ptr<NWebDateTimeChooserCallback> callback)804 virtual void OnDateTimeChooserPopup(std::shared_ptr<NWebDateTimeChooser> chooser, 805 const std::vector<std::shared_ptr<NWebDateTimeSuggestion>>& suggestions, 806 std::shared_ptr<NWebDateTimeChooserCallback> callback) 807 {} 808 OnDateTimeChooserClose()809 virtual void OnDateTimeChooserClose() {} 810 OnDragAndDropDataUdmf(std::shared_ptr<NWebDragData> dragData)811 virtual bool OnDragAndDropDataUdmf(std::shared_ptr<NWebDragData> dragData) 812 { 813 return false; 814 } 815 UpdateDragCursor(NWebDragData::DragOperation op)816 virtual void UpdateDragCursor(NWebDragData::DragOperation op) {} 817 OnOverScroll(float xOffset,float yOffset)818 virtual void OnOverScroll(float xOffset, float yOffset) {} 819 820 /** 821 * @brief Ask for the screen capture permission. 822 * 823 * @param request std::shared_ptr<NWebScreenCaptureAccessRequest>: A request to ask for the 824 * screen capture permission. 825 */ OnScreenCaptureRequest(std::shared_ptr<NWebScreenCaptureAccessRequest> request)826 virtual void OnScreenCaptureRequest(std::shared_ptr<NWebScreenCaptureAccessRequest> request) {} 827 OnOverScrollFlingVelocity(float xVelocity,float yVelocity,bool isFling)828 virtual void OnOverScrollFlingVelocity(float xVelocity, float yVelocity, bool isFling) {} 829 OnOverScrollFlingEnd()830 virtual void OnOverScrollFlingEnd() {} 831 832 /** 833 * @brief Called when the media or form state on the web page changed. 834 * @param state state of the media or form. Refer to the enum class MediaPlayingState and FormState 835 * @param ActivityType it can be form, media, or audio 836 */ OnActivityStateChanged(int state,ActivityType type)837 virtual void OnActivityStateChanged(int state, ActivityType type) {} 838 OnScrollState(bool scrollState)839 virtual void OnScrollState(bool scrollState) {} 840 OnRootLayerChanged(int width,int height)841 virtual void OnRootLayerChanged(int width, int height) {} 842 FilterScrollEvent(const float x,const float y,const float xVelocity,const float yVelocity)843 virtual bool FilterScrollEvent(const float x, const float y, const float xVelocity, const float yVelocity) 844 { 845 return false; 846 } 847 848 /** 849 * @brief Called when received website security risk check result. 850 * @param threat_type The threat type of website. 851 */ OnSafeBrowsingCheckResult(int threat_type)852 virtual void OnSafeBrowsingCheckResult(int threat_type) {} 853 854 /** 855 * @brief called when the navigation entry has been committed. 856 * @param details represents the details of a committed navigation entry. 857 */ OnNavigationEntryCommitted(std::shared_ptr<NWebLoadCommittedDetails> details)858 virtual void OnNavigationEntryCommitted(std::shared_ptr<NWebLoadCommittedDetails> details) {} 859 OnNativeEmbedLifecycleChange(std::shared_ptr<NWebNativeEmbedDataInfo> dataInfo)860 virtual void OnNativeEmbedLifecycleChange(std::shared_ptr<NWebNativeEmbedDataInfo> dataInfo) {} 861 OnNativeEmbedGestureEvent(std::shared_ptr<NWebNativeEmbedTouchEvent> event)862 virtual void OnNativeEmbedGestureEvent(std::shared_ptr<NWebNativeEmbedTouchEvent> event) {} 863 864 /** 865 * @brief called when the page enter the full-screen mode. 866 * 867 * @param handler to exit full-screen mode. 868 * @param video_natural_width indicates the width of the <video> element 869 * entering full screen. 870 * @param video_natural_height indicates the height of the <video> element 871 * entering full screen. 872 */ OnFullScreenEnterWithVideoSize(std::shared_ptr<NWebFullScreenExitHandler> handler,int video_natural_width,int video_natural_height)873 virtual void OnFullScreenEnterWithVideoSize( 874 std::shared_ptr<NWebFullScreenExitHandler> handler, int video_natural_width, int video_natural_height) 875 {} 876 877 /** 878 * @brief Called when tracker's cookie is prevented. 879 * @param website_host The host of website url. 880 * @param tracker_host The host of tracker url. 881 */ OnIntelligentTrackingPreventionResult(const std::string & websiteHost,const std::string & trackerHost)882 virtual void OnIntelligentTrackingPreventionResult(const std::string& websiteHost, const std::string& trackerHost) 883 {} 884 885 /** 886 * @brief Give the application a chance to decide whether to override loading the 887 * url. 888 * 889 * @param request The request information. 890 * @return true to abort loading the url, false to continue loading the url 891 * as usual. 892 */ OnHandleOverrideUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request)893 virtual bool OnHandleOverrideUrlLoading(std::shared_ptr<OHOS::NWeb::NWebUrlResourceRequest> request) 894 { 895 return false; 896 } 897 OnAllSslErrorRequestByJS(std::shared_ptr<NWebJSAllSslErrorResult> result,SslError error,const std::string & url,const std::string & originalUrl,const std::string & referrer,bool isFatalError,bool isMainFrame)898 virtual bool OnAllSslErrorRequestByJS(std::shared_ptr<NWebJSAllSslErrorResult> result, SslError error, 899 const std::string& url, const std::string& originalUrl, const std::string& referrer, bool isFatalError, 900 bool isMainFrame) 901 { 902 return false; 903 } 904 905 /** 906 * @brief Called when a tooltip should be presented for a component. 907 * 908 * @param tooltip The content of the tooltip. 909 */ OnTooltip(const std::string & param)910 virtual void OnTooltip(const std::string& param) {} 911 912 /** 913 * @brief called when resizehold is released. 914 */ ReleaseResizeHold()915 virtual void ReleaseResizeHold() {} 916 917 /** 918 * @brief Called when select a word. 919 * 920 * @param text The content of the text. 921 * @param offset The offset of the point. 922 */ GetWordSelection(const std::string & text,int8_t offset)923 virtual std::vector<int8_t> GetWordSelection(const std::string& text, int8_t offset) 924 { 925 return { -1, -1 }; 926 } 927 UpdateClippedSelectionBounds(int x,int y,int w,int h)928 virtual void UpdateClippedSelectionBounds(int x, int y, int w, int h) {} 929 OnOpenAppLink(const std::string & url,std::shared_ptr<NWebAppLinkCallback> callback)930 virtual bool OnOpenAppLink(const std::string& url, std::shared_ptr<NWebAppLinkCallback> callback) 931 { 932 return false; 933 } 934 935 /** 936 * @brief Called when the render process not responding. 937 * 938 * @param js_stack Javascript stack info of webpage when render process not 939 * responding. 940 * @param pid Process id of the render process not responding. 941 * @param reason Reason of the render process not responding. 942 */ OnRenderProcessNotResponding(const std::string & js_stack,int pid,RenderProcessNotRespondingReason reason)943 virtual void OnRenderProcessNotResponding( 944 const std::string& js_stack, int pid, RenderProcessNotRespondingReason reason) 945 {} 946 947 /** 948 * @brief Called when the unresponding render process becomes responsive. 949 * 950 */ OnRenderProcessResponding()951 virtual void OnRenderProcessResponding() {} 952 OnShowAutofillPopup(const float offsetX,const float offsetY,const std::vector<std::string> & menu_items)953 virtual void OnShowAutofillPopup( 954 const float offsetX, const float offsetY, const std::vector<std::string>& menu_items) 955 {} 956 OnHideAutofillPopup()957 virtual void OnHideAutofillPopup() {} 958 959 /** 960 * @brief Called when the viewport-fit meta is detected for web page. 961 * 962 * @param viewportFit The type of the viewport-fit. 963 */ OnViewportFitChange(ViewportFit viewportFit)964 virtual void OnViewportFitChange(ViewportFit viewportFit) {} 965 966 /** 967 * @brief Request display and focus for a new nweb. 968 * 969 * @param source The Focus Source. 970 * @return Return true if request focus success, false if request focus fail. 971 */ OnFocus(NWebFocusSource source)972 virtual bool OnFocus(NWebFocusSource source) 973 { 974 return false; 975 } 976 977 /** 978 * @brief Called when the page is over scroll. 979 * 980 * @param xOffset The offset of x axis. 981 * @param yOffset The offset of y axis. 982 * @param xVelocity The velocity of x axis. 983 * @param yVelocity The velocity of y axis. 984 * @return Return true if value is consumed, false if value is unconsumed. 985 */ OnOverScroll(float xOffset,float yOffset,float xVelocity,float yVelocity)986 virtual bool OnOverScroll(float xOffset, float yOffset, float xVelocity, float yVelocity) 987 { 988 return false; 989 } 990 991 /** 992 * @brief called when creating overlay. 993 */ CreateOverlay(void * data,size_t len,int width,int height,int offsetX,int offsetY,int rectWidth,int rectHeight,int pointX,int pointY)994 virtual void CreateOverlay(void* data, size_t len, int width, int height, int offsetX, int offsetY, int rectWidth, 995 int rectHeight, int pointX, int pointY) 996 {} 997 998 /** 999 * @brief called when state changed. 1000 */ OnOverlayStateChanged(int offsetX,int offsetY,int rectWidth,int rectHeight)1001 virtual void OnOverlayStateChanged(int offsetX, int offsetY, int rectWidth, int rectHeight) {} 1002 1003 /** 1004 * @brief Called when the key board redispatch. 1005 * 1006 * @param event Key information. 1007 * @param isUsed Whether the key is used by the kernel. 1008 */ KeyboardReDispatch(std::shared_ptr<NWebKeyEvent> event,bool isUsed)1009 virtual void KeyboardReDispatch(std::shared_ptr<NWebKeyEvent> event, bool isUsed) {} 1010 1011 /** 1012 * @brief Called when received Ads blocked results. 1013 * 1014 * @param url The url of webpage. 1015 * @param adsBlocked The ads' blocked urls. 1016 * 1017 */ OnAdsBlocked(const std::string & url,const std::vector<std::string> & adsBlocked)1018 virtual void OnAdsBlocked(const std::string& url, const std::vector<std::string>& adsBlocked) {} 1019 OnInterceptKeyboardAttach(const std::shared_ptr<NWebCustomKeyboardHandler> keyboardHandler,const std::map<std::string,std::string> & attributes,bool & useSystemKeyboard,int32_t & enterKeyType)1020 virtual void OnInterceptKeyboardAttach( 1021 const std::shared_ptr<NWebCustomKeyboardHandler> keyboardHandler, 1022 const std::map<std::string, std::string> &attributes, bool &useSystemKeyboard, int32_t &enterKeyType) { 1023 useSystemKeyboard = true; 1024 enterKeyType = -1; 1025 } 1026 OnCustomKeyboardAttach()1027 virtual void OnCustomKeyboardAttach() {} 1028 OnCustomKeyboardClose()1029 virtual void OnCustomKeyboardClose() {} 1030 1031 /** 1032 * @brief Called when you need to temporarily hide/restore the handle menu. 1033 * 1034 * @param hide hide. 1035 */ HideHandleAndQuickMenuIfNecessary(bool hide)1036 virtual void HideHandleAndQuickMenuIfNecessary(bool hide) {} 1037 1038 /** 1039 * @brief called when the cursor info is updated. 1040 * 1041 * @param x, y relative coordinates within web components of the cursor 1042 * @param width, height width and height of the cursor 1043 */ OnCursorUpdate(double x,double y,double width,double height)1044 virtual void OnCursorUpdate(double x, double y, double width, double height) {} 1045 1046 /** 1047 * @brief Called When you click on the selected area. 1048 * 1049 */ ChangeVisibilityOfQuickMenu()1050 virtual void ChangeVisibilityOfQuickMenu() {} 1051 1052 /** 1053 * @brief Called when you need to start vibrator. 1054 */ StartVibraFeedback(const std::string & vibratorType)1055 virtual void StartVibraFeedback(const std::string& vibratorType) {} 1056 OnNativeEmbedVisibilityChange(const std::string & embed_id,bool visibility)1057 virtual void OnNativeEmbedVisibilityChange(const std::string& embed_id, bool visibility) {} 1058 CloseImageOverlaySelection()1059 virtual bool CloseImageOverlaySelection() { return false; } 1060 1061 /** 1062 * @brief Called when a popup is shown with the given size. 1063 * 1064 * @param x The offset of the popup on the x coordinate axis. 1065 * @param y The offset of the popup on the y coordinate axis. 1066 * @param width The width of the popup. 1067 * @param height The height of the popup. 1068 * 1069 */ OnPopupSize(int x,int y,int width,int height)1070 virtual void OnPopupSize(int x, int y, int width, int height) {} 1071 1072 /** 1073 * @brief Called when the popup is shown or hidden. 1074 * 1075 * @param show Whether the popup is shown or hidden. 1076 * 1077 */ OnPopupShow(bool show)1078 virtual void OnPopupShow(bool show) {} 1079 OnAccessibilityEvent(int64_t accessibilityId,int32_t eventType)1080 virtual void OnAccessibilityEvent(int64_t accessibilityId, int32_t eventType) {} 1081 1082 /** 1083 * @brief Called when web occurs frame loss event. 1084 * 1085 * @param sceneId The id of event scene. 1086 * @param isStart True if is start. 1087 */ ReportDynamicFrameLossEvent(const std::string & sceneId,bool isStart)1088 virtual void ReportDynamicFrameLossEvent(const std::string& sceneId, bool isStart) {} 1089 IsCurrentFocus()1090 virtual bool IsCurrentFocus() { return false; } 1091 OnSslErrorRequestByJSV2(std::shared_ptr<NWebJSSslErrorResult> result,SslError error,const std::vector<std::string> & certChainData)1092 virtual bool OnSslErrorRequestByJSV2(std::shared_ptr<NWebJSSslErrorResult> result, SslError error, 1093 const std::vector<std::string>& certChainData) 1094 { 1095 return false; 1096 } 1097 1098 /** 1099 * @brief Get the visible area relative to the web. 1100 */ GetVisibleRectToWeb(int & visibleX,int & visibleY,int & visibleWidth,int & visibleHeight)1101 virtual void GetVisibleRectToWeb(int& visibleX, int& visibleY, int& visibleWidth, int& visibleHeight) {} 1102 OnScrollStart(const float x,const float y)1103 virtual void OnScrollStart(const float x, const float y) {} 1104 OnShowAutofillPopupV2(const float offsetX,const float offsetY,const float height,const float width,const std::vector<std::string> & menu_items)1105 virtual void OnShowAutofillPopupV2( 1106 const float offsetX, const float offsetY, const float height, const float width, 1107 const std::vector<std::string>& menu_items) 1108 {} 1109 1110 /** 1111 * @brief Restore web component renderfit. 1112 */ RestoreRenderFit()1113 virtual void RestoreRenderFit() {} 1114 OnAccessibilityEventV2(int64_t accessibilityId,int32_t eventType,const std::string & argument)1115 virtual void OnAccessibilityEventV2(int64_t accessibilityId, int32_t eventType, const std::string& argument) {} 1116 OnNestedScroll(float & x,float & y,float & xVelocity,float & yVelocity,bool & isAvailable)1117 virtual bool OnNestedScroll(float& x, float& y, float& xVelocity, float& yVelocity, bool& isAvailable) 1118 { 1119 return false; 1120 } 1121 1122 /** 1123 * @brief Called When you click on the selected area. 1124 */ ChangeVisibilityOfQuickMenuV2()1125 virtual bool ChangeVisibilityOfQuickMenuV2() { return false; } 1126 1127 /** 1128 * @brief called when the web page is active for window.open called by other web component. 1129 */ OnActivateContentByJS()1130 virtual void OnActivateContentByJS() {} 1131 1132 /** 1133 * @brief Notify the SDK that a web site has started loading. This method is 1134 * called once for each main frame load. Embedded frame changes, i.e. clicking 1135 * a link whose target is an iframe and fragment navigations (navigations to 1136 * #fragment_id) will not trigger this callback. 1137 * 1138 * @param url The url to be loaded. 1139 */ OnLoadStarted(const std::string & url)1140 virtual void OnLoadStarted(const std::string& url) {} 1141 1142 /** 1143 * @brief Notify the SDK that a web site has finished loading. This method is 1144 * called only for main frame. Different from onPageEnd, onLoadFinished is 1145 * triggered only once if the mainframe is automatically redirected before the 1146 * page is completely loaded. OnPageEnd is triggered every navigation. 1147 * fragment navigation also triggers onLoadFinished. 1148 * 1149 * @param url The url of the web site. 1150 */ OnLoadFinished(const std::string & url)1151 virtual void OnLoadFinished(const std::string& url) {} 1152 1153 /** 1154 * @brief Notify the host application that the web page wants to handle 1155 * JavaScript onbeforeunload. 1156 * 1157 * @param url String: The url of the page requesting. 1158 * @param message String: The message of the dialog. 1159 * @param isReload bool: The isReload parameter is set to true when the page is refreshed; 1160 * otherwise, it remains false. Default is false. 1161 * @param result std::shared_ptr<NWebJSDialogResult>: A NWebJSDialogResult to 1162 * confirm that the user closed the window. 1163 * @return To show a custom dialog, the app should return true. 1164 */ OnBeforeUnloadByJSV2(const std::string & url,const std::string & message,bool isReload,std::shared_ptr<NWebJSDialogResult> result)1165 virtual bool OnBeforeUnloadByJSV2( 1166 const std::string& url, const std::string& message, bool isReload, std::shared_ptr<NWebJSDialogResult> result) 1167 { 1168 return false; 1169 } 1170 1171 /** 1172 * @Description: Called when an mouse native event occurs on native embed area. 1173 * @Input mouse_event: Mouse events that contain information about the same layer. 1174 */ OnNativeEmbedMouseEvent(std::shared_ptr<NWebNativeEmbedMouseEvent> event)1175 virtual void OnNativeEmbedMouseEvent(std::shared_ptr<NWebNativeEmbedMouseEvent> event) {} 1176 1177 /** 1178 * @brief Called when web occurs event of picture in picture. 1179 */ OnPip(int status,int delegate_id,int child_id,int frame_routing_id,int width,int height)1180 virtual void OnPip(int status, 1181 int delegate_id, 1182 int child_id, 1183 int frame_routing_id, 1184 int width, 1185 int height) {} 1186 EnableSecurityLayer(bool isNeedSecurityLayer)1187 virtual void EnableSecurityLayer(bool isNeedSecurityLayer) {} 1188 OnAllSslErrorRequestByJSV2(std::shared_ptr<NWebJSAllSslErrorResult> result,SslError error,const std::string & url,const std::string & originalUrl,const std::string & referrer,bool isFatalError,bool isMainFrame,const std::vector<std::string> & certChainData)1189 virtual bool OnAllSslErrorRequestByJSV2(std::shared_ptr<NWebJSAllSslErrorResult> result, SslError error, 1190 const std::string& url, const std::string& originalUrl, const std::string& referrer, bool isFatalError, 1191 bool isMainFrame, const std::vector<std::string>& certChainData) 1192 { 1193 return false; 1194 } 1195 1196 /** 1197 * @brief Notify the web client to insert blankless frame. 1198 * 1199 * @param pathToFrame The file used to insert frame. 1200 */ OnInsertBlanklessFrame(const std::string & pathToFrame)1201 virtual void OnInsertBlanklessFrame(const std::string& pathToFrame) {} 1202 1203 /** 1204 * @brief Notify the web client to remove blankless frame. 1205 * 1206 * @param delayTime The delayTime for web client to remove blankless frame. 1207 */ OnRemoveBlanklessFrame(int delayTime)1208 virtual void OnRemoveBlanklessFrame(int delayTime) {} 1209 1210 /** 1211 * @brief Called when you need to show magnifier. 1212 */ ShowMagnifier()1213 virtual void ShowMagnifier() {} 1214 1215 /** 1216 * @brief Called when you need to hide magnifier. 1217 */ HideMagnifier()1218 virtual void HideMagnifier() {} 1219 1220 /** 1221 * @brief Notify the SDK of the changed document title. 1222 * 1223 * @param title The document title. 1224 * @param isRealTitle Mark the source of the title. If it is true, the title is derived from the H5 title element; 1225 * If it is false, it is calculated from the URL. By default, it is calculated from the URL. 1226 */ OnPageTitleV2(const std::string & title,bool isRealTitle)1227 virtual void OnPageTitleV2(const std::string& title, bool isRealTitle) {} 1228 1229 /** 1230 * @brief Triggered when the web page's document resource error 1231 * 1232 * @param request The request information. 1233 * @param error The error information. 1234 */ OnHandleOverrideErrorPage(std::shared_ptr<NWebUrlResourceRequest> request,std::shared_ptr<NWebUrlResourceError> error)1235 virtual std::string OnHandleOverrideErrorPage( 1236 std::shared_ptr<NWebUrlResourceRequest> request, 1237 std::shared_ptr<NWebUrlResourceError> error) 1238 { 1239 return ""; 1240 } 1241 1242 /** 1243 * @brief Called when web occurs event of pdf scroll at bottom. 1244 * 1245 * @param url The url of the pdf. 1246 */ OnPdfScrollAtBottom(const std::string & url)1247 virtual void OnPdfScrollAtBottom(const std::string& url) {} 1248 1249 /** 1250 * @brief Called when web occurs event of pdf load. 1251 * 1252 * @param result The result of the pdf load. 1253 * @param url The url of the pdf. 1254 */ OnPdfLoadEvent(int32_t result,const std::string & url)1255 virtual void OnPdfLoadEvent(int32_t result, const std::string& url) {} 1256 OnTakeFocus(std::shared_ptr<NWebKeyEvent> event)1257 virtual void OnTakeFocus(std::shared_ptr<NWebKeyEvent> event) {} 1258 }; 1259 1260 } // namespace OHOS::NWeb 1261 1262 #endif // NWEB_HANDLER_H 1263