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_NWEB_WRAPPER_H_ 17 #define ARK_WEB_NWEB_WRAPPER_H_ 18 #pragma once 19 20 #include "include/nweb.h" 21 #include "ohos_nweb/include/ark_web_nweb.h" 22 23 namespace OHOS::ArkWeb { 24 25 using ArkWebBlurReason = OHOS::NWeb::BlurReason; 26 using ArkWebFocusReason = OHOS::NWeb::FocusReason; 27 using ArkWebImageColorType = OHOS::NWeb::ImageColorType; 28 using ArkWebImageAlphaType = OHOS::NWeb::ImageAlphaType; 29 using ArkWebNestedScrollMode = OHOS::NWeb::NestedScrollMode; 30 using ArkPixelUnit = OHOS::NWeb::PixelUnit; 31 using ArkWebDestroyMode = OHOS::NWeb::WebDestroyMode; 32 33 class ArkWebNWebWrapper : public OHOS::NWeb::NWeb { 34 public: 35 ArkWebNWebWrapper(ArkWebRefPtr<ArkWebNWeb> ark_web_nweb); 36 ~ArkWebNWebWrapper() = default; 37 38 void Resize(uint32_t width, uint32_t height, bool is_keyboard) override; 39 40 void OnPause() override; 41 42 void OnContinue() override; 43 44 void OnDestroy() override; 45 46 void OnFocus(const ArkWebFocusReason& focus_reason) override; 47 48 void OnBlur(const ArkWebBlurReason& blur_reason) override; 49 50 void OnTouchPress(int32_t id, double x, double y, bool from_overlay) override; 51 52 void OnTouchRelease(int32_t id, double x, double y, bool from_overlay) override; 53 54 void OnTouchMove(int32_t id, double x, double y, bool from_overlay) override; 55 56 void OnTouchMove(const std::vector<std::shared_ptr<OHOS::NWeb::NWebTouchPointInfo>>& touch_point_infos, 57 bool from_overlay) override; 58 59 void OnTouchCancel() override; 60 61 void OnNavigateBack() override; 62 63 bool SendKeyEvent(int32_t key_code, int32_t key_action) override; 64 65 void SendMouseWheelEvent(double x, double y, double delta_x, double delta_y) override; 66 67 void SendMouseEvent(int x, int y, int button, int action, int count) override; 68 69 /** 70 * @brief Loads the given URL. 71 * 72 * @param url: the URL of the resource to load This value cannot be null. 73 * 74 * @return title string for the current page. 75 */ 76 int Load(const std::string& url) override; 77 78 /** 79 * @brief Gets whether this NWeb has a back history item. 80 * 81 * @return true if this NWeb has a back history item 82 */ 83 bool IsNavigatebackwardAllowed() override; 84 85 /** 86 * @brief Gets whether this NWeb has a forward history item. 87 * 88 * @return true if this NWeb has a forward history item 89 */ 90 bool IsNavigateForwardAllowed() override; 91 92 /** 93 * @brief Gets whether this NWeb has a back or forward history item for number 94 * of steps. 95 * 96 * @param num_steps: the negative or positive number of steps to move the 97 * history 98 * 99 * @return true if this NWeb has a forward history item 100 */ 101 bool CanNavigateBackOrForward(int num_steps) override; 102 103 /** 104 * @brief Goes back in the history of this NWeb. 105 */ 106 void NavigateBack() override; 107 108 /** 109 * @brief Goes forward in the history of this NWeb. 110 */ 111 void NavigateForward() override; 112 113 /** 114 * @brief Goes to the history item that is the number of steps away from the 115 * current item. 116 */ 117 void NavigateBackOrForward(int step) override; 118 119 /** 120 * @brief Delete back and forward history list. 121 */ 122 void DeleteNavigateHistory() override; 123 124 /** 125 * @brief Reloads the current URL. 126 */ 127 void Reload() override; 128 129 /** 130 * @brief Performs a zoom operation in this NWeb. 131 * 132 * @param zoom_factor: the zoom factor to apply. The zoom factor will be 133 * clamped to the NWeb's zoom limits. This value must be in the range 134 * 0.01 to 100.0 inclusive. 135 * 136 * @return the error id. 137 */ 138 int Zoom(float zoom_factor) override; 139 140 /** 141 * @brief Performs a zooming in operation in this NWeb. 142 * 143 * @return the error id. 144 */ 145 int ZoomIn() override; 146 147 /** 148 * @brief Performs a zooming out operation in this NWeb. 149 * 150 * @return the error id. 151 */ 152 int ZoomOut() override; 153 154 /** 155 * @brief Stops the current load. 156 * 157 * @param code string: javascript code 158 */ 159 void Stop() override; 160 161 /** 162 * @brief ExecuteJavaScript 163 */ 164 void ExecuteJavaScript(const std::string& code) override; 165 166 /** 167 * @brief ExecuteJavaScript plus 168 * 169 * @param code: javascript code 170 * @param callback: javascript running result 171 */ 172 void ExecuteJavaScript(const std::string& code, std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback, 173 bool extention) override; 174 175 /** 176 * @brief Gets the NWebPreference object used to control the settings for this 177 * NWeb. 178 * 179 * @return a NWebPreference object that can be used to control this NWeb's 180 * settings This value cannot be null. 181 */ 182 std::shared_ptr<OHOS::NWeb::NWebPreference> GetPreference() override; 183 184 /** 185 * @brief Gets the web id. 186 * 187 * @return the web id 188 */ 189 unsigned int GetWebId() override; 190 191 /** 192 * @brief Gets the last hit test result. 193 * 194 * @return the last HitTestResult 195 */ 196 std::shared_ptr<OHOS::NWeb::HitTestResult> GetHitTestResult() override; 197 198 /** 199 * @brief Sets the background color for this view. 200 * 201 * @param color: the color of the background 202 */ 203 void PutBackgroundColor(int color) override; 204 205 /** 206 * @brief Sets the initla scale for the page. 207 * 208 * @param scale: the initla scale of the page. 209 */ 210 void InitialScale(float scale) override; 211 212 /** 213 * @brief Sets the NWebDownloadCallback that will receive download event. This 214 * will replace the current handler. 215 * 216 * @param download_listener: download listener 217 */ 218 void PutDownloadCallback(std::shared_ptr<OHOS::NWeb::NWebDownloadCallback> download_listener) override; 219 220 /** 221 * @brief Set the NWebAccessibilityEventCallback that will receive 222 * accessibility event. This will replace the current handler. 223 * 224 * @param accessibility_event_listener: accessibility event listener 225 */ 226 void PutAccessibilityEventCallback( 227 std::shared_ptr<OHOS::NWeb::NWebAccessibilityEventCallback> accessibility_event_listener) override; 228 229 /** 230 * @brief Set the accessibility id generator that will generate accessibility 231 * id for accessibility nodes in the web. This will replace the current 232 * handler. 233 * 234 * @param accessibility_id_generator: Accessibility id generator. 235 */ 236 void PutAccessibilityIdGenerator(const AccessibilityIdGenerateFunc accessibility_id_generator) override; 237 238 /** 239 * @brief Set the NWebHandler that will receive various notifications and 240 * requests. This will replace the current handler. 241 * 242 * @param handler: an implementation of NWebHandler This value cannot be null. 243 */ 244 void SetNWebHandler(std::shared_ptr<OHOS::NWeb::NWebHandler> handler) override; 245 246 /** 247 * @brief Gets the title for the current page. 248 * 249 * @return title string for the current page. 250 */ 251 std::string Title() override; 252 253 /** 254 * @brief Gets the progress for the current page. 255 * 256 * @return progress for the current page. 257 */ 258 int PageLoadProgress() override; 259 260 /** 261 * @brief Gets the height of the HTML content. 262 * 263 * @return the height of the HTML content. 264 */ 265 int ContentHeight() override; 266 267 /** 268 * @brief Gets the current scale of this NWeb. 269 * 270 * @return the current scale 271 */ 272 float Scale() override; 273 274 /** 275 * @brief Loads the given URL with additional HTTP headers, specified as a map 276 * from name to value. Note that if this map contains any of the 277 * headers that are set by default by this NWeb, such as those 278 * controlling caching, accept types or the User-Agent, their values 279 * may be overridden by this NWeb's defaults. 280 * 281 * @param url: the URL of the resource to load This value cannot be null. 282 * @param additional_http_headers: additional http headers 283 */ 284 int Load(const std::string& url, const std::map<std::string, std::string>& additional_http_headers) override; 285 286 /** 287 * @brief Loads the given data into this NWeb, using baseUrl as the base URL 288 * for the content. The base URL is used both to resolve relative URLs 289 * and when applying JavaScript's same origin policy. The historyUrl is 290 * used for the history entry. 291 * 292 * @param base_url: the URL to use as the page's base URL. If null defaults to 293 * 'about:blank'. This value may be null. 294 * @param data: the URL to use as the page's base URL. If null defaults to 295 * 'about:blank'. This value may be null. 296 * @param mime_type: the MIME type of the data, e.g. 'text/html'. This value 297 * may be null. 298 * @param encoding: the encoding of the data This value may be null. 299 * @param history_url: the URL to use as the history entry. If null defaults 300 * to 'about:blank'. If non-null, this must be a valid URL. This value 301 * may be null. 302 */ 303 int LoadWithDataAndBaseUrl(const std::string& base_url, const std::string& data, const std::string& mime_type, 304 const std::string& encoding, const std::string& history_url) override; 305 306 /** 307 * @brief Loads the given data into this NWeb. 308 * 309 * @param data: the URL to use as the page's base URL. If null defaults to 310 * 'about:blank'. This value may be null. 311 * @param mime_type: the MIME type of the data, e.g. 'text/html'. This value 312 * may be null. 313 * @param encoding: the encoding of the data This value may be null. 314 */ 315 int LoadWithData(const std::string& data, const std::string& mime_type, const std::string& encoding) override; 316 317 /** 318 * @brief RegisterArkJSfunction 319 * 320 * @param object_name String: objector name 321 * @param method_list vector<String>: vector list ,method list 322 * @param object_id int32_t: object id 323 */ 324 void RegisterArkJSfunction( 325 const std::string& object_name, const std::vector<std::string>& method_list, const int32_t object_id) override; 326 327 /** 328 * @brief UnregisterArkJSfunction 329 * 330 * @param object_name: objector name 331 * @param method_list: vector list ,method list 332 */ 333 void UnregisterArkJSfunction(const std::string& object_name, const std::vector<std::string>& method_list) override; 334 335 /** 336 * @brief SetNWebJavaScriptResultCallBack 337 * 338 * @param callback: callback client 339 */ 340 void SetNWebJavaScriptResultCallBack(std::shared_ptr<OHOS::NWeb::NWebJavaScriptResultCallBack> callback) override; 341 342 /** 343 * @brief Set the NWebFindCallback that will receive find event. This will 344 * replace the current handler. 345 * 346 * @param find_listener: find callback 347 */ 348 void PutFindCallback(std::shared_ptr<OHOS::NWeb::NWebFindCallback> find_listener) override; 349 350 /** 351 * @brief Finds all instances of find on the page and highlights them, 352 * asynchronously. 353 * 354 * @param search_str: target string to find. 355 */ 356 void FindAllAsync(const std::string& search_str) override; 357 358 /** 359 * @brief Clears the highlighting surrounding text matches created by 360 * findAllAsync 361 */ 362 void ClearMatches() override; 363 364 /** 365 * @brief Highlights and scrolls to the next match found by 366 * findAllAsync(String), wrapping around page boundaries as necessary. 367 * 368 * @param forward: find back or forward: 369 */ 370 void FindNext(const bool forward) override; 371 372 /** 373 * @brief Saves the current view as a web archive. 374 * 375 * @param base_name: the filename where the archive should be placed This 376 * value cannot be null. 377 * @param auto_name: if false, takes basename to be a file. If true, basename 378 * is assumed to be a directory in which a filename will be chosen 379 * according to the URL of the current page. 380 */ 381 void StoreWebArchive(const std::string& base_name, bool auto_name, 382 std::shared_ptr<OHOS::NWeb::NWebStringValueCallback> callback) override; 383 384 /** 385 * @brief creating two ends of a message channel. 386 * 387 * @return the web message ports get from nweb. 388 */ 389 std::vector<std::string> CreateWebMessagePorts() override; 390 391 /** 392 * @brief Posts MessageEvent to the main frame. 393 * 394 * @param message: message send to mmain frame. 395 * @param ports: the web message ports send to main frame. 396 * @param target_uri: the uri which can received the ports. 397 */ 398 void PostWebMessage( 399 const std::string& message, const std::vector<std::string>& ports, const std::string& target_uri) override; 400 401 /** 402 * @brief close the message port. 403 * 404 * @param port_handle: the port to close. 405 */ 406 void ClosePort(const std::string& port_handle) override; 407 408 /** 409 * @brief use the port to send message. 410 * 411 * @param port_handle: the port to send message. 412 * @param data: the message to send. 413 */ 414 void PostPortMessage(const std::string& port_handle, std::shared_ptr<OHOS::NWeb::NWebMessage> data) override; 415 416 /** 417 * @brief set the callback of the message port. 418 * 419 * @param port_handle: the port to set callback. 420 * @param callback: to reveive the result when the other port post message. 421 */ 422 void SetPortMessageCallback( 423 const std::string& port_handle, std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback) override; 424 425 void SendDragEvent(std::shared_ptr<OHOS::NWeb::NWebDragEvent> drag_event) override; 426 427 /** 428 * @brief Clear ssl cache. 429 */ 430 void ClearSslCache() override; 431 432 /** 433 * @brief get web page url. 434 * 435 * @return web page url. 436 */ 437 std::string GetUrl() override; 438 439 /** 440 * @brief Clears the client authentication certificate Cache in the Web. 441 */ 442 void ClearClientAuthenticationCache() override; 443 444 /** 445 * @brief set the locale name of current system setting.. 446 * 447 * @param region: the locale name of current system setting. 448 */ 449 void UpdateLocale(const std::string& language, const std::string& region) override; 450 451 /** 452 * @brief get original url of the request. 453 * 454 * @return original url. 455 */ 456 const std::string GetOriginalUrl() override; 457 458 /** 459 * @brief get original url of the request. 460 * 461 * @param data: raw image data of the icon. 462 * @param width: width of the icon. 463 * @param height: height of the icon. 464 * @param color_type: the color type of the icon. 465 * @param alpha_type: the alpha type of the icon. 466 * 467 * @return the result of get favicon. 468 */ 469 bool GetFavicon(const void** data, size_t& width, size_t& height, ArkWebImageColorType& color_type, 470 ArkWebImageAlphaType& alpha_type) override; 471 472 /** 473 * @brief set the network status, just notify the webview to change the JS 474 * navigatoer.online. 475 * 476 * @param available: width of the icon. 477 */ 478 void PutNetworkAvailable(bool available) override; 479 480 /** 481 * @brief web has image or not. 482 * 483 * @param callback: has image or not 484 */ 485 void HasImages(std::shared_ptr<OHOS::NWeb::NWebBoolValueCallback> callback) override; 486 487 /** 488 * @brief web remove cache. 489 * 490 * @param include_disk_files: if false, only the RAM cache is removed 491 */ 492 void RemoveCache(bool include_disk_files) override; 493 494 /** 495 * @brief web has image or not. 496 */ 497 std::shared_ptr<OHOS::NWeb::NWebHistoryList> GetHistoryList() override; 498 499 /** 500 * @brief Set the NWebReleaseSurfaceCallback that will receive release surface 501 * event. This will replace the current handler. 502 * 503 * @param release_surface_listener: release surface listener 504 */ 505 void PutReleaseSurfaceCallback( 506 std::shared_ptr<OHOS::NWeb::NWebReleaseSurfaceCallback> release_surface_listener) override; 507 508 /** 509 * @brief Get web back forward state. 510 * 511 * @return web back forward state. 512 */ 513 std::vector<uint8_t> SerializeWebState() override; 514 515 /** 516 * @brief Restore web back forward state. 517 * 518 * @param state: web back forward state. 519 */ 520 bool RestoreWebState(const std::vector<uint8_t>& state) override; 521 522 /** 523 * @brief Move page up. 524 * 525 * @param top: whether move to the top. 526 */ 527 void PageUp(bool top) override; 528 529 /** 530 * @brief Move page down. 531 * 532 * @param bottom: whether move to the bottom. 533 */ 534 void PageDown(bool bottom) override; 535 536 /** 537 * @brief Scroll to the position. 538 * 539 * @param x: horizontal coordinate. 540 * @param y: vertical coordinate. 541 */ 542 void ScrollTo(float x, float y) override; 543 544 /** 545 * @brief Scroll by the delta distance. 546 * 547 * @param delta_x: horizontal offset. 548 * @param delta_y: vertical offset. 549 */ 550 void ScrollBy(float delta_x, float delta_y) override; 551 552 /** 553 * @brief Slide scroll by the speed. 554 * 555 * @param vx: horizontal slide speed. 556 * @param vy: vertical slide speed. 557 */ 558 void SlideScroll(float vx, float vy) override; 559 560 /** 561 * @brief Get current website certificate. 562 * 563 * @param cert_chain_data: current website certificate array. 564 * @param is_single_cert: true if only get one certificate of current website, 565 * false if get certificate chain of the website. 566 * 567 * @return true if get certificate successfully, otherwise false. 568 */ 569 bool GetCertChainDerData(std::vector<std::string>& cert_chain_data, bool is_single_cert) override; 570 571 /** 572 * @brief Set screen offset. 573 * 574 * @param x: the offset in x direction. 575 * @param y: the offset in y direction. 576 */ 577 void SetScreenOffSet(double x, double y) override; 578 579 /** 580 * @brief Set audio muted. 581 * 582 * @param muted: Aduio mute state. 583 */ 584 void SetAudioMuted(bool muted) override; 585 586 /** 587 * @brief Set should frame submission before draw. 588 * 589 * @param should: whether wait render frame submission. 590 */ 591 void SetShouldFrameSubmissionBeforeDraw(bool should) override; 592 593 /** 594 * @brief Notify whether the popup window is initialized successfully. 595 * 596 * @param result: whether success. 597 */ 598 void NotifyPopupWindowResult(bool result) override; 599 600 /** 601 * @brief Set audio resume interval. 602 * 603 * @param resume_interval: Aduio resume interval. 604 */ 605 void SetAudioResumeInterval(int32_t resume_interval) override; 606 607 /** 608 * @brief Set audio exclusive state. 609 * 610 * @param audio_exclusive: Aduio exclusive state. 611 */ 612 void SetAudioExclusive(bool audio_exclusive) override; 613 614 /** 615 * @brief Rigest the keep srceen on interface. 616 * 617 * @param window_id: the window id. 618 * @param callback the screenon handle callback. 619 */ 620 void RegisterScreenLockFunction( 621 int32_t window_id, std::shared_ptr<OHOS::NWeb::NWebScreenLockCallback> callback) override; 622 623 /** 624 * @brief UnRigest the keep srceen on interface. 625 * 626 * @param window_id: the window id. 627 */ 628 void UnRegisterScreenLockFunction(int32_t window_id) override; 629 630 /** 631 * @brief Notify memory level. 632 * 633 * @param level: the memory level. 634 */ 635 void NotifyMemoryLevel(int32_t level) override; 636 637 /** 638 * @brief Notify webview window status. 639 */ 640 void OnWebviewHide() override; 641 642 void OnWebviewShow() override; 643 644 /** 645 * @brief Get drag data. 646 * 647 * @return the drag data. 648 */ 649 std::shared_ptr<OHOS::NWeb::NWebDragData> GetOrCreateDragData() override; 650 651 /** 652 * @brief Prefetch the resources required by the page, but will not execute js 653 * or render the page. 654 * 655 * @param url: Which url to preresolve/preconnect. 656 * @param additional_http_headers: Additional HTTP request header of the URL. 657 */ 658 void PrefetchPage( 659 const std::string& url, const std::map<std::string, std::string>& additional_http_headers) override; 660 661 /** 662 * @brief Set the window id. 663 */ 664 void SetWindowId(uint32_t window_id) override; 665 666 /** 667 * @brief Notify that browser was occluded by other windows. 668 */ 669 void OnOccluded() override; 670 671 /** 672 * @brief Notify that browser was unoccluded by other windows. 673 */ 674 void OnUnoccluded() override; 675 676 /** 677 * @brief Set the token. 678 */ 679 void SetToken(void* token) override; 680 681 /** 682 * @brief Set the nested scroll mode. 683 */ 684 void SetNestedScrollMode(const ArkWebNestedScrollMode& nested_scroll_mode) override; 685 686 /** 687 * @brief Set enable lower the frame rate. 688 */ 689 void SetEnableLowerFrameRate(bool enabled) override; 690 691 /** 692 * @brief Set the property values for width, height, and keyboard height. 693 */ 694 void SetVirtualKeyBoardArg(int32_t width, int32_t height, double keyboard) override; 695 696 /** 697 * @brief Set the virtual keyboard to override the web status. 698 */ 699 bool ShouldVirtualKeyboardOverlay() override; 700 701 /** 702 * @brief Set draw rect. 703 */ 704 void SetDrawRect(int32_t x, int32_t y, int32_t width, int32_t height) override; 705 706 /** 707 * @brief Set draw mode. 708 */ 709 void SetDrawMode(int32_t mode) override; 710 711 /** 712 * @brief Create web print document adapter. 713 */ 714 void* CreateWebPrintDocumentAdapter(const std::string& job_name) override; 715 716 /** 717 * @brief Loads the URL with postData using "POST" method into this WebView. 718 * If url is not a network URL, it will be loaded with loadUrl(String) 719 * instead. 720 * 721 * @param url: the URL of the resource to load This value cannot be null. 722 * @param post_data: the data will be passed to "POST" request, whilch must be 723 * "application/x-www-form-urlencoded" encoded. 724 * 725 * @return title string for the current page. 726 */ 727 int PostUrl(const std::string& url, const std::vector<char>& post_data) override; 728 729 /** 730 * @brief Inject the JavaScript before WebView load the DOM tree. 731 */ 732 void JavaScriptOnDocumentStart(const std::map<std::string, std::vector<std::string>>& script_items) override; 733 734 /** 735 * @brief Execute an accessibility action on an accessibility node in the 736 * browser. 737 * 738 * @param accessibility_id: The id of the accessibility node. 739 * @param action: The action to be performed on the accessibility node. 740 */ 741 void ExecuteAction(int64_t accessibility_id, uint32_t action) override; 742 743 /** 744 * @brief Get the information of the focused accessibility node on the given 745 * accessibility node in the browser. 746 * 747 * @param accessibility_id: Indicate the accessibility id of the parent node 748 * of the focused accessibility node. 749 * @param is_accessibility_focus: Indicate whether the focused accessibility 750 * node is accessibility focused or input focused. 751 * 752 * @return The obtained information of the accessibility node. 753 */ 754 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> GetFocusedAccessibilityNodeInfo( 755 int64_t accessibility_id, bool is_accessibility_focus) override; 756 757 /** 758 * @brief Get the information of the accessibility node by its accessibility 759 * id in the browser. 760 * 761 * @param accessibility_id: The accessibility id of the accessibility node. 762 * 763 * @return The obtained information of the accessibility node. 764 */ 765 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> GetAccessibilityNodeInfoById( 766 int64_t accessibility_id) override; 767 768 /** 769 * @brief Get the information of the accessibility node by focus move in the 770 * browser. 771 * 772 * @param accessibility_id: The accessibility id of the original accessibility 773 * node. 774 * @param direction: The focus move direction of the original accessibility 775 * node. 776 * 777 * @return The obtained information of the accessibility node. 778 */ 779 std::shared_ptr<OHOS::NWeb::NWebAccessibilityNodeInfo> GetAccessibilityNodeInfoByFocusMove( 780 int64_t accessibility_id, int32_t direction) override; 781 782 /** 783 * @brief Set the accessibility state in the browser. 784 * 785 * @param state: Indicate whether the accessibility state is enabled or 786 * disabled. 787 */ 788 void SetAccessibilityState(bool state) override; 789 790 /** 791 * @brief Get whether need soft keyboard. 792 * 793 * @return true if need soft keyboard, otherwise false. 794 */ 795 bool NeedSoftKeyboard() override; 796 797 /** 798 * @brief Discard the webview window. 799 * 800 * @return true if the discarding success, otherwise false. 801 */ 802 bool Discard() override; 803 804 /** 805 * @brief Reload the webview window that has been discarded before. 806 * 807 * @return true if the discarded window reload success, otherwise false. 808 */ 809 bool Restore() override; 810 811 /** 812 * @brief Get the security level of current page. 813 * 814 * @return security level for current page. 815 */ 816 int GetSecurityLevel() override; 817 818 /** 819 * @brief CallH5Function 820 * 821 * @param routingId int32_t: the h5 frame routing id 822 * @param h5ObjectId int32_t: the h5 side object id 823 * @param h5MethodName string: the h5 side object method name 824 * @param args vector<shared_ptr<NWebValue>>: the call args 825 */ 826 void CallH5Function(int32_t routingId, int32_t h5ObjectId, const std::string& h5MethodName, 827 const std::vector<std::shared_ptr<OHOS::NWeb::NWebValue>>& args) override; 828 829 /** 830 * @brief Get web weather has been set incognito mode. 831 * 832 * @return true if web is in incognito mode; otherwise fase. 833 */ 834 bool IsIncognitoMode() override; 835 836 /** 837 * @brief Register native function. 838 */ 839 void RegisterNativeArkJSFunction( 840 const char* objName, const std::vector<std::shared_ptr<OHOS::NWeb::NWebJsProxyCallback>>& callbacks) override; 841 842 /** 843 * @brief Unregister native function. 844 */ 845 void UnRegisterNativeArkJSFunction(const char* objName) override; 846 847 /** 848 * @brief Register native valide callback function. 849 */ 850 void RegisterNativeValideCallback(const char* webName, const NativeArkWebOnValidCallback callback) override; 851 852 /** 853 * @brief Register native destroy callback function. 854 */ 855 void RegisterNativeDestroyCallback(const char* webName, const NativeArkWebOnValidCallback callback) override; 856 857 /** 858 * @brief Inject the JavaScript after WebView loads the DOM tree and run 859 * JavaScripts. 860 */ 861 void JavaScriptOnDocumentEnd(const std::map<std::string, std::vector<std::string>>& script_items) override; 862 863 /** 864 * @brief Enable the ability to check website security risks.Illegal and 865 * fraudulent websites are mandatory enabled and cann't be disabled by 866 * this function. 867 */ 868 void EnableSafeBrowsing(bool enable) override; 869 870 /** 871 * @brief Get whether checking website security risks is enabled. 872 * 873 * @return true if enable the ability to check website security risks else 874 * false. 875 */ 876 bool IsSafeBrowsingEnabled() override; 877 878 /** 879 * @brief Set the ability to print web page background. 880 * 881 * @param enable Indicate whether the ability is enabled or disabled. 882 */ 883 void SetPrintBackground(bool enable) override; 884 885 /** 886 * @brief Obtains whether to print the background of a web page. 887 * 888 * @return true if enable print web page background, otherwise false. 889 */ 890 bool GetPrintBackground() override; 891 892 /** 893 * @brief Close fullScreen video. 894 */ 895 void CloseAllMediaPresentations() override; 896 897 /** 898 * @brief Stop all audio and video playback on the web page. 899 */ 900 void StopAllMedia() override; 901 902 /** 903 * @brief Restart playback of all audio and video on the web page. 904 */ 905 void ResumeAllMedia() override; 906 907 /** 908 * @brief Pause all audio and video playback on the web page. 909 */ 910 void PauseAllMedia() override; 911 912 /** 913 * @brief View the playback status of all audio and video on the web page. 914 * 915 * @return The playback status of all audio and video. 916 */ 917 int GetMediaPlaybackState() override; 918 919 /** 920 * Enable the ability to intelligent tracking prevention, default disabled. 921 */ 922 void EnableIntelligentTrackingPrevention(bool enable) override; 923 924 /** 925 * Get whether intelligent tracking prevention is enabled. 926 * @return true if enable the ability intelligent tracking prevention; else 927 * false. 928 */ 929 bool IsIntelligentTrackingPreventionEnabled() const override; 930 931 /** 932 * @brief Start current camera. 933 */ 934 /*--ark web()--*/ 935 void StartCamera() override; 936 937 /** 938 * @brief Stop current camera. 939 */ 940 /*--ark web()--*/ 941 void StopCamera() override; 942 943 /** 944 * @brief Close current camera. 945 */ 946 /*--ark web()--*/ 947 void CloseCamera() override; 948 949 /** 950 * @brief Obtains the last javascript proxy calling frame url. 951 * 952 * @return the url of last calling frame url. 953 */ 954 /*--ark web()--*/ 955 std::string GetLastJavascriptProxyCallingFrameUrl() override; 956 957 /** 958 * @brief get pendingsize status. 959 * 960 * @return the result of last pendingsize status. 961 */ 962 /*--ark web()--*/ 963 bool GetPendingSizeStatus() override; 964 965 /** 966 * Scroll by the delta distance or velocity takes the screen as a reference. 967 * 968 * @param delta_x horizontal offset in physical pixel. 969 * @param delta_y vertical offset in physical pixel. 970 * @param vx horizontal velocity in physical pixel. 971 * @param vx vertical velocity in physical pixel. 972 */ 973 /*--ark web()--*/ 974 void ScrollByRefScreen(float delta_x, float delta_y, float vx, float vy) override; 975 976 /** 977 * @brief ExecuteJavaScript with ashmem 978 * 979 * @param fd fd of the ashmem 980 * @param scriptLength javascript code length 981 * @param callback javascript running result 982 * @param extention true if is extension 983 */ 984 void ExecuteJavaScriptExt(const int fd, const size_t scriptLength, 985 std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback, bool extention) override; 986 987 /** 988 * @brief Render process switch to background. 989 */ 990 /*--ark web()--*/ 991 void OnRenderToBackground() override; 992 993 /** 994 * @brief Render process switch to foreground. 995 */ 996 /*--ark web()--*/ 997 void OnRenderToForeground() override; 998 999 /** 1000 * @brief Compile javascript and generate code cache. 1001 * 1002 * @param url url of javascript. 1003 * @param script javascript text content. 1004 * @param cacheOptions compile options and info. 1005 * @param callback callback will be called on getting the result of compiling 1006 * javascript. 1007 */ 1008 /*--ark web()--*/ 1009 void PrecompileJavaScript(const std::string& url, const std::string& script, 1010 std::shared_ptr<OHOS::NWeb::CacheOptions>& cacheOptions, 1011 std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback) override; 1012 1013 void OnCreateNativeMediaPlayer(std::shared_ptr<OHOS::NWeb::NWebCreateNativeMediaPlayerCallback> callback) override; 1014 1015 /** 1016 * @brief Send touchpad fling event. 1017 * 1018 * @param x location of x. 1019 * @param y location of y. 1020 * @param vx velocity of x. 1021 * @param vy velocity of y. 1022 */ 1023 /*--ark web()--*/ 1024 void SendTouchpadFlingEvent(double x, double y, double vx, double vy) override; 1025 1026 /** 1027 * @brief Web drag resize optimize. 1028 */ 1029 /*--ark web()--*/ 1030 void DragResize(uint32_t width, uint32_t height, uint32_t pre_height, uint32_t pre_width) override; 1031 1032 void OnTouchCancelById(int32_t id, double x, double y, bool from_overlay) override; 1033 1034 /** 1035 * @brief Inject offline resource into MemoryCache. 1036 * 1037 * @param url url of resource. 1038 * @param origin origin of resource. 1039 * @param resource data of resource. 1040 * @param response_headers response headers of resource. 1041 * @param type resource type. 1042 */ 1043 /*--ark web()--*/ 1044 void InjectOfflineResource(const std::string& url, const std::string& origin, const std::vector<uint8_t>& resource, 1045 const std::map<std::string, std::string>& responseHeaders, const int type) override; 1046 /** 1047 * @brief RegisterArkJSfunction 1048 * 1049 * @param object_name String: objector name 1050 * @param method_list vector<String>: vector list, sync method list 1051 * @param async_method_list vector<String>: vector list, async method list 1052 * @param object_id int32_t: object id 1053 */ 1054 /*--ark web()--*/ 1055 void RegisterArkJSfunction(const std::string& object_name, const std::vector<std::string>& method_list, 1056 const std::vector<std::string>& async_method_list, const int32_t object_id) override; 1057 1058 /** 1059 * @brief Set fit content mode. 1060 */ 1061 void SetFitContentMode(int32_t mode) override; 1062 1063 /** 1064 * @brief Terminate render process 1065 * 1066 * @return true if it was possible to terminate this render process, false 1067 * otherwise. 1068 */ 1069 /*--ark web()--*/ 1070 bool TerminateRenderProcess() override; 1071 1072 /** 1073 * @brief Get select info. 1074 */ 1075 std::string GetSelectInfo() override; 1076 1077 /** 1078 * @brief Render process switch to foreground. 1079 */ 1080 /*--ark web()--*/ 1081 void OnOnlineRenderToForeground() override; 1082 1083 /** 1084 * @brief Set the params when the scale of WebView changed by pinch gestrue. 1085 * 1086 * @param scale: the scale factor to apply. The scale will be 1087 * clamped to the pinch limits. This value must be in the range 1088 * 0.01 to 8.0 inclusive. 1089 * @param centerX: X-coordinate of the pinch center 1090 * @param centerX: Y-coordinate of the pinch center 1091 * 1092 * @return the error id. 1093 */ 1094 /*--ark web()--*/ 1095 int ScaleGestureChange(double scale, double centerX, double centerY) override; 1096 1097 /** 1098 * Get value of Autofill index. 1099 * @param index index value. 1100 */ 1101 /*--ark web()--*/ 1102 void SuggestionSelected(int32_t index) override; 1103 1104 /** 1105 * @brief Notify that safe insets changed. 1106 */ 1107 /*--ark web()--*/ 1108 void OnSafeInsetsChange(int left, int top, int right, int bottom) override; 1109 1110 /** 1111 * @brief Called when text is selected in image. 1112 */ 1113 /*--ark web()--*/ 1114 void OnTextSelected() override; 1115 1116 /** 1117 * @brief Notify for next touch move event. 1118 */ 1119 /*--ark web()--*/ 1120 void NotifyForNextTouchEvent() override; 1121 1122 /** 1123 * @brief Enable the ability to block Ads, default disabled. 1124 */ 1125 /*--ark web()--*/ 1126 void EnableAdsBlock(bool enable) override; 1127 1128 /** 1129 * @brief Get whether Ads block is enabled. 1130 */ 1131 /*--ark web()--*/ 1132 bool IsAdsBlockEnabled() override; 1133 1134 /** 1135 * @brief Get whether Ads block is enabled for current Webpage. 1136 */ 1137 /*--ark web()--*/ 1138 bool IsAdsBlockEnabledForCurPage() override; 1139 1140 /** 1141 * @brief Get Web page snapshot 1142 * 1143 * @param id Request id. 1144 * @param type Request snapshot pixel unit. 1145 * @param width Request SnapShot width. 1146 * @param height Request SnapShot height. 1147 * @param callback SnapShot result callback. 1148 * @return ture if succuess request snapshot to renderer. 1149 */ 1150 /*--ark web()--*/ 1151 bool WebPageSnapshot(const char* id, 1152 ArkPixelUnit type, 1153 int width, 1154 int height, 1155 const WebSnapshotCallback callback) override; 1156 1157 /** 1158 * @brief Notify that system configuration changed. 1159 * 1160 * @param configuration system configuration. 1161 */ 1162 /*--ark web()--*/ 1163 void OnConfigurationUpdated(std::shared_ptr<OHOS::NWeb::NWebSystemConfiguration> configuration) override; 1164 1165 /** 1166 * @brief Set url trust list. 1167 */ 1168 /*--ark web()--*/ 1169 int SetUrlTrustList(const std::string& urlTrustList) override; 1170 1171 /** 1172 * @brief Put the callback for convert spanstring to html. 1173 * 1174 * @param callback will convert spanstring to html. 1175 */ 1176 /*--ark web()--*/ 1177 void PutSpanstringConvertHtmlCallback( 1178 std::shared_ptr<OHOS::NWeb::NWebSpanstringConvertHtmlCallback> callback) override; 1179 1180 /** 1181 * Web send key event. 1182 * @param key_code code value. 1183 * @param key_action action value. 1184 * @param pressedCodes pressedCodes value. 1185 */ 1186 /*--ark web()--*/ 1187 bool WebSendKeyEvent(int32_t key_code, int32_t key_action, 1188 const std::vector<int32_t>& pressedCodes) override; 1189 1190 /** 1191 * @brief Set grant file access dirs. 1192 */ 1193 /*--ark web()--*/ 1194 void SetPathAllowingUniversalAccess(const std::vector<std::string>& dirs, 1195 const std::vector<std::string>& moduleName, std::string& errorPath) override; 1196 1197 /** 1198 * @brief Send mouse wheel event. 1199 */ 1200 /*--ark web()--*/ 1201 void WebSendMouseWheelEvent(double x, 1202 double y, 1203 double delta_x, 1204 double delta_y, 1205 const std::vector<int32_t>& pressedCodes) override; 1206 1207 /** 1208 * @brief Send touchpad fling event. 1209 * 1210 * @param x location of x. 1211 * @param y location of y. 1212 * @param vx velocity of x. 1213 * @param vy velocity of y. 1214 * @param pressedCodes pressed codes. 1215 */ 1216 /*--ark web()--*/ 1217 void WebSendTouchpadFlingEvent(double x, 1218 double y, 1219 double vx, 1220 double vy, 1221 const std::vector<int32_t>& pressedCodes) override; 1222 1223 /** 1224 * @brief Set url trust list with error message. 1225 */ 1226 /*--ark web()--*/ 1227 int SetUrlTrustListWithErrMsg(const std::string& urlTrustList, std::string& detailErrMsg) override; 1228 1229 /** 1230 * @brief resize visual viewport. 1231 * 1232 * @param width width. 1233 * @param height height. 1234 * @param iskeyboard from keybord. 1235 */ 1236 /*--ark web()--*/ 1237 void ResizeVisibleViewport(uint32_t width, uint32_t height, bool isKeyboard) override; 1238 1239 /** 1240 * @brief set backforward cache options. 1241 * @param size The size of the back forward cache could saved. 1242 * @param timeToLive The time of the back forward cache page could stay. 1243 */ 1244 /*--ark web()--*/ 1245 void SetBackForwardCacheOptions(int32_t size, int32_t timeToLive) override; 1246 1247 /** 1248 * @brief RegisterArkJSfunction 1249 * 1250 * @param object_name String: objector name 1251 * @param method_list vector<String>: vector list, sync method list 1252 * @param async_method_list vector<String>: vector list, async method list 1253 * @param object_id int32_t: object id 1254 * @param permission String: allow list 1255 */ 1256 /*--ark web()--*/ 1257 void RegisterArkJSfunction(const std::string& object_name, 1258 const std::vector<std::string>& method_list, 1259 const std::vector<std::string>& async_method_list, 1260 const int32_t object_id, 1261 const std::string& permission) override; 1262 1263 /** 1264 * @brief set the callback of the autofill event. 1265 * @param callback callback. 1266 */ 1267 /*--ark web()--*/ 1268 void SetAutofillCallback(std::shared_ptr<OHOS::NWeb::NWebMessageValueCallback> callback) override; 1269 1270 /** 1271 * @brief fill autofill data. 1272 * @param data data. 1273 */ 1274 /*--ark web()--*/ 1275 void FillAutofillData(std::shared_ptr<OHOS::NWeb::NWebMessage> data) override; 1276 1277 /** 1278 * @brief on autofill cancel. 1279 * @param fillContent fillContent. 1280 */ 1281 /*--ark web()--*/ 1282 void OnAutofillCancel(const std::string& fillContent) override; 1283 1284 /** 1285 * Execute an accessibility action on an accessibility node in the browser. 1286 * @param accessibilityId The id of the accessibility node. 1287 * @param action The action to be performed on the accessibility node. 1288 * @param actionArguments Data related to the current action. 1289 */ 1290 /*--ark web()--*/ 1291 void PerformAction(int64_t accessibilityId, uint32_t action, 1292 const std::map<std::string, std::string>& actionArguments) override; 1293 1294 /** 1295 * @brief Send the accessibility hover event coordinate. 1296 * 1297 * @param x horizontal location of coordinate. 1298 * @param y vertical location of coordinate. 1299 */ 1300 /*--ark web()--*/ 1301 void SendAccessibilityHoverEvent(int32_t x, int32_t y) override; 1302 1303 /** 1304 * @brief Get the current scroll offset of the webpage. 1305 * @param offset_x The current horizontal scroll offset of the webpage. 1306 * @param offset_y The current vertical scroll offset of the webpage. 1307 */ 1308 /*--ark web()--*/ 1309 void GetScrollOffset(float* offset_x, float* offset_y) override; 1310 1311 /** 1312 * @brief ExecuteCreatePDF 1313 * 1314 * @param pdfConfig The current configuration when creating pdf. 1315 * @param callback NWebArrayBufferValueCallback: CreatePDF running result. 1316 */ 1317 /*--ark web()--*/ 1318 void ExecuteCreatePDFExt(std::shared_ptr<OHOS::NWeb::NWebPDFConfigArgs> pdfConfig, 1319 std::shared_ptr<OHOS::NWeb::NWebArrayBufferValueCallback> callback) override; 1320 1321 /** 1322 * @brief Scroll by the delta distance. 1323 * @param delta_x: horizontal offset. 1324 * @param delta_y: vertical offset. 1325 * @return false if web don't scroll by the delta, when web is focused. 1326 */ 1327 /*--ark web()--*/ 1328 bool ScrollByWithResult(float delta_x, float delta_y) override; 1329 1330 /** 1331 * @brief Called when image analyzer is destory. 1332 */ 1333 /*--ark web()--*/ 1334 void OnDestroyImageAnalyzerOverlay() override; 1335 1336 /** 1337 * Scroll to the position. 1338 * 1339 * @param x horizontal coordinate. 1340 * @param y vertical coordinate. 1341 * @param duration: anime duration. 1342 */ 1343 /*--ark web()--*/ 1344 void ScrollToWithAnime(float x, float y, int32_t duration) override; 1345 1346 /** 1347 * Scroll by the delta distance. 1348 * 1349 * @param delta_x: horizontal offset. 1350 * @param delta_y: vertical offset. 1351 * @param duration: anime duration. 1352 */ 1353 /*--ark web()--*/ 1354 void ScrollByWithAnime(float delta_x, float delta_y, int32_t duration) override; 1355 1356 /** 1357 * @brief set a popupSurface to draw popup content 1358 * @param popupSurface popupSurface. 1359 */ 1360 /*--ark web()--*/ 1361 void SetPopupSurface(void* popupSurface) override; 1362 1363 /** 1364 * @Description: Sends mouse events to the web kernel. 1365 * @Input mouseEvent: Basic information about mouse events. 1366 * @Since: 12005 1367 */ 1368 /*--ark web()--*/ 1369 void WebSendMouseEvent(const std::shared_ptr<OHOS::NWeb::NWebMouseEvent>& mouseEvent) override; 1370 1371 /** 1372 * @Description: Get the accessibility visibility of the accessibility node by its accessibility id in the browser. 1373 * @Input accessibility_id: The accessibility id of the accessibility node. 1374 * @Return: The accessibility visibility of the accessibility node. 1375 * @Since: 12005 1376 */ 1377 /*--ark web()--*/ 1378 bool GetAccessibilityVisible(int64_t accessibility_id) override; 1379 1380 /** 1381 * @Description: Set the rotation to psurface. 1382 * @Input rotation: The rotation of buffer. 1383 * @Since: 12005 1384 */ 1385 /*--ark web()--*/ 1386 void SetTransformHint(uint32_t rotation) override; 1387 1388 /** 1389 * @brief Web components blur when the keyboard is hidden by gesture back. 1390 */ 1391 /*--ark web()--*/ 1392 void WebComponentsBlur() override; 1393 1394 /** 1395 * @Description: Get the GPU memory size used by web. 1396 * @Return: Total size of web GPU. 1397 */ 1398 /*--ark web()--*/ 1399 float DumpGpuInfo() override; 1400 1401 /** 1402 * @brief Set the params when the scale of WebView changed by pinch gestrue. 1403 * 1404 * @param type: gesture status 1405 * @param scale: the scale factor to apply. The scale will be 1406 * clamped to the pinch limits. This value must be in the range 1407 * 0.01 to 8.0 inclusive. 1408 * @param originScale: the origin scale factor to apply. The scale will be 1409 * clamped to the pinch limits. This value must be in the range 1410 * 0.01 to 8.0 inclusive. 1411 * @param centerX: X-coordinate of the pinch center 1412 * @param centerX: Y-coordinate of the pinch center 1413 * 1414 * @return the error id. 1415 */ 1416 int ScaleGestureChangeV2(int type, double scale, double originScale, double centerX, double centerY) override; 1417 1418 /** 1419 * @Description: Sends key events to the web kernel. 1420 * @Input mouseEvent: Basic information about key events. 1421 */ 1422 /*--ark web()--*/ 1423 bool SendKeyboardEvent(const std::shared_ptr<OHOS::NWeb::NWebKeyboardEvent>& keyboardEvent) override; 1424 1425 /** 1426 * @Description: Execute an accessibility action on an accessibility node in the browser. 1427 * @Input accessibilityId: The id of the accessibility node. 1428 * @Input action: The action to be performed on the accessibility node. 1429 * @Input actionArguments: Data related to the current action. 1430 * @Return: Whether the action is performed successfully. 1431 */ 1432 /*--ark web()--*/ 1433 bool PerformActionV2(int64_t accessibilityId, uint32_t action, 1434 const std::map<std::string, std::string>& actionArguments) override; 1435 1436 /** 1437 * @brief Inject the JavaScript before WebView load the DOM tree. 1438 */ 1439 void JavaScriptOnDocumentStartByOrder(const std::map<std::string, std::vector<std::string>>& script_items, 1440 const std::vector<std::string>& script_items_by_order) override; 1441 1442 /** 1443 * @brief Inject the JavaScript after WebView loads the DOM tree and run 1444 * JavaScripts. 1445 */ 1446 void JavaScriptOnDocumentEndByOrder(const std::map<std::string, std::vector<std::string>>& script_items, 1447 const std::vector<std::string>& script_items_by_order) override; 1448 1449 /** 1450 * @Description: Check web component active policy disable, default: false 1451 * @Return: Whether the policy is disable. 1452 */ 1453 /*--ark web()--*/ 1454 virtual bool IsActivePolicyDisable() override; 1455 1456 /** 1457 * @Description: Inject the JavaScript when the head element has been created. 1458 * @Input scriptItems: The injected JavaScript code is stored in lexicographical order. 1459 * @Input scriptItemsByOrder: The injected JavaScript code is stored in the order of the injection array. 1460 */ 1461 /*--ark web()--*/ 1462 void JavaScriptOnHeadReadyByOrder(const std::map<std::string, std::vector<std::string>>& script_items, 1463 const std::vector<std::string>& script_items_by_order) override; 1464 1465 /** 1466 * @Description: Optimize HTML parser budget to reduce FCP time. 1467 * @Input enable: Set whether to use optimized parser budget. 1468 */ 1469 void PutOptimizeParserBudgetEnabled(bool enable) override; 1470 1471 /** 1472 * @Description: Get the bounding rectangle of the accessibility node of the given id. 1473 * @Input accessibilityId: The id of the accessibility node. 1474 * @Output width: The width of the rectangle. 1475 * @Output height: The height of the rectangle. 1476 * @Output offsetX: The X-coordinate offset of the rectangle. 1477 * @Output offsetY: The Y-coordinate offset of the rectangle. 1478 * @Return: Whether the bounding rectangle is obtained successfully. 1479 */ 1480 /*--ark web()--*/ 1481 bool GetAccessibilityNodeRectById( 1482 int64_t accessibilityId, int32_t* width, int32_t* height, int32_t* offsetX, int32_t* offsetY) override; 1483 1484 /** 1485 * @brief Gets the last hit test result. 1486 * 1487 * @return the last HitTestResult 1488 */ 1489 std::shared_ptr<OHOS::NWeb::HitTestResult> GetLastHitTestResult() override; 1490 1491 /** 1492 * @Description: Get the current language in the webview. 1493 * @Return: The current language in the webview. 1494 */ 1495 std::string GetCurrentLanguage() override; 1496 1497 /* 1498 * @brief Send mouse wheel event with sourceTool info. 1499 */ 1500 /*--ark web()--*/ 1501 bool WebSendMouseWheelEventV2(double x, double y, double delta_x, double delta_y, 1502 const std::vector<int32_t> &pressedCodes, int32_t source) override; 1503 1504 /** 1505 * @brief judge if browser use drag resize. 1506 */ 1507 bool IsNWebEx() override; 1508 1509 /** 1510 * @brief Set enable Half the frame rate. 1511 */ 1512 void SetEnableHalfFrameRate(bool enabled) override; 1513 1514 /** 1515 * @brief Web maximize resize optimize. 1516 */ 1517 /*--ark web()--*/ 1518 void MaximizeResize() override; 1519 1520 /** 1521 * @brief Try to attach web inputmethod after drag. 1522 */ 1523 void OnDragAttach() override; 1524 1525 /** 1526 * Set focus by position 1527 * 1528 * @Return: if hit node editable. 1529 */ 1530 bool SetFocusByPosition(float x, float y) override; 1531 1532 /** 1533 * @brief set DPI when DPI changes. 1534 * @param density The new density value. 1535 */ 1536 /*--ark web()--*/ 1537 void SetSurfaceDensity(const double& density) override; 1538 1539 /** 1540 * @brief When the user sets the webpage's border radius, 1541 * update Chromium with this radius value for repaint the scrollbar. 1542 * @param borderRadiusTopLeft: Radius value of the rounded corner in the top-left of the webpage. 1543 * @param borderRadiusTopRight: Radius value of the rounded corner in the top-right of the webpage. 1544 * @param borderRadiusBottomLeft: Radius value of the rounded corner in the bottom-left of the webpage. 1545 * @param borderRadiusBottomRight: Radius value of the rounded corner in the bottom-right of the webpage. 1546 */ 1547 void SetBorderRadiusFromWeb(double borderRadiusTopLeft, double borderRadiusTopRight, double borderRadiusBottomLeft, 1548 double borderRadiusBottomRight) override; 1549 1550 /** 1551 * @brief Set the native inner web 1552 */ 1553 void SetNativeInnerWeb(bool isInnerWeb) override; 1554 1555 /** 1556 * @brief Send the accessibility hover event coordinate. 1557 * 1558 * @param x horizontal location of coordinate. 1559 * @param y vertical location of coordinate. 1560 * @param isHoverEnter whether the accessibility hover event is a hover enter event. 1561 */ 1562 /*--ark web()--*/ 1563 void SendAccessibilityHoverEventV2(int32_t x, int32_t y, bool isHoverEnter) override; 1564 1565 /** 1566 * @brief Notify browser is foreground. 1567 */ 1568 void OnBrowserForeground() override; 1569 1570 /** 1571 * @brief Notify browser is background. 1572 */ 1573 void OnBrowserBackground() override; 1574 1575 /** 1576 * @brief: register native javaScriptProxy. 1577 * 1578 * @param objName object name. 1579 * @param methodName methodName list 1580 * @param data The ptr of NWebJsProxyMethod. 1581 * @param isAsync True mean. 1582 * @param permission permission. 1583 */ 1584 virtual void RegisterNativeJavaScriptProxy(const std::string& objName, 1585 const std::vector<std::string>& methodName, 1586 std::shared_ptr<OHOS::NWeb::NWebJsProxyMethod> data, 1587 bool isAsync, 1588 const std::string& permission) override; 1589 1590 /** 1591 * @brief Set the window id. 1592 */ 1593 void SetFocusWindowId(uint32_t focus_window_id) override; 1594 1595 /** 1596 * @brief Run data detector JS 1597 */ 1598 void RunDataDetectorJS() override; 1599 1600 /** 1601 * @brief Set data detector enable. 1602 */ 1603 void SetDataDetectorEnable(bool enable) override; 1604 1605 /** 1606 * @brief On data detector select text. 1607 */ 1608 void OnDataDetectorSelectText() override; 1609 1610 /** 1611 * @brief On data detector copy. 1612 */ 1613 void OnDataDetectorCopy(const std::vector<std::string>& recordMix) override; 1614 1615 /** 1616 * @brief Set the native window of picture in picture. 1617 */ 1618 void SetPipNativeWindow(int delegate_id, 1619 int child_id, 1620 int frame_routing_id, 1621 void* window) override; 1622 1623 /** 1624 * @brief Send event of picture in picture. 1625 */ 1626 void SendPipEvent(int delegate_id, 1627 int child_id, 1628 int frame_routing_id, 1629 int event) override; 1630 1631 /* 1632 * @brief Set unique key of current page for insert frame. 1633 * 1634 * @param key The unique key of current page. 1635 */ 1636 void SetBlanklessLoadingKey(const std::string& key) override; 1637 1638 /** 1639 * @brief Set privacy status. 1640 * 1641 * @param isPrivate bool: privacy status page. 1642 */ 1643 void SetPrivacyStatus(bool isPrivate) override; 1644 1645 /** 1646 * @brief Get select startIndex. 1647 */ 1648 int GetSelectStartIndex() override; 1649 1650 /** 1651 * @brief Get select endIndex. 1652 */ 1653 int GetSelectEndIndex() override; 1654 1655 /** 1656 * @brief Get all text info. 1657 */ 1658 std::string GetAllTextInfo() override; 1659 1660 /** 1661 * @brief Set audio session type. 1662 * 1663 * @param audio_session_type Audio session type. 1664 */ 1665 void SetAudioSessionType(int32_t audio_session_type) override; 1666 1667 /** 1668 * @brief Get accessibility id by its html element id in the browser. 1669 * @param htmlElementId The html element id of the Same-layer rendering. 1670 * @return The accessibility id of the accessibility node with Same-layer rendering. 1671 */ 1672 int64_t GetWebAccessibilityIdByHtmlElementId(const std::string& htmlElementId) override; 1673 1674 /** 1675 * @brief Get the prediction info of blankless loading on the current page. 1676 * 1677 * @param key The unique key of current page. 1678 * @param similarity The historical snapshot similarity. 1679 * @param loadingTime The historical loading time. 1680 * @return The error code. 1681 */ 1682 int32_t GetBlanklessInfoWithKey(const std::string& key, double* similarity, int32_t* loadingTime) override; 1683 1684 /** 1685 * @brief Set whether to enable blankless loading on the current page. 1686 * 1687 * @param key The unique key of current page. 1688 * @param isStart Whether to enable blankless loading. 1689 * @return The error code. 1690 */ 1691 int32_t SetBlanklessLoadingWithKey(const std::string& key, bool isStart) override; 1692 1693 /** 1694 * @brief Update the single handle visible. 1695 * @param isVisible The single handle visible. 1696 */ 1697 void UpdateSingleHandleVisible(bool isVisible) override; 1698 1699 /** 1700 * @brief Set the state of touch handle when it exists. 1701 * @param touchHandleExist The state of the touch handle, Which is true if the touch handle exists. 1702 */ 1703 void SetTouchHandleExistState(bool touchHandleExist) override; 1704 1705 /** 1706 * @brief Sets the bottom avoidance height of the web visible viewport. 1707 * @param avoidHeight The height value of the visible viewport avoidance. Unit: px. 1708 */ 1709 void AvoidVisibleViewportBottom(int32_t avoidHeight) override; 1710 1711 /** 1712 * @brief Get the bottom avoidance height of the web visible viewport. 1713 * @return The bottom avoidance height of the visible viewport. 1714 */ 1715 int32_t GetVisibleViewportAvoidHeight() override; 1716 1717 /** 1718 * @brief Try to trigger blankless for url. 1719 * @param url The url to use for blankless. 1720 * @return Blankless is triggered for this url. 1721 */ 1722 bool TriggerBlanklessForUrl(const std::string& url) override; 1723 1724 /** 1725 * @brief Set visibility of the web. 1726 * @param isVisible The visibility to be set. 1727 */ 1728 void SetVisibility(bool isVisible) override; 1729 1730 /** 1731 * @brief Current viewport is being scaled. 1732 */ 1733 void SetViewportScaleState() override; 1734 1735 /** 1736 * @brief Get the current scroll offset of the webpage. 1737 * @param offset_x The current horizontal scroll offset of the webpage. 1738 * @param offset_y The current vertical scroll offset of the webpage. 1739 */ 1740 /*--ark web()--*/ 1741 void GetPageOffset(float* offset_x, float* offset_y) override; 1742 1743 /** 1744 * @brief Set whether enable the error page. onOverrideErrorPage will be triggered when the page error. 1745 * 1746 * @param enable bool: Whether enable the error page. 1747 */ 1748 void SetErrorPageEnabled(bool enable) override; 1749 1750 /** 1751 * @brief Get whether default error page feature is enabled. 1752 */ 1753 bool GetErrorPageEnabled() override; 1754 1755 /** 1756 * @brief Get web component destroy mode. 1757 * @return The web destroy mode. 1758 */ 1759 ArkWebDestroyMode GetWebDestroyMode() override; 1760 1761 void CallH5FunctionV2(int32_t routing_id, int32_t h5_object_id, const std::string& h5_method_name, 1762 const std::vector<std::shared_ptr<OHOS::NWeb::NWebRomValue>>& args) override; 1763 1764 void PostPortMessageV2(const std::string& portHandle, std::shared_ptr<OHOS::NWeb::NWebRomValue> data) override; 1765 1766 void FillAutofillDataV2(std::shared_ptr<OHOS::NWeb::NWebRomValue> data) override; 1767 1768 /** 1769 * @brief Create web print document adapter V2. 1770 */ 1771 std::unique_ptr<OHOS::NWeb::NWebPrintDocumentAdapterAdapter> CreateWebPrintDocumentAdapterV2( 1772 const std::string& job_name) override; 1773 1774 private: 1775 ArkWebRefPtr<ArkWebNWeb> ark_web_nweb_; 1776 }; 1777 1778 } // namespace OHOS::ArkWeb 1779 1780 #endif // ARK_WEB_NWEB_WRAPPER_H_ 1781