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