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