1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkWeb 19 */ 20 21/*** if arkts 1.2 */ 22import { Resource } from './global/resource'; 23/*** endif */ 24import { AsyncCallback, BusinessError } from './@ohos.base'; 25import { Callback } from './@ohos.base'; 26/*** if arkts 1.1 */ 27import cert from './@ohos.security.cert'; 28import image from './@ohos.multimedia.image'; 29import type print from './@ohos.print'; 30import { WebNetErrorList } from './@ohos.web.netErrorList'; 31/*** endif */ 32 33/** 34 * This module provides the capability to manage web modules. 35 * 36 * @namespace webview 37 * @syscap SystemCapability.Web.Webview.Core 38 * @since 9 39 */ 40/** 41 * This module provides the capability to manage web modules. 42 * 43 * @namespace webview 44 * @syscap SystemCapability.Web.Webview.Core 45 * @crossplatform 46 * @since 10 47 */ 48/** 49 * This module provides the capability to manage web modules. 50 * 51 * @namespace webview 52 * @syscap SystemCapability.Web.Webview.Core 53 * @crossplatform 54 * @atomicservice 55 * @since arkts {'1.1':'11', '1.2':'20'} 56 * @arkts 1.1&1.2 57 */ 58declare namespace webview { 59 /** 60 * Defines the Web's request/response header. 61 * 62 * @interface WebHeader 63 * @syscap SystemCapability.Web.Webview.Core 64 * @since 9 65 */ 66 /** 67 * Defines the Web's request/response header. 68 * 69 * @interface WebHeader 70 * @syscap SystemCapability.Web.Webview.Core 71 * @crossplatform 72 * @since 10 73 */ 74 /** 75 * Defines the Web's request/response header. 76 * 77 * @interface WebHeader 78 * @syscap SystemCapability.Web.Webview.Core 79 * @crossplatform 80 * @atomicservice 81 * @since 11 82 */ 83 /** 84 * Defines the Web's request/response header. 85 * 86 * @typedef WebHeader 87 * @syscap SystemCapability.Web.Webview.Core 88 * @crossplatform 89 * @atomicservice 90 * @since arkts {'1.1':'12', '1.2':'20'} 91 * @arkts 1.1&1.2 92 */ 93 interface WebHeader { 94 /** 95 * Gets the key of the request/response header. 96 * @syscap SystemCapability.Web.Webview.Core 97 * @since 9 98 */ 99 /** 100 * Gets the key of the request/response header. 101 * @syscap SystemCapability.Web.Webview.Core 102 * @crossplatform 103 * @since 10 104 */ 105 /** 106 * Gets the key of the request/response header. 107 * @type { string } 108 * @syscap SystemCapability.Web.Webview.Core 109 * @crossplatform 110 * @atomicservice 111 * @since arkts {'1.1':'11', '1.2':'20'} 112 * @arkts 1.1&1.2 113 */ 114 headerKey: string; 115 116 /** 117 * Gets the value of the request/response header. 118 * @syscap SystemCapability.Web.Webview.Core 119 * @since 9 120 */ 121 /** 122 * Gets the value of the request/response header. 123 * @syscap SystemCapability.Web.Webview.Core 124 * @crossplatform 125 * @since 10 126 */ 127 /** 128 * Gets the value of the request/response header. 129 * @type { string } 130 * @syscap SystemCapability.Web.Webview.Core 131 * @crossplatform 132 * @atomicservice 133 * @since arkts {'1.1':'11', '1.2':'20'} 134 * @arkts 1.1&1.2 135 */ 136 headerValue: string; 137 } 138 139 /** 140 * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. 141 * @enum {number} 142 * @syscap SystemCapability.Web.Webview.Core 143 * @since 9 144 */ 145 /** 146 * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. 147 * @enum {number} 148 * @syscap SystemCapability.Web.Webview.Core 149 * @atomicservice 150 * @since 11 151 */ 152 enum WebHitTestType { 153 /** 154 * The edit text. 155 * @syscap SystemCapability.Web.Webview.Core 156 * @since 9 157 */ 158 /** 159 * The edit text. 160 * @syscap SystemCapability.Web.Webview.Core 161 * @atomicservice 162 * @since 11 163 */ 164 EditText, 165 166 /** 167 * The email address. 168 * @syscap SystemCapability.Web.Webview.Core 169 * @since 9 170 */ 171 /** 172 * The email address. 173 * @syscap SystemCapability.Web.Webview.Core 174 * @atomicservice 175 * @since 11 176 */ 177 Email, 178 179 /** 180 * The HTML::a tag with src=http. 181 * @syscap SystemCapability.Web.Webview.Core 182 * @since 9 183 */ 184 /** 185 * The HTML::a tag with src=http. 186 * @syscap SystemCapability.Web.Webview.Core 187 * @atomicservice 188 * @since 11 189 */ 190 HttpAnchor, 191 192 /** 193 * The HTML::a tag with src=http + HTML::img. 194 * @syscap SystemCapability.Web.Webview.Core 195 * @since 9 196 */ 197 /** 198 * The HTML::a tag with src=http + HTML::img. 199 * @syscap SystemCapability.Web.Webview.Core 200 * @atomicservice 201 * @since 11 202 */ 203 HttpAnchorImg, 204 205 /** 206 * The HTML::img tag. 207 * @syscap SystemCapability.Web.Webview.Core 208 * @since 9 209 */ 210 /** 211 * The HTML::img tag. 212 * @syscap SystemCapability.Web.Webview.Core 213 * @atomicservice 214 * @since 11 215 */ 216 Img, 217 218 /** 219 * The map address. 220 * @syscap SystemCapability.Web.Webview.Core 221 * @since 9 222 */ 223 /** 224 * The map address. 225 * @syscap SystemCapability.Web.Webview.Core 226 * @atomicservice 227 * @since 11 228 */ 229 Map, 230 231 /** 232 * The phone number. 233 * @syscap SystemCapability.Web.Webview.Core 234 * @since 9 235 */ 236 /** 237 * The phone number. 238 * @syscap SystemCapability.Web.Webview.Core 239 * @atomicservice 240 * @since 11 241 */ 242 Phone, 243 244 /** 245 * Other unknown HitTest. 246 * @syscap SystemCapability.Web.Webview.Core 247 * @since 9 248 */ 249 /** 250 * Other unknown HitTest. 251 * @syscap SystemCapability.Web.Webview.Core 252 * @atomicservice 253 * @since 11 254 */ 255 Unknown 256 } 257 258 /** 259 * Defines the mode for using HttpDns. 260 * @enum {number} 261 * @syscap SystemCapability.Web.Webview.Core 262 * @since 10 263 */ 264 /** 265 * Defines the mode for using HttpDns. 266 * @enum {number} 267 * @syscap SystemCapability.Web.Webview.Core 268 * @atomicservice 269 * @since 11 270 */ 271 enum SecureDnsMode { 272 /** 273 * Do not use HttpDns, can be used to revoke previously used HttpDns configuration. 274 * @syscap SystemCapability.Web.Webview.Core 275 * @since 10 276 */ 277 /** 278 * Do not use HttpDns, can be used to revoke previously used HttpDns configuration. 279 * @syscap SystemCapability.Web.Webview.Core 280 * @atomicservice 281 * @since 11 282 */ 283 OFF = 0, 284 /** 285 * By default, the user-settings of HttpDns is used for dns resolution, and if it fails, 286 * the system dns is used for resolution. 287 * @syscap SystemCapability.Web.Webview.Core 288 * @since 10 289 */ 290 /** 291 * By default, the user-settings of HttpDns is used for dns resolution, and if it fails, 292 * the system dns is used for resolution. 293 * @syscap SystemCapability.Web.Webview.Core 294 * @atomicservice 295 * @since 11 296 */ 297 AUTO = 1, 298 /** 299 * Use the user-settings of HttpDns for dns resolution. If it fails, it will not 300 * fall back to the system dns, which will directly cause the page to fail to load. 301 * @syscap SystemCapability.Web.Webview.Core 302 * @since 10 303 */ 304 /** 305 * Use the user-settings of HttpDns for dns resolution. If it fails, it will not 306 * fall back to the system dns, which will directly cause the page to fail to load. 307 * @syscap SystemCapability.Web.Webview.Core 308 * @atomicservice 309 * @since 11 310 */ 311 SECURE_ONLY = 2, 312 } 313 314 /** 315 * Enum type for ArkWeb Engine Version. 316 * 317 * <strong>ArkWeb Dual Web Engine Versioning Convention</strong>: 318 * <p>See [ArkWeb Dual Web Engine Versioning Convention] for switching between Legacy and Evergreen Web Engine. 319 * @enum {number} 320 * @syscap SystemCapability.Web.Webview.Core 321 * @since 20 322 */ 323 enum ArkWebEngineVersion { 324 /** 325 * Use the system default ArkWeb engine. 326 * @syscap SystemCapability.Web.Webview.Core 327 * @since 20 328 */ 329 SYSTEM_DEFAULT = 0, 330 331 /** 332 * ArkWeb M114 version. 333 * @syscap SystemCapability.Web.Webview.Core 334 * @since 20 335 */ 336 M114 = 1, 337 338 /** 339 * ArkWeb M132 version. 340 * @syscap SystemCapability.Web.Webview.Core 341 * @since 20 342 */ 343 M132 = 2, 344 } 345 346 /** 347 * Defines the security level for the page. 348 * 349 * @enum {number} 350 * @syscap SystemCapability.Web.Webview.Core 351 * @atomicservice 352 * @since 11 353 */ 354 enum SecurityLevel { 355 /** 356 * Unable to determine whether it is safe or not, the non-http/https protocol used. 357 * 358 * @syscap SystemCapability.Web.Webview.Core 359 * @atomicservice 360 * @since 11 361 */ 362 NONE = 0, 363 364 /** 365 * Indicates the HTTPS protocol used by the page and the authentication is successful. 366 * 367 * @syscap SystemCapability.Web.Webview.Core 368 * @atomicservice 369 * @since 11 370 */ 371 SECURE = 1, 372 373 /** 374 * The page is insecure. For example, the HTTP protocol is used or the HTTPS protocol 375 * is used but use an legacy TLS version. 376 * 377 * @syscap SystemCapability.Web.Webview.Core 378 * @atomicservice 379 * @since 11 380 */ 381 WARNING = 2, 382 383 /** 384 * Attempted HTTPS and failed, the authentication is failed. 385 * 386 * @syscap SystemCapability.Web.Webview.Core 387 * @atomicservice 388 * @since 11 389 */ 390 DANGEROUS = 3, 391 } 392 393 /** 394 * The playback status of all audio and video. 395 * @enum {number} 396 * @syscap SystemCapability.Web.Webview.Core 397 * @atomicservice 398 * @since 12 399 */ 400 enum MediaPlaybackState { 401 /** 402 * No audio or video currently. 403 * @syscap SystemCapability.Web.Webview.Core 404 * @atomicservice 405 * @since 12 406 */ 407 NONE = 0, 408 409 /** 410 * The audio and video on the page are being played. 411 * @syscap SystemCapability.Web.Webview.Core 412 * @atomicservice 413 * @since 12 414 */ 415 PLAYING = 1, 416 417 /** 418 * The audio and video on the page are paused. 419 * @syscap SystemCapability.Web.Webview.Core 420 * @atomicservice 421 * @since 12 422 */ 423 PAUSED = 2, 424 425 /** 426 * The audio and video on the page are stopped. 427 * @syscap SystemCapability.Web.Webview.Core 428 * @atomicservice 429 * @since 12 430 */ 431 STOPPED = 3 432 } 433 434 /** 435 * The memory pressure level that can be set. 436 * @enum {number} 437 * @syscap SystemCapability.Web.Webview.Core 438 * @atomicservice 439 * @since 14 440 */ 441 enum PressureLevel { 442 /** 443 * Modules are advised to free buffers that are cheap to re-allocate and not immediately needed. 444 * @syscap SystemCapability.Web.Webview.Core 445 * @atomicservice 446 * @since 14 447 */ 448 MEMORY_PRESSURE_LEVEL_MODERATE = 1, 449 450 /** 451 * At this level, modules are advised to free all possible memory. 452 * @syscap SystemCapability.Web.Webview.Core 453 * @atomicservice 454 * @since 14 455 */ 456 MEMORY_PRESSURE_LEVEL_CRITICAL = 2 457 } 458 459 /** 460 * Defines the hit test value, related to {@link getHitTestValue} method. 461 * 462 * @interface HitTestValue 463 * @syscap SystemCapability.Web.Webview.Core 464 * @since 9 465 */ 466 /** 467 * Defines the hit test value, related to {@link getHitTestValue} method. 468 * 469 * @interface HitTestValue 470 * @syscap SystemCapability.Web.Webview.Core 471 * @atomicservice 472 * @since 11 473 */ 474 /** 475 * Provides element information of the click area. related to {@link getLastHitTest} method. 476 * 477 * @typedef HitTestValue 478 * @syscap SystemCapability.Web.Webview.Core 479 * @atomicservice 480 * @since 12 481 */ 482 interface HitTestValue { 483 484 /** 485 * Get the hit test type. 486 * 487 * @syscap SystemCapability.Web.Webview.Core 488 * @since 9 489 */ 490 /** 491 * Get the hit test type. 492 * 493 * @type { WebHitTestType } 494 * @syscap SystemCapability.Web.Webview.Core 495 * @atomicservice 496 * @since 11 497 */ 498 type: WebHitTestType; 499 500 /** 501 * Get the hit test extra data. 502 * 503 * @syscap SystemCapability.Web.Webview.Core 504 * @since 9 505 */ 506 /** 507 * Get the hit test extra data. 508 * If the clicked area is an image or a link, the additional parameter information is it's URL address. 509 * 510 * @type { string } 511 * @syscap SystemCapability.Web.Webview.Core 512 * @atomicservice 513 * @since 11 514 */ 515 extra: string; 516 } 517 518 /** 519 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 520 * 521 * @interface WebCustomScheme 522 * @syscap SystemCapability.Web.Webview.Core 523 * @since 9 524 */ 525 /** 526 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 527 * 528 * @interface WebCustomScheme 529 * @syscap SystemCapability.Web.Webview.Core 530 * @atomicservice 531 * @since 11 532 */ 533 /** 534 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 535 * 536 * @typedef WebCustomScheme 537 * @syscap SystemCapability.Web.Webview.Core 538 * @atomicservice 539 * @since 12 540 */ 541 interface WebCustomScheme { 542 543 /** 544 * Name of the custom scheme. 545 * 546 * @syscap SystemCapability.Web.Webview.Core 547 * @since 9 548 */ 549 /** 550 * Name of the custom scheme. 551 * 552 * @type { string } 553 * @syscap SystemCapability.Web.Webview.Core 554 * @atomicservice 555 * @since 11 556 */ 557 schemeName: string; 558 559 /** 560 * Whether Cross-Origin Resource Sharing is supported. 561 * 562 * @syscap SystemCapability.Web.Webview.Core 563 * @since 9 564 */ 565 /** 566 * Whether Cross-Origin Resource Sharing is supported. 567 * 568 * @type { boolean } 569 * @syscap SystemCapability.Web.Webview.Core 570 * @atomicservice 571 * @since 11 572 */ 573 isSupportCORS: boolean; 574 575 /** 576 * Whether fetch request is supported. 577 * 578 * @syscap SystemCapability.Web.Webview.Core 579 * @since 9 580 */ 581 /** 582 * Whether fetch request is supported. 583 * 584 * @type { boolean } 585 * @syscap SystemCapability.Web.Webview.Core 586 * @atomicservice 587 * @since 11 588 */ 589 isSupportFetch: boolean; 590 591 /** 592 * If isStandard is true, the scheme will be handled as a standard scheme. The standard 593 * schemes needs to comply with the URL normalization and parsing rules defined in Section 3.1 of RFC 1738, 594 * which can be found in the http://www.ietf.org/rfc/rfc1738.txt. 595 * 596 * @type { ?boolean } 597 * @syscap SystemCapability.Web.Webview.Core 598 * @atomicservice 599 * @since 12 600 */ 601 isStandard?: boolean; 602 603 /** 604 * If isLocal is true, the same security rules as those applied to the "file" URL will be 605 * used to handle the scheme. 606 * 607 * @type { ?boolean } 608 * @syscap SystemCapability.Web.Webview.Core 609 * @atomicservice 610 * @since 12 611 */ 612 isLocal?: boolean; 613 614 /** 615 * If isDisplayIsolated is true, then the scheme can only be displayed from other content 616 * hosted using the same scheme. 617 * 618 * @type { ?boolean } 619 * @syscap SystemCapability.Web.Webview.Core 620 * @atomicservice 621 * @since 12 622 */ 623 isDisplayIsolated?: boolean; 624 625 /** 626 * If isSecure is true, the same security rules as those applied to the "https" URL will be 627 * used to handle the scheme. 628 * 629 * @type { ?boolean } 630 * @syscap SystemCapability.Web.Webview.Core 631 * @atomicservice 632 * @since 12 633 */ 634 isSecure?: boolean; 635 636 /** 637 * If isCspBypassing is true, then this scheme can bypass Content Security Policy (CSP) 638 * checks. In most cases, this value should not be true when isStandard is true. 639 * 640 * @type { ?boolean } 641 * @syscap SystemCapability.Web.Webview.Core 642 * @atomicservice 643 * @since 12 644 */ 645 isCspBypassing?: boolean; 646 647 /** 648 * If isCodeCacheSupported is true, then the js of this scheme can generate code cache. 649 * 650 * @type { ?boolean } 651 * @syscap SystemCapability.Web.Webview.Core 652 * @since 12 653 */ 654 isCodeCacheSupported?: boolean; 655 } 656 657 /** 658 * Defines the callback of createPdf, related to {@link createPDF} method. 659 * 660 * @syscap SystemCapability.Web.Webview.Core 661 * @atomicservice 662 * @since 14 663 */ 664 class PdfData { 665 /** 666 * Return the data stream generated by the webpage. 667 * 668 * @returns { Uint8Array } return pdf data. 669 * @syscap SystemCapability.Web.Webview.Core 670 * @atomicservice 671 * @since 14 672 */ 673 pdfArrayBuffer(): Uint8Array; 674 } 675 676 /** 677 * Defines the configuration of creating pdf, related to {@Link createPdf} method. 678 * 679 * @typedef PdfConfiguration 680 * @syscap SystemCapability.Web.Webview.Core 681 * @atomicservice 682 * @since 14 683 */ 684 interface PdfConfiguration { 685 /** 686 * Number of the width. 687 * 688 * @type { number } 689 * @syscap SystemCapability.Web.Webview.Core 690 * @atomicservice 691 * @since 14 692 */ 693 width: number; 694 695 /** 696 * Number of the height. 697 * 698 * @type { number } 699 * @syscap SystemCapability.Web.Webview.Core 700 * @atomicservice 701 * @since 14 702 */ 703 height: number; 704 705 /** 706 * Number of the marginTop. 707 * 708 * @type { number } 709 * @syscap SystemCapability.Web.Webview.Core 710 * @atomicservice 711 * @since 14 712 */ 713 marginTop: number; 714 715 /** 716 * Number of the marginBottom. 717 * 718 * @type { number } 719 * @syscap SystemCapability.Web.Webview.Core 720 * @atomicservice 721 * @since 14 722 */ 723 marginBottom: number; 724 725 /** 726 * Number of the marginRight. 727 * 728 * @type { number } 729 * @syscap SystemCapability.Web.Webview.Core 730 * @atomicservice 731 * @since 14 732 */ 733 marginRight: number; 734 735 /** 736 * Number of the marginLeft. 737 * 738 * @type { number } 739 * @syscap SystemCapability.Web.Webview.Core 740 * @atomicservice 741 * @since 14 742 */ 743 marginLeft: number; 744 745 /** 746 * Number of the scaling. 747 * 748 * @type { ?number } 749 * @syscap SystemCapability.Web.Webview.Core 750 * @atomicservice 751 * @since 14 752 */ 753 scale?: number; 754 755 /** 756 * Whether background should be printed when creating pdf. 757 * 758 * @type { ?boolean } 759 * @syscap SystemCapability.Web.Webview.Core 760 * @atomicservice 761 * @since 14 762 */ 763 shouldPrintBackground?: boolean; 764 } 765 766 /** 767 * Provides basic information of web storage. 768 * 769 * @interface WebStorageOrigin 770 * @syscap SystemCapability.Web.Webview.Core 771 * @since 9 772 */ 773 /** 774 * Provides basic information of web storage. 775 * 776 * @interface WebStorageOrigin 777 * @syscap SystemCapability.Web.Webview.Core 778 * @atomicservice 779 * @since 11 780 */ 781 /** 782 * Provides basic information of web storage. 783 * 784 * @typedef WebStorageOrigin 785 * @syscap SystemCapability.Web.Webview.Core 786 * @atomicservice 787 * @since 12 788 */ 789 /** 790 * Provides basic information of web storage. 791 * 792 * @typedef WebStorageOrigin 793 * @syscap SystemCapability.Web.Webview.Core 794 * @crossplatform 795 * @atomicservice 796 * @since arkts {'1.1':'18', '1.2':'20'} 797 * @arkts 1.1&1.2 798 */ 799 interface WebStorageOrigin { 800 /** 801 * Url source. 802 * 803 * @syscap SystemCapability.Web.Webview.Core 804 * @since 9 805 */ 806 /** 807 * Url source. 808 * 809 * @type { string } 810 * @syscap SystemCapability.Web.Webview.Core 811 * @atomicservice 812 * @since 11 813 */ 814 /** 815 * Url source. 816 * 817 * @type { string } 818 * @syscap SystemCapability.Web.Webview.Core 819 * @crossplatform 820 * @atomicservice 821 * @since arkts {'1.1':'18', '1.2':'20'} 822 * @arkts 1.1&1.2 823 */ 824 origin: string; 825 /** 826 * Specify the amount of storage for the source. 827 * 828 * @syscap SystemCapability.Web.Webview.Core 829 * @since 9 830 */ 831 /** 832 * Specify the amount of storage for the source. 833 * 834 * @type { number } 835 * @syscap SystemCapability.Web.Webview.Core 836 * @atomicservice 837 * @since 11 838 */ 839 /** 840 * Specify the amount of storage for the source. 841 * 842 * @type { number } 843 * @syscap SystemCapability.Web.Webview.Core 844 * @crossplatform 845 * @atomicservice 846 * @since arkts {'1.1':'18', '1.2':'20'} 847 * @arkts 1.1&1.2 848 */ 849 usage: number; 850 /** 851 * the callback of getOriginUsage. 852 * 853 * @syscap SystemCapability.Web.Webview.Core 854 * @since 9 855 */ 856 /** 857 * the callback of getOriginUsage. 858 * 859 * @type { number } 860 * @syscap SystemCapability.Web.Webview.Core 861 * @atomicservice 862 * @since 11 863 */ 864 /** 865 * the callback of getOriginUsage. 866 * 867 * @type { number } 868 * @syscap SystemCapability.Web.Webview.Core 869 * @crossplatform 870 * @atomicservice 871 * @since arkts {'1.1':'18', '1.2':'20'} 872 * @arkts 1.1&1.2 873 */ 874 quota: number; 875 } 876 877 /** 878 * Defines the Web's request info. 879 * 880 * @typedef RequestInfo 881 * @syscap SystemCapability.Web.Webview.Core 882 * @atomicservice 883 * @since 12 884 */ 885 interface RequestInfo { 886 /** 887 * Gets the url of the request. 888 * @type { string } 889 * @syscap SystemCapability.Web.Webview.Core 890 * @atomicservice 891 * @since 12 892 */ 893 url: string; 894 895 /** 896 * Gets the method of the request. 897 * @type { string } 898 * @syscap SystemCapability.Web.Webview.Core 899 * @atomicservice 900 * @since 12 901 */ 902 method: string; 903 904 /** 905 * Gets the form data of the request. 906 * @type { string } 907 * @syscap SystemCapability.Web.Webview.Core 908 * @atomicservice 909 * @since 12 910 */ 911 formData: string; 912 } 913 914 /** 915 * Defines the scroll offset of the webpage in view port, the unit is virtual pixel. 916 * Related to {@link getScrollOffset} method. 917 * 918 * @typedef ScrollOffset 919 * @syscap SystemCapability.Web.Webview.Core 920 * @atomicservice 921 * @since 13 922 */ 923 interface ScrollOffset { 924 /** 925 * The horizontal scroll offset of the web page. The value is the difference between 926 * the x-coordinate of the left border of the web page and the x-coordinate of the 927 * left border of the Web component. When the web page scrolls to the right, 928 * the value range is negative. 929 * When the web page is not over-scrolled or the web page is over-scrolled to the left, 930 * the value is 0 or a positive value. Unit: vp. 931 * 932 * @type { number } 933 * @syscap SystemCapability.Web.Webview.Core 934 * @atomicservice 935 * @since 13 936 */ 937 x: number; 938 939 /** 940 * The vertical scroll offset of the web page. The value is the difference between 941 * the y-coordinate of the upper border of the web page and the y-coordinate of the 942 * upper boundary of the Web component. When the web page is scrolled down, 943 * the value range is negative. 944 * When the web page is not over-scrolled or the web page is over-scrolled to the up, 945 * the value is 0 or a positive value. Unit: vp. 946 * 947 * @type { number } 948 * @syscap SystemCapability.Web.Webview.Core 949 * @atomicservice 950 * @since 13 951 */ 952 y: number; 953 } 954 955 /** 956 * Subscribe to a callback of a specified type of web event once. 957 * 958 * @param {string} type Types of web event. 959 * @param {Callback<void>} callback Indicate callback used to receive the web event. 960 * 961 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 962 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 963 * @syscap SystemCapability.Web.Webview.Core 964 * @since 9 965 */ 966 /** 967 * Subscribe to a callback of a specified type of web event once. 968 * 969 * @param {string} type Types of web event. 970 * @param {Callback<void>} callback Indicate callback used to receive the web event. 971 * 972 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 973 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 974 * @syscap SystemCapability.Web.Webview.Core 975 * @atomicservice 976 * @since 11 977 */ 978 function once(type: string, callback: Callback<void>): void; 979 980 /** 981 * Provides methods for managing web storage.3 982 * 983 * @syscap SystemCapability.Web.Webview.Core 984 * @since 9 985 */ 986 /** 987 * Provides methods for managing web storage.3 988 * 989 * @syscap SystemCapability.Web.Webview.Core 990 * @atomicservice 991 * @since 11 992 */ 993 /** 994 * Implements a WebStorage object to manage the Web SQL database and HTML5 Web Storage APIs. 995 * All Web components in an application share a WebStorage object. 996 * 997 * <p><strong>API Note</strong>:<br> 998 * You must load the Web component before calling the APIs in WebStorage. 999 * </p> 1000 * 1001 * @syscap SystemCapability.Web.Webview.Core 1002 * @crossplatform 1003 * @atomicservice 1004 * @since arkts {'1.1':'18', '1.2':'20'} 1005 * @arkts 1.1&1.2 1006 */ 1007 class WebStorage { 1008 /** 1009 * Delete all the storage data. 1010 * 1011 * @syscap SystemCapability.Web.Webview.Core 1012 * @since 9 1013 */ 1014 /** 1015 * Delete all the storage data. 1016 * 1017 * @param { boolean } incognito - {@code true} delete all the storage data in incognito mode; 1018 * {@code false} otherwise. 1019 * @syscap SystemCapability.Web.Webview.Core 1020 * @atomicservice 1021 * @since 11 1022 */ 1023 /** 1024 * Deletes all data in the Web SQL Database. 1025 * 1026 * @param { boolean } incognito - Whether to delete all data in the Web SQL Database in incognito mode. 1027 * {@code true} means to delete all data in the Web SQL Database in incognito mode; 1028 * {@code false} means to delete all data in the Web SQL Database in normal non-incognito mode. 1029 * @syscap SystemCapability.Web.Webview.Core 1030 * @crossplatform 1031 * @atomicservice 1032 * @since arkts {'1.1':'18', '1.2':'20'} 1033 * @arkts 1.1&1.2 1034 */ 1035 static deleteAllData(incognito?: boolean): void; 1036 1037 /** 1038 * Delete the storage data with the origin. 1039 * 1040 * @param { string } origin - The origin which to be deleted. 1041 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1042 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1043 * @throws { BusinessError } 17100011 - Invalid origin. 1044 * @syscap SystemCapability.Web.Webview.Core 1045 * @since 9 1046 */ 1047 /** 1048 * Delete the storage data with the origin. 1049 * 1050 * @param { string } origin - The origin which to be deleted. 1051 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1052 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1053 * @throws { BusinessError } 17100011 - Invalid origin. 1054 * @syscap SystemCapability.Web.Webview.Core 1055 * @atomicservice 1056 * @since 11 1057 */ 1058 /** 1059 * Deletes all data in the specified origin. 1060 * 1061 * @param { string } origin - Index of the origin, which is obtained through {@link getOrigins}. 1062 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1063 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1064 * @throws { BusinessError } 17100011 - Invalid origin. 1065 * @syscap SystemCapability.Web.Webview.Core 1066 * @crossplatform 1067 * @atomicservice 1068 * @since arkts {'1.1':'18', '1.2':'20'} 1069 * @arkts 1.1&1.2 1070 */ 1071 static deleteOrigin(origin: string): void; 1072 1073 /** 1074 * Get current all the web storage origins. 1075 * @returns { Promise<Array<WebStorageOrigin>> } - returns all the WebStorageOrigin. 1076 * @throws { BusinessError } 401 - Invalid input parameter. 1077 * @throws { BusinessError } 17100012 - Invalid web storage origin. 1078 * @syscap SystemCapability.Web.Webview.Core 1079 * @since 9 1080 */ 1081 /** 1082 * Get current all the web storage origins. 1083 * @returns { Promise<Array<WebStorageOrigin>> } - returns all the WebStorageOrigin. 1084 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1085 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1086 * @throws { BusinessError } 17100012 - Invalid web storage origin. 1087 * @syscap SystemCapability.Web.Webview.Core 1088 * @atomicservice 1089 * @since 11 1090 */ 1091 /** 1092 * Obtains information about all origins that are currently using the Web SQL Database. 1093 * This API uses a promise to return the result. 1094 * 1095 * @returns { Promise<Array<WebStorageOrigin>> } - Promise used to return the information about the origins. 1096 * For details, see {@link WebStorageOrigin}. 1097 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1098 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1099 * @throws { BusinessError } 17100012 - Invalid web storage origin. 1100 * @syscap SystemCapability.Web.Webview.Core 1101 * @crossplatform 1102 * @atomicservice 1103 * @since arkts {'1.1':'18', '1.2':'20'} 1104 * @arkts 1.1&1.2 1105 */ 1106 static getOrigins(): Promise<Array<WebStorageOrigin>>; 1107 1108 /** 1109 * Get current all the web storage origins. 1110 * @param { AsyncCallback<Array<WebStorageOrigin>> } callback - callback used to return all the WebStorageOrigin. 1111 * @throws { BusinessError } 401 - Invalid input parameter. 1112 * @throws { BusinessError } 17100012 - Invalid web storage origin. 1113 * @syscap SystemCapability.Web.Webview.Core 1114 * @since 9 1115 */ 1116 /** 1117 * Get current all the web storage origins. 1118 * @param { AsyncCallback<Array<WebStorageOrigin>> } callback - callback used to return all the WebStorageOrigin. 1119 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1120 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1121 * @throws { BusinessError } 17100012 - Invalid web storage origin. 1122 * @syscap SystemCapability.Web.Webview.Core 1123 * @atomicservice 1124 * @since 11 1125 */ 1126 /** 1127 * Obtains information about all origins that are currently using the Web SQL Database. 1128 * This API uses an asynchronous callback to return the result. 1129 * 1130 * @param { AsyncCallback<Array<WebStorageOrigin>> } callback - Callback used to return the information about the 1131 * origins. For details, see {@link WebStorageOrigin}. 1132 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1133 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1134 * @throws { BusinessError } 17100012 - Invalid web storage origin. 1135 * @syscap SystemCapability.Web.Webview.Core 1136 * @crossplatform 1137 * @atomicservice 1138 * @since arkts {'1.1':'18', '1.2':'20'} 1139 * @arkts 1.1&1.2 1140 */ 1141 static getOrigins(callback: AsyncCallback<Array<WebStorageOrigin>>): void; 1142 1143 /** 1144 * Get the web storage quota with the origin. 1145 * @param { string } origin - The origin which to be inquired. 1146 * @returns { Promise<number> } - the promise returned by the function 1147 * @throws { BusinessError } 401 - Invalid input parameter. 1148 * @throws { BusinessError } 17100011 - Invalid origin. 1149 * @syscap SystemCapability.Web.Webview.Core 1150 * @since 9 1151 */ 1152 /** 1153 * Get the web storage quota with the origin. 1154 * @param { string } origin - The origin which to be inquired. 1155 * @returns { Promise<number> } - the promise returned by the function 1156 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1157 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1158 * @throws { BusinessError } 17100011 - Invalid origin. 1159 * @syscap SystemCapability.Web.Webview.Core 1160 * @atomicservice 1161 * @since 11 1162 */ 1163 /** 1164 * Get the web storage quota with the origin. 1165 * @param { string } origin - The origin which to be inquired. 1166 * @returns { Promise<number> } - the promise returned by the function 1167 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1168 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1169 * @throws { BusinessError } 17100011 - Invalid origin. 1170 * @syscap SystemCapability.Web.Webview.Core 1171 * @crossplatform 1172 * @atomicservice 1173 * @since arkts {'1.1':'18', '1.2':'20'} 1174 * @arkts 1.1&1.2 1175 */ 1176 static getOriginQuota(origin: string): Promise<number>; 1177 1178 /** 1179 * Get the web storage quota with the origin. 1180 * @param { string } origin - The origin which to be inquired. 1181 * @param { AsyncCallback<number> } callback - the callback of getOriginQuota. 1182 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1183 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1184 * @throws { BusinessError } 17100011 - Invalid origin. 1185 * @syscap SystemCapability.Web.Webview.Core 1186 * @since 9 1187 */ 1188 /** 1189 * Get the web storage quota with the origin. 1190 * @param { string } origin - The origin which to be inquired. 1191 * @param { AsyncCallback<number> } callback - the callback of getOriginQuota. 1192 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1193 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1194 * @throws { BusinessError } 17100011 - Invalid origin. 1195 * @syscap SystemCapability.Web.Webview.Core 1196 * @atomicservice 1197 * @since 11 1198 */ 1199 /** 1200 * Get the web storage quota with the origin. 1201 * @param { string } origin - The origin which to be inquired. 1202 * @param { AsyncCallback<number> } callback - the callback of getOriginQuota. 1203 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1204 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1205 * @throws { BusinessError } 17100011 - Invalid origin. 1206 * @syscap SystemCapability.Web.Webview.Core 1207 * @crossplatform 1208 * @atomicservice 1209 * @since arkts {'1.1':'18', '1.2':'20'} 1210 * @arkts 1.1&1.2 1211 */ 1212 static getOriginQuota(origin: string, callback: AsyncCallback<number>): void; 1213 1214 /** 1215 * Get the web amount of storage with the origin. 1216 * @param { string } origin - The origin which to be inquired. 1217 * @returns { Promise<number> } - the promise returned by the function 1218 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1219 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1220 * @throws { BusinessError } 17100011 - Invalid origin. 1221 * @syscap SystemCapability.Web.Webview.Core 1222 * @since 9 1223 */ 1224 /** 1225 * Get the web amount of storage with the origin. 1226 * @param { string } origin - The origin which to be inquired. 1227 * @returns { Promise<number> } - the promise returned by the function 1228 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1229 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1230 * @throws { BusinessError } 17100011 - Invalid origin. 1231 * @syscap SystemCapability.Web.Webview.Core 1232 * @atomicservice 1233 * @since 11 1234 */ 1235 /** 1236 * Get the web amount of storage with the origin. 1237 * @param { string } origin - The origin which to be inquired. 1238 * @returns { Promise<number> } - the promise returned by the function 1239 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1240 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1241 * @throws { BusinessError } 17100011 - Invalid origin. 1242 * @syscap SystemCapability.Web.Webview.Core 1243 * @crossplatform 1244 * @atomicservice 1245 * @since arkts {'1.1':'18', '1.2':'20'} 1246 * @arkts 1.1&1.2 1247 */ 1248 static getOriginUsage(origin: string): Promise<number>; 1249 1250 /** 1251 * Get the web amount of storage with the origin. 1252 * @param { string } origin - The origin which to be inquired. 1253 * @param { AsyncCallback<number> } callback - the callback of getOriginUsage. 1254 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1255 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1256 * @throws { BusinessError } 17100011 - Invalid origin. 1257 * @syscap SystemCapability.Web.Webview.Core 1258 * @since 9 1259 */ 1260 /** 1261 * Get the web amount of storage with the origin. 1262 * @param { string } origin - The origin which to be inquired. 1263 * @param { AsyncCallback<number> } callback - the callback of getOriginUsage. 1264 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1265 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1266 * @throws { BusinessError } 17100011 - Invalid origin. 1267 * @syscap SystemCapability.Web.Webview.Core 1268 * @atomicservice 1269 * @since 11 1270 */ 1271 /** 1272 * Get the web amount of storage with the origin. 1273 * @param { string } origin - The origin which to be inquired. 1274 * @param { AsyncCallback<number> } callback - the callback of getOriginUsage. 1275 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1276 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1277 * @throws { BusinessError } 17100011 - Invalid origin. 1278 * @syscap SystemCapability.Web.Webview.Core 1279 * @crossplatform 1280 * @atomicservice 1281 * @since arkts {'1.1':'18', '1.2':'20'} 1282 * @arkts 1.1&1.2 1283 */ 1284 static getOriginUsage(origin: string, callback: AsyncCallback<number>): void; 1285 } 1286 1287 /** 1288 * Provides methods for managing web database. 1289 * @syscap SystemCapability.Web.Webview.Core 1290 * @since 9 1291 */ 1292 /** 1293 * Implements a WebDataBase object. 1294 * 1295 * <p><strong>API Note</strong>:<br> 1296 * You must load the Web component before calling the APIs in WebDataBase. 1297 * </p> 1298 * 1299 * @syscap SystemCapability.Web.Webview.Core 1300 * @crossplatform 1301 * @atomicservice 1302 * @since 11 1303 */ 1304 class WebDataBase { 1305 /** 1306 * Get whether instances holds any http authentication credentials. 1307 * @returns { boolean } true if instances saved any http authentication credentials otherwise false. 1308 * @syscap SystemCapability.Web.Webview.Core 1309 * @since 9 1310 */ 1311 /** 1312 * Get whether instances holds any http authentication credentials. 1313 * @returns { boolean } true if instances saved any http authentication credentials otherwise false. 1314 * @syscap SystemCapability.Web.Webview.Core 1315 * @crossplatform 1316 * @atomicservice 1317 * @since 11 1318 */ 1319 static existHttpAuthCredentials(): boolean; 1320 1321 /** 1322 * Delete all http authentication credentials. 1323 * 1324 * @syscap SystemCapability.Web.Webview.Core 1325 * @since 9 1326 */ 1327 /** 1328 * Deletes all HTTP authentication credentials saved in the cache. This API returns the result synchronously. 1329 * 1330 * @syscap SystemCapability.Web.Webview.Core 1331 * @crossplatform 1332 * @atomicservice 1333 * @since 11 1334 */ 1335 static deleteHttpAuthCredentials(): void; 1336 1337 /** 1338 * Get http authentication credentials. 1339 * @param { string } host - The host to which the credentials apply. 1340 * @param { string } realm - The realm to which the credentials apply. 1341 * @returns { Array<string> } Return an array containing username and password. 1342 * @throws { BusinessError } 401 - Invalid input parameter. 1343 * @syscap SystemCapability.Web.Webview.Core 1344 * @since 9 1345 */ 1346 /** 1347 * Get http authentication credentials. 1348 * @param { string } host - The host to which the credentials apply. 1349 * @param { string } realm - The realm to which the credentials apply. 1350 * @returns { Array<string> } Return an array containing username and password. 1351 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1352 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1353 * @syscap SystemCapability.Web.Webview.Core 1354 * @crossplatform 1355 * @atomicservice 1356 * @since 11 1357 */ 1358 static getHttpAuthCredentials(host: string, realm: string): Array<string>; 1359 1360 /** 1361 * Save http authentication credentials. 1362 * @param { string } host - The host to which the credentials apply. 1363 * @param { string } realm - The realm to which the credentials apply. 1364 * @param { string } username - The username. 1365 * @param { string } password - The password. 1366 * @throws { BusinessError } 401 - Invalid input parameter. 1367 * @syscap SystemCapability.Web.Webview.Core 1368 * @since 9 1369 */ 1370 /** 1371 * Saves HTTP authentication credentials for a given host and realm. This API returns the result synchronously. 1372 * @param { string } host - Host to which HTTP authentication credentials apply. 1373 * @param { string } realm - Realm to which HTTP authentication credentials apply. 1374 * @param { string } username - User name. 1375 * @param { string } password - Password. 1376 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1377 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1378 * @syscap SystemCapability.Web.Webview.Core 1379 * @crossplatform 1380 * @atomicservice 1381 * @since 11 1382 */ 1383 static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; 1384 } 1385 1386 /** 1387 * Provides a method for managing web geographic location permissions. 1388 * @syscap SystemCapability.Web.Webview.Core 1389 * @since 9 1390 */ 1391 /** 1392 * Provides a method for managing web geographic location permissions. 1393 * @syscap SystemCapability.Web.Webview.Core 1394 * @atomicservice 1395 * @since 11 1396 */ 1397 /** 1398 * Implements a GeolocationPermissions object. 1399 * 1400 * <p><strong>API Note</strong>:<br> 1401 * You must load the Web component before calling the APIs in GeolocationPermissions. 1402 * </p> 1403 * 1404 * @syscap SystemCapability.Web.Webview.Core 1405 * @crossplatform 1406 * @atomicservice 1407 * @since 18 1408 */ 1409 class GeolocationPermissions { 1410 /** 1411 * Allow geolocation permissions for specifies source. 1412 * @param { string } origin - Url source. 1413 * @throws { BusinessError } 401 - Invalid input parameter. 1414 * @throws { BusinessError } 17100011 - Invalid origin. 1415 * @syscap SystemCapability.Web.Webview.Core 1416 * @since 9 1417 */ 1418 /** 1419 * Allow geolocation permissions for specifies source. 1420 * @param { string } origin - Url source. 1421 * @param { boolean } incognito - {@code true} Allow geolocation permissions for specifies source 1422 * in incognito mode; {@code false} otherwise. 1423 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1424 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1425 * @throws { BusinessError } 17100011 - Invalid origin. 1426 * @syscap SystemCapability.Web.Webview.Core 1427 * @atomicservice 1428 * @since 11 1429 */ 1430 /** 1431 * Allows the specified origin to use the geolocation information. 1432 * @param { string } origin - Index of the origin. 1433 * @param { boolean } incognito - Whether to allow the specified origin to use the geolocation information 1434 * in incognito mode. {@code true} means to allow the specified origin to use the 1435 * geolocation information in incognito mode; {@code false} means to allow the 1436 * specified origin to use the geolocation information in normal non-incognito mode. 1437 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1438 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1439 * @throws { BusinessError } 17100011 - Invalid origin. 1440 * @syscap SystemCapability.Web.Webview.Core 1441 * @crossplatform 1442 * @atomicservice 1443 * @since 18 1444 */ 1445 static allowGeolocation(origin: string, incognito?: boolean): void; 1446 1447 /** 1448 * Delete geolocation permissions for specifies source. 1449 * @param { string } origin - Url source. 1450 * @throws { BusinessError } 401 - Invalid input parameter. 1451 * @throws { BusinessError } 17100011 - Invalid origin. 1452 * @syscap SystemCapability.Web.Webview.Core 1453 * @since 9 1454 */ 1455 /** 1456 * Delete geolocation permissions for specifies source. 1457 * @param { string } origin - Url source. 1458 * @param { boolean } incognito - {@code true} delete geolocation permissions for specifies source 1459 * in incognito mode; {@code false} otherwise. 1460 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1461 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1462 * @throws { BusinessError } 17100011 - Invalid origin. 1463 * @syscap SystemCapability.Web.Webview.Core 1464 * @atomicservice 1465 * @since 11 1466 */ 1467 /** 1468 * Delete geolocation permissions for specifies source. 1469 * @param { string } origin - Url source. 1470 * @param { boolean } incognito - {@code true} delete geolocation permissions for specifies source 1471 * in incognito mode; {@code false} otherwise. 1472 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1473 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1474 * @throws { BusinessError } 17100011 - Invalid origin. 1475 * @syscap SystemCapability.Web.Webview.Core 1476 * @crossplatform 1477 * @atomicservice 1478 * @since 18 1479 */ 1480 static deleteGeolocation(origin: string, incognito?: boolean): void; 1481 1482 /** 1483 * Delete all geolocation permissions. 1484 * 1485 * @syscap SystemCapability.Web.Webview.Core 1486 * @since 9 1487 */ 1488 /** 1489 * Delete all geolocation permissions. 1490 * 1491 * @param { boolean } incognito - {@code true} delete all geolocation in incognito mode; 1492 * {@code false} otherwise. 1493 * @syscap SystemCapability.Web.Webview.Core 1494 * @atomicservice 1495 * @since 11 1496 */ 1497 /** 1498 * Clears the geolocation permission status of all sources. 1499 * 1500 * @param { boolean } incognito - Whether to clear the geolocation permission status of all sources in incognito 1501 * mode. {@code true} means to clear the geolocation permission status of 1502 * all sources in incognito mode; {@code false} means to clear the geolocation 1503 * permission status of all sources in normal non-incognito mode. 1504 * @syscap SystemCapability.Web.Webview.Core 1505 * @crossplatform 1506 * @atomicservice 1507 * @since 18 1508 */ 1509 static deleteAllGeolocation(incognito?: boolean): void; 1510 1511 /** 1512 * Gets the geolocation permission status of the specified source. 1513 * @param { string } origin - Url source. 1514 * @returns { Promise<boolean> } A Promise instance that obtains the permission 1515 * status of the specified source and obtains successfully, 1516 * true for authorization, false for access denial. Failed 1517 * to get, indicating that the permission status of the 1518 * specified source does not exist. 1519 * @throws { BusinessError } 401 - Invalid input parameter. 1520 * @throws { BusinessError } 17100011 - Invalid origin. 1521 * @syscap SystemCapability.Web.Webview.Core 1522 * @since 9 1523 */ 1524 /** 1525 * Gets the geolocation permission status of the specified source. 1526 * @param { string } origin - Url source. 1527 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 1528 * specified source in incognito mode; {@code false} otherwise. 1529 * @returns { Promise<boolean> } A Promise instance that obtains the permission 1530 * status of the specified source and obtains successfully, 1531 * true for authorization, false for access denial. Failed 1532 * to get, indicating that the permission status of the 1533 * specified source does not exist. 1534 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1535 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1536 * @throws { BusinessError } 17100011 - Invalid origin. 1537 * @syscap SystemCapability.Web.Webview.Core 1538 * @atomicservice 1539 * @since 11 1540 */ 1541 /** 1542 * Gets the geolocation permission status of the specified source. 1543 * @param { string } origin - Url source. 1544 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 1545 * specified source in incognito mode; {@code false} otherwise. 1546 * @returns { Promise<boolean> } A Promise instance that obtains the permission 1547 * status of the specified source and obtains successfully, 1548 * true for authorization, false for access denial. Failed 1549 * to get, indicating that the permission status of the 1550 * specified source does not exist. 1551 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1552 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1553 * @throws { BusinessError } 17100011 - Invalid origin. 1554 * @syscap SystemCapability.Web.Webview.Core 1555 * @crossplatform 1556 * @atomicservice 1557 * @since 18 1558 */ 1559 static getAccessibleGeolocation(origin: string, incognito?: boolean): Promise<boolean>; 1560 1561 /** 1562 * Gets the geolocation permission status of the specified source. 1563 * @param { string } origin - Url source. 1564 * @param { AsyncCallback<boolean> } callback - Returns the geolocation permission status for 1565 * the specified source. Successful acquisition, 1566 * true means authorized, false means access is 1567 * denied. Failed to get, indicating that the 1568 * permission status of the specified source does 1569 * not exist. 1570 * @throws { BusinessError } 401 - Invalid input parameter. 1571 * @throws { BusinessError } 17100011 - Invalid origin. 1572 * @syscap SystemCapability.Web.Webview.Core 1573 * @since 9 1574 */ 1575 /** 1576 * Gets the geolocation permission status of the specified source. 1577 * @param { string } origin - Url source. 1578 * @param { AsyncCallback<boolean> } callback - Returns the geolocation permission status for 1579 * the specified source. Successful acquisition, 1580 * true means authorized, false means access is 1581 * denied. Failed to get, indicating that the 1582 * permission status of the specified source does 1583 * not exist. 1584 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 1585 * specified source in incognito mode; {@code false} otherwise. 1586 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1587 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1588 * @throws { BusinessError } 17100011 - Invalid origin. 1589 * @syscap SystemCapability.Web.Webview.Core 1590 * @atomicservice 1591 * @since 11 1592 */ 1593 /** 1594 * Gets the geolocation permission status of the specified source. 1595 * @param { string } origin - Url source. 1596 * @param { AsyncCallback<boolean> } callback - Returns the geolocation permission status for 1597 * the specified source. Successful acquisition, 1598 * true means authorized, false means access is 1599 * denied. Failed to get, indicating that the 1600 * permission status of the specified source does 1601 * not exist. 1602 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 1603 * specified source in incognito mode; {@code false} otherwise. 1604 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1605 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1606 * @throws { BusinessError } 17100011 - Invalid origin. 1607 * @syscap SystemCapability.Web.Webview.Core 1608 * @crossplatform 1609 * @atomicservice 1610 * @since 18 1611 */ 1612 static getAccessibleGeolocation(origin: string, callback: AsyncCallback<boolean>, incognito?: boolean): void; 1613 1614 /** 1615 * Get all stored geolocation permission url source. 1616 * 1617 * @returns { Promise<Array<string>> } A Promise instance that gets all source information about 1618 * the stored geolocation permission state. 1619 * @throws { BusinessError } 401 - Invalid input parameter. 1620 * @syscap SystemCapability.Web.Webview.Core 1621 * @since 9 1622 */ 1623 /** 1624 * Get all stored geolocation permission url source. 1625 * @param { boolean } incognito - {@code true} get all stored geolocation permission url source 1626 * in incognito mode; {@code false} otherwise. 1627 * @returns { Promise<Array<string>> } A Promise instance that gets all source information about 1628 * the stored geolocation permission state. 1629 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1630 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1631 * @syscap SystemCapability.Web.Webview.Core 1632 * @atomicservice 1633 * @since 11 1634 */ 1635 /** 1636 * Get all stored geolocation permission url source. 1637 * @param { boolean } incognito - {@code true} get all stored geolocation permission url source 1638 * in incognito mode; {@code false} otherwise. 1639 * @returns { Promise<Array<string>> } A Promise instance that gets all source information about 1640 * the stored geolocation permission state. 1641 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1642 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1643 * @syscap SystemCapability.Web.Webview.Core 1644 * @crossplatform 1645 * @atomicservice 1646 * @since 18 1647 */ 1648 static getStoredGeolocation(incognito?: boolean): Promise<Array<string>>; 1649 1650 /** 1651 * Get all stored geolocation permission url source. 1652 * @param { AsyncCallback<Array<string>> } callback - Returns all source information for 1653 * stored geolocation permission states. 1654 * @throws { BusinessError } 401 - Invalid input parameter. 1655 * @syscap SystemCapability.Web.Webview.Core 1656 * @since 9 1657 */ 1658 /** 1659 * Get all stored geolocation permission url source. 1660 * @param { AsyncCallback<Array<string>> } callback - Returns all source information for 1661 * stored geolocation permission states. 1662 * @param { boolean } incognito - {@code true} gets all stored geolocation permission url 1663 * source in incognito mode; {@code false} otherwise. 1664 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1665 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1666 * @syscap SystemCapability.Web.Webview.Core 1667 * @atomicservice 1668 * @since 11 1669 */ 1670 /** 1671 * Get all stored geolocation permission url source. 1672 * @param { AsyncCallback<Array<string>> } callback - Returns all source information for 1673 * stored geolocation permission states. 1674 * @param { boolean } incognito - {@code true} gets all stored geolocation permission url 1675 * source in incognito mode; {@code false} otherwise. 1676 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1677 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1678 * @syscap SystemCapability.Web.Webview.Core 1679 * @crossplatform 1680 * @atomicservice 1681 * @since 18 1682 */ 1683 static getStoredGeolocation(callback: AsyncCallback<Array<string>>, incognito?: boolean): void; 1684 } 1685 1686 /** 1687 * Provides methods for managing the web cookies. 1688 * 1689 * @syscap SystemCapability.Web.Webview.Core 1690 * @since 9 1691 */ 1692 /** 1693 * Provides methods for managing the web cookies. 1694 * 1695 * @syscap SystemCapability.Web.Webview.Core 1696 * @crossplatform 1697 * @atomicservice 1698 * @since arkts {'1.1':'11', '1.2':'20'} 1699 * @arkts 1.1&1.2 1700 */ 1701 class WebCookieManager { 1702 /** 1703 * Gets all cookies for the given URL. 1704 * 1705 * @param { string } url - The URL for which the cookies are requested. 1706 * @returns { string } - The cookie value for the given URL. 1707 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1708 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1709 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1710 * @syscap SystemCapability.Web.Webview.Core 1711 * @since 9 1712 * @deprecated since 11 1713 * @useinstead ohos.web.webview.WebCookieManager#fetchCookieSync 1714 */ 1715 static getCookie(url: string): string; 1716 1717 /** 1718 * Gets all cookies for the given URL. 1719 * 1720 * @param { string } url - The URL for which the cookies are requested. 1721 * @param { boolean } incognito - {@code true} gets all cookies for the given URL 1722 * in incognito mode; {@code false} otherwise. 1723 * @returns { string } - The cookie value for the given URL. 1724 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1725 * <br>2. Incorrect parameter types. 1726 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1727 * @syscap SystemCapability.Web.Webview.Core 1728 * @atomicservice 1729 * @since 11 1730 */ 1731 static fetchCookieSync(url: string, incognito?: boolean): string; 1732 1733 /** 1734 * Gets all cookies for the given URL Asynchronously. 1735 * 1736 * @param { string } url - The URL for which the cookies are requested. 1737 * @returns { Promise<string> } - A promise resolved after the cookies of given URL have been gotten. 1738 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1739 * <br>2. Incorrect parameter types. 1740 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1741 * @syscap SystemCapability.Web.Webview.Core 1742 * @crossplatform 1743 * @atomicservice 1744 * @since 11 1745 */ 1746 static fetchCookie(url: string): Promise<string>; 1747 1748 /** 1749 * Gets all cookies for the given URL Asynchronously. 1750 * 1751 * @param { string } url - The URL for which the cookies are requested. 1752 * @param { boolean } incognito - {@code true} gets all cookies for the given URL 1753 * in incognito mode; {@code false} otherwise. 1754 * @returns { Promise<string> } - A promise resolved after the cookies of given URL have been gotten. 1755 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1756 * <br>2. Incorrect parameter types. 1757 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1758 * @syscap SystemCapability.Web.Webview.Core 1759 * @since 14 1760 */ 1761 static fetchCookie(url: string, incognito: boolean): Promise<string>; 1762 1763 /** 1764 * Gets all cookies for the given URL Asynchronously. 1765 * 1766 * @param { string } url - The URL for which the cookies are requested. 1767 * @param { AsyncCallback<string> } callback - Called after the cookies of given URL have been gotten. 1768 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1769 * <br>2. Incorrect parameter types. 1770 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1771 * @syscap SystemCapability.Web.Webview.Core 1772 * @crossplatform 1773 * @atomicservice 1774 * @since 11 1775 */ 1776 static fetchCookie(url: string, callback: AsyncCallback<string>): void; 1777 1778 /** 1779 * Set a single cookie (key-value pair) for the given URL. 1780 * 1781 * @param { string } url - The URL for which the cookie is to be set. 1782 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1783 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1784 * <br>2. Incorrect parameter types. 1785 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1786 * @throws { BusinessError } 17100005 - The provided cookie value is invalid. It must follow the format specified 1787 * <br>in RFC 6265. 1788 * @syscap SystemCapability.Web.Webview.Core 1789 * @since 9 1790 * @deprecated since 11 1791 * @useinstead ohos.web.webview.WebCookieManager#configCookieSync 1792 */ 1793 static setCookie(url: string, value: string): void; 1794 1795 /** 1796 * Set a single cookie (key-value pair) for the given URL. 1797 * 1798 * @param { string } url - The URL for which the cookie is to be set. 1799 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1800 * @param { boolean } incognito - {@code true} set a single cookie (key-value pair) for the given URL 1801 * in incognito mode; {@code false} otherwise. 1802 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1803 * <br>2. Incorrect parameter types. 1804 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1805 * @throws { BusinessError } 17100005 - The provided cookie value is invalid. It must follow the format specified 1806 * <br>in RFC 6265. 1807 * @syscap SystemCapability.Web.Webview.Core 1808 * @atomicservice 1809 * @since 11 1810 */ 1811 static configCookieSync(url: string, value: string, incognito?: boolean): void; 1812 1813 /** 1814 * Set a single cookie (key-value pair) for the given URL. 1815 * 1816 * @param { string } url - The URL for which the cookie is to be set. 1817 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1818 * @param { boolean } incognito - {@code true} set a single cookie (key-value pair) for the given URL 1819 * in incognito mode; {@code false} otherwise. 1820 * @param { boolean } includeHttpOnly - {@code true} HTTP-only cookies can also be overwritten; 1821 * {@code false} otherwise. 1822 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1823 * <br>2. Incorrect parameter types. 1824 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1825 * @throws { BusinessError } 17100005 - The provided cookie value is invalid. It must follow the format specified 1826 * <br>in RFC 6265. 1827 * @syscap SystemCapability.Web.Webview.Core 1828 * @since 14 1829 */ 1830 static configCookieSync(url: string, value: string, incognito: boolean, includeHttpOnly: boolean): void; 1831 1832 /** 1833 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1834 * 1835 * @param { string } url - The URL for which the cookie is to be set. 1836 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1837 * @returns { Promise<void> } - A promise resolved after the cookies of given URL have been set. 1838 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1839 * <br>2. Incorrect parameter types. 1840 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1841 * @throws { BusinessError } 17100005 - The provided cookie value is invalid. It must follow the format specified 1842 * <br>in RFC 6265. 1843 * @syscap SystemCapability.Web.Webview.Core 1844 * @crossplatform 1845 * @atomicservice 1846 * @since 11 1847 */ 1848 static configCookie(url: string, value: string): Promise<void>; 1849 1850 /** 1851 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1852 * 1853 * @param { string } url - The URL for which the cookie is to be set. 1854 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1855 * @param { boolean } incognito - {@code true} set a single cookie (key-value pair) for the given URL 1856 * in incognito mode; {@code false} otherwise. 1857 * @param { boolean } includeHttpOnly - {@code true} HTTP-only cookies can also be overwritten; 1858 * {@code false} otherwise. 1859 * @returns { Promise<void> } - A promise resolved after the cookies of given URL have been set. 1860 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1861 * <br>2. Incorrect parameter types. 1862 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1863 * @throws { BusinessError } 17100005 - The provided cookie value is invalid. It must follow the format specified 1864 * <br>in RFC 6265. 1865 * @syscap SystemCapability.Web.Webview.Core 1866 * @since 14 1867 */ 1868 static configCookie(url: string, value: string, incognito: boolean, includeHttpOnly: boolean): Promise<void>; 1869 1870 /** 1871 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1872 * 1873 * @param { string } url - The URL for which the cookie is to be set. 1874 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1875 * @param { AsyncCallback<void> } callback - Called after the cookies have been set. 1876 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1877 * <br>2. Incorrect parameter types. 1878 * @throws { BusinessError } 17100002 - URL error. No valid cookie found for the specified URL. 1879 * @throws { BusinessError } 17100005 - The provided cookie value is invalid. It must follow the format specified 1880 * <br>in RFC 6265. 1881 * @syscap SystemCapability.Web.Webview.Core 1882 * @crossplatform 1883 * @atomicservice 1884 * @since 11 1885 */ 1886 static configCookie(url: string, value: string, callback: AsyncCallback<void>): void; 1887 1888 /** 1889 * Save the cookies synchronously. 1890 * @syscap SystemCapability.Web.Webview.Core 1891 * @since 15 1892 */ 1893 static saveCookieSync(): void; 1894 1895 /** 1896 * Save the cookies Asynchronously. 1897 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1898 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1899 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1900 * @syscap SystemCapability.Web.Webview.Core 1901 * @since 9 1902 */ 1903 /** 1904 * Save the cookies Asynchronously. 1905 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1906 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1907 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1908 * @syscap SystemCapability.Web.Webview.Core 1909 * @atomicservice 1910 * @since 11 1911 */ 1912 static saveCookieAsync(): Promise<void>; 1913 1914 /** 1915 * Save the cookies Asynchronously. 1916 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1917 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1918 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1919 * @syscap SystemCapability.Web.Webview.Core 1920 * @since 9 1921 */ 1922 /** 1923 * Save the cookies Asynchronously. 1924 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1925 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1926 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1927 * @syscap SystemCapability.Web.Webview.Core 1928 * @atomicservice 1929 * @since 11 1930 */ 1931 static saveCookieAsync(callback: AsyncCallback<void>): void; 1932 1933 /** 1934 * Get whether the instance can send and accept cookies. 1935 * 1936 * @returns { boolean } True if the instance can send and accept cookies else false. 1937 * @syscap SystemCapability.Web.Webview.Core 1938 * @since 9 1939 */ 1940 /** 1941 * Get whether the instance can send and accept cookies. 1942 * 1943 * @returns { boolean } True if the instance can send and accept cookies else false. 1944 * @syscap SystemCapability.Web.Webview.Core 1945 * @atomicservice 1946 * @since 11 1947 */ 1948 static isCookieAllowed(): boolean; 1949 1950 /** 1951 * Set whether the instance should send and accept cookies. 1952 * By default this is set to be true. 1953 * 1954 * @param { boolean } accept - Whether the instance should send and accept cookies. 1955 * @throws { BusinessError } 401 - Invalid input parameter. 1956 * @syscap SystemCapability.Web.Webview.Core 1957 * @since 9 1958 */ 1959 /** 1960 * Set whether the instance should send and accept cookies. 1961 * By default this is set to be true. 1962 * 1963 * @param { boolean } accept - Whether the instance should send and accept cookies. 1964 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1965 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1966 * @syscap SystemCapability.Web.Webview.Core 1967 * @atomicservice 1968 * @since 11 1969 */ 1970 static putAcceptCookieEnabled(accept: boolean): void; 1971 1972 /** 1973 * Get whether the instance can send and accept thirdparty cookies. 1974 * 1975 * @returns { boolean } True if the instance can send and accept thirdparty cookies else false. 1976 * @syscap SystemCapability.Web.Webview.Core 1977 * @since 9 1978 */ 1979 /** 1980 * Get whether the instance can send and accept thirdparty cookies. 1981 * 1982 * @returns { boolean } True if the instance can send and accept thirdparty cookies else false. 1983 * @syscap SystemCapability.Web.Webview.Core 1984 * @atomicservice 1985 * @since 11 1986 */ 1987 static isThirdPartyCookieAllowed(): boolean; 1988 1989 /** 1990 * Set whether the instance should send and accept thirdparty cookies. 1991 * By default this is set to be false. 1992 * 1993 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 1994 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1995 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1996 * @syscap SystemCapability.Web.Webview.Core 1997 * @since 9 1998 */ 1999 /** 2000 * Set whether the instance should send and accept thirdparty cookies. 2001 * By default this is set to be false. 2002 * 2003 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 2004 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2005 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2006 * @syscap SystemCapability.Web.Webview.Core 2007 * @atomicservice 2008 * @since 11 2009 */ 2010 static putAcceptThirdPartyCookieEnabled(accept: boolean): void; 2011 2012 /** 2013 * Check whether exists any cookies. 2014 * 2015 * @returns { boolean } True if exists more than one cookie else false; 2016 * @syscap SystemCapability.Web.Webview.Core 2017 * @since 9 2018 */ 2019 /** 2020 * Check whether exists any cookies. 2021 * 2022 * @param { boolean } incognito - {@code true} check whether exists any cookies. 2023 * in incognito mode; {@code false} otherwise. 2024 * @returns { boolean } True if exists more than one cookie else false; 2025 * @syscap SystemCapability.Web.Webview.Core 2026 * @atomicservice 2027 * @since 11 2028 */ 2029 /** 2030 * Check whether exists any cookies. 2031 * 2032 * @param { boolean } incognito - {@code true} check whether exists any cookies. 2033 * in incognito mode; {@code false} otherwise. 2034 * @returns { boolean } True if exists more than one cookie else false; 2035 * @syscap SystemCapability.Web.Webview.Core 2036 * @crossplatform 2037 * @atomicservice 2038 * @since 18 2039 */ 2040 static existCookie(incognito?: boolean): boolean; 2041 2042 /** 2043 * Remove all cookies. 2044 * @syscap SystemCapability.Web.Webview.Core 2045 * @since 9 2046 * @deprecated since 11 2047 * @useinstead ohos.web.webview.WebCookieManager#clearAllCookiesSync 2048 */ 2049 static deleteEntireCookie(): void; 2050 2051 /** 2052 * Remove all cookies. 2053 * 2054 * @param { boolean } incognito - {@code true} remove all cookies in incognito mode; 2055 * {@code false} otherwise. 2056 * @syscap SystemCapability.Web.Webview.Core 2057 * @atomicservice 2058 * @since 11 2059 */ 2060 static clearAllCookiesSync(incognito?: boolean): void; 2061 2062 /** 2063 * Remove all cookies Asynchronously. 2064 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 2065 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2066 * @syscap SystemCapability.Web.Webview.Core 2067 * @crossplatform 2068 * @atomicservice 2069 * @since 11 2070 */ 2071 static clearAllCookies(): Promise<void>; 2072 2073 /** 2074 * Remove all cookies Asynchronously. 2075 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 2076 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2077 * <br>2. Incorrect parameter types. 2078 * @syscap SystemCapability.Web.Webview.Core 2079 * @crossplatform 2080 * @atomicservice 2081 * @since 11 2082 */ 2083 static clearAllCookies(callback: AsyncCallback<void>): void; 2084 2085 /** 2086 * Delete the session cookies. 2087 * @syscap SystemCapability.Web.Webview.Core 2088 * @since 9 2089 * @deprecated since 11 2090 * @useinstead ohos.web.webview.WebCookieManager#clearSessionCookieSync 2091 */ 2092 static deleteSessionCookie(): void; 2093 2094 /** 2095 * Delete the session cookies. 2096 * @syscap SystemCapability.Web.Webview.Core 2097 * @atomicservice 2098 * @since 11 2099 */ 2100 static clearSessionCookieSync(): void; 2101 2102 /** 2103 * Delete the session cookies Asynchronously. 2104 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 2105 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2106 * @syscap SystemCapability.Web.Webview.Core 2107 * @atomicservice 2108 * @since 11 2109 */ 2110 static clearSessionCookie(): Promise<void>; 2111 2112 /** 2113 * Delete the session cookies Asynchronously. 2114 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 2115 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2116 * <br>2. Incorrect parameter types. 2117 * @syscap SystemCapability.Web.Webview.Core 2118 * @atomicservice 2119 * @since 11 2120 */ 2121 /** 2122 * Delete the session cookies Asynchronously. 2123 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 2124 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2125 * <br>2. Incorrect parameter types. 2126 * @syscap SystemCapability.Web.Webview.Core 2127 * @crossplatform 2128 * @atomicservice 2129 * @since 18 2130 */ 2131 static clearSessionCookie(callback: AsyncCallback<void>): void; 2132 } 2133 2134 /** 2135 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 2136 * 2137 * @enum {number} 2138 * @syscap SystemCapability.Web.Webview.Core 2139 * @since 10 2140 */ 2141 /** 2142 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 2143 * 2144 * @enum {number} 2145 * @syscap SystemCapability.Web.Webview.Core 2146 * @atomicservice 2147 * @since 11 2148 */ 2149 /** 2150 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 2151 * 2152 * @enum {number} 2153 * @syscap SystemCapability.Web.Webview.Core 2154 * @crossplatform 2155 * @atomicservice 2156 * @since 18 2157 */ 2158 enum WebMessageType { 2159 /** 2160 * Unsupported data type. 2161 * 2162 * @syscap SystemCapability.Web.Webview.Core 2163 * @since 10 2164 */ 2165 /** 2166 * Unsupported data type. 2167 * 2168 * @syscap SystemCapability.Web.Webview.Core 2169 * @atomicservice 2170 * @since 11 2171 */ 2172 NOT_SUPPORT, 2173 2174 /** 2175 * The string data type. 2176 * 2177 * @syscap SystemCapability.Web.Webview.Core 2178 * @since 10 2179 */ 2180 /** 2181 * The string data type. 2182 * 2183 * @syscap SystemCapability.Web.Webview.Core 2184 * @atomicservice 2185 * @since 11 2186 */ 2187 /** 2188 * The string data type. 2189 * 2190 * @syscap SystemCapability.Web.Webview.Core 2191 * @crossplatform 2192 * @atomicservice 2193 * @since 18 2194 */ 2195 STRING, 2196 2197 /** 2198 * The number data type. 2199 * 2200 * @syscap SystemCapability.Web.Webview.Core 2201 * @since 10 2202 */ 2203 /** 2204 * The number data type. 2205 * 2206 * @syscap SystemCapability.Web.Webview.Core 2207 * @atomicservice 2208 * @since 11 2209 */ 2210 /** 2211 * The number data type. 2212 * 2213 * @syscap SystemCapability.Web.Webview.Core 2214 * @crossplatform 2215 * @atomicservice 2216 * @since 18 2217 */ 2218 NUMBER, 2219 2220 /** 2221 * The boolean data type. 2222 * 2223 * @syscap SystemCapability.Web.Webview.Core 2224 * @since 10 2225 */ 2226 /** 2227 * The boolean data type. 2228 * 2229 * @syscap SystemCapability.Web.Webview.Core 2230 * @atomicservice 2231 * @since 11 2232 */ 2233 /** 2234 * The boolean data type. 2235 * 2236 * @syscap SystemCapability.Web.Webview.Core 2237 * @crossplatform 2238 * @atomicservice 2239 * @since 18 2240 */ 2241 BOOLEAN, 2242 2243 /** 2244 * The arraybuffer data type. 2245 * 2246 * @syscap SystemCapability.Web.Webview.Core 2247 * @since 10 2248 */ 2249 /** 2250 * The arraybuffer data type. 2251 * 2252 * @syscap SystemCapability.Web.Webview.Core 2253 * @atomicservice 2254 * @since 11 2255 */ 2256 ARRAY_BUFFER, 2257 2258 /** 2259 * The array data type. 2260 * 2261 * @syscap SystemCapability.Web.Webview.Core 2262 * @since 10 2263 */ 2264 /** 2265 * The array data type. 2266 * 2267 * @syscap SystemCapability.Web.Webview.Core 2268 * @atomicservice 2269 * @since 11 2270 */ 2271 /** 2272 * The array data type. 2273 * 2274 * @syscap SystemCapability.Web.Webview.Core 2275 * @crossplatform 2276 * @atomicservice 2277 * @since 18 2278 */ 2279 ARRAY, 2280 2281 /** 2282 * The error data type. 2283 * 2284 * @syscap SystemCapability.Web.Webview.Core 2285 * @since 10 2286 */ 2287 /** 2288 * The error data type. 2289 * 2290 * @syscap SystemCapability.Web.Webview.Core 2291 * @atomicservice 2292 * @since 11 2293 */ 2294 /** 2295 * The error data type. 2296 * 2297 * @syscap SystemCapability.Web.Webview.Core 2298 * @crossplatform 2299 * @atomicservice 2300 * @since 18 2301 */ 2302 ERROR 2303 } 2304 2305 /** 2306 * The message received or sent from web message port. 2307 * 2308 * @syscap SystemCapability.Web.Webview.Core 2309 * @since 10 2310 */ 2311 /** 2312 * The message received or sent from web message port. 2313 * 2314 * @syscap SystemCapability.Web.Webview.Core 2315 * @atomicservice 2316 * @since 11 2317 */ 2318 /** 2319 * The message received or sent from web message port. 2320 * 2321 * @syscap SystemCapability.Web.Webview.Core 2322 * @crossplatform 2323 * @atomicservice 2324 * @since 18 2325 */ 2326 class WebMessageExt { 2327 /** 2328 * Get the type of the web message. 2329 * @returns { WebMessageType } - Returns data of WebMessageType type 2330 * @syscap SystemCapability.Web.Webview.Core 2331 * @since 10 2332 */ 2333 /** 2334 * Get the type of the web message. 2335 * @returns { WebMessageType } - Returns data of WebMessageType type 2336 * @syscap SystemCapability.Web.Webview.Core 2337 * @atomicservice 2338 * @since 11 2339 */ 2340 /** 2341 * Get the type of the web message. 2342 * @returns { WebMessageType } - Returns data of WebMessageType type 2343 * @syscap SystemCapability.Web.Webview.Core 2344 * @crossplatform 2345 * @atomicservice 2346 * @since 18 2347 */ 2348 getType(): WebMessageType; 2349 2350 /** 2351 * Get the string value of the web message. 2352 * @returns { string } - Returns data of string type 2353 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2354 * 2355 * @syscap SystemCapability.Web.Webview.Core 2356 * @since 10 2357 */ 2358 /** 2359 * Get the string value of the web message. 2360 * @returns { string } - Returns data of string type 2361 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2362 * 2363 * @syscap SystemCapability.Web.Webview.Core 2364 * @atomicservice 2365 * @since 11 2366 */ 2367 /** 2368 * Get the string value of the web message. 2369 * @returns { string } - Returns data of string type 2370 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2371 * 2372 * @syscap SystemCapability.Web.Webview.Core 2373 * @crossplatform 2374 * @atomicservice 2375 * @since 18 2376 */ 2377 getString(): string; 2378 2379 /** 2380 * Get the number value of the web message. 2381 * @returns { number } - Returns data of number type 2382 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2383 * 2384 * @syscap SystemCapability.Web.Webview.Core 2385 * @since 10 2386 */ 2387 /** 2388 * Get the number value of the web message. 2389 * @returns { number } - Returns data of number type 2390 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2391 * 2392 * @syscap SystemCapability.Web.Webview.Core 2393 * @atomicservice 2394 * @since 11 2395 */ 2396 /** 2397 * Get the number value of the web message. 2398 * @returns { number } - Returns data of number type 2399 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2400 * 2401 * @syscap SystemCapability.Web.Webview.Core 2402 * @crossplatform 2403 * @atomicservice 2404 * @since 18 2405 */ 2406 getNumber(): number; 2407 2408 /** 2409 * Get the boolean value of the web message. 2410 * @returns { boolean } - Returns data of Boolean type 2411 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2412 * 2413 * @syscap SystemCapability.Web.Webview.Core 2414 * @since 10 2415 */ 2416 /** 2417 * Get the boolean value of the web message. 2418 * @returns { boolean } - Returns data of Boolean type 2419 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2420 * 2421 * @syscap SystemCapability.Web.Webview.Core 2422 * @atomicservice 2423 * @since 11 2424 */ 2425 /** 2426 * Get the boolean value of the web message. 2427 * @returns { boolean } - Returns data of Boolean type 2428 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2429 * 2430 * @syscap SystemCapability.Web.Webview.Core 2431 * @crossplatform 2432 * @atomicservice 2433 * @since 18 2434 */ 2435 getBoolean(): boolean; 2436 2437 /** 2438 * Get the array buffer value of the web message. 2439 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 2440 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2441 * 2442 * @syscap SystemCapability.Web.Webview.Core 2443 * @since 10 2444 */ 2445 /** 2446 * Get the array buffer value of the web message. 2447 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 2448 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2449 * 2450 * @syscap SystemCapability.Web.Webview.Core 2451 * @atomicservice 2452 * @since 11 2453 */ 2454 getArrayBuffer(): ArrayBuffer; 2455 2456 /** 2457 * Get the array value of the web message. 2458 * @returns { Array<string | number | boolean> } - Returns data of Array type 2459 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2460 * 2461 * @syscap SystemCapability.Web.Webview.Core 2462 * @since 10 2463 */ 2464 /** 2465 * Get the array value of the web message. 2466 * @returns { Array<string | number | boolean> } - Returns data of Array type 2467 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2468 * 2469 * @syscap SystemCapability.Web.Webview.Core 2470 * @atomicservice 2471 * @since 11 2472 */ 2473 /** 2474 * Get the array value of the web message. 2475 * @returns { Array<string | number | boolean> } - Returns data of Array type 2476 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2477 * 2478 * @syscap SystemCapability.Web.Webview.Core 2479 * @crossplatform 2480 * @atomicservice 2481 * @since 18 2482 */ 2483 getArray(): Array<string | number | boolean>; 2484 2485 /** 2486 * Get the error value of the web message. 2487 * @returns { Error } - Returns data of Error type 2488 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2489 * 2490 * @syscap SystemCapability.Web.Webview.Core 2491 * @since 10 2492 */ 2493 /** 2494 * Get the error value of the web message. 2495 * @returns { Error } - Returns data of Error type 2496 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2497 * 2498 * @syscap SystemCapability.Web.Webview.Core 2499 * @atomicservice 2500 * @since 11 2501 */ 2502 /** 2503 * Get the error value of the web message. 2504 * @returns { Error } - Returns data of Error type 2505 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2506 * 2507 * @syscap SystemCapability.Web.Webview.Core 2508 * @crossplatform 2509 * @atomicservice 2510 * @since 18 2511 */ 2512 getError(): Error; 2513 2514 /** 2515 * Set the type of the web message. 2516 * @param { WebMessageType } type - set WebMessageType type data 2517 * @throws { BusinessError } 401 - Invalid input parameter. 2518 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2519 * 2520 * @syscap SystemCapability.Web.Webview.Core 2521 * @since 10 2522 */ 2523 /** 2524 * Set the type of the web message. 2525 * @param { WebMessageType } type - set WebMessageType type data 2526 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2527 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2528 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2529 * 2530 * @syscap SystemCapability.Web.Webview.Core 2531 * @atomicservice 2532 * @since 11 2533 */ 2534 /** 2535 * Set the type of the web message. 2536 * @param { WebMessageType } type - set WebMessageType type data 2537 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2538 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2539 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2540 * 2541 * @syscap SystemCapability.Web.Webview.Core 2542 * @crossplatform 2543 * @atomicservice 2544 * @since 18 2545 */ 2546 setType(type: WebMessageType): void; 2547 2548 /** 2549 * Set the string value of the web message. 2550 * @param { string } message - set string type data 2551 * @throws { BusinessError } 401 - Invalid input parameter. 2552 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2553 * 2554 * @syscap SystemCapability.Web.Webview.Core 2555 * @since 10 2556 */ 2557 /** 2558 * Set the string value of the web message. 2559 * @param { string } message - set string type data 2560 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2561 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2562 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2563 * 2564 * @syscap SystemCapability.Web.Webview.Core 2565 * @atomicservice 2566 * @since 11 2567 */ 2568 /** 2569 * Set the string value of the web message. 2570 * @param { string } message - set string type data 2571 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2572 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2573 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2574 * 2575 * @syscap SystemCapability.Web.Webview.Core 2576 * @crossplatform 2577 * @atomicservice 2578 * @since 18 2579 */ 2580 setString(message: string): void; 2581 2582 /** 2583 * Set the number value of the web message. 2584 * @param { number } message - set number type data 2585 * @throws { BusinessError } 401 - Invalid input parameter. 2586 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2587 * 2588 * @syscap SystemCapability.Web.Webview.Core 2589 * @since 10 2590 */ 2591 /** 2592 * Set the number value of the web message. 2593 * @param { number } message - set number type data 2594 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2595 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2596 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2597 * 2598 * @syscap SystemCapability.Web.Webview.Core 2599 * @atomicservice 2600 * @since 11 2601 */ 2602 /** 2603 * Set the number value of the web message. 2604 * @param { number } message - set number type data 2605 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2606 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2607 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2608 * 2609 * @syscap SystemCapability.Web.Webview.Core 2610 * @crossplatform 2611 * @atomicservice 2612 * @since 18 2613 */ 2614 setNumber(message: number): void; 2615 2616 /** 2617 * Set the boolean value of the web message. 2618 * @param { boolean } message - set boolean type data 2619 * @throws { BusinessError } 401 - Invalid input parameter. 2620 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2621 * 2622 * @syscap SystemCapability.Web.Webview.Core 2623 * @since 10 2624 */ 2625 /** 2626 * Set the boolean value of the web message. 2627 * @param { boolean } message - set boolean type data 2628 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2629 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2630 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2631 * 2632 * @syscap SystemCapability.Web.Webview.Core 2633 * @atomicservice 2634 * @since 11 2635 */ 2636 /** 2637 * Set the boolean value of the web message. 2638 * @param { boolean } message - set boolean type data 2639 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2640 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2641 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2642 * 2643 * @syscap SystemCapability.Web.Webview.Core 2644 * @crossplatform 2645 * @atomicservice 2646 * @since 18 2647 */ 2648 setBoolean(message: boolean): void; 2649 2650 /** 2651 * Set the array buffer value of the web message. 2652 * @param { ArrayBuffer } message - set ArrayBuffer type data 2653 * @throws { BusinessError } 401 - Invalid input parameter. 2654 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2655 * 2656 * @syscap SystemCapability.Web.Webview.Core 2657 * @since 10 2658 */ 2659 /** 2660 * Set the array buffer value of the web message. 2661 * @param { ArrayBuffer } message - set ArrayBuffer type data 2662 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2663 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2664 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2665 * 2666 * @syscap SystemCapability.Web.Webview.Core 2667 * @atomicservice 2668 * @since 11 2669 */ 2670 setArrayBuffer(message: ArrayBuffer): void; 2671 2672 /** 2673 * Set the array value of the web message. 2674 * @param { Array<string | number | boolean> } message - set Array type data 2675 * @throws { BusinessError } 401 - Invalid input parameter. 2676 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2677 * @syscap SystemCapability.Web.Webview.Core 2678 * @since 10 2679 */ 2680 /** 2681 * Set the array value of the web message. 2682 * @param { Array<string | number | boolean> } message - set Array type data 2683 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2684 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2685 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2686 * @syscap SystemCapability.Web.Webview.Core 2687 * @atomicservice 2688 * @since 11 2689 */ 2690 /** 2691 * Set the array value of the web message. 2692 * @param { Array<string | number | boolean> } message - set Array type data 2693 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2694 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2695 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2696 * @syscap SystemCapability.Web.Webview.Core 2697 * @crossplatform 2698 * @atomicservice 2699 * @since 18 2700 */ 2701 setArray(message: Array<string | number | boolean>): void; 2702 2703 /** 2704 * Set the error value of the web message. 2705 * @param { Error } message - set Error type data 2706 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2707 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2708 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2709 * 2710 * @syscap SystemCapability.Web.Webview.Core 2711 * @since 10 2712 */ 2713 /** 2714 * Set the error value of the web message. 2715 * @param { Error } message - set Error type data 2716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2717 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2718 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2719 * 2720 * @syscap SystemCapability.Web.Webview.Core 2721 * @atomicservice 2722 * @since 11 2723 */ 2724 /** 2725 * Set the error value of the web message. 2726 * @param { Error } message - set Error type data 2727 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2728 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2729 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2730 * 2731 * @syscap SystemCapability.Web.Webview.Core 2732 * @crossplatform 2733 * @atomicservice 2734 * @since 18 2735 */ 2736 setError(message: Error): void; 2737 } 2738 2739 /** 2740 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 2741 * 2742 * @syscap SystemCapability.Web.Webview.Core 2743 * @since 9 2744 */ 2745 /** 2746 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 2747 * 2748 * @typedef { ArrayBuffer | string } 2749 * @syscap SystemCapability.Web.Webview.Core 2750 * @atomicservice 2751 * @since 11 2752 */ 2753 type WebMessage = ArrayBuffer | string; 2754 /** 2755 * Define html web message port. 2756 * @interface WebMessagePort 2757 * @syscap SystemCapability.Web.Webview.Core 2758 * @since 9 2759 */ 2760 /** 2761 * Define html web message port. 2762 * @interface WebMessagePort 2763 * @syscap SystemCapability.Web.Webview.Core 2764 * @crossplatform 2765 * @atomicservice 2766 * @since 11 2767 */ 2768 /** 2769 * Define html web message port. 2770 * @typedef WebMessagePort 2771 * @syscap SystemCapability.Web.Webview.Core 2772 * @crossplatform 2773 * @atomicservice 2774 * @since 12 2775 */ 2776 interface WebMessagePort { 2777 /** 2778 * The flag indicates whether more formats are supported than string and array buffers. 2779 * 2780 * @syscap SystemCapability.Web.Webview.Core 2781 * @since 10 2782 */ 2783 /** 2784 * The flag indicates whether more formats are supported than string and array buffers. 2785 * 2786 * @type { ?boolean } 2787 * @syscap SystemCapability.Web.Webview.Core 2788 * @atomicservice 2789 * @since 11 2790 */ 2791 isExtentionType?: boolean; 2792 2793 /** 2794 * Close port. 2795 * @syscap SystemCapability.Web.Webview.Core 2796 * @since 9 2797 */ 2798 /** 2799 * Close port. 2800 * @syscap SystemCapability.Web.Webview.Core 2801 * @crossplatform 2802 * @atomicservice 2803 * @since 11 2804 */ 2805 close(): void; 2806 2807 /** 2808 * Post a message to other port. 2809 * @param { WebMessage } message - Message to send. 2810 * @throws { BusinessError } 401 - Invalid input parameter. 2811 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2812 * @syscap SystemCapability.Web.Webview.Core 2813 * @since 9 2814 */ 2815 /** 2816 * Post a message to other port. 2817 * @param { WebMessage } message - Message to send. 2818 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2819 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2820 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2821 * @syscap SystemCapability.Web.Webview.Core 2822 * @crossplatform 2823 * @atomicservice 2824 * @since 11 2825 */ 2826 postMessageEvent(message: WebMessage): void; 2827 2828 /** 2829 * Receive message from other port. 2830 * @param { function } callback - Callback function for receiving messages. 2831 * @throws { BusinessError } 401 - Invalid input parameter. 2832 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2833 * @syscap SystemCapability.Web.Webview.Core 2834 * @since 9 2835 */ 2836 /** 2837 * Receive message from other port. 2838 * @param { function } callback - Callback function for receiving messages. 2839 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2840 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2841 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2842 * @syscap SystemCapability.Web.Webview.Core 2843 * @crossplatform 2844 * @atomicservice 2845 * @since 11 2846 */ 2847 onMessageEvent(callback: (result: WebMessage) => void): void; 2848 2849 /** 2850 * Post a message to other port. 2851 * @param { WebMessageExt } message - Message to send. 2852 * @throws { BusinessError } 401 - Invalid input parameter. 2853 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2854 * @syscap SystemCapability.Web.Webview.Core 2855 * @since 10 2856 */ 2857 /** 2858 * Post a message to other port. 2859 * @param { WebMessageExt } message - Message to send. 2860 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2861 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2862 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2863 * @syscap SystemCapability.Web.Webview.Core 2864 * @atomicservice 2865 * @since 11 2866 */ 2867 /** 2868 * Post a message to other port. 2869 * @param { WebMessageExt } message - Message to send. 2870 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2871 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2872 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2873 * @syscap SystemCapability.Web.Webview.Core 2874 * @crossplatform 2875 * @atomicservice 2876 * @since 18 2877 */ 2878 postMessageEventExt(message: WebMessageExt): void; 2879 2880 /** 2881 * Receive message from other port. 2882 * @param { function } callback - Callback function for receiving messages. 2883 * @throws { BusinessError } 401 - Invalid input parameter. 2884 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2885 * @syscap SystemCapability.Web.Webview.Core 2886 * @since 10 2887 */ 2888 /** 2889 * Receive message from other port. 2890 * @param { function } callback - Callback function for receiving messages. 2891 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2892 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2893 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2894 * @syscap SystemCapability.Web.Webview.Core 2895 * @atomicservice 2896 * @since 11 2897 */ 2898 /** 2899 * Receive message from other port. 2900 * @param { function } callback - Callback function for receiving messages. 2901 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2902 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2903 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2904 * @syscap SystemCapability.Web.Webview.Core 2905 * @crossplatform 2906 * @atomicservice 2907 * @since 18 2908 */ 2909 onMessageEventExt(callback: (result: WebMessageExt) => void): void; 2910 } 2911 2912 /** 2913 * Provides information for history item in BackForwardList. 2914 * @interface HistoryItem 2915 * @syscap SystemCapability.Web.Webview.Core 2916 * @since 9 2917 */ 2918 /** 2919 * Provides information for history item in BackForwardList. 2920 * @interface HistoryItem 2921 * @syscap SystemCapability.Web.Webview.Core 2922 * @crossplatform 2923 * @atomicservice 2924 * @since 11 2925 */ 2926 /** 2927 * Provides information for history item in BackForwardList. 2928 * @typedef HistoryItem 2929 * @syscap SystemCapability.Web.Webview.Core 2930 * @crossplatform 2931 * @atomicservice 2932 * @since 12 2933 */ 2934 interface HistoryItem { 2935 /** 2936 * Pixelmap of icon. 2937 * @syscap SystemCapability.Web.Webview.Core 2938 * @since 9 2939 */ 2940 /** 2941 * Pixelmap of icon. 2942 * @type { image.PixelMap } 2943 * @syscap SystemCapability.Web.Webview.Core 2944 * @atomicservice 2945 * @since 11 2946 */ 2947 icon: image.PixelMap; 2948 2949 /** 2950 * Url of this history item. 2951 * @syscap SystemCapability.Web.Webview.Core 2952 * @since 9 2953 */ 2954 /** 2955 * Url of this history item. 2956 * @type { string } 2957 * @syscap SystemCapability.Web.Webview.Core 2958 * @crossplatform 2959 * @atomicservice 2960 * @since 11 2961 */ 2962 historyUrl: string; 2963 2964 /** 2965 * Original request url of this history item. 2966 * @syscap SystemCapability.Web.Webview.Core 2967 * @since 9 2968 */ 2969 /** 2970 * Original request url of this history item. 2971 * @type { string } 2972 * @syscap SystemCapability.Web.Webview.Core 2973 * @crossplatform 2974 * @atomicservice 2975 * @since 11 2976 */ 2977 historyRawUrl: string; 2978 2979 /** 2980 * Title of this history item. 2981 * @syscap SystemCapability.Web.Webview.Core 2982 * @since 9 2983 */ 2984 /** 2985 * Title of this history item. 2986 * @type { string } 2987 * @syscap SystemCapability.Web.Webview.Core 2988 * @crossplatform 2989 * @atomicservice 2990 * @since 11 2991 */ 2992 title: string; 2993 } 2994 2995 /** 2996 * Provides back and forward history list information method. related to {@link HistoryItem}. 2997 * @interface BackForwardList 2998 * @syscap SystemCapability.Web.Webview.Core 2999 * @since 9 3000 */ 3001 /** 3002 * Provides back and forward history list information method. related to {@link HistoryItem}. 3003 * @interface BackForwardList 3004 * @syscap SystemCapability.Web.Webview.Core 3005 * @crossplatform 3006 * @atomicservice 3007 * @since 11 3008 */ 3009 /** 3010 * Provides back and forward history list information method. related to {@link HistoryItem}. 3011 * @typedef BackForwardList 3012 * @syscap SystemCapability.Web.Webview.Core 3013 * @crossplatform 3014 * @atomicservice 3015 * @since 12 3016 */ 3017 interface BackForwardList { 3018 /** 3019 * Current index in BackForwardList. 3020 * @syscap SystemCapability.Web.Webview.Core 3021 * @since 9 3022 */ 3023 /** 3024 * Current index in BackForwardList. 3025 * @type { number } 3026 * @syscap SystemCapability.Web.Webview.Core 3027 * @crossplatform 3028 * @atomicservice 3029 * @since 11 3030 */ 3031 currentIndex: number; 3032 3033 /** 3034 * Size of in BackForwardList. 3035 * @syscap SystemCapability.Web.Webview.Core 3036 * @since 9 3037 */ 3038 /** 3039 * Size of in BackForwardList. 3040 * @type { number } 3041 * @syscap SystemCapability.Web.Webview.Core 3042 * @crossplatform 3043 * @atomicservice 3044 * @since 11 3045 */ 3046 size: number; 3047 3048 /** 3049 * Get history entry at given index. 3050 * 3051 * @param { number } index Index of back forward list entry. 3052 * @returns { HistoryItem } HistoryItem at given index in back forward list. 3053 * @throws { BusinessError } 401 - Invalid input parameter. 3054 * @syscap SystemCapability.Web.Webview.Core 3055 * @since 9 3056 */ 3057 /** 3058 * Get history entry at given index. 3059 * 3060 * @param { number } index Index of back forward list entry. 3061 * @returns { HistoryItem } HistoryItem at given index in back forward list. 3062 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3063 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3064 * @syscap SystemCapability.Web.Webview.Core 3065 * @crossplatform 3066 * @atomicservice 3067 * @since 11 3068 */ 3069 getItemAtIndex(index: number): HistoryItem; 3070 } 3071 3072 /** 3073 * Defines the snapshot info. 3074 * 3075 * @typedef SnapshotInfo 3076 * @syscap SystemCapability.Web.Webview.Core 3077 * @atomicservice 3078 * @since 12 3079 */ 3080 interface SnapshotInfo { 3081 /** 3082 * Id of the snapshot. 3083 * 3084 * @type { ?string } 3085 * @syscap SystemCapability.Web.Webview.Core 3086 * @atomicservice 3087 * @since 12 3088 */ 3089 id?: string; 3090 3091 /** 3092 * Size of the web. 3093 * 3094 * @type { ?SizeOptions } 3095 * @syscap SystemCapability.Web.Webview.Core 3096 * @atomicservice 3097 * @since 12 3098 */ 3099 size?: SizeOptions; 3100 } 3101 3102 /** 3103 * Defines the snapshot result. 3104 * 3105 * @typedef SnapshotResult 3106 * @syscap SystemCapability.Web.Webview.Core 3107 * @atomicservice 3108 * @since 12 3109 */ 3110 interface SnapshotResult { 3111 /** 3112 * Id of the snapshot. 3113 * 3114 * @type { ?string } 3115 * @syscap SystemCapability.Web.Webview.Core 3116 * @atomicservice 3117 * @since 12 3118 */ 3119 id?: string; 3120 3121 /** 3122 * The status of the snapshot. 3123 * 3124 * @type { ?boolean } 3125 * @syscap SystemCapability.Web.Webview.Core 3126 * @atomicservice 3127 * @since 12 3128 */ 3129 status?: boolean; 3130 3131 /** 3132 * Size of the web. 3133 * 3134 * @type { ?SizeOptions } 3135 * @syscap SystemCapability.Web.Webview.Core 3136 * @atomicservice 3137 * @since 12 3138 */ 3139 size?: SizeOptions; 3140 3141 /** 3142 * The image in PixelMap format. 3143 * 3144 * @type { ?image.PixelMap } 3145 * @syscap SystemCapability.Web.Webview.Core 3146 * @atomicservice 3147 * @since 12 3148 */ 3149 imagePixelMap?: image.PixelMap; 3150 } 3151 /** 3152 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 3153 * @enum {number} 3154 * @syscap SystemCapability.Web.Webview.Core 3155 * @since 10 3156 */ 3157 /** 3158 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 3159 * @enum {number} 3160 * @syscap SystemCapability.Web.Webview.Core 3161 * @atomicservice 3162 * @since 11 3163 */ 3164 /** 3165 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 3166 * @enum {number} 3167 * @syscap SystemCapability.Web.Webview.Core 3168 * @crossplatform 3169 * @atomicservice 3170 * @since 18 3171 */ 3172 enum JsMessageType { 3173 /** 3174 * Unsupported data type. 3175 * @syscap SystemCapability.Web.Webview.Core 3176 * @since 10 3177 */ 3178 /** 3179 * Unsupported data type. 3180 * @syscap SystemCapability.Web.Webview.Core 3181 * @atomicservice 3182 * @since 11 3183 */ 3184 NOT_SUPPORT, 3185 3186 /** 3187 * The string data type. 3188 * @syscap SystemCapability.Web.Webview.Core 3189 * @since 10 3190 */ 3191 /** 3192 * The string data type. 3193 * @syscap SystemCapability.Web.Webview.Core 3194 * @atomicservice 3195 * @since 11 3196 */ 3197 /** 3198 * The string data type. 3199 * @syscap SystemCapability.Web.Webview.Core 3200 * @crossplatform 3201 * @atomicservice 3202 * @since 18 3203 */ 3204 STRING, 3205 3206 /** 3207 * The number data type. 3208 * @syscap SystemCapability.Web.Webview.Core 3209 * @since 10 3210 */ 3211 /** 3212 * The number data type. 3213 * @syscap SystemCapability.Web.Webview.Core 3214 * @atomicservice 3215 * @since 11 3216 */ 3217 /** 3218 * The number data type. 3219 * @syscap SystemCapability.Web.Webview.Core 3220 * @crossplatform 3221 * @atomicservice 3222 * @since 18 3223 */ 3224 NUMBER, 3225 3226 /** 3227 * The boolean data type. 3228 * @syscap SystemCapability.Web.Webview.Core 3229 * @since 10 3230 */ 3231 /** 3232 * The boolean data type. 3233 * @syscap SystemCapability.Web.Webview.Core 3234 * @atomicservice 3235 * @since 11 3236 */ 3237 /** 3238 * The boolean data type. 3239 * @syscap SystemCapability.Web.Webview.Core 3240 * @crossplatform 3241 * @atomicservice 3242 * @since 18 3243 */ 3244 BOOLEAN, 3245 3246 /** 3247 * The arraybuffer data type. 3248 * @syscap SystemCapability.Web.Webview.Core 3249 * @since 10 3250 */ 3251 /** 3252 * The arraybuffer data type. 3253 * @syscap SystemCapability.Web.Webview.Core 3254 * @atomicservice 3255 * @since 11 3256 */ 3257 ARRAY_BUFFER, 3258 3259 /** 3260 * The array data type. 3261 * @syscap SystemCapability.Web.Webview.Core 3262 * @since 10 3263 */ 3264 /** 3265 * The array data type. 3266 * @syscap SystemCapability.Web.Webview.Core 3267 * @atomicservice 3268 * @since 11 3269 */ 3270 /** 3271 * The array data type. 3272 * @syscap SystemCapability.Web.Webview.Core 3273 * @crossplatform 3274 * @atomicservice 3275 * @since 18 3276 */ 3277 ARRAY 3278 } 3279 3280 /** 3281 * The message for indicating the of result of JavaScript code execution. 3282 * @syscap SystemCapability.Web.Webview.Core 3283 * @since 10 3284 */ 3285 /** 3286 * The message for indicating the of result of JavaScript code execution. 3287 * @syscap SystemCapability.Web.Webview.Core 3288 * @atomicservice 3289 * @since 11 3290 */ 3291 /** 3292 * The message for indicating the of result of JavaScript code execution. 3293 * @syscap SystemCapability.Web.Webview.Core 3294 * @crossplatform 3295 * @atomicservice 3296 * @since 18 3297 */ 3298 class JsMessageExt { 3299 /** 3300 * Get the type of the JavaScript code execution result. 3301 * @returns { JsMessageType } - Returns data of JsMessageType type 3302 * @syscap SystemCapability.Web.Webview.Core 3303 * @since 10 3304 */ 3305 /** 3306 * Get the type of the JavaScript code execution result. 3307 * @returns { JsMessageType } - Returns data of JsMessageType type 3308 * @syscap SystemCapability.Web.Webview.Core 3309 * @atomicservice 3310 * @since 11 3311 */ 3312 /** 3313 * Get the type of the JavaScript code execution result. 3314 * @returns { JsMessageType } - Returns data of JsMessageType type 3315 * @syscap SystemCapability.Web.Webview.Core 3316 * @crossplatform 3317 * @atomicservice 3318 * @since 18 3319 */ 3320 getType(): JsMessageType; 3321 3322 /** 3323 * Get the string value of the JavaScript code execution result. 3324 * @returns { string } - Returns data of string type 3325 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3326 * @syscap SystemCapability.Web.Webview.Core 3327 * @since 10 3328 */ 3329 /** 3330 * Get the string value of the JavaScript code execution result. 3331 * @returns { string } - Returns data of string type 3332 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3333 * @syscap SystemCapability.Web.Webview.Core 3334 * @atomicservice 3335 * @since 11 3336 */ 3337 /** 3338 * Get the string value of the JavaScript code execution result. 3339 * @returns { string } - Returns data of string type 3340 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3341 * @syscap SystemCapability.Web.Webview.Core 3342 * @crossplatform 3343 * @atomicservice 3344 * @since 18 3345 */ 3346 getString(): string; 3347 3348 /** 3349 * Get the number value of the JavaScript code execution result. 3350 * @returns { number } - Returns data of number type 3351 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3352 * @syscap SystemCapability.Web.Webview.Core 3353 * @since 10 3354 */ 3355 /** 3356 * Get the number value of the JavaScript code execution result. 3357 * @returns { number } - Returns data of number type 3358 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3359 * @syscap SystemCapability.Web.Webview.Core 3360 * @atomicservice 3361 * @since 11 3362 */ 3363 /** 3364 * Get the number value of the JavaScript code execution result. 3365 * @returns { number } - Returns data of number type 3366 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3367 * @syscap SystemCapability.Web.Webview.Core 3368 * @crossplatform 3369 * @atomicservice 3370 * @since 18 3371 */ 3372 getNumber(): number; 3373 3374 /** 3375 * Get the boolean value of the JavaScript code execution result. 3376 * @returns { boolean } - Returns data of Boolean type 3377 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3378 * @syscap SystemCapability.Web.Webview.Core 3379 * @since 10 3380 */ 3381 /** 3382 * Get the boolean value of the JavaScript code execution result. 3383 * @returns { boolean } - Returns data of Boolean type 3384 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3385 * @syscap SystemCapability.Web.Webview.Core 3386 * @atomicservice 3387 * @since 11 3388 */ 3389 /** 3390 * Get the boolean value of the JavaScript code execution result. 3391 * @returns { boolean } - Returns data of Boolean type 3392 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3393 * @syscap SystemCapability.Web.Webview.Core 3394 * @crossplatform 3395 * @atomicservice 3396 * @since 18 3397 */ 3398 getBoolean(): boolean; 3399 3400 /** 3401 * Get the array buffer value of the JavaScript code execution result. 3402 * @returns { ArrayBuffer } - Returns data of ArrayBuffer 3403 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3404 * @syscap SystemCapability.Web.Webview.Core 3405 * @since 10 3406 */ 3407 /** 3408 * Get the array buffer value of the JavaScript code execution result. 3409 * @returns { ArrayBuffer } - Returns data of ArrayBuffer 3410 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3411 * @syscap SystemCapability.Web.Webview.Core 3412 * @atomicservice 3413 * @since 11 3414 */ 3415 getArrayBuffer(): ArrayBuffer; 3416 3417 /** 3418 * Get the array value of the the JavaScript code execution result. 3419 * @returns { Array<string | number | boolean> } - Returns data of Array type 3420 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3421 * @syscap SystemCapability.Web.Webview.Core 3422 * @since 10 3423 */ 3424 /** 3425 * Get the array value of the the JavaScript code execution result. 3426 * @returns { Array<string | number | boolean> } - Returns data of Array type 3427 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3428 * @syscap SystemCapability.Web.Webview.Core 3429 * @atomicservice 3430 * @since 11 3431 */ 3432 /** 3433 * Get the array value of the the JavaScript code execution result. 3434 * @returns { Array<string | number | boolean> } - Returns data of Array type 3435 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 3436 * @syscap SystemCapability.Web.Webview.Core 3437 * @crossplatform 3438 * @atomicservice 3439 * @since 18 3440 */ 3441 getArray(): Array<string | number | boolean>; 3442 } 3443 3444 /** 3445 * Defines the render process mode. 3446 * 3447 * @enum {number} 3448 * @syscap SystemCapability.Web.Webview.Core 3449 * @atomicservice 3450 * @since 12 3451 */ 3452 enum RenderProcessMode { 3453 /** 3454 * ArkWeb single rendering subprocess mode. In this mode, multiple Web pages reuse a rendering subprocess. 3455 * 3456 * @syscap SystemCapability.Web.Webview.Core 3457 * @atomicservice 3458 * @since 12 3459 */ 3460 SINGLE = 0, 3461 3462 /** 3463 * ArkWeb multi-rendering subprocess mode. In this mode, there is one rendering subprocess per Web. 3464 * 3465 * @syscap SystemCapability.Web.Webview.Core 3466 * @atomicservice 3467 * @since 12 3468 */ 3469 MULTIPLE, 3470 } 3471 3472 /** 3473 * Options of generating code cache 3474 * @typedef CacheOptions 3475 * @syscap SystemCapability.Web.Webview.Core 3476 * @since 12 3477 */ 3478 interface CacheOptions { 3479 /** 3480 * Response headers used to configure the validation key of code cache. 3481 * Currently only support E-Tag and Last-Modified. 3482 * 3483 * @type { Array<WebHeader> } 3484 * @syscap SystemCapability.Web.Webview.Core 3485 * @since 12 3486 */ 3487 responseHeaders: Array<WebHeader>; 3488 } 3489 3490 /** 3491 * Enum type supplied to {@link OfflineResourceMap} for indicating the type of resource. 3492 * @enum {number} 3493 * @syscap SystemCapability.Web.Webview.Core 3494 * @since 12 3495 */ 3496 enum OfflineResourceType { 3497 /** 3498 * Resource of the image type. 3499 * 3500 * @syscap SystemCapability.Web.Webview.Core 3501 * @since 12 3502 */ 3503 IMAGE, 3504 3505 /** 3506 * Resource of the CSS type. 3507 * 3508 * @syscap SystemCapability.Web.Webview.Core 3509 * @since 12 3510 */ 3511 CSS, 3512 3513 /** 3514 * Javascript resource loaded through the <script src="" /> tag. 3515 * 3516 * @syscap SystemCapability.Web.Webview.Core 3517 * @since 12 3518 */ 3519 CLASSIC_JS, 3520 3521 /** 3522 * Javascript resource loaded through the <script src="" type="module" /> tag. 3523 * 3524 * @syscap SystemCapability.Web.Webview.Core 3525 * @since 12 3526 */ 3527 MODULE_JS 3528 } 3529 3530 /** 3531 * Define offline resource's content and info. 3532 * @typedef OfflineResourceMap 3533 * @syscap SystemCapability.Web.Webview.Core 3534 * @since 12 3535 */ 3536 interface OfflineResourceMap { 3537 /** 3538 * Url list of resource. Url of urlList must be HTTP/HTTPS protocol and no longer than 2048. 3539 * 3540 * @type { Array<string> } 3541 * @syscap SystemCapability.Web.Webview.Core 3542 * @since 12 3543 */ 3544 urlList: Array<string>, 3545 3546 /** 3547 * Arraybuffer of resource. Size must less than 10Mb and cannot be empty. 3548 * 3549 * @type { Uint8Array } 3550 * @syscap SystemCapability.Web.Webview.Core 3551 * @since 12 3552 */ 3553 resource: Uint8Array, 3554 3555 /** 3556 * Response headers of resource. 3557 * 3558 * @type { Array<WebHeader> } 3559 * @syscap SystemCapability.Web.Webview.Core 3560 * @since 12 3561 */ 3562 responseHeaders: Array<WebHeader>, 3563 3564 /** 3565 * Resource type 3566 * 3567 * @type { OfflineResourceType } 3568 * @syscap SystemCapability.Web.Webview.Core 3569 * @since 12 3570 */ 3571 type: OfflineResourceType 3572 } 3573 3574 /** 3575 * Enum type supplied to {@link setScrollable} for indicating the type of scroll. 3576 * 3577 * @enum { number } 3578 * @syscap SystemCapability.Web.Webview.Core 3579 * @since 12 3580 */ 3581 enum ScrollType { 3582 /** 3583 * Indicates scrolling the web page through scroll event, include touch screen, touch pad, and mouse wheel. 3584 * 3585 * @syscap SystemCapability.Web.Webview.Core 3586 * @since 12 3587 */ 3588 EVENT 3589 } 3590 3591 /** 3592 * Enum type supplied to {@link getAttachState} for indicating the attach state of controller. 3593 * 3594 * @enum { number } 3595 * @syscap SystemCapability.Web.Webview.Core 3596 * @since 20 3597 */ 3598 enum ControllerAttachState { 3599 /** 3600 * Indicates webviewController is not attached a web component. 3601 * 3602 * @syscap SystemCapability.Web.Webview.Core 3603 * @since 20 3604 */ 3605 UNATTACHED = 0, 3606 3607 /** 3608 * Indicates webviewController is attached a web component. 3609 * 3610 * @syscap SystemCapability.Web.Webview.Core 3611 * @since 20 3612 */ 3613 ATTACHED = 1 3614 } 3615 3616 /** 3617 * Enumerates the error codes of blankless. For details, see {@link setBlanklessLoadingWithKey} or {@link 3618 * BlanklessInfo}. 3619 * 3620 * @enum { number } 3621 * @syscap SystemCapability.Web.Webview.Core 3622 * @since 20 3623 */ 3624 enum WebBlanklessErrorCode { 3625 /** 3626 * The operation is successful. 3627 * 3628 * @syscap SystemCapability.Web.Webview.Core 3629 * @since 20 3630 */ 3631 SUCCESS = 0, 3632 3633 /** 3634 * Unknown error. 3635 * 3636 * @syscap SystemCapability.Web.Webview.Core 3637 * @since 20 3638 */ 3639 ERR_UNKNOWN = -1, 3640 3641 /** 3642 * Invalid parameter. 3643 * 3644 * @syscap SystemCapability.Web.Webview.Core 3645 * @since 20 3646 */ 3647 ERR_INVALID_PARAM = -2, 3648 3649 /** 3650 * The web controller is not bound to any component. 3651 * 3652 * @syscap SystemCapability.Web.Webview.Core 3653 * @since 20 3654 */ 3655 ERR_CONTROLLER_NOT_INITED = -3, 3656 3657 /** 3658 * The key value is not matched. This error code is returned when the key values of 3659 * setBlanklessLodingWithKey and getBlanklessInfoWithKey are not matched. 3660 * 3661 * @syscap SystemCapability.Web.Webview.Core 3662 * @since 20 3663 */ 3664 ERR_KEY_NOT_MATCH = -4, 3665 3666 /** 3667 * The system determines that the change is too large when the similarity is less than 0.33. As a result, 3668 * the setBlanklessLodingWithKey API fails to enable frame interpolation. 3669 * 3670 * @syscap SystemCapability.Web.Webview.Core 3671 * @since 20 3672 */ 3673 ERR_SIGNIFICANT_CHANGE = -5 3674 } 3675 3676 /** 3677 * Defines the blankless information. 3678 * 3679 * @typedef BlanklessInfo 3680 * @syscap SystemCapability.Web.Webview.Core 3681 * @since 20 3682 */ 3683 interface BlanklessInfo { 3684 /** 3685 * Defines the error codes of blankless. 3686 * @type { WebBlanklessErrorCode } 3687 * @syscap SystemCapability.Web.Webview.Core 3688 * @since 20 3689 */ 3690 errCode: WebBlanklessErrorCode; 3691 3692 /** 3693 * Obtains the similarity of snapshots generated by the blankless loading solution based on the last 3694 * several snapshots. The value ranges from 0 to 1.0. The value 1.0 indicates that the snapshots are the same. A 3695 * value closer to 1 indicates higher similarity. This value has a certain lag, meaning that the similarity of 3696 * the current loading will only be reflected in the next loading. It is recommended that the frame interpolation 3697 * functionality be disabled when the similarity is 0. 3698 * @type { number } 3699 * @syscap SystemCapability.Web.Webview.Core 3700 * @since 20 3701 */ 3702 similarity: number; 3703 3704 /** 3705 * Obtains the loading time based on the historical loading time. The unit is ms and the value is greater 3706 * than 0. 3707 * 3708 * @type { number } 3709 * @syscap SystemCapability.Web.Webview.Core 3710 * @since 20 3711 */ 3712 loadingTime: number; 3713 } 3714 3715 /** 3716 * Provides methods for controlling the web controller. 3717 * @syscap SystemCapability.Web.Webview.Core 3718 * @since 9 3719 */ 3720 /** 3721 * Provides methods for controlling the web controller. 3722 * @syscap SystemCapability.Web.Webview.Core 3723 * @crossplatform 3724 * @since 10 3725 */ 3726 /** 3727 * WebviewController can control various behaviors of Web components 3728 * (including page navigation, declaring cycle state, JavaScript interaction and so on). 3729 * A WebviewController object can only control one Web component, 3730 * and methods on the Webviewcontroller (except static methods) can only be called 3731 * after the web component is bound to the WebviewController. 3732 * @syscap SystemCapability.Web.Webview.Core 3733 * @crossplatform 3734 * @atomicservice 3735 * @since arkts {'1.1':'11', '1.2':'20'} 3736 * @arkts 1.1&1.2 3737 */ 3738 class WebviewController { 3739 /** 3740 * A constructor used to create a WebviewController object. 3741 * 3742 * @param { string } [webTag] - specified the name of the web component, Empty by default. 3743 * @syscap SystemCapability.Web.Webview.Core 3744 * @atomicservice 3745 * @since arkts {'1.1':'11', '1.2':'20'} 3746 * @arkts 1.1&1.2 3747 */ 3748 constructor(webTag?: string); 3749 3750 /** 3751 * Initialize the web engine before loading the Web components. 3752 * This is a global static API that must be called on the UI thread, and it will have no effect if any 3753 * Web components are loaded. 3754 * @syscap SystemCapability.Web.Webview.Core 3755 * @since 9 3756 */ 3757 /** 3758 * Initialize the web engine before loading the Web components. 3759 * This is a global static API that must be called on the UI thread, and it will have no effect if any 3760 * Web components are loaded. 3761 * @syscap SystemCapability.Web.Webview.Core 3762 * @atomicservice 3763 * @since arkts {'1.1':'11', '1.2':'20'} 3764 * @arkts 1.1&1.2 3765 */ 3766 static initializeWebEngine(): void; 3767 3768 /** 3769 * Set active ArkWeb engine version. 3770 * If the system does not support the specified version, it will not take effect. 3771 * This is a global static API that must be called before initializeWebEngine, and it will have no effect if any 3772 * Web components are loaded. 3773 * 3774 * <strong>Legacy Web Engine Compatibility Note</strong>: 3775 * <p>When using legacy ArkWeb Engine, some ArkWeb newly created API will not take effect,<br> 3776 * see [Compatible with Legacy Web Engine in release note] for compatibility guidelines. 3777 * </p> 3778 * 3779 * @param {ArkWebEngineVersion} engineVersion - the ArkWebEngineVersion 3780 * @static 3781 * @syscap SystemCapability.Web.Webview.Core 3782 * @since 20 3783 */ 3784 static setActiveWebEngineVersion(engineVersion: ArkWebEngineVersion): void; 3785 3786 /** 3787 * Get the currently active ArkWeb engine version. 3788 * @returns {ArkWebEngineVersion} Active ArkWeb Engine version as defined by ArkWebEngineVersion 3789 * @static 3790 * @syscap SystemCapability.Web.Webview.Core 3791 * @since 20 3792 */ 3793 static getActiveWebEngineVersion(): ArkWebEngineVersion; 3794 3795 /** 3796 * Set web engine to use HttpDns server to resolve dns. 3797 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 3798 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 3799 * Must be https protocol and only allow one server to be configured. 3800 * @throws { BusinessError } 401 - Invalid input parameter. 3801 * @syscap SystemCapability.Web.Webview.Core 3802 * @since 10 3803 */ 3804 /** 3805 * Set web engine to use HttpDns server to resolve dns. 3806 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 3807 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 3808 * Must be https protocol and only allow one server to be configured. 3809 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3810 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 3811 * @syscap SystemCapability.Web.Webview.Core 3812 * @atomicservice 3813 * @since 11 3814 */ 3815 static setHttpDns(secureDnsMode: SecureDnsMode, secureDnsConfig: string): void; 3816 3817 /** 3818 * Enables debugging of web contents. 3819 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 3820 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3821 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3822 * @syscap SystemCapability.Web.Webview.Core 3823 * @since 9 3824 */ 3825 /** 3826 * Enables debugging of web contents. 3827 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 3828 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3829 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3830 * @syscap SystemCapability.Web.Webview.Core 3831 * @atomicservice 3832 * @since 11 3833 */ 3834 /** 3835 * Sets whether to enable web debugging. By default, web debugging is disabled. 3836 * For details, see Debugging Frontend Pages by Using DevTools. 3837 * 3838 * <p><strong>API Note</strong>:<br> 3839 * Enabling web debugging allows users to check and modify the internal status of the web page, 3840 * which poses security risks. Therefore, you are advised not to enable this function 3841 * in the officially released version of the app. 3842 * </p> 3843 * 3844 * @param { boolean } webDebuggingAccess - Sets whether to enable web debugging.{@code true} enable web debugging; 3845 {@code false} disable web debugging. The default value is false. 3846 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3847 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3848 * @syscap SystemCapability.Web.Webview.Core 3849 * @crossplatform 3850 * @atomicservice 3851 * @since 18 3852 */ 3853 static setWebDebuggingAccess(webDebuggingAccess: boolean): void; 3854 3855 /** 3856 * Enable the ability to check website security risks. 3857 * Illegal and fraudulent websites are mandatory enabled and can't be disabled by this function. 3858 * @param { boolean } enable - {@code true} enable check the website security risks; {@code false} otherwise. 3859 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3860 * <br>2. Incorrect parameter types. 3861 * @syscap SystemCapability.Web.Webview.Core 3862 * @atomicservice 3863 * @since 11 3864 */ 3865 enableSafeBrowsing(enable: boolean): void; 3866 3867 /** 3868 * Get whether checking website security risks is enabled. 3869 * @returns { boolean } True if enable the ability to check website security risks else false. 3870 * @syscap SystemCapability.Web.Webview.Core 3871 * @atomicservice 3872 * @since 11 3873 */ 3874 isSafeBrowsingEnabled(): boolean; 3875 3876 /** 3877 * Checks whether the web page can go forward. 3878 * @returns { boolean } True if the web page can go forward else false. 3879 * @throws { BusinessError } 17100001 - Init error. 3880 * The WebviewController must be associated with a Web component. 3881 * @syscap SystemCapability.Web.Webview.Core 3882 * @since 9 3883 */ 3884 /** 3885 * Checks whether the web page can go forward. 3886 * @returns { boolean } True if the web page can go forward else false. 3887 * @throws { BusinessError } 17100001 - Init error. 3888 * The WebviewController must be associated with a Web component. 3889 * @syscap SystemCapability.Web.Webview.Core 3890 * @crossplatform 3891 * @atomicservice 3892 * @since arkts {'1.1':'11', '1.2':'20'} 3893 * @arkts 1.1&1.2 3894 */ 3895 accessForward(): boolean; 3896 3897 /** 3898 * Checks whether the web page can go back. 3899 * @returns { boolean } True if the web page can go back else false. 3900 * @throws { BusinessError } 17100001 - Init error. 3901 * The WebviewController must be associated with a Web component. 3902 * @syscap SystemCapability.Web.Webview.Core 3903 * @since 9 3904 */ 3905 /** 3906 * Checks whether the web page can go back. 3907 * @returns { boolean } True if the web page can go back else false. 3908 * @throws { BusinessError } 17100001 - Init error. 3909 * The WebviewController must be associated with a Web component. 3910 * @syscap SystemCapability.Web.Webview.Core 3911 * @crossplatform 3912 * @atomicservice 3913 * @since arkts {'1.1':'11', '1.2':'20'} 3914 * @arkts 1.1&1.2 3915 */ 3916 accessBackward(): boolean; 3917 3918 /** 3919 * Checks whether the web page can go back or forward the given number of steps. 3920 * 3921 * @param { number } step - The number of steps. 3922 * @returns { boolean } True if the web page can go back else false. 3923 * @throws { BusinessError } 401 - Invalid input parameter. 3924 * @throws { BusinessError } 17100001 - Init error. 3925 * The WebviewController must be associated with a Web component. 3926 * @syscap SystemCapability.Web.Webview.Core 3927 * @since 9 3928 */ 3929 /** 3930 * Checks whether the web page can go back or forward the given number of steps. 3931 * 3932 * @param { number } step - The number of steps. 3933 * @returns { boolean } True if the web page can go back else false. 3934 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3935 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3936 * @throws { BusinessError } 17100001 - Init error. 3937 * The WebviewController must be associated with a Web component. 3938 * @syscap SystemCapability.Web.Webview.Core 3939 * @crossplatform 3940 * @atomicservice 3941 * @since 11 3942 */ 3943 accessStep(step: number): boolean; 3944 3945 /** 3946 * Goes forward in the history of the web page. 3947 * 3948 * @throws { BusinessError } 17100001 - Init error. 3949 * The WebviewController must be associated with a Web component. 3950 * @syscap SystemCapability.Web.Webview.Core 3951 * @since 9 3952 */ 3953 /** 3954 * Goes forward in the history of the web page. 3955 * 3956 * @throws { BusinessError } 17100001 - Init error. 3957 * The WebviewController must be associated with a Web component. 3958 * @syscap SystemCapability.Web.Webview.Core 3959 * @crossplatform 3960 * @atomicservice 3961 * @since arkts {'1.1':'11', '1.2':'20'} 3962 * @arkts 1.1&1.2 3963 */ 3964 forward(): void; 3965 3966 /** 3967 * Goes back in the history of the web page. 3968 * 3969 * @throws { BusinessError } 17100001 - Init error. 3970 * The WebviewController must be associated with a Web component. 3971 * @syscap SystemCapability.Web.Webview.Core 3972 * @since 9 3973 */ 3974 /** 3975 * Goes back in the history of the web page. 3976 * 3977 * @throws { BusinessError } 17100001 - Init error. 3978 * The WebviewController must be associated with a Web component. 3979 * @syscap SystemCapability.Web.Webview.Core 3980 * @crossplatform 3981 * @atomicservice 3982 * @since arkts {'1.1':'11', '1.2':'20'} 3983 * @arkts 1.1&1.2 3984 */ 3985 backward(): void; 3986 3987 /** 3988 * Clears the history in the Web. 3989 * 3990 * @throws { BusinessError } 17100001 - Init error. 3991 * The WebviewController must be associated with a Web component. 3992 * @syscap SystemCapability.Web.Webview.Core 3993 * @since 9 3994 */ 3995 /** 3996 * Clears the history in the Web. 3997 * 3998 * @throws { BusinessError } 17100001 - Init error. 3999 * The WebviewController must be associated with a Web component. 4000 * @syscap SystemCapability.Web.Webview.Core 4001 * @crossplatform 4002 * @atomicservice 4003 * @since 11 4004 */ 4005 clearHistory(): void; 4006 4007 /** 4008 * Let the Web active. 4009 * 4010 * @throws { BusinessError } 17100001 - Init error. 4011 * The WebviewController must be associated with a Web component. 4012 * @syscap SystemCapability.Web.Webview.Core 4013 * @since 9 4014 */ 4015 /** 4016 * Call this interface to notify the Web component to enter the foreground activation state. 4017 * The activation state is the state in which the application interacts with the user. 4018 * The application will remain in this state until something happens, 4019 * such as receiving an incoming call or closing the screen of the device, 4020 * to shift the focus away from the application. 4021 * 4022 * @throws { BusinessError } 17100001 - Init error. 4023 * The WebviewController must be associated with a Web component. 4024 * @syscap SystemCapability.Web.Webview.Core 4025 * @atomicservice 4026 * @since arkts {'1.1':'11', '1.2':'20'} 4027 * @arkts 1.1&1.2 4028 */ 4029 onActive(): void; 4030 4031 /** 4032 * Let the Web inactive. 4033 * 4034 * @throws { BusinessError } 17100001 - Init error. 4035 * The WebviewController must be associated with a Web component. 4036 * @syscap SystemCapability.Web.Webview.Core 4037 * @since 9 4038 */ 4039 /** 4040 * Call this interface to notify the Web component to enter the inactive state. 4041 * In this callback, the developer can realize the appropriate behavior when the application loses focus. 4042 * In this state, any content that can be safely paused will be paused as much as possible, 4043 * such as animation and geographical location. However, JavaScript will not be paused. 4044 * To pause JavaScript globally, please use {@link pauseAllTimers}.To reactivate the Web component, call onActive. 4045 * 4046 * @throws { BusinessError } 17100001 - Init error. 4047 * The WebviewController must be associated with a Web component. 4048 * @syscap SystemCapability.Web.Webview.Core 4049 * @atomicservice 4050 * @since arkts {'1.1':'11', '1.2':'20'} 4051 * @arkts 1.1&1.2 4052 */ 4053 onInactive(): void; 4054 4055 /** 4056 * Refreshes the current URL. 4057 * 4058 * @throws { BusinessError } 17100001 - Init error. 4059 * The WebviewController must be associated with a Web component. 4060 * @syscap SystemCapability.Web.Webview.Core 4061 * @since 9 4062 */ 4063 /** 4064 * Refreshes the current URL. 4065 * 4066 * @throws { BusinessError } 17100001 - Init error. 4067 * The WebviewController must be associated with a Web component. 4068 * @syscap SystemCapability.Web.Webview.Core 4069 * @crossplatform 4070 * @atomicservice 4071 * @since arkts {'1.1':'11', '1.2':'20'} 4072 * @arkts 1.1&1.2 4073 */ 4074 refresh(): void; 4075 4076 /** 4077 * Loads the data or URL. 4078 * 4079 * @param { string } data - A string encoded according to "Base64" or "URL". 4080 * @param { string } mimeType - Media type. For example: "text/html". 4081 * @param { string } encoding - Encoding type. For example: "UTF-8". 4082 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 4083 * which is assigned to window.origin by the Web component. 4084 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 4085 * history records to realize the back and forth function. 4086 * This property is invalid when baseUrl is empty. 4087 * @throws { BusinessError } 401 - Invalid input parameter. 4088 * @throws { BusinessError } 17100001 - Init error. 4089 * The WebviewController must be associated with a Web component. 4090 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 4091 * length exceeds 2048. 4092 * @syscap SystemCapability.Web.Webview.Core 4093 * @since 9 4094 */ 4095 /** 4096 * Loads the data or URL. 4097 * 4098 * @param { string } data - A string encoded according to "Base64" or "URL". 4099 * @param { string } mimeType - Media type. For example: "text/html". 4100 * @param { string } encoding - Encoding type. For example: "UTF-8". 4101 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 4102 * which is assigned to window.origin by the Web component. 4103 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 4104 * history records to realize the back and forth function. 4105 * This property is invalid when baseUrl is empty. 4106 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4107 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4108 * @throws { BusinessError } 17100001 - Init error. 4109 * The WebviewController must be associated with a Web component. 4110 * @syscap SystemCapability.Web.Webview.Core 4111 * @crossplatform 4112 * @atomicservice 4113 * @since arkts {'1.1':'11', '1.2':'20'} 4114 * @arkts 1.1&1.2 4115 */ 4116 loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string): void; 4117 4118 /** 4119 * Loads the data or URL. 4120 * 4121 * @param { string | Resource } url - The URL to load. 4122 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 4123 * @throws { BusinessError } 401 - Invalid input parameter. 4124 * @throws { BusinessError } 17100001 - Init error. 4125 * The WebviewController must be associated with a Web component. 4126 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 4127 * length exceeds 2048. 4128 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 4129 * @syscap SystemCapability.Web.Webview.Core 4130 * @since 9 4131 */ 4132 /** 4133 * Loads the data or URL. 4134 * 4135 * @param { string | Resource } url - The URL to load. 4136 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 4137 * @throws { BusinessError } 401 - Invalid input parameter. 4138 * @throws { BusinessError } 17100001 - Init error. 4139 * The WebviewController must be associated with a Web component. 4140 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 4141 * length exceeds 2048. 4142 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 4143 * @syscap SystemCapability.Web.Webview.Core 4144 * @crossplatform 4145 * @since 10 4146 */ 4147 /** 4148 * Loads the data or URL. 4149 * 4150 * @param { string | Resource } url - The URL to load. 4151 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 4152 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4153 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4154 * @throws { BusinessError } 17100001 - Init error. 4155 * The WebviewController must be associated with a Web component. 4156 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 4157 * length exceeds 2048. 4158 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 4159 * @syscap SystemCapability.Web.Webview.Core 4160 * @crossplatform 4161 * @atomicservice 4162 * @since arkts {'1.1':'11', '1.2':'20'} 4163 * @arkts 1.1&1.2 4164 */ 4165 loadUrl(url: string | Resource, headers?: Array<WebHeader>): void; 4166 4167 /** 4168 * Gets the type of HitTest. 4169 * @returns { WebHitTestType } The type of HitTest. 4170 * @throws { BusinessError } 17100001 - Init error. 4171 * The WebviewController must be associated with a Web component. 4172 * @syscap SystemCapability.Web.Webview.Core 4173 * @since 9 4174 */ 4175 /** 4176 * Gets the type of HitTest. 4177 * @returns { WebHitTestType } The type of HitTest. 4178 * @throws { BusinessError } 17100001 - Init error. 4179 * The WebviewController must be associated with a Web component. 4180 * @syscap SystemCapability.Web.Webview.Core 4181 * @atomicservice 4182 * @since 11 4183 * @deprecated since 18 4184 * @useinstead ohos.web.webview.WebviewController#getLastHitTest 4185 */ 4186 getHitTest(): WebHitTestType; 4187 4188 /** 4189 * Stores the current page as a web archive. 4190 * 4191 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 4192 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 4193 * stored by the file name of baseName. If true, the file name is 4194 * automatically generated based on the current URL and stored in the file 4195 * directory of baseName. 4196 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 4197 * will either be the filename under which the file was stored, or empty 4198 * if storing the file failed. 4199 * @throws { BusinessError } 401 - Invalid input parameter. 4200 * @throws { BusinessError } 17100001 - Init error. 4201 * The WebviewController must be associated with a Web component. 4202 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 4203 * @syscap SystemCapability.Web.Webview.Core 4204 * @since 9 4205 */ 4206 /** 4207 * Stores the current page as a web archive. 4208 * 4209 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 4210 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 4211 * stored by the file name of baseName. If true, the file name is 4212 * automatically generated based on the current URL and stored in the file 4213 * directory of baseName. 4214 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 4215 * will either be the filename under which the file was stored, or empty 4216 * if storing the file failed. 4217 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4218 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 4219 * @throws { BusinessError } 17100001 - Init error. 4220 * The WebviewController must be associated with a Web component. 4221 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 4222 * @syscap SystemCapability.Web.Webview.Core 4223 * @atomicservice 4224 * @since 11 4225 */ 4226 storeWebArchive(baseName: string, autoName: boolean): Promise<string>; 4227 4228 /** 4229 * Stores the current page as a web archive. 4230 * 4231 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 4232 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 4233 * stored by the file name of baseName. If true, the file name is 4234 * automatically generated based on the current URL and stored in the file 4235 * directory of baseName. 4236 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 4237 * will either be the filename under which the file was stored, 4238 * or empty if storing the file failed. 4239 * @throws { BusinessError } 401 - Invalid input parameter. 4240 * @throws { BusinessError } 17100001 - Init error. 4241 * The WebviewController must be associated with a Web component. 4242 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 4243 * @syscap SystemCapability.Web.Webview.Core 4244 * @since 9 4245 */ 4246 /** 4247 * Stores the current page as a web archive. 4248 * 4249 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 4250 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 4251 * stored by the file name of baseName. If true, the file name is 4252 * automatically generated based on the current URL and stored in the file 4253 * directory of baseName. 4254 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 4255 * will either be the filename under which the file was stored, 4256 * or empty if storing the file failed. 4257 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4258 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 4259 * @throws { BusinessError } 17100001 - Init error. 4260 * The WebviewController must be associated with a Web component. 4261 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 4262 * @syscap SystemCapability.Web.Webview.Core 4263 * @atomicservice 4264 * @since 11 4265 */ 4266 storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback<string>): void; 4267 4268 /** 4269 * Let the Web zoom by. 4270 * 4271 * @param { number } factor - The zoom factor. 4272 * Reduced when the input parameter is less than 1. Enlarged when the input parameter is greater than 1.Value range: (0, 100]. 4273 * @throws { BusinessError } 401 - Invalid input parameter. 4274 * @throws { BusinessError } 17100001 - Init error. 4275 * The WebviewController must be associated with a Web component. 4276 * @throws { BusinessError } 17100004 - Function not enabled. 4277 * @syscap SystemCapability.Web.Webview.Core 4278 * @since 9 4279 */ 4280 /** 4281 * Let the Web zoom by. 4282 * 4283 * <p><strong>API Note</strong>:<br> 4284 * zoomAccess must be true. 4285 * </p> 4286 * 4287 * @param { number } factor - The zoom factor. 4288 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4289 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4290 * @throws { BusinessError } 17100001 - Init error. 4291 * The WebviewController must be associated with a Web component. 4292 * @throws { BusinessError } 17100004 - Function not enabled. 4293 * @syscap SystemCapability.Web.Webview.Core 4294 * @crossplatform 4295 * @atomicservice 4296 * @since 11 4297 */ 4298 zoom(factor: number): void; 4299 4300 /** 4301 * Let the Web zoom in. 4302 * 4303 * @throws { BusinessError } 17100001 - Init error. 4304 * The WebviewController must be associated with a Web component. 4305 * @throws { BusinessError } 17100004 - Function not enabled. 4306 * @syscap SystemCapability.Web.Webview.Core 4307 * @since 9 4308 */ 4309 /** 4310 * Let the Web zoom in. 4311 * 4312 * @throws { BusinessError } 17100001 - Init error. 4313 * The WebviewController must be associated with a Web component. 4314 * @throws { BusinessError } 17100004 - Function not enabled. 4315 * @syscap SystemCapability.Web.Webview.Core 4316 * @atomicservice 4317 * @since 11 4318 */ 4319 /** 4320 * Let the Web zoom in. 4321 * Call this interface to enlarge the current page by 25%. 4322 * 4323 * @throws { BusinessError } 17100001 - Init error. 4324 * The WebviewController must be associated with a Web component. 4325 * @throws { BusinessError } 17100004 - Function not enabled. 4326 * @syscap SystemCapability.Web.Webview.Core 4327 * @crossplatform 4328 * @atomicservice 4329 * @since 18 4330 */ 4331 zoomIn(): void; 4332 4333 /** 4334 * Let the Web zoom out. 4335 * 4336 * @throws { BusinessError } 17100001 - Init error. 4337 * The WebviewController must be associated with a Web component. 4338 * @throws { BusinessError } 17100004 - Function not enabled. 4339 * @syscap SystemCapability.Web.Webview.Core 4340 * @since 9 4341 */ 4342 /** 4343 * Let the Web zoom out. 4344 * 4345 * @throws { BusinessError } 17100001 - Init error. 4346 * The WebviewController must be associated with a Web component. 4347 * @throws { BusinessError } 17100004 - Function not enabled. 4348 * @syscap SystemCapability.Web.Webview.Core 4349 * @atomicservice 4350 * @since 11 4351 */ 4352 /** 4353 * Let the Web zoom out. 4354 * Call this interface to shrink the current page by 20%. 4355 * 4356 * @throws { BusinessError } 17100001 - Init error. 4357 * The WebviewController must be associated with a Web component. 4358 * @throws { BusinessError } 17100004 - Function not enabled. 4359 * @syscap SystemCapability.Web.Webview.Core 4360 * @crossplatform 4361 * @atomicservice 4362 * @since 18 4363 */ 4364 zoomOut(): void; 4365 4366 /** 4367 * Gets the hit test value of HitTest. 4368 * @returns { HitTestValue } Return the element information of the clicked area. 4369 * @throws { BusinessError } 17100001 - Init error. 4370 * The WebviewController must be associated with a Web component. 4371 * @syscap SystemCapability.Web.Webview.Core 4372 * @since 9 4373 */ 4374 /** 4375 * Get the element information of the currently clicked area. 4376 * @returns { HitTestValue } Return the element information of the clicked area. 4377 * @throws { BusinessError } 17100001 - Init error. 4378 * The WebviewController must be associated with a Web component. 4379 * @syscap SystemCapability.Web.Webview.Core 4380 * @atomicservice 4381 * @since 11 4382 * @deprecated since 18 4383 * @useinstead ohos.web.webview.WebviewController#getLastHitTest 4384 */ 4385 getHitTestValue(): HitTestValue; 4386 4387 /** 4388 * Gets the id for the current Web. 4389 * @returns { number } Returns the index value of the current Web component. 4390 * @throws { BusinessError } 17100001 - Init error. 4391 * The WebviewController must be associated with a Web component. 4392 * @syscap SystemCapability.Web.Webview.Core 4393 * @since 9 4394 */ 4395 /** 4396 * Gets the id for the current Web. 4397 * @returns { number } Returns the index value of the current Web component. 4398 * @throws { BusinessError } 17100001 - Init error. 4399 * The WebviewController must be associated with a Web component. 4400 * @syscap SystemCapability.Web.Webview.Core 4401 * @atomicservice 4402 * @since 11 4403 */ 4404 /** 4405 * Gets the index value of the current Web component for the management of multiple Web components. 4406 * @returns { number } Returns the index value of the current Web component. 4407 * @throws { BusinessError } 17100001 - Init error. 4408 * The WebviewController must be associated with a Web component. 4409 * @syscap SystemCapability.Web.Webview.Core 4410 * @crossplatform 4411 * @atomicservice 4412 * @since arkts {'1.1':'18', '1.2':'20'} 4413 * @arkts 1.1&1.2 4414 */ 4415 getWebId(): number; 4416 4417 /** 4418 * Gets the default user agent. 4419 * @returns { string } Return user agent information. 4420 * @throws { BusinessError } 17100001 - Init error. 4421 * The WebviewController must be associated with a Web component. 4422 * @syscap SystemCapability.Web.Webview.Core 4423 * @since 9 4424 */ 4425 /** 4426 * Gets the default user agent. 4427 * @returns { string } Return user agent information. 4428 * @throws { BusinessError } 17100001 - Init error. 4429 * The WebviewController must be associated with a Web component. 4430 * @syscap SystemCapability.Web.Webview.Core 4431 * @atomicservice 4432 * @since 11 4433 */ 4434 getUserAgent(): string; 4435 4436 /** 4437 * Gets the title of current Web page. 4438 * @returns { string } Return to File Selector Title. 4439 * @throws { BusinessError } 17100001 - Init error. 4440 * The WebviewController must be associated with a Web component. 4441 * @syscap SystemCapability.Web.Webview.Core 4442 * @since 9 4443 */ 4444 /** 4445 * Gets the title of current Web page. 4446 * @returns { string } Return to File Selector Title. 4447 * @throws { BusinessError } 17100001 - Init error. 4448 * The WebviewController must be associated with a Web component. 4449 * @syscap SystemCapability.Web.Webview.Core 4450 * @crossplatform 4451 * @atomicservice 4452 * @since arkts {'1.1':'11', '1.2':'20'} 4453 * @arkts 1.1&1.2 4454 */ 4455 getTitle(): string; 4456 4457 /** 4458 * Gets the content height of current Web page. 4459 * @returns { number } Returns the page height of the current page. 4460 * @throws { BusinessError } 17100001 - Init error. 4461 * The WebviewController must be associated with a Web component. 4462 * @syscap SystemCapability.Web.Webview.Core 4463 * @since 9 4464 */ 4465 /** 4466 * Obtains the height of this web page. 4467 * @returns { number } Height of the current web page. Unit: vp. 4468 * @throws { BusinessError } 17100001 - Init error. 4469 * The WebviewController must be associated with a Web component. 4470 * @syscap SystemCapability.Web.Webview.Core 4471 * @crossplatform 4472 * @atomicservice 4473 * @since arkts {'1.1':'11', '1.2':'20'} 4474 * @arkts 1.1&1.2 4475 */ 4476 getPageHeight(): number; 4477 4478 /** 4479 * Goes forward or back backOrForward in the history of the web page. 4480 * 4481 * @param { number } step - Steps to go forward or backward. 4482 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4483 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4484 * @throws { BusinessError } 17100001 - Init error. 4485 * The WebviewController must be associated with a Web component. 4486 * @syscap SystemCapability.Web.Webview.Core 4487 * @since 9 4488 */ 4489 /** 4490 * Goes forward or back backOrForward in the history of the web page. 4491 * 4492 * @param { number } step - Steps to go forward or backward. 4493 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4494 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4495 * @throws { BusinessError } 17100001 - Init error. 4496 * The WebviewController must be associated with a Web component. 4497 * @syscap SystemCapability.Web.Webview.Core 4498 * @crossplatform 4499 * @atomicservice 4500 * @since 11 4501 */ 4502 backOrForward(step: number): void; 4503 4504 /** 4505 * Gets the request focus. 4506 * 4507 * @throws { BusinessError } 17100001 - Init error. 4508 * The WebviewController must be associated with a Web component. 4509 * @syscap SystemCapability.Web.Webview.Core 4510 * @since 9 4511 */ 4512 /** 4513 * Gets the request focus. 4514 * 4515 * @throws { BusinessError } 17100001 - Init error. 4516 * The WebviewController must be associated with a Web component. 4517 * @syscap SystemCapability.Web.Webview.Core 4518 * @atomicservice 4519 * @since arkts {'1.1':'11', '1.2':'20'} 4520 * @arkts 1.1&1.2 4521 */ 4522 requestFocus(): void; 4523 4524 /** 4525 * Create web message ports 4526 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 4527 * those ports to communication with html pages. 4528 * @throws { BusinessError } 17100001 - Init error. 4529 * The WebviewController must be associated with a Web component. 4530 * @syscap SystemCapability.Web.Webview.Core 4531 * @since 9 4532 */ 4533 /** 4534 * Create web message ports 4535 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 4536 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 4537 * those ports to communication with html pages. 4538 * @throws { BusinessError } 401 - Invalid input parameter. 4539 * @throws { BusinessError } 17100001 - Init error. 4540 * The WebviewController must be associated with a Web component. 4541 * @syscap SystemCapability.Web.Webview.Core 4542 * @since 10 4543 */ 4544 /** 4545 * Create web message ports 4546 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 4547 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 4548 * those ports to communication with html pages. 4549 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4550 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4551 * @throws { BusinessError } 17100001 - Init error. 4552 * The WebviewController must be associated with a Web component. 4553 * @syscap SystemCapability.Web.Webview.Core 4554 * @crossplatform 4555 * @atomicservice 4556 * @since 11 4557 */ 4558 createWebMessagePorts(isExtentionType?: boolean): Array<WebMessagePort>; 4559 4560 /** 4561 * Post web message port to html 4562 * 4563 * @param { string } name - Data name information to send. 4564 * @param { Array<WebMessagePort> } ports - Port number array information to send. 4565 * @param { string } uri - URI to receive this information. 4566 * @throws { BusinessError } 401 - Invalid input parameter. 4567 * @throws { BusinessError } 17100001 - Init error. 4568 * The WebviewController must be associated with a Web component. 4569 * @syscap SystemCapability.Web.Webview.Core 4570 * @since 9 4571 */ 4572 /** 4573 * Post web message port to html 4574 * 4575 * @param { string } name - Data name information to send. 4576 * @param { Array<WebMessagePort> } ports - Port number array information to send. 4577 * @param { string } uri - URI to receive this information. 4578 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4579 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4580 * @throws { BusinessError } 17100001 - Init error. 4581 * The WebviewController must be associated with a Web component. 4582 * @syscap SystemCapability.Web.Webview.Core 4583 * @crossplatform 4584 * @atomicservice 4585 * @since 11 4586 */ 4587 postMessage(name: string, ports: Array<WebMessagePort>, uri: string): void; 4588 4589 /** 4590 * Stops the current load. 4591 * 4592 * @throws { BusinessError } 17100001 - Init error. 4593 * The WebviewController must be associated with a Web component. 4594 * @syscap SystemCapability.Web.Webview.Core 4595 * @since 9 4596 */ 4597 /** 4598 * Stops the current load. 4599 * 4600 * @throws { BusinessError } 17100001 - Init error. 4601 * The WebviewController must be associated with a Web component. 4602 * @syscap SystemCapability.Web.Webview.Core 4603 * @crossplatform 4604 * @atomicservice 4605 * @since arkts {'1.1':'11', '1.2':'20'} 4606 * @arkts 1.1&1.2 4607 */ 4608 stop(): void; 4609 4610 /** 4611 * Registers the JavaScript object and method list. 4612 * 4613 * @param { object } object - Application side JavaScript objects participating in registration. 4614 * @param { string } name - The name of the registered object, which is consistent with the 4615 * object name called in the window. 4616 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 4617 * in the registration. 4618 * @throws { BusinessError } 401 - Invalid input parameter. 4619 * @throws { BusinessError } 17100001 - Init error. 4620 * The WebviewController must be associated with a Web component. 4621 * @syscap SystemCapability.Web.Webview.Core 4622 * @since 9 4623 */ 4624 /** 4625 * Registers the JavaScript object and method list. 4626 * 4627 * @param { object } object - Application side JavaScript objects participating in registration. 4628 * @param { string } name - The name of the registered object, which is consistent with the 4629 * object name called in the window. 4630 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 4631 * in the registration. 4632 * @throws { BusinessError } 401 - Invalid input parameter. 4633 * @throws { BusinessError } 17100001 - Init error. 4634 * The WebviewController must be associated with a Web component. 4635 * @syscap SystemCapability.Web.Webview.Core 4636 * @atomicservice 4637 * @since 11 4638 */ 4639 /** 4640 * Registers the supplied ArkTS object into this Web component. 4641 * The object is registered into all frames of the web page, including all iframes, using the specified name. 4642 * This allows the methods of the ArkTS object to be accessed from JavaScript. 4643 * <p><strong>API Note</strong>:<br> 4644 * Registed objects will not appear in JavaScript until the page is next (re)load. 4645 * To avoid memory leaks, registerJavaScriptProxy must be used together with deleteJavaScriptProxy. 4646 * To avoid security risks, it is recommended that registerJavaScriptProxy be used with trusted web components. 4647 * If the same method is registered repeatedly in both synchronous and asynchronous list, it will default to an asynchronous method. 4648 * The synchronous function list and asynchronous function list cannot be empty at the same time.<br> 4649 * otherwise, this registration will fail. 4650 * <p> 4651 * 4652 * @param { object } object - Application side JavaScript objects participating in registration. 4653 * @param { string } name - The name of the registered object, which is consistent with the 4654 * object name called in the window. 4655 * @param { Array<string> } methodList - The method of the application side JavaScript object participating 4656 * in the registration. 4657 * @param { Array<string> } [asyncMethodList] - The async method of the application side JavaScript object 4658 * participating in the registration. 4659 * @param { string } [permission] - permission configuration defining web page URLs that can access JavaScriptProxy methods. 4660 * The configuration can be defined at two levels, object level and method level. 4661 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4662 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4663 * @throws { BusinessError } 17100001 - Init error. 4664 * The WebviewController must be associated with a Web component. 4665 * @syscap SystemCapability.Web.Webview.Core 4666 * @atomicservice 4667 * @since 12 4668 */ 4669 /** 4670 * Registers the supplied ArkTS object into this Web component. 4671 * The object is registered into all frames of the web page, including all iframes, using the specified name. 4672 * This allows the methods of the ArkTS object to be accessed from JavaScript. 4673 * <p><strong>API Note</strong>:<br> 4674 * Registed objects will not appear in JavaScript until the page is next (re)load. 4675 * To avoid memory leaks, registerJavaScriptProxy must be used together with deleteJavaScriptProxy. 4676 * To avoid security risks, it is recommended that registerJavaScriptProxy be used with trusted web components. 4677 * If the same method is registered repeatedly in both synchronous and asynchronous list, it will default to an asynchronous method. 4678 * The synchronous function list and asynchronous function list cannot be empty at the same time.<br> 4679 * otherwise, this registration will fail. 4680 * <p> 4681 * 4682 * @param { object } object - Application side JavaScript objects participating in registration. 4683 * @param { string } name - The name of the registered object, which is consistent with the 4684 * object name called in the window. 4685 * @param { Array<string> } methodList - The method of the application side JavaScript object participating 4686 * in the registration. 4687 * @param { Array<string> } [asyncMethodList] - The async method of the application side JavaScript object 4688 * participating in the registration. 4689 * @param { string } [permission] - permission configuration defining web page URLs that can access JavaScriptProxy methods. 4690 * The configuration can be defined at two levels, object level and method level. 4691 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4692 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4693 * @throws { BusinessError } 17100001 - Init error. 4694 * The WebviewController must be associated with a Web component. 4695 * @syscap SystemCapability.Web.Webview.Core 4696 * @crossplatform 4697 * @atomicservice 4698 * @since 20 4699 */ 4700 registerJavaScriptProxy(object: object, name: string, methodList: Array<string>, 4701 asyncMethodList?: Array<string>, permission?: string): void; 4702 4703 /** 4704 * Deletes a registered JavaScript object with given name. 4705 * 4706 * @param { string } name - The name of a registered JavaScript object to be deleted. 4707 * @throws { BusinessError } 401 - Invalid input parameter. 4708 * @throws { BusinessError } 17100001 - Init error. 4709 * The WebviewController must be associated with a Web component. 4710 * @throws { BusinessError } 17100008 - Failed to delete JavaScriptProxy because it does not exist. 4711 * @syscap SystemCapability.Web.Webview.Core 4712 * @since 9 4713 */ 4714 /** 4715 * Deletes a registered JavaScript object with given name. 4716 * 4717 * @param { string } name - The name of a registered JavaScript object to be deleted. 4718 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4719 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4720 * @throws { BusinessError } 17100001 - Init error. 4721 * The WebviewController must be associated with a Web component. 4722 * @throws { BusinessError } 17100008 - Failed to delete JavaScriptProxy because it does not exist. 4723 * @syscap SystemCapability.Web.Webview.Core 4724 * @atomicservice 4725 * @since 11 4726 */ 4727 /** 4728 * Deletes a registered JavaScript object with given name. 4729 * 4730 * @param { string } name - The name of a registered JavaScript object to be deleted. 4731 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4732 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4733 * @throws { BusinessError } 17100001 - Init error. 4734 * The WebviewController must be associated with a Web component. 4735 * @throws { BusinessError } 17100008 - Failed to delete JavaScriptProxy because it does not exist. 4736 * @syscap SystemCapability.Web.Webview.Core 4737 * @crossplatform 4738 * @atomicservice 4739 * @since 20 4740 */ 4741 deleteJavaScriptRegister(name: string): void; 4742 4743 /** 4744 * Search all instances of 'searchString' on the page and highlights them, 4745 * result will be notify through callback onSearchResultReceive. 4746 * 4747 * @param { string } searchString - String to be search. 4748 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4749 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4750 * @throws { BusinessError } 17100001 - Init error. 4751 * The WebviewController must be associated with a Web component. 4752 * @syscap SystemCapability.Web.Webview.Core 4753 * @since 9 4754 */ 4755 /** 4756 * Search all instances of 'searchString' on the page and highlights them, 4757 * result will be notify through callback onSearchResultReceive. 4758 * 4759 * @param { string } searchString - String to be search. 4760 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4761 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4762 * @throws { BusinessError } 17100001 - Init error. 4763 * The WebviewController must be associated with a Web component. 4764 * @syscap SystemCapability.Web.Webview.Core 4765 * @atomicservice 4766 * @since 11 4767 */ 4768 searchAllAsync(searchString: string): void; 4769 4770 /** 4771 * Clears the highlighting surrounding text matches created by searchAllAsync. 4772 * 4773 * @throws { BusinessError } 17100001 - Init error. 4774 * The WebviewController must be associated with a Web component. 4775 * @syscap SystemCapability.Web.Webview.Core 4776 * @since 9 4777 */ 4778 /** 4779 * Clears the highlighting surrounding text matches created by searchAllAsync. 4780 * 4781 * @throws { BusinessError } 17100001 - Init error. 4782 * The WebviewController must be associated with a Web component. 4783 * @syscap SystemCapability.Web.Webview.Core 4784 * @atomicservice 4785 * @since 11 4786 */ 4787 clearMatches(): void; 4788 4789 /** 4790 * Highlights and scrolls to the next match search. 4791 * 4792 * @param { boolean } forward - Step of search is back or forward. 4793 * @throws { BusinessError } 401 - Invalid input parameter. 4794 * @throws { BusinessError } 17100001 - Init error. 4795 * The WebviewController must be associated with a Web component. 4796 * @syscap SystemCapability.Web.Webview.Core 4797 * @since 9 4798 */ 4799 /** 4800 * Highlights and scrolls to the next match search. 4801 * 4802 * @param { boolean } forward - Step of search is back or forward. 4803 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4804 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4805 * @throws { BusinessError } 17100001 - Init error. 4806 * The WebviewController must be associated with a Web component. 4807 * @syscap SystemCapability.Web.Webview.Core 4808 * @atomicservice 4809 * @since 11 4810 */ 4811 searchNext(forward: boolean): void; 4812 4813 /** 4814 * Clears the ssl cache in the Web. 4815 * 4816 * @throws { BusinessError } 17100001 - Init error. 4817 * The WebviewController must be associated with a Web component. 4818 * @syscap SystemCapability.Web.Webview.Core 4819 * @since 9 4820 */ 4821 /** 4822 * Clears the ssl cache in the Web. 4823 * 4824 * @throws { BusinessError } 17100001 - Init error. 4825 * The WebviewController must be associated with a Web component. 4826 * @syscap SystemCapability.Web.Webview.Core 4827 * @atomicservice 4828 * @since 11 4829 */ 4830 clearSslCache(): void; 4831 4832 /** 4833 * Clears the client authentication certificate cache in the Web. 4834 * 4835 * @throws { BusinessError } 17100001 - Init error. 4836 * The WebviewController must be associated with a Web component. 4837 * @syscap SystemCapability.Web.Webview.Core 4838 * @since 9 4839 */ 4840 /** 4841 * Clears the client authentication certificate cache in the Web. 4842 * 4843 * @throws { BusinessError } 17100001 - Init error. 4844 * The WebviewController must be associated with a Web component. 4845 * @syscap SystemCapability.Web.Webview.Core 4846 * @atomicservice 4847 * @since 11 4848 */ 4849 clearClientAuthenticationCache(): void; 4850 4851 /** 4852 * Loads a piece of code and execute JS code in the context of the currently displayed page. 4853 * 4854 * @param { string } script - JavaScript Script. 4855 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 4856 * This parameter will be the result of JavaScript script execution. 4857 * If the JavaScript script fails to execute or has no return value, 4858 * null will be returned. 4859 * @throws { BusinessError } 401 - Invalid input parameter. 4860 * @throws { BusinessError } 17100001 - Init error. 4861 * The WebviewController must be associated with a Web component. 4862 * @syscap SystemCapability.Web.Webview.Core 4863 * @since 9 4864 */ 4865 /** 4866 * Asynchronously execute JavaScript in the context of the currently displayed page. 4867 * The result of the script execution will be returned through a via Promise. 4868 * This method must be used on the UI thread, and the callback will also be invoked on the UI thread. 4869 * <p><strong>API Note</strong>:<br> 4870 * The state of JavaScript is no longer persisted across navigations like loadUrl. 4871 * For example, global variables and functions defined before calling loadUrl will not exist in the loaded page.<br> 4872 * It is recommended that applications use registerJavaScriptProxy to ensure that the JavaScript state can be persisted across page navigations.<br> 4873 * If you cannot obtain the return value by executing the asynchronous method, 4874 * you need to determine whether to use synchronous or asynchronous mode based on the specific situation. 4875 * <p> 4876 * 4877 * @param { string } script - JavaScript Script. 4878 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 4879 * This parameter will be the result of JavaScript script execution. 4880 * If the JavaScript script fails to execute or has no return value, 4881 * null will be returned. 4882 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4883 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4884 * @throws { BusinessError } 17100001 - Init error. 4885 * The WebviewController must be associated with a Web component. 4886 * @syscap SystemCapability.Web.Webview.Core 4887 * @crossplatform 4888 * @atomicservice 4889 * @since 11 4890 */ 4891 runJavaScript(script: string): Promise<string>; 4892 4893 /** 4894 * Loads a piece of code and execute JS code in the context of the currently displayed page. 4895 * 4896 * @param { string } script - JavaScript Script. 4897 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 4898 * @throws { BusinessError } 401 - Invalid input parameter. 4899 * @throws { BusinessError } 17100001 - Init error. 4900 * The WebviewController must be associated with a Web component. 4901 * @syscap SystemCapability.Web.Webview.Core 4902 * @since 9 4903 */ 4904 /** 4905 * Asynchronously execute JavaScript in the context of the currently displayed page. 4906 * The result of the script execution will be returned through an asynchronous callback. 4907 * This method must be used on the UI thread, and the callback will also be invoked on the UI thread. 4908 * <p><strong>API Note</strong>:<br> 4909 * The state of JavaScript is no longer persisted across navigations like loadUrl. 4910 * For example, global variables and functions defined before calling loadUrl will not exist in the loaded page. 4911 * It is recommended that applications use registerJavaScriptProxy to ensure that the JavaScript state can be persisted across page navigations. 4912 * <p> 4913 * 4914 * @param { string } script - JavaScript Script. 4915 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 4916 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4917 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4918 * @throws { BusinessError } 17100001 - Init error. 4919 * The WebviewController must be associated with a Web component. 4920 * @syscap SystemCapability.Web.Webview.Core 4921 * @crossplatform 4922 * @atomicservice 4923 * @since arkts {'1.1':'11', '1.2':'20'} 4924 * @arkts 1.1&1.2 4925 */ 4926 runJavaScript(script: string, callback: AsyncCallback<string>): void; 4927 4928 /** 4929 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4930 * 4931 * @param { string } script - JavaScript Script. 4932 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 4933 * This parameter will be the result of JavaScript script execution. 4934 * If the JavaScript script fails to execute or has no return value, 4935 * a none type value will be returned. 4936 * @throws { BusinessError } 401 - Invalid input parameter. 4937 * @throws { BusinessError } 17100001 - Init error. 4938 * The WebviewController must be associated with a Web component. 4939 * @syscap SystemCapability.Web.Webview.Core 4940 * @since 10 4941 */ 4942 /** 4943 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4944 * 4945 * @param { string } script - JavaScript Script. 4946 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 4947 * This parameter will be the result of JavaScript script execution. 4948 * If the JavaScript script fails to execute or has no return value, 4949 * a none type value will be returned. 4950 * @throws { BusinessError } 401 - Invalid input parameter. 4951 * @throws { BusinessError } 17100001 - Init error. 4952 * The WebviewController must be associated with a Web component. 4953 * @syscap SystemCapability.Web.Webview.Core 4954 * @atomicservice 4955 * @since 11 4956 */ 4957 /** 4958 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4959 * 4960 * @param { string | ArrayBuffer } script - JavaScript Script. 4961 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 4962 * This parameter will be the result of JavaScript script execution. 4963 * If the JavaScript script fails to execute or has no return value, 4964 * a none type value will be returned. 4965 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4966 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4967 * @throws { BusinessError } 17100001 - Init error. 4968 * The WebviewController must be associated with a Web component. 4969 * @syscap SystemCapability.Web.Webview.Core 4970 * @atomicservice 4971 * @since 12 4972 */ 4973 /** 4974 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4975 * 4976 * @param { string | ArrayBuffer } script - JavaScript Script. 4977 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 4978 * This parameter will be the result of JavaScript script execution. 4979 * If the JavaScript script fails to execute or has no return value, 4980 * a none type value will be returned. 4981 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4982 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4983 * @throws { BusinessError } 17100001 - Init error. 4984 * The WebviewController must be associated with a Web component. 4985 * @syscap SystemCapability.Web.Webview.Core 4986 * @crossplatform 4987 * @atomicservice 4988 * @since 18 4989 */ 4990 runJavaScriptExt(script: string | ArrayBuffer): Promise<JsMessageExt>; 4991 4992 /** 4993 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4994 * 4995 * @param { string } script - JavaScript Script. 4996 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 4997 * @throws { BusinessError } 401 - Invalid input parameter. 4998 * @throws { BusinessError } 17100001 - Init error. 4999 * The WebviewController must be associated with a Web component. 5000 * @syscap SystemCapability.Web.Webview.Core 5001 * @since 10 5002 */ 5003 /** 5004 * Execute JavaScript code in the context of the currently displayed page, and return the result. 5005 * 5006 * @param { string } script - JavaScript Script. 5007 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 5008 * @throws { BusinessError } 401 - Invalid input parameter. 5009 * @throws { BusinessError } 17100001 - Init error. 5010 * The WebviewController must be associated with a Web component. 5011 * @syscap SystemCapability.Web.Webview.Core 5012 * @atomicservice 5013 * @since 11 5014 */ 5015 /** 5016 * Execute JavaScript code in the context of the currently displayed page, and return the result. 5017 * 5018 * @param { string | ArrayBuffer } script - JavaScript Script. 5019 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 5020 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5021 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5022 * @throws { BusinessError } 17100001 - Init error. 5023 * The WebviewController must be associated with a Web component. 5024 * @syscap SystemCapability.Web.Webview.Core 5025 * @atomicservice 5026 * @since 12 5027 */ 5028 /** 5029 * Execute JavaScript code in the context of the currently displayed page, and return the result. 5030 * 5031 * @param { string | ArrayBuffer } script - JavaScript Script. 5032 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 5033 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5034 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5035 * @throws { BusinessError } 17100001 - Init error. 5036 * The WebviewController must be associated with a Web component. 5037 * @syscap SystemCapability.Web.Webview.Core 5038 * @crossplatform 5039 * @atomicservice 5040 * @since 18 5041 */ 5042 runJavaScriptExt(script: string | ArrayBuffer, callback: AsyncCallback<JsMessageExt>): void; 5043 5044 /** 5045 * Rendering current Web page into Pdf data, return the result in async mode. 5046 * 5047 * @param { PdfConfiguration } configuration - configuration for createPdf, 5048 * including page width and height, etc. 5049 * {@Link PdfConfiguration} 5050 * @param { AsyncCallback<PdfData> } callback - Callbacks execute createPdf results. 5051 * PdfData is pdf data stream of current web page in Uint8Array 5052 * {@Link PdfData}. 5053 * @throws { BusinessError } 401 - Invalid input parameter. 5054 * @throws { BusinessError } 17100001 - Init error. 5055 * The WebviewController must be associated with a Web component. 5056 * @syscap SystemCapability.Web.Webview.Core 5057 * @atomicservice 5058 * @since 14 5059 */ 5060 createPdf(configuration: PdfConfiguration, callback: AsyncCallback<PdfData>): void; 5061 5062 /** 5063 * Rendering current Web page into Pdf data, return the result in promise mode. 5064 * 5065 * @param { PdfConfiguration } configuration - configuration for createPdf, 5066 * including page width and height, etc. 5067 * {@Link PdfConfiguration} 5068 * @returns { Promise<PdfData> } The promise returned by the function. 5069 * PdfData is pdf data stream of current web page in Uint8Array 5070 * {@Link PdfData}. 5071 * If createPdf fails or no return value, 5072 * a none type value will be returned. 5073 * @throws { BusinessError } 401 - Invalid input parameter. 5074 * @throws { BusinessError } 17100001 - Init error. 5075 * The WebviewController must be associated with a Web component. 5076 * @syscap SystemCapability.Web.Webview.Core 5077 * @atomicservice 5078 * @since 14 5079 */ 5080 createPdf(configuration: PdfConfiguration): Promise<PdfData>; 5081 5082 /** 5083 * Gets the url of current Web page. 5084 * @returns { string } Return the url of the current page. 5085 * @throws { BusinessError } 17100001 - Init error. 5086 * The WebviewController must be associated with a Web component. 5087 * @syscap SystemCapability.Web.Webview.Core 5088 * @since 9 5089 */ 5090 /** 5091 * Gets the url of current Web page. 5092 * @returns { string } Return the url of the current page. 5093 * @throws { BusinessError } 17100001 - Init error. 5094 * The WebviewController must be associated with a Web component. 5095 * @syscap SystemCapability.Web.Webview.Core 5096 * @crossplatform 5097 * @atomicservice 5098 * @since arkts {'1.1':'11', '1.2':'20'} 5099 * @arkts 1.1&1.2 5100 */ 5101 getUrl(): string; 5102 5103 /** 5104 * Scroll the contents of this Webview up by half the view size. 5105 * 5106 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 5107 * the page content will scroll up half the size of the viewframe, 5108 * and when set to true, it will jump to the top of the page. 5109 * @throws { BusinessError } 401 - Invalid input parameter. 5110 * @throws { BusinessError } 17100001 - Init error. 5111 * The WebviewController must be associated with a Web component. 5112 * @syscap SystemCapability.Web.Webview.Core 5113 * @since 9 5114 */ 5115 /** 5116 * Scroll the contents of this Webview up by half the view size. 5117 * 5118 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 5119 * the page content will scroll up half the size of the viewframe, 5120 * and when set to true, it will jump to the top of the page. 5121 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5122 * <br>2. Incorrect parameter types. 5123 * @throws { BusinessError } 17100001 - Init error. 5124 * The WebviewController must be associated with a Web component. 5125 * @syscap SystemCapability.Web.Webview.Core 5126 * @atomicservice 5127 * @since 11 5128 */ 5129 /** 5130 * Scroll the contents of this Webview up by half the view size. 5131 * 5132 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 5133 * the page content will scroll up half the size of the viewframe, 5134 * and when set to true, it will jump to the top of the page. 5135 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5136 * <br>2. Incorrect parameter types. 5137 * @throws { BusinessError } 17100001 - Init error. 5138 * The WebviewController must be associated with a Web component. 5139 * @syscap SystemCapability.Web.Webview.Core 5140 * @crossplatform 5141 * @atomicservice 5142 * @since 18 5143 */ 5144 pageUp(top: boolean): void; 5145 5146 /** 5147 * Scroll the contents of this Webview down by half the view size. 5148 * 5149 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 5150 * the page content will scroll up half the size of the viewframe, 5151 * and when set to true, it will jump to the top of the page. 5152 * @throws { BusinessError } 401 - Invalid input parameter. 5153 * @throws { BusinessError } 17100001 - Init error. 5154 * The WebviewController must be associated with a Web component. 5155 * @syscap SystemCapability.Web.Webview.Core 5156 * @since 9 5157 */ 5158 /** 5159 * Scroll the contents of this Webview down by half the view size. 5160 * 5161 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 5162 * the page content will scroll up half the size of the viewframe, 5163 * and when set to true, it will jump to the top of the page. 5164 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5165 * <br>2. Incorrect parameter types. 5166 * @throws { BusinessError } 17100001 - Init error. 5167 * The WebviewController must be associated with a Web component. 5168 * @syscap SystemCapability.Web.Webview.Core 5169 * @atomicservice 5170 * @since 11 5171 */ 5172 /** 5173 * Scroll the contents of this Webview down by half the view size. 5174 * 5175 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 5176 * the page content will scroll up half the size of the viewframe, 5177 * and when set to true, it will jump to the top of the page. 5178 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5179 * <br>2. Incorrect parameter types. 5180 * @throws { BusinessError } 17100001 - Init error. 5181 * The WebviewController must be associated with a Web component. 5182 * @syscap SystemCapability.Web.Webview.Core 5183 * @crossplatform 5184 * @atomicservice 5185 * @since 18 5186 */ 5187 pageDown(bottom: boolean): void; 5188 5189 /** 5190 * Gets the original url of current Web page. 5191 * @returns { string } Return the original url of the current page. 5192 * @throws { BusinessError } 17100001 - Init error. 5193 * The WebviewController must be associated with a Web component. 5194 * @syscap SystemCapability.Web.Webview.Core 5195 * @since 9 5196 */ 5197 /** 5198 * Gets the original url of current Web page. 5199 * @returns { string } Return the original url of the current page. 5200 * @throws { BusinessError } 17100001 - Init error. 5201 * The WebviewController must be associated with a Web component. 5202 * @syscap SystemCapability.Web.Webview.Core 5203 * @atomicservice 5204 * @since 11 5205 */ 5206 /** 5207 * Gets the original url of current Web page. 5208 * @returns { string } Return the original url of the current page. 5209 * @throws { BusinessError } 17100001 - Init error. 5210 * The WebviewController must be associated with a Web component. 5211 * @syscap SystemCapability.Web.Webview.Core 5212 * @crossplatform 5213 * @atomicservice 5214 * @since arkts {'1.1':'18', '1.2':'20'} 5215 * @arkts 1.1&1.2 5216 */ 5217 getOriginalUrl(): string; 5218 5219 /** 5220 * Gets the favicon of current Web page. 5221 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 5222 * @throws { BusinessError } 17100001 - Init error. 5223 * The WebviewController must be associated with a Web component. 5224 * @syscap SystemCapability.Web.Webview.Core 5225 * @since 9 5226 */ 5227 /** 5228 * Gets the favicon of current Web page. 5229 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 5230 * @throws { BusinessError } 17100001 - Init error. 5231 * The WebviewController must be associated with a Web component. 5232 * @syscap SystemCapability.Web.Webview.Core 5233 * @atomicservice 5234 * @since 11 5235 */ 5236 getFavicon(): image.PixelMap; 5237 5238 /** 5239 * Put network state for web. Which is used to set window.navigator.onLine property in 5240 * JavaScript. 5241 * @param { boolean } enable - Whether enable window.navigator.onLine. 5242 * @throws { BusinessError } 401 - Invalid input parameter. 5243 * @throws { BusinessError } 17100001 - Init error. 5244 * The WebviewController must be associated with a Web component. 5245 * @syscap SystemCapability.Web.Webview.Core 5246 * @since 9 5247 */ 5248 /** 5249 * Put network state for web. Which is used to set window.navigator.onLine property in 5250 * JavaScript. 5251 * @param { boolean } enable - Whether enable window.navigator.onLine. 5252 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5253 * <br>2. Incorrect parameter types. 5254 * @throws { BusinessError } 17100001 - Init error. 5255 * The WebviewController must be associated with a Web component. 5256 * @syscap SystemCapability.Web.Webview.Core 5257 * @atomicservice 5258 * @since 11 5259 */ 5260 setNetworkAvailable(enable: boolean): void; 5261 5262 /** 5263 * Query if current document has image. 5264 * 5265 * @returns { Promise<boolean> } A promise resolved after query image has finished. 5266 * @throws { BusinessError } 401 - Invalid input parameter. 5267 * @throws { BusinessError } 17100001 - Init error. 5268 * The WebviewController must be associated with a Web component. 5269 * @syscap SystemCapability.Web.Webview.Core 5270 * @since 9 5271 */ 5272 /** 5273 * Asynchronous search for image existence on the current page through Promise method. 5274 * 5275 * @returns { Promise<boolean> } A promise resolved after query image has finished. 5276 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5277 * @throws { BusinessError } 17100001 - Init error. 5278 * The WebviewController must be associated with a Web component. 5279 * @syscap SystemCapability.Web.Webview.Core 5280 * @atomicservice 5281 * @since 11 5282 */ 5283 hasImage(): Promise<boolean>; 5284 5285 /** 5286 * Query if current document has image. 5287 * 5288 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 5289 * @throws { BusinessError } 401 - Invalid input parameter. 5290 * @throws { BusinessError } 17100001 - Init error. 5291 * The WebviewController must be associated with a Web component. 5292 * @syscap SystemCapability.Web.Webview.Core 5293 * @since 9 5294 */ 5295 /** 5296 * Asynchronous search for the presence of an image on the current page through callback method. 5297 * 5298 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 5299 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5300 * <br>2. Incorrect parameter types. 5301 * @throws { BusinessError } 17100001 - Init error. 5302 * The WebviewController must be associated with a Web component. 5303 * @syscap SystemCapability.Web.Webview.Core 5304 * @atomicservice 5305 * @since 11 5306 */ 5307 hasImage(callback: AsyncCallback<boolean>): void; 5308 5309 /** 5310 * Get back forward stack list from current webview. 5311 * @returns { BackForwardList } Back forward list for current webview. 5312 * @throws { BusinessError } 17100001 - Init error. 5313 * The WebviewController must be associated with a Web component. 5314 * @syscap SystemCapability.Web.Webview.Core 5315 * @since 9 5316 */ 5317 /** 5318 * Get back forward stack list from current webview. 5319 * @returns { BackForwardList } Back forward list for current webview. 5320 * @throws { BusinessError } 17100001 - Init error. 5321 * The WebviewController must be associated with a Web component. 5322 * @syscap SystemCapability.Web.Webview.Core 5323 * @crossplatform 5324 * @atomicservice 5325 * @since 11 5326 */ 5327 getBackForwardEntries(): BackForwardList; 5328 5329 /** 5330 * Remove resource cache in application. So this method will remove all cache for all web components in the 5331 * same application. 5332 * 5333 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 5334 * in ram. 5335 * @throws { BusinessError } 401 - Invalid input parameter. 5336 * @throws { BusinessError } 17100001 - Init error. 5337 * The WebviewController must be associated with a Web component. 5338 * @syscap SystemCapability.Web.Webview.Core 5339 * @since 9 5340 */ 5341 /** 5342 * Clears the cache in the application. This API will clear the cache for all webviews in the same application. 5343 * 5344 * <p><strong>API Note</strong>:<br> 5345 * You can view the Webview cache in the data/storage/el2/base/cache/web/Cache directory. 5346 * </p> 5347 * 5348 * @param { boolean } clearRom - Whether to clear the cache in the ROM and RAM at the same time. 5349 * {@code true} means to clear the cache in the ROM and RAM at the same time; 5350 * {@code false} means to only clear the cache in the RAM. 5351 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5352 * <br>2. Incorrect parameter types. 5353 * @throws { BusinessError } 17100001 - Init error. 5354 * The WebviewController must be associated with a Web component. 5355 * @syscap SystemCapability.Web.Webview.Core 5356 * @crossplatform 5357 * @atomicservice 5358 * @since 11 5359 */ 5360 removeCache(clearRom: boolean): void; 5361 5362 /** 5363 * Remove resource cache in application. So this method will remove all cache for all web components in the 5364 * same application. 5365 * 5366 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 5367 * in ram. 5368 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5369 * <br>2. Incorrect parameter types. 5370 * @syscap SystemCapability.Web.Webview.Core 5371 * @since 18 5372 */ 5373 static removeAllCache(clearRom: boolean): void; 5374 5375 /** 5376 * Scroll to the position. 5377 * 5378 * @param { number } x - the x of the position. 5379 * @param { number } y - the y of the position. 5380 * @throws { BusinessError } 401 - Invalid input parameter. 5381 * @throws { BusinessError } 17100001 - Init error. 5382 * The WebviewController must be associated with a Web component. 5383 * @syscap SystemCapability.Web.Webview.Core 5384 * @since 9 5385 */ 5386 /** 5387 * Scroll to the position. 5388 * 5389 * @param { number } x - the x of the position. 5390 * @param { number } y - the y of the position. 5391 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5392 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5393 * @throws { BusinessError } 17100001 - Init error. 5394 * The WebviewController must be associated with a Web component. 5395 * @syscap SystemCapability.Web.Webview.Core 5396 * @crossplatform 5397 * @atomicservice 5398 * @since 11 5399 */ 5400 /** 5401 * Scroll to the position within specified time. 5402 * 5403 * @param { number } x - the x of the position.Unit: vp. 5404 * @param { number } y - the y of the position.Unit: vp. 5405 * @param { number } duration - the scroll animation duration. Unit: millisecond. 5406 * If the value is not passed, or is negative or 0, there is no animation. 5407 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5408 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5409 * @throws { BusinessError } 17100001 - Init error. 5410 * The WebviewController must be associated with a Web component. 5411 * @syscap SystemCapability.Web.Webview.Core 5412 * @crossplatform 5413 * @atomicservice 5414 * @since 14 5415 */ 5416 scrollTo(x: number, y: number, duration?: number): void; 5417 5418 /** 5419 * Scroll by the delta position. 5420 * 5421 * @param { number } deltaX - the delta x of the position. 5422 * @param { number } deltaY - the delta y of the position. 5423 * @throws { BusinessError } 401 - Invalid input parameter. 5424 * @throws { BusinessError } 17100001 - Init error. 5425 * The WebviewController must be associated with a Web component. 5426 * @syscap SystemCapability.Web.Webview.Core 5427 * @since 9 5428 */ 5429 /** 5430 * Scroll by the delta position. 5431 * 5432 * @param { number } deltaX - the delta x of the position. 5433 * @param { number } deltaY - the delta y of the position. 5434 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5435 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5436 * @throws { BusinessError } 17100001 - Init error. 5437 * The WebviewController must be associated with a Web component. 5438 * @syscap SystemCapability.Web.Webview.Core 5439 * @crossplatform 5440 * @atomicservice 5441 * @since 11 5442 */ 5443 /** 5444 * Scroll by the delta position within specified time. 5445 * 5446 * <p><strong>API Note</strong>:<br> 5447 * In nested scroll scenarios, calling scrollBy does not trigger nested scrolling in the parent component. 5448 * </p> 5449 * 5450 * @param { number } deltaX - the delta x of the position.Unit: vp. 5451 * @param { number } deltaY - the delta y of the position.Unit: vp. 5452 * @param { number } duration - the scroll animation duration. Unit: millisecond. 5453 * If the value is not passed, or is negative or 0, there is no animation. 5454 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5455 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5456 * @throws { BusinessError } 17100001 - Init error. 5457 * The WebviewController must be associated with a Web component. 5458 * @syscap SystemCapability.Web.Webview.Core 5459 * @crossplatform 5460 * @atomicservice 5461 * @since 14 5462 */ 5463 scrollBy(deltaX: number, deltaY: number, duration?: number): void; 5464 5465 /** 5466 * Slide by the speed. 5467 * 5468 * @param { number } vx - the x speed of the speed. 5469 * @param { number } vy - the y speed of the speed. 5470 * @throws { BusinessError } 401 - Invalid input parameter. 5471 * @throws { BusinessError } 17100001 - Init error. 5472 * The WebviewController must be associated with a Web component. 5473 * @syscap SystemCapability.Web.Webview.Core 5474 * @since 9 5475 */ 5476 /** 5477 * Slide by the speed. 5478 * 5479 * @param { number } vx - the x speed of the speed. Unit: vp/ms. 5480 * @param { number } vy - the y speed of the speed. Unit: vp/ms. 5481 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5482 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5483 * @throws { BusinessError } 17100001 - Init error. 5484 * The WebviewController must be associated with a Web component. 5485 * @syscap SystemCapability.Web.Webview.Core 5486 * @atomicservice 5487 * @since 11 5488 */ 5489 slideScroll(vx: number, vy: number): void; 5490 5491 /** 5492 * Serialize the access stack of the web, that is, the history of access. 5493 * @returns { Uint8Array } Web access stack after serialization. 5494 * @throws { BusinessError } 17100001 - Init error. 5495 * The WebviewController must be associated with a Web component. 5496 * @syscap SystemCapability.Web.Webview.Core 5497 * @since 9 5498 */ 5499 /** 5500 * Serialize the access stack of the web, that is, the history of access. 5501 * @returns { Uint8Array } Web access stack after serialization. 5502 * @throws { BusinessError } 17100001 - Init error. 5503 * The WebviewController must be associated with a Web component. 5504 * @syscap SystemCapability.Web.Webview.Core 5505 * @atomicservice 5506 * @since 11 5507 */ 5508 serializeWebState(): Uint8Array; 5509 5510 /** 5511 * Restoring the web access stack, that is, the history of access. 5512 * @param { Uint8Array } state - Web access stack after serialization. 5513 * @throws { BusinessError } 401 - Invalid input parameter. 5514 * @throws { BusinessError } 17100001 - Init error. 5515 * The WebviewController must be associated with a Web component. 5516 * @syscap SystemCapability.Web.Webview.Core 5517 * @since 9 5518 */ 5519 /** 5520 * Restoring the web access stack, that is, the history of access. 5521 * @param { Uint8Array } state - Web access stack after serialization. 5522 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5523 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5524 * @throws { BusinessError } 17100001 - Init error. 5525 * The WebviewController must be associated with a Web component. 5526 * @syscap SystemCapability.Web.Webview.Core 5527 * @atomicservice 5528 * @since 11 5529 */ 5530 restoreWebState(state: Uint8Array): void; 5531 5532 /** 5533 * Set whether the Web custom scheme supports cross domain and fetch requests. 5534 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 5535 * @throws { BusinessError } 401 - Invalid input parameter. 5536 * @syscap SystemCapability.Web.Webview.Core 5537 * @since 9 5538 */ 5539 /** 5540 * Set whether the Web custom scheme supports cross domain and fetch requests. 5541 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 5542 * @throws { BusinessError } 401 - Invalid input parameter. 5543 * @syscap SystemCapability.Web.Webview.Core 5544 * @atomicservice 5545 * @since 11 5546 */ 5547 /** 5548 * Register Web custom schemes. 5549 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 5550 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5551 * <br>2. Incorrect parameter types. 5552 * @throws { BusinessError } 17100020 - Failed to register custom schemes. 5553 * @syscap SystemCapability.Web.Webview.Core 5554 * @atomicservice 5555 * @since 12 5556 */ 5557 static customizeSchemes(schemes: Array<WebCustomScheme>): void; 5558 5559 /** 5560 * Get certificate for the current website. 5561 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 5562 * @throws { BusinessError } 17100001 - Init error. 5563 * The WebviewController must be associated with a web component. 5564 * @syscap SystemCapability.Web.Webview.Core 5565 * @since 10 5566 */ 5567 /** 5568 * Get certificate for the current website. 5569 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 5570 * @throws { BusinessError } 17100001 - Init error. 5571 * The WebviewController must be associated with a web component. 5572 * @syscap SystemCapability.Web.Webview.Core 5573 * @atomicservice 5574 * @since 11 5575 */ 5576 getCertificate(): Promise<Array<cert.X509Cert>>; 5577 5578 /** 5579 * Get certificate for the current website. 5580 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 5581 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5582 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5583 * @throws { BusinessError } 17100001 - Init error. 5584 * The WebviewController must be associated with a web component. 5585 * @syscap SystemCapability.Web.Webview.Core 5586 * @since 10 5587 */ 5588 /** 5589 * Get certificate for the current website. 5590 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 5591 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5592 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5593 * @throws { BusinessError } 17100001 - Init error. 5594 * The WebviewController must be associated with a web component. 5595 * @syscap SystemCapability.Web.Webview.Core 5596 * @atomicservice 5597 * @since 11 5598 */ 5599 getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void; 5600 5601 /** 5602 * Set audio muted. 5603 * @param { boolean } mute - Set the audio muted or not. 5604 * @throws { BusinessError } 401 - Invalid input parameter. 5605 * @throws { BusinessError } 17100001 - Init error. 5606 * The WebviewController must be associated with a Web component. 5607 * @syscap SystemCapability.Web.Webview.Core 5608 * @since 10 5609 */ 5610 /** 5611 * Set webpage mute. 5612 * @param { boolean } mute - Set the audio muted or not. 5613 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5614 * <br>2. Incorrect parameter types. 5615 * @throws { BusinessError } 17100001 - Init error. 5616 * The WebviewController must be associated with a Web component. 5617 * @syscap SystemCapability.Web.Webview.Core 5618 * @atomicservice 5619 * @since 11 5620 */ 5621 setAudioMuted(mute: boolean): void; 5622 5623 /** 5624 * Prefetch the resources required by the page, but will not execute js or render the page. 5625 * @param { string } url - Which url to preresolve/preconnect. 5626 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 5627 * @throws { BusinessError } 17100001 - Init error. 5628 * The WebviewController must be associated with a Web component. 5629 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5630 * length exceeds 2048. 5631 * @syscap SystemCapability.Web.Webview.Core 5632 * @since 10 5633 */ 5634 /** 5635 * Prefetch the resources required by the page, but will not execute js or render the page. 5636 * @param { string } url - Which url to preresolve/preconnect. 5637 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 5638 * @throws { BusinessError } 17100001 - Init error. 5639 * The WebviewController must be associated with a Web component. 5640 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5641 * length exceeds 2048. 5642 * @syscap SystemCapability.Web.Webview.Core 5643 * @atomicservice 5644 * @since 11 5645 */ 5646 prefetchPage(url: string, additionalHeaders?: Array<WebHeader>): void; 5647 5648 /** 5649 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 5650 * @param { string } url - Which url to preresolve/preconnect. 5651 * @param { boolean } preconnectable - Indicates whether to preconnect. 5652 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 5653 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5654 * length exceeds 2048. 5655 * @throws { BusinessError } 17100013 - The number of preconnect sockets is invalid. 5656 * @syscap SystemCapability.Web.Webview.Core 5657 * @since 10 5658 */ 5659 /** 5660 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 5661 * @param { string } url - Which url to preresolve/preconnect. 5662 * @param { boolean } preconnectable - Indicates whether to preconnect. 5663 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 5664 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5665 * length exceeds 2048. 5666 * @throws { BusinessError } 17100013 - The number of preconnect sockets is invalid. 5667 * @syscap SystemCapability.Web.Webview.Core 5668 * @atomicservice 5669 * @since 11 5670 */ 5671 static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void; 5672 5673 /** 5674 * Set custom user agent. 5675 * @param { string } userAgent - User custom agent information. 5676 * @throws { BusinessError } 401 - Invalid input parameter. 5677 * @throws { BusinessError } 17100001 - Init error. 5678 * The WebviewController must be associated with a Web component. 5679 * @syscap SystemCapability.Web.Webview.Core 5680 * @since 10 5681 */ 5682 /** 5683 * Set custom user agent. 5684 * @param { string } userAgent - User custom agent information. 5685 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5686 * <br>2. Incorrect parameter types. 5687 * @throws { BusinessError } 17100001 - Init error. 5688 * The WebviewController must be associated with a Web component. 5689 * @syscap SystemCapability.Web.Webview.Core 5690 * @crossplatform 5691 * @atomicservice 5692 * @since 11 5693 */ 5694 setCustomUserAgent(userAgent: string): void; 5695 5696 /** 5697 * Get custom user agent. 5698 * @returns { string } Get custom User agent information. 5699 * @throws { BusinessError } 17100001 - Init error. 5700 * The WebviewController must be associated with a Web component. 5701 * @syscap SystemCapability.Web.Webview.Core 5702 * @since 10 5703 */ 5704 /** 5705 * Get custom user agent. 5706 * @returns { string } Get custom User agent information. 5707 * @throws { BusinessError } 17100001 - Init error. 5708 * The WebviewController must be associated with a Web component. 5709 * @syscap SystemCapability.Web.Webview.Core 5710 * @crossplatform 5711 * @atomicservice 5712 * @since 11 5713 */ 5714 getCustomUserAgent(): string; 5715 5716 /** 5717 * Set web engine socket connection timeout. 5718 * @param { number } timeout - Socket connection timeout. 5719 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5720 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 5721 * @syscap SystemCapability.Web.Webview.Core 5722 * @atomicservice 5723 * @since 11 5724 */ 5725 static setConnectionTimeout(timeout: number): void; 5726 5727 /** 5728 * Set delegate for download. 5729 * Used to notify the progress of the download triggered from web. 5730 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from web. 5731 * @throws { BusinessError } 17100001 - Init error. 5732 * The WebviewController must be associated with a Web component. 5733 * @syscap SystemCapability.Web.Webview.Core 5734 * @atomicservice 5735 * @since 11 5736 */ 5737 /** 5738 * Set delegate for download. 5739 * Used to notify the progress of the download triggered from web. 5740 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from web. 5741 * @throws { BusinessError } 17100001 - Init error. 5742 * The WebviewController must be associated with a Web component. 5743 * @syscap SystemCapability.Web.Webview.Core 5744 * @crossplatform 5745 * @atomicservice 5746 * @since arkts {'1.1':'18', '1.2':'20'} 5747 * @arkts 1.1&1.2 5748 */ 5749 setDownloadDelegate(delegate: WebDownloadDelegate): void; 5750 5751 /** 5752 * Start a download. 5753 * @param { string } url - The download url. 5754 * @throws { BusinessError } 17100001 - Init error. 5755 * The WebviewController must be associated with a Web component. 5756 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5757 * length exceeds 2048. 5758 * @syscap SystemCapability.Web.Webview.Core 5759 * @atomicservice 5760 * @since 11 5761 */ 5762 /** 5763 * Start a download. 5764 * @param { string } url - The download url. 5765 * @throws { BusinessError } 17100001 - Init error. 5766 * The WebviewController must be associated with a Web component. 5767 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5768 * length exceeds 2048. 5769 * @syscap SystemCapability.Web.Webview.Core 5770 * @crossplatform 5771 * @atomicservice 5772 * @since arkts {'1.1':'18', '1.2':'20'} 5773 * @arkts 1.1&1.2 5774 */ 5775 startDownload(url: string): void; 5776 5777 /** 5778 * Loads the URL use "POST" method with post data. 5779 * 5780 * @param { string } url - Request the URL use "POST" method. 5781 * @param { ArrayBuffer } postData - This data will passed to "POST" request. 5782 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5783 * <br>2. Incorrect parameter types. 5784 * @throws { BusinessError } 17100001 - Init error. 5785 * The WebviewController must be associated with a Web component. 5786 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5787 * length exceeds 2048. 5788 * @syscap SystemCapability.Web.Webview.Core 5789 * @atomicservice 5790 * @since 11 5791 */ 5792 /** 5793 * Loads the URL use "POST" method with post data. 5794 * 5795 * @param { string } url - Request the URL use "POST" method. 5796 * @param { ArrayBuffer } postData - This data will passed to "POST" request. 5797 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5798 * <br>2. Incorrect parameter types. 5799 * @throws { BusinessError } 17100001 - Init error. 5800 * The WebviewController must be associated with a Web component. 5801 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 5802 * length exceeds 2048. 5803 * @syscap SystemCapability.Web.Webview.Core 5804 * @crossplatform 5805 * @atomicservice 5806 * @since arkts {'1.1':'18', '1.2':'20'} 5807 * @arkts 1.1&1.2 5808 */ 5809 postUrl(url: string, postData: ArrayBuffer): void; 5810 5811 /** 5812 * Creates a PrintDocumentAdapter instance to provide content for printing. 5813 * @param { string } jobName - Name of the file to print. 5814 * @returns { print.PrintDocumentAdapter } Return PrintDocumentAdapter instance created. 5815 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5816 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5817 * @throws { BusinessError } 17100001 - Init error. 5818 * The WebviewController must be associated with a Web component. 5819 * @syscap SystemCapability.Web.Webview.Core 5820 * @since 11 5821 */ 5822 createWebPrintDocumentAdapter(jobName: string): print.PrintDocumentAdapter; 5823 5824 /** 5825 * Get the security level of the current page. 5826 * 5827 * @returns { SecurityLevel } the security level of current page. 5828 * @throws { BusinessError } 17100001 - Init error. 5829 * The WebviewController must be associated with a Web component. 5830 * @syscap SystemCapability.Web.Webview.Core 5831 * @atomicservice 5832 * @since 11 5833 */ 5834 getSecurityLevel(): SecurityLevel; 5835 5836 /** 5837 * Whether the incognito mode is set. 5838 * 5839 * @returns { boolean } {@code true} has been set the incognito mode; {@code false} otherwise. 5840 * @throws { BusinessError } 17100001 - Init error. 5841 * The WebviewController must be associated with a Web component. 5842 * @syscap SystemCapability.Web.Webview.Core 5843 * @atomicservice 5844 * @since 11 5845 */ 5846 isIncognitoMode(): boolean; 5847 5848 /** 5849 * Set whether scroll is allowed; default is true. 5850 * 5851 * @param { boolean } enable - Set whether scrolling is allowed 5852 * {@code true} means scrolling is allowed. 5853 * {@code false} means scrolling is disabled. 5854 * @param { ScrollType } type - Enable scrolling type 5855 * When the input parameter enable is false, it indicates that scrolling of the ScrollType type is prohibited.When ScrollType 5856 * is not specified,it indicates that all types of webpage scrolling are prohibited. 5857 * When the input parameter enable is true, regardless of whether ScrollType is specified, it indicates that all types 5858 * of webpage scrolling are allowed. 5859 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5860 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5861 * @throws { BusinessError } 17100001 - Init error. 5862 * The WebviewController must be associated with a Web component. 5863 * @syscap SystemCapability.Web.Webview.Core 5864 * @atomicservice 5865 * @since 12 5866 */ 5867 setScrollable(enable: boolean, type?: ScrollType): void; 5868 5869 /** 5870 * Get whether scrolling is allowed. 5871 * @returns { boolean } Get scrolling is allowed information. 5872 * @throws { BusinessError } 17100001 - Init error. 5873 * The WebviewController must be associated with a Web component. 5874 * @syscap SystemCapability.Web.Webview.Core 5875 * @atomicservice 5876 * @since arkts {'1.1':'12', '1.2':'20'} 5877 * @arkts 1.1&1.2 5878 */ 5879 getScrollable(): boolean; 5880 5881 /** 5882 * Set whether print web page background. 5883 * 5884 * @param { boolean } enable - Set whether print web page background 5885 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5886 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5887 * @throws { BusinessError } 17100001 - Init error. 5888 * The WebviewController must be associated with a Web component. 5889 * @syscap SystemCapability.Web.Webview.Core 5890 * @atomicservice 5891 * @since 12 5892 */ 5893 setPrintBackground(enable: boolean): void; 5894 5895 /** 5896 * Get whether print web page background. 5897 * @returns { boolean } Get whether print web page background. 5898 * @throws { BusinessError } 17100001 - Init error. 5899 * The WebviewController must be associated with a Web component. 5900 * @syscap SystemCapability.Web.Webview.Core 5901 * @atomicservice 5902 * @since 12 5903 */ 5904 getPrintBackground(): boolean; 5905 5906 /** 5907 * Get the url of the last frame that calls the JavaScriptProxy. 5908 * This should be called on the UI thread. 5909 * 5910 * @returns { string } The url of the last frame that calls the JavaScriptProxy. 5911 * @throws { BusinessError } 17100001 - Init error. 5912 * The WebviewController must be associated with a Web component. 5913 * @syscap SystemCapability.Web.Webview.Core 5914 * @atomicservice 5915 * @since arkts {'1.1':'12', '1.2':'20'} 5916 * @arkts 1.1&1.2 5917 */ 5918 getLastJavascriptProxyCallingFrameUrl(): string; 5919 5920 /** 5921 * Start current camera, and before using the camera function, please add the permission in module.json5: ohos.permission.CAMERA. 5922 * 5923 * @throws { BusinessError } 17100001 - Init error. 5924 * The WebviewController must be associated with a Web component. 5925 * @syscap SystemCapability.Web.Webview.Core 5926 * @atomicservice 5927 * @since 12 5928 */ 5929 startCamera(): void; 5930 5931 /** 5932 * Stop current camera. 5933 * 5934 * @throws { BusinessError } 17100001 - Init error. 5935 * The WebviewController must be associated with a Web component. 5936 * @syscap SystemCapability.Web.Webview.Core 5937 * @atomicservice 5938 * @since 12 5939 */ 5940 stopCamera(): void; 5941 5942 /** 5943 * Close current camera. 5944 * 5945 * @throws { BusinessError } 17100001 - Init error. 5946 * The WebviewController must be associated with a Web component. 5947 * @syscap SystemCapability.Web.Webview.Core 5948 * @atomicservice 5949 * @since 12 5950 */ 5951 closeCamera(): void; 5952 5953 /** 5954 * Pause all WebView timers. 5955 * 5956 * @throws { BusinessError } 17100001 - Init error. 5957 * The WebviewController must be associated with a Web component. 5958 * @syscap SystemCapability.Web.Webview.Core 5959 * @atomicservice 5960 * @since 12 5961 */ 5962 static pauseAllTimers(): void; 5963 5964 /** 5965 * Resume all timers suspended from the pauseAllTimers() interface. 5966 * 5967 * @throws { BusinessError } 17100001 - Init error. 5968 * The WebviewController must be associated with a Web component. 5969 * @syscap SystemCapability.Web.Webview.Core 5970 * @atomicservice 5971 * @since 12 5972 */ 5973 static resumeAllTimers(): void; 5974 5975 /** 5976 * Stop all audio and video playback on the web page. 5977 * 5978 * @throws { BusinessError } 17100001 - Init error. 5979 * The WebviewController must be associated with a Web component. 5980 * @syscap SystemCapability.Web.Webview.Core 5981 * @atomicservice 5982 * @since 12 5983 */ 5984 stopAllMedia(): void; 5985 5986 /** 5987 * Resumes the playback of the audio and video that are paused by the pauseAllMedia interface. 5988 * 5989 * @throws { BusinessError } 17100001 - Init error. 5990 * The WebviewController must be associated with a Web component. 5991 * @syscap SystemCapability.Web.Webview.Core 5992 * @atomicservice 5993 * @since 12 5994 */ 5995 resumeAllMedia(): void; 5996 5997 /** 5998 * Pause all audio and video playback on the web page. 5999 * 6000 * @throws { BusinessError } 17100001 - Init error. 6001 * The WebviewController must be associated with a Web component. 6002 * @syscap SystemCapability.Web.Webview.Core 6003 * @atomicservice 6004 * @since 12 6005 */ 6006 pauseAllMedia(): void; 6007 6008 /** 6009 * Closes all full-screen videos on a web page. 6010 * 6011 * @throws { BusinessError } 17100001 - Init error. 6012 * The WebviewController must be associated with a Web component. 6013 * @syscap SystemCapability.Web.Webview.Core 6014 * @atomicservice 6015 * @since 12 6016 */ 6017 closeAllMediaPresentations(): void; 6018 6019 /** 6020 * View the playback status of all audio and video on the web page. 6021 * 6022 * @returns { MediaPlaybackState } The playback status of all audio and video. 6023 * @throws { BusinessError } 17100001 - Init error. 6024 * The WebviewController must be associated with a Web component. 6025 * @syscap SystemCapability.Web.Webview.Core 6026 * @atomicservice 6027 * @since 12 6028 */ 6029 getMediaPlaybackState(): MediaPlaybackState; 6030 6031 /** 6032 * Set web scheme handler for specific scheme. This is only used for related web component. 6033 * 6034 * @param { string } scheme - String value for url scheme. 6035 * @param { WebSchemeHandler } handler - Web scheme handler. 6036 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6037 * @throws { BusinessError } 17100001 - Init error. 6038 * The WebviewController must be associated with a Web component. 6039 * @syscap SystemCapability.Web.Webview.Core 6040 * @atomicservice 6041 * @since 12 6042 */ 6043 setWebSchemeHandler(scheme: string, handler: WebSchemeHandler): void; 6044 6045 /** 6046 * Clear all web scheme handlers for related web component. 6047 * @throws { BusinessError } 17100001 - Init error. 6048 * The WebviewController must be associated with a Web component. 6049 * @syscap SystemCapability.Web.Webview.Core 6050 * @atomicservice 6051 * @since arkts {'1.1':'12', '1.2':'20'} 6052 * @arkts 1.1&1.2 6053 */ 6054 clearWebSchemeHandler(): void; 6055 6056 /** 6057 * Set web scheme handler for specific scheme. This is used for service worker. 6058 * @param { string } scheme - String value for url scheme. 6059 * @param { WebSchemeHandler } handler - Web scheme handler. 6060 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6061 * @syscap SystemCapability.Web.Webview.Core 6062 * @atomicservice 6063 * @since 12 6064 */ 6065 static setServiceWorkerWebSchemeHandler(scheme: string, handler: WebSchemeHandler): void; 6066 6067 /** 6068 * Clear all web service worker scheme handlers. 6069 * @syscap SystemCapability.Web.Webview.Core 6070 * @atomicservice 6071 * @since 12 6072 */ 6073 static clearServiceWorkerWebSchemeHandler(): void; 6074 6075 /** 6076 * Enable the ability to use Intelligent Tracking Prevention; default is disabled. 6077 * 6078 * @param { boolean } enable {@code true} enable Intelligent Tracking Prevention; {@code false} otherwise. 6079 * @throws { BusinessError } 17100001 - Init error. 6080 * The WebviewController must be associated with a Web component. 6081 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6082 * <br>2. Incorrect parameter types. 6083 * @syscap SystemCapability.Web.Webview.Core 6084 * @atomicservice 6085 * @since 12 6086 */ 6087 /** 6088 * Enable the ability to use Intelligent Tracking Prevention; default is disabled. 6089 * 6090 * @param { boolean } enable {@code true} enable Intelligent Tracking Prevention; {@code false} otherwise. 6091 * @throws { BusinessError } 17100001 - Init error. 6092 * The WebviewController must be associated with a Web component. 6093 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6094 * <br>2. Incorrect parameter types. 6095 * @throws { BusinessError } 801 - Capability not supported. 6096 * @syscap SystemCapability.Web.Webview.Core 6097 * @atomicservice 6098 * @since 18 6099 */ 6100 enableIntelligentTrackingPrevention(enable: boolean): void; 6101 6102 /** 6103 * Get whether Intelligent Tracking Prevention is enabled. 6104 * 6105 * @returns { boolean } True if enable the Intelligent Tracking Prevention; else false. 6106 * @throws { BusinessError } 17100001 - Init error. 6107 * The WebviewController must be associated with a Web component. 6108 * @syscap SystemCapability.Web.Webview.Core 6109 * @atomicservice 6110 * @since 12 6111 */ 6112 /** 6113 * Get whether Intelligent Tracking Prevention is enabled. 6114 * 6115 * @returns { boolean } True if enable the Intelligent Tracking Prevention; else false. 6116 * @throws { BusinessError } 17100001 - Init error. 6117 * The WebviewController must be associated with a Web component. 6118 * @throws { BusinessError } 801 - Capability not supported. 6119 * @syscap SystemCapability.Web.Webview.Core 6120 * @atomicservice 6121 * @since 18 6122 */ 6123 isIntelligentTrackingPreventionEnabled(): boolean; 6124 6125 /** 6126 * Add bypassing hosts for Intelligent Tracking Prevention. 6127 * 6128 * @param { Array<string> } hostList - Hosts that bypass the Intelligent Tracking Prevention. 6129 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6130 * <br>2. Incorrect parameter types. 6131 * @syscap SystemCapability.Web.Webview.Core 6132 * @atomicservice 6133 * @since 12 6134 */ 6135 /** 6136 * Add bypassing hosts for Intelligent Tracking Prevention. 6137 * 6138 * @param { Array<string> } hostList - Hosts that bypass the Intelligent Tracking Prevention. 6139 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6140 * <br>2. Incorrect parameter types. 6141 * @throws { BusinessError } 801 - Capability not supported. 6142 * @syscap SystemCapability.Web.Webview.Core 6143 * @atomicservice 6144 * @since 18 6145 */ 6146 static addIntelligentTrackingPreventionBypassingList(hostList: Array<string>): void; 6147 6148 /** 6149 * Remove bypassing hosts for Intelligent Tracking Prevention. 6150 * 6151 * @param { Array<string> } hostList - Hosts needs to remove from bypass list. 6152 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6153 * <br>2. Incorrect parameter types. 6154 * @syscap SystemCapability.Web.Webview.Core 6155 * @atomicservice 6156 * @since 12 6157 */ 6158 /** 6159 * Remove bypassing hosts for Intelligent Tracking Prevention. 6160 * 6161 * @param { Array<string> } hostList - Hosts needs to remove from bypass list. 6162 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6163 * <br>2. Incorrect parameter types. 6164 * @throws { BusinessError } 801 - Capability not supported. 6165 * @syscap SystemCapability.Web.Webview.Core 6166 * @atomicservice 6167 * @since 18 6168 */ 6169 static removeIntelligentTrackingPreventionBypassingList(hostList: Array<string>): void; 6170 6171 /** 6172 * Clear bypassing hosts for Intelligent Tracking Prevention. 6173 * 6174 * @syscap SystemCapability.Web.Webview.Core 6175 * @atomicservice 6176 * @since 12 6177 */ 6178 /** 6179 * Clear bypassing hosts for Intelligent Tracking Prevention. 6180 * 6181 * @throws { BusinessError } 801 - Capability not supported. 6182 * @syscap SystemCapability.Web.Webview.Core 6183 * @atomicservice 6184 * @since 18 6185 */ 6186 static clearIntelligentTrackingPreventionBypassingList(): void; 6187 6188 /** 6189 * Get the default user agent. 6190 * 6191 * @returns {string} The default user agent string. 6192 * @syscap SystemCapability.Web.Webview.Core 6193 * @since 14 6194 */ 6195 static getDefaultUserAgent(): string; 6196 6197 /** 6198 * Register a callback to intercept web pages playing media. 6199 * 6200 * @param { CreateNativeMediaPlayerCallback } callback - Called everytime when web pages try to play media. 6201 * @syscap SystemCapability.Web.Webview.Core 6202 * @atomicservice 6203 * @since 12 6204 */ 6205 onCreateNativeMediaPlayer(callback: CreateNativeMediaPlayerCallback): void; 6206 6207 /** 6208 * Enables the full drawing capability for the web page. 6209 * This API works only during Web component initialization. 6210 * 6211 * @syscap SystemCapability.Web.Webview.Core 6212 * @atomicservice 6213 * @since 12 6214 */ 6215 static enableWholeWebPageDrawing(): void; 6216 6217 /** 6218 * Web page snapshot. 6219 * 6220 * <p><strong>API Note</strong>:<br> 6221 * Only screenshots of assets on the rendering process are supported: still images and text. 6222 * If there is a video on the page, the placeholder image of the video will be displayed when you take a screenshot, 6223 * and blank if there is no placeholder. 6224 * </p> 6225 * 6226 * @param { SnapshotInfo } info - The snapshot info. 6227 * @param { AsyncCallback<SnapshotResult> } callback - the callback of snapshot. 6228 * @syscap SystemCapability.Web.Webview.Core 6229 * @atomicservice 6230 * @since 12 6231 */ 6232 webPageSnapshot(info: SnapshotInfo, callback: AsyncCallback<SnapshotResult>): void; 6233 6234 /** 6235 * Prefetches resource requests based on specified request information and additional HTTP request headers, 6236 * saves the requests to the memory cache, and specifies the cache key and validity period to accelerate loading. 6237 * Currently, only POST requests whose Content-Type is application/x-www-form-urlencoded are supported. 6238 * A maximum of six POST requests can be pre-obtained. To prefetch the seventh post request, 6239 * call API{@link clearPrefetchedResource} to clear the cache of unnecessary post requests. 6240 * Otherwise, the cache of the earliest prefetched POST request will be automatically cleared. 6241 * To use the prefetched resource cache, you need to add the key value ArkWebPostCacheKey to the header of the POST request. 6242 * The content of the key value is the cacheKey of the corresponding cache. 6243 * @param { RequestInfo } request - The information of the request. 6244 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the request. 6245 * @param { string } [cacheKey] - The key for memory cache. Default value is the url of the request. 6246 * Only support number and letters. 6247 * @param { number } [cacheValidTime] - The valid time of the cache for request, ranges greater than 0. 6248 * The unit is second. Default value is 300s. 6249 * The value of cacheValidTime must between 1 and 2147483647. 6250 * @throws { BusinessError } 401 - Invalid input parameter.Possible causes: 1. Mandatory parameters are left unspecified. 6251 * 2. Incorrect parameter types. 3. Parameter verification failed. 6252 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 6253 * length exceeds 2048. 6254 * @syscap SystemCapability.Web.Webview.Core 6255 * @atomicservice 6256 * @since 12 6257 */ 6258 static prefetchResource(request: RequestInfo, additionalHeaders?: Array<WebHeader>, cacheKey?: string, 6259 cacheValidTime?: number): void; 6260 6261 /** 6262 * Clears the cache of prefetched resources based on the specified cache key list. 6263 * The cache key in the input parameter must be the prefetched resource cache key specified by API{@link prefetchResource}. 6264 * @param { Array<string> } cacheKeyList - The keys for memory cache. 6265 * The key in cacheKeyList only support number and letters. 6266 * @syscap SystemCapability.Web.Webview.Core 6267 * @atomicservice 6268 * @since 12 6269 */ 6270 static clearPrefetchedResource(cacheKeyList: Array<string>): void; 6271 6272 /** 6273 * Set render process mode of the ArkWeb. 6274 * 6275 * @param { RenderProcessMode } mode - The render process mode for the ArkWeb. 6276 * Call {@link getRenderProcessMode} to get the ArkWeb rendering subprocess mode of the current device. 6277 * The enumerated value **0** indicates the single render subprocess mode, 6278 * and **1** indicates the multi-render subprocess mode. 6279 * If an invalid number other than the enumerated value of **RenderProcessMode** is passed, 6280 * the multi-render subprocess mode is used by default. 6281 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6282 * <br>2. Incorrect parameter types. 6283 * @syscap SystemCapability.Web.Webview.Core 6284 * @atomicservice 6285 * @since 12 6286 */ 6287 static setRenderProcessMode(mode: RenderProcessMode): void; 6288 6289 /** 6290 * Get render process mode of the ArkWeb. 6291 * 6292 * @returns { RenderProcessMode } mode - The render process mode of the ArkWeb. 6293 * Call {@link getRenderProcessMode} to get the ArkWeb rendering subprocess mode of the current device, 6294 * with an enumeration value of 0 as a single subprocess mode and an enumeration value of 1 as a multi-subprocess mode. 6295 * If the obtained value is not within the range of the RenderProcessMode enumeration value, 6296 * it defaults to the multi-rendering subprocess mode. 6297 * @syscap SystemCapability.Web.Webview.Core 6298 * @atomicservice 6299 * @since 12 6300 */ 6301 static getRenderProcessMode(): RenderProcessMode; 6302 6303 /** 6304 * Destroy the rendering process. 6305 * Calling this interface will actively destroy the associated rendering process. 6306 * If the rendering process has not been started or destroyed, it has no effect. 6307 * In addition, destroying the rendering process will also affect all other instances associated with 6308 * the rendering process. 6309 * 6310 * @returns { boolean } true if it was possible to terminate the render process, otherwise false. 6311 * Calling this on a not yet started, or an already terminated render will have no effect. 6312 * @throws { BusinessError } 17100001 - Init error. 6313 * The WebviewController must be associated with a Web component. 6314 * @syscap SystemCapability.Web.Webview.Core 6315 * @since 12 6316 */ 6317 terminateRenderProcess(): boolean; 6318 6319 /** 6320 * Compile javascript and generate code cache. 6321 * @param { string } url - Url of the javascript. Only support HTTP/HTTPS protocol and length no longer than 2048. 6322 * @param { string | Uint8Array } script - Javascript source code. script must not be empty. 6323 * @param { CacheOptions } cacheOptions - Generate code cache option. 6324 * @returns { Promise<number> } - The promise returned by the function. 6325 * 0 means generate code cache successfully, -1 means internal error. 6326 * @throws { BusinessError } 401 - Invalid input parameter. 6327 * Possible causes: 1. Mandatory parameters are left unspecified. 6328 * 2. Incorrect parameter types. 3. Parameter verification failed. 6329 * @throws { BusinessError } 17100001 - Init error. 6330 * The WebviewController must be associated with a Web component. 6331 * @syscap SystemCapability.Web.Webview.Core 6332 * @since 12 6333 */ 6334 precompileJavaScript(url: string, script: string | Uint8Array, cacheOptions: CacheOptions): Promise<number>; 6335 6336 /** 6337 * Set IP address for host name. 6338 * 6339 * @param { string } hostName - Which host name to be resolved. 6340 * @param { string } address - Resolved IP address. 6341 * @param { number } aliveTime - The validity seconds for resolve cache. 6342 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6343 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 6344 * @syscap SystemCapability.Web.Webview.Core 6345 * @atomicservice 6346 * @since 12 6347 */ 6348 static setHostIP(hostName: string, address: string, aliveTime: number): void; 6349 6350 /** 6351 * Clear the host name IP address. 6352 * 6353 * @param { string } hostName - Which host name to be cleared. 6354 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6355 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 6356 * @syscap SystemCapability.Web.Webview.Core 6357 * @atomicservice 6358 * @since 12 6359 */ 6360 static clearHostIP(hostName: string): void; 6361 6362 /** 6363 * Warmup the registered service worker associated the url. 6364 * @param { string } url - The url. 6365 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 6366 * length exceeds 2048. 6367 * @syscap SystemCapability.Web.Webview.Core 6368 * @atomicservice 6369 * @since 12 6370 */ 6371 static warmupServiceWorker(url: string): void; 6372 6373 /** 6374 * Inject offline resources into cache. 6375 * 6376 * @param { Array<OfflineResourceMap> } resourceMaps - Array of offline resource info maps. 6377 * The count of array must between 1 and 30. 6378 * @throws { BusinessError } 401 - Invalid input parameter. 6379 * Possible causes: 1. Mandatory parameters are left unspecified. 6380 * 2. Incorrect parameter types. 3. Parameter verification failed. 6381 * @throws { BusinessError } 17100001 - Init error. 6382 * The WebviewController must be associated with a Web component. 6383 * @throws { BusinessError } 17100002 - URL error. The webpage corresponding to the URL is invalid, or the URL 6384 * length exceeds 2048. 6385 * @syscap SystemCapability.Web.Webview.Core 6386 * @since 12 6387 */ 6388 injectOfflineResources(resourceMaps: Array<OfflineResourceMap>): void; 6389 6390 /** 6391 * Enable the ability to block Ads, disabled by default. 6392 * 6393 * @param { boolean } enable {@code true} Enable Ads block; {@code false} otherwise. 6394 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6395 * <br>2. Parameter string is too long. 3.Parameter verification failed. 6396 * @throws { BusinessError } 17100001 - Init error. 6397 * The WebviewController must be associated with a Web component. 6398 * @syscap SystemCapability.Web.Webview.Core 6399 * @atomicservice 6400 * @since 12 6401 */ 6402 /** 6403 * Enable the ability to block Ads, disabled by default. 6404 * 6405 * @param { boolean } enable {@code true} Enable Ads block; {@code false} otherwise. 6406 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6407 * <br>2. Parameter string is too long. 3.Parameter verification failed. 6408 * @throws { BusinessError } 17100001 - Init error. 6409 * The WebviewController must be associated with a Web component. 6410 * @throws { BusinessError } 801 - Capability not supported. 6411 * @syscap SystemCapability.Web.Webview.Core 6412 * @atomicservice 6413 * @since 18 6414 */ 6415 enableAdsBlock(enable: boolean): void; 6416 6417 /** 6418 * Get whether Ads block is enabled. 6419 * 6420 * @returns { boolean } True if the ability of AdsBlock is enabled; else false. 6421 * @syscap SystemCapability.Web.Webview.Core 6422 * @atomicservice 6423 * @since 12 6424 */ 6425 /** 6426 * Get whether Ads block is enabled. 6427 * 6428 * @returns { boolean } True if the ability of AdsBlock is enabled; else false. 6429 * @throws { BusinessError } 801 - Capability not supported. 6430 * @syscap SystemCapability.Web.Webview.Core 6431 * @atomicservice 6432 * @since 18 6433 */ 6434 isAdsBlockEnabled(): boolean; 6435 6436 /** 6437 * Get whether Ads block is enabled for current Webpage. 6438 * 6439 * @returns { boolean } True if the ability of AdsBlock is enabled for current Webpage; else false. 6440 * @syscap SystemCapability.Web.Webview.Core 6441 * @atomicservice 6442 * @since 12 6443 */ 6444 /** 6445 * Get whether Ads block is enabled for current Webpage. 6446 * 6447 * @returns { boolean } True if the ability of AdsBlock is enabled for current Webpage; else false. 6448 * @throws { BusinessError } 801 - Capability not supported. 6449 * @syscap SystemCapability.Web.Webview.Core 6450 * @atomicservice 6451 * @since 18 6452 */ 6453 isAdsBlockEnabledForCurPage(): boolean; 6454 6455 /** 6456 * Get the ID of the surface created by ArkWeb. This ID can be used for web page screenshots. 6457 * 6458 * @returns { string } The ID of the surface created by ArkWeb. 6459 * @syscap SystemCapability.Web.Webview.Core 6460 * @atomicservice 6461 * @since 12 6462 */ 6463 getSurfaceId(): string; 6464 6465 /** 6466 * Set the URL trust list for the ArkWeb. 6467 * When the URL trust list has been set, only the URLs in the list can be accessed. 6468 * 6469 * @param { string } urlTrustList - the URL trust list in JSON format. 6470 * An empty string means that all URLs are allowed to access. 6471 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6472 * <br>2. Parameter string is too long. 3.Parameter verification failed. 6473 * @throws { BusinessError } 17100001 - Init error. 6474 * The WebviewController must be associated with a Web component. 6475 * @syscap SystemCapability.Web.Webview.Core 6476 * @atomicservice 6477 * @since 12 6478 */ 6479 setUrlTrustList(urlTrustList: string): void; 6480 6481 /** 6482 * Sets a path list. When a file protocol accesses resources in the path list, it can access the local files across 6483 * domains. In addition, when a path list is set, the file protocol can access only the resources in the path list. 6484 * The behavior of {@link fileAccess} will be overwritten by that of this API. 6485 * 6486 * The paths in the list must be any of the following(sub path and module name must be provided): 6487 * 6488 * 1. The path of subdirectory of the application file directory, like "/data/storage/el2/base/files/example" 6489 * or "/data/storage/el2/base/haps/entry/files/example". 6490 * The application file directory is obtained using Context.filesDir in the Ability Kit. 6491 * 2. The path of application resource directory or its subdirectory, like "/data/storage/el1/bundle/entry/resource/resfile" 6492 * or "/data/storage/el1/bundle/entry/resource/resfile/example". 6493 * The application resource directory is obtained from Context.resourceDir in the Ability Kit. 6494 * 6495 * If a path in the list is not of the preceding paths, error code 401 is reported and the path list fails 6496 * to be set. When the path list is set to empty, the accessible files for the file protocol are subject to 6497 * the behavior of the {@link fileAccess}. 6498 * 6499 * @param { Array<string> } pathList - The path list allow universal access. 6500 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6501 * <br>2. Parameter string is too long. 3.Parameter verification failed. 6502 * @throws { BusinessError } 17100001 - Init error. 6503 * The WebviewController must be associated with a Web component. 6504 * @syscap SystemCapability.Web.Webview.Core 6505 * @since 12 6506 */ 6507 setPathAllowingUniversalAccess(pathList: Array<string>): void; 6508 6509 /** 6510 * Trim memory by different memory pressure level. 6511 * 6512 * @param { PressureLevel } level - The memory pressure level for the ArkWeb. 6513 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6514 * <br>2. Parameter string is too long. 3.Parameter verification failed. 6515 * @syscap SystemCapability.Web.Webview.Core 6516 * @atomicservice 6517 * @since 14 6518 */ 6519 static trimMemoryByPressureLevel(level: PressureLevel): void; 6520 6521 /** 6522 * Enable the BackForwardCache and indicate features that are allowed to enter BackForwardCache. 6523 * Default is disabled. 6524 * 6525 * @param { BackForwardCacheSupportedFeatures } features - The features that supports BackForwardCache. 6526 * @syscap SystemCapability.Web.Webview.Core 6527 * @since 12 6528 */ 6529 static enableBackForwardCache(features: BackForwardCacheSupportedFeatures): void; 6530 6531 /** 6532 * Configure the BackForwardCache. 6533 * 6534 * @param { BackForwardCacheOptions } options - The configuration of BackForwardCache. 6535 * @throws { BusinessError } 17100001 - Init error. 6536 * The WebviewController must be associated with a Web component. 6537 * @syscap SystemCapability.Web.Webview.Core 6538 * @since 12 6539 */ 6540 setBackForwardCacheOptions(options: BackForwardCacheOptions): void; 6541 6542 /** 6543 * The current scroll offset of the web page (including the over-scroll offset). 6544 * 6545 * @returns { ScrollOffset } The current scroll offset of the web page (including the over-scroll offset). 6546 * @syscap SystemCapability.Web.Webview.Core 6547 * @atomicservice 6548 * @since 13 6549 */ 6550 getScrollOffset(): ScrollOffset; 6551 6552 /** 6553 * Scrolls by the specified delta position and returns a result indicating whether the scrolling operation was successful or not. 6554 * 6555 * @param { number } deltaX - the delta x of the position. Unit: vp. 6556 * @param { number } deltaY - the delta y of the position. Unit: vp. 6557 * @returns { boolean } true if the scroll operation is successful, otherwise false. 6558 * Return value scenario: when the Web page is in the touch state, return false, otherwise return true. 6559 * In the same layer rendering scene, when the same layer rendering area of the Web is in the touching state, the return value is true. 6560 * In a nested scrolling scenario, calling scrollByWithResult will not trigger nested scrolling of the parent component. 6561 * This interface does not guarantee sliding frame rate performance. 6562 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6563 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 6564 * @throws { BusinessError } 17100001 - Init error. 6565 * The WebviewController must be associated with a Web component. 6566 * @syscap SystemCapability.Web.Webview.Core 6567 * @since 12 6568 */ 6569 scrollByWithResult(deltaX: number, deltaY: number): boolean; 6570 6571 /** 6572 * Gets the last hit test value of HitTest. 6573 * @returns { HitTestValue } Return the element information of the clicked area. 6574 * @throws { BusinessError } 17100001 - Init error. 6575 * The WebviewController must be associated with a Web component. 6576 * @syscap SystemCapability.Web.Webview.Core 6577 * @since 18 6578 */ 6579 getLastHitTest(): HitTestValue; 6580 6581 /** 6582 * The current scroll offset of the web page (excluding over-scroll offset). 6583 * 6584 * @returns { ScrollOffset } The current scroll offset of the web page (excluding over-scroll offset). 6585 * @throws { BusinessError } 801 - Capability not supported. 6586 * @syscap SystemCapability.Web.Webview.Core 6587 * @since 20 6588 */ 6589 getPageOffset(): ScrollOffset; 6590 6591 /** 6592 * Set the default User-Agent for the application. 6593 * 6594 * <p><strong>API Note</strong>:<br> 6595 * Unlike setCustomUserAgent, which only takes effect in the current web context, the 6596 * priority for pages loaded in the web is as follows: 6597 * 1. The User-Agent set by setCustomUserAgent is used first. 6598 * 2. If not set, it will check whether a specific User-Agent has been 6599 * assigned to the current page via setUserAgentForHosts. 6600 * 3. If no specific User-Agent is assigned, the application will fall back 6601 * to using the User-Agent set by setAppCustomUserAgent. 6602 * 4. If the app's default User-Agent is also not specified, the web's default 6603 * User-Agent will be used as the final fallback. 6604 * </p> 6605 * 6606 * @param { string } userAgent - The User-Agent string. 6607 * @static 6608 * @syscap SystemCapability.Web.Webview.Core 6609 * @since 20 6610 */ 6611 static setAppCustomUserAgent(userAgent: string) : void; 6612 6613 /** 6614 * Set the User-Agent to be used for specified hosts, with a maximum of 20,000 hosts. 6615 * <p><strong>API Note</strong>:<br> 6616 * Setting the same host list multiple times for the same User-Agent will override 6617 * the previous settings. That is, if you want to cancel certain hosts from using 6618 * the specified User-Agent, you need to reset the host list for that User-Agent. 6619 * </p> 6620 * 6621 * @param { string } userAgent - The User-Agent string. 6622 * @param { Array<string> } hosts - The hosts to which the User-Agent apply. 6623 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6624 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 6625 * @static 6626 * @syscap SystemCapability.Web.Webview.Core 6627 * @since 20 6628 */ 6629 static setUserAgentForHosts(userAgent: string, hosts : Array<string>) : void; 6630 6631 /** 6632 * Get whether webviewController is attached to a web component. 6633 * @returns { ControllerAttachState } the attach state of controller 6634 * @syscap SystemCapability.Web.Webview.Core 6635 * @since 20 6636 */ 6637 getAttachState(): ControllerAttachState; 6638 6639 /** 6640 * Register the callback for controller attach state change. 6641 * 6642 * @param { 'controllerAttachStateChange' } type the event of controller attach state change. 6643 * @param { Callback<ControllerAttachState> } callback Callback used to return the controller attach state. 6644 * @syscap SystemCapability.Web.Webview.Core 6645 * @since 20 6646 */ 6647 on(type: 'controllerAttachStateChange', callback: Callback<ControllerAttachState>): void; 6648 6649 /** 6650 * Unregister the callback for controller attach state change. 6651 * 6652 * @param { 'controllerAttachStateChange' } type the event of controller attach state change. 6653 * @param { Callback<ControllerAttachState> } callback Callback used to return the controller attach state. 6654 * @syscap SystemCapability.Web.Webview.Core 6655 * @since 20 6656 */ 6657 off(type: 'controllerAttachStateChange', callback?: Callback<ControllerAttachState>): void; 6658 6659 6660 /** 6661 * Wait for the controller to attach a web component until timeout. 6662 * 6663 * @param { number } timeout - the wait timeout, if timeout reach, promise will return, the unit is millisecond. 6664 * @returns { Promise<ControllerAttachState> } Promise used to return the state of attach. 6665 * @syscap SystemCapability.Web.Webview.Core 6666 * @since 20 6667 */ 6668 waitForAttached(timeout: number): Promise<ControllerAttachState>; 6669 6670 /** 6671 * Enables debugging of web contents. 6672 * <p><strong>API Note</strong>:<br> 6673 * The port numbers from 0 to 1024 are prohibited. Ports less than 0 or greater than 65535 are considered invalid. 6674 * If an attempt is made to set these disabled or invalid ports, an exception will be thrown. 6675 * </p> 6676 * 6677 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 6678 * @param { number } port Indicates the port of the devtools server. After the port is specified, a tcp server 6679 * socket is created instead of a unix domain socket. 6680 * @throws { BusinessError } 17100023 - The port number is not within the allowed range. 6681 * @static 6682 * @syscap SystemCapability.Web.Webview.Core 6683 * @since 20 6684 */ 6685 static setWebDebuggingAccess(webDebuggingAccess: boolean, port: number): void; 6686 6687 /** 6688 * Gets the loading progress for the current page. 6689 * 6690 * @returns { number } The loading progress for the current page. 6691 * @throws { BusinessError } 801 - Capability not supported. 6692 * @syscap SystemCapability.Web.Webview.Core 6693 * @since 20 6694 */ 6695 getProgress() : number; 6696 6697 /** 6698 * Sets the bottom avoidance height of the web visible viewport. 6699 * When setting non-zero height, the position and size of the web component remain unchanged, 6700 * <br>and the visible viewport upward avoids avoidHeight, as manifested by the web page content raising avoidHeight. 6701 * <br>This interface is generally used for customizing the bottom avoidance area, and it is not recommended for 6702 * <br>simultaneous use with clicking the editable area of the web page showing the keyboard. 6703 * <br>In this case, the keyboardAvoidMode will be OVERLAYS_CONTENT. 6704 * When setting zero, web page content can be restored and the keyboardAvoidMode will be the value set by keyboardAvoidMode(). 6705 * 6706 * @param { number } avoidHeight - the height value of the visible viewport avoidance. Unit: vp. 6707 * <br>The valid interval of avoidHeight is [0, the height of web component]. 6708 * <br>When avoidHeight is out of the valid interval, it takes the boundary value of the interval. 6709 * @throws { BusinessError } 17100001 - Init error. 6710 * The WebviewController must be associated with a Web component. 6711 * @throws { BusinessError } 801 - Capability not supported. 6712 * @syscap SystemCapability.Web.Webview.Core 6713 * @since 20 6714 */ 6715 avoidVisibleViewportBottom(avoidHeight: number): void; 6716 6717 /** 6718 * Obtains the prediction information about the blankless loading solution and enables the generation of 6719 * the transition frame for the current loading. The application determines whether to enable the blankless 6720 * loading solution based on the information. 6721 * 6722 * @param { string } key The key value that uniquely identifies the page. 6723 * Default value: N/A. 6724 * The value cannot be empty or exceed 2048 characters. 6725 * When an invalid value is set, this API does not take effect. 6726 * @returns { BlanklessInfo } The prediction information about the blankless loading solution. 6727 * @throws { BusinessError } 801 Capability not supported. 6728 * @syscap SystemCapability.Web.Webview.Core 6729 * @since 20 6730 */ 6731 getBlanklessInfoWithKey(key: string) : BlanklessInfo; 6732 6733 /** 6734 * Sets whether to enable blankless page loading. This API must be used in pair with the 6735 * getBlanklessInfoWithKey API. 6736 * 6737 * @param { string } key The key value that uniquely identifies the current page. It must be the same as 6738 * the key value of the getBlanklessInfoWithKey API. 6739 * Default value: N/A. 6740 * The value cannot be empty or exceed 2048 characters. 6741 * When an invalid value is set, the error code WebBlanklessErrorCode is returned, and the API does not 6742 * take effect. 6743 * @param { boolean } is_start Whether to enable frame interpolation. The value true indicates to enable 6744 * frame interpolation, and the value false indicates the opposite. 6745 * The default value is false. 6746 * The value can be true or false. 6747 * Action for setting an invalid value: N/A. 6748 * @returns { WebBlanklessErrorCode } WebBlanklessErrorCode. 6749 * @throws { BusinessError } 801 Capability not supported. 6750 * @syscap SystemCapability.Web.Webview.Core 6751 * @since 20 6752 */ 6753 setBlanklessLoadingWithKey(key: string, is_start: boolean) : WebBlanklessErrorCode; 6754 6755 /** 6756 * Clears the blankless loading cache of the page with a specified key value. 6757 * 6758 * @param { Array<string> } [keys] The list of key values of pages cached in the blankless loading 6759 * solution. These key values are specified in getBlanklessInfoKey. 6760 * The default value is the list of key values of all pages cached in the blankless loading solution. 6761 * The key length cannot exceed 2048 characters, and the number of keys must be less than or equal to 100. 6762 * The URL is the same as that input to the Web component during page loading. 6763 * When the key length exceeds 2048 characters, the key does not take effect. When the number of keys 6764 * exceeds 100, the first 100 keys are used. If these parameters are left empty, the default values are used. 6765 * @throws { BusinessError } 801 Capability not supported. 6766 * @static 6767 * @syscap SystemCapability.Web.Webview.Core 6768 * @since 20 6769 */ 6770 static clearBlanklessLoadingCache(keys?: Array<string>) : void; 6771 6772 /** 6773 * Sets the cache capacity of the blankless loading solution and returns the value that takes effect. If 6774 * this API is not called, the default capacity 30 MB is used. The maximum capacity cannot exceed 100 MB. 6775 * 6776 * @param { number } capacity Cache capacity, in MB. The maximum value is 100 MB. 6777 * The default value is 30 MB. 6778 * The value ranges from 0 to 100. If this parameter is set to 0, no cache capacity is available and the 6779 * functionality is disabled globally. 6780 * When the value is set to a number smaller than 0, the value 0 takes effect. When the value is set to a 6781 * number greater than 100, the value 100 takes effect. 6782 * @returns { number } The effective value that ranges from 0 MB to 100 MB. 6783 * @throws { BusinessError } 801 Capability not supported. 6784 * @static 6785 * @syscap SystemCapability.Web.Webview.Core 6786 * @since 20 6787 */ 6788 static setBlanklessLoadingCacheCapacity(capacity: number) : number; 6789 6790 /** 6791 * Get whether default error page feature is enabled. 6792 * 6793 * @returns { boolean } - True if enable the default error page feature; else false. 6794 * @throws { BusinessError } 17100001 - Init error. 6795 * The WebviewController must be associated with a Web component. 6796 * @syscap SystemCapability.Web.Webview.Core 6797 * @since 20 6798 */ 6799 getErrorPageEnabled(): boolean; 6800 6801 /** 6802 * Set whether enable the error page. onOverrideErrorPage will be triggered when the page error. 6803 * 6804 * @param { boolean } enable - Whether to enable the default error page feature. 6805 * @throws { BusinessError } 17100001 - Init error. 6806 * The WebviewController must be associated with a Web component. 6807 * @syscap SystemCapability.Web.Webview.Core 6808 * @since 20 6809 */ 6810 setErrorPageEnabled(enable: boolean): void; 6811 6812 /** 6813 * After enable PrivateNetworkAccess feature, ArkWeb will send a CORS preflight request before issuing any 6814 * sub-resource private network requests to request explicit permission from the target server. 6815 * After disable PrivateNetworkAccess, ArkWeb will no longer check whether the private network request 6816 * is legitimate. 6817 * 6818 * @param {boolean} enable - {@code true} enable the private network access check; {@code false} otherwise. 6819 * @static 6820 * @syscap SystemCapability.Web.Webview.Core 6821 * @since 20 6822 */ 6823 static enablePrivateNetworkAccess(enable: boolean): void; 6824 6825 /** 6826 * Get whether PrivateNetworkAccess is enabled. 6827 * 6828 * @returns {boolean} True is enable the ability to check private network access else false. 6829 * @static 6830 * @syscap SystemCapability.Web.Webview.Core 6831 * @since 20 6832 */ 6833 static isPrivateNetworkAccessEnabled(): boolean; 6834 6835 /** 6836 * Set web destroy mode. 6837 * @param { WebDestroyMode } mode web destroy mode, default NORMAL_MODE. 6838 * @static 6839 * @syscap SystemCapability.Web.Webview.Core 6840 * @since 20 6841 */ 6842 static setWebDestroyMode(mode: WebDestroyMode): void; 6843 } 6844 6845 /** 6846 * Defines the state for download. 6847 * @enum {number} 6848 * @syscap SystemCapability.Web.Webview.Core 6849 * @atomicservice 6850 * @since 11 6851 */ 6852 /** 6853 * Defines the state for download. 6854 * @enum {number} 6855 * @syscap SystemCapability.Web.Webview.Core 6856 * @crossplatform 6857 * @atomicservice 6858 * @since 18 6859 */ 6860 enum WebDownloadState { 6861 /** 6862 * The web download is in progress. 6863 * @syscap SystemCapability.Web.Webview.Core 6864 * @atomicservice 6865 * @since 11 6866 */ 6867 /** 6868 * The web download is in progress. 6869 * @syscap SystemCapability.Web.Webview.Core 6870 * @crossplatform 6871 * @atomicservice 6872 * @since 18 6873 */ 6874 IN_PROGRESS = 0, 6875 6876 /** 6877 * The web download has been completed. 6878 * @syscap SystemCapability.Web.Webview.Core 6879 * @atomicservice 6880 * @since 11 6881 */ 6882 /** 6883 * The web download has been completed. 6884 * @syscap SystemCapability.Web.Webview.Core 6885 * @crossplatform 6886 * @atomicservice 6887 * @since 18 6888 */ 6889 COMPLETED, 6890 6891 /** 6892 * The web download was canceled. 6893 * @syscap SystemCapability.Web.Webview.Core 6894 * @atomicservice 6895 * @since 11 6896 */ 6897 /** 6898 * The web download was canceled. 6899 * @syscap SystemCapability.Web.Webview.Core 6900 * @crossplatform 6901 * @atomicservice 6902 * @since 18 6903 */ 6904 CANCELED, 6905 6906 /** 6907 * The web download was interrupted. 6908 * @syscap SystemCapability.Web.Webview.Core 6909 * @atomicservice 6910 * @since 11 6911 */ 6912 /** 6913 * The web download was interrupted. 6914 * @syscap SystemCapability.Web.Webview.Core 6915 * @crossplatform 6916 * @atomicservice 6917 * @since 18 6918 */ 6919 INTERRUPTED, 6920 6921 /** 6922 * The web download is pending. 6923 * @syscap SystemCapability.Web.Webview.Core 6924 * @atomicservice 6925 * @since 11 6926 */ 6927 /** 6928 * The web download is pending. 6929 * @syscap SystemCapability.Web.Webview.Core 6930 * @crossplatform 6931 * @atomicservice 6932 * @since 18 6933 */ 6934 PENDING, 6935 6936 /** 6937 * The web download has been paused. 6938 * @syscap SystemCapability.Web.Webview.Core 6939 * @atomicservice 6940 * @since 11 6941 */ 6942 /** 6943 * The web download has been paused. 6944 * @syscap SystemCapability.Web.Webview.Core 6945 * @crossplatform 6946 * @atomicservice 6947 * @since 18 6948 */ 6949 PAUSED, 6950 6951 /** 6952 * Unknown state. 6953 * @syscap SystemCapability.Web.Webview.Core 6954 * @atomicservice 6955 * @since 11 6956 */ 6957 /** 6958 * Unknown state. 6959 * @syscap SystemCapability.Web.Webview.Core 6960 * @crossplatform 6961 * @atomicservice 6962 * @since 18 6963 */ 6964 UNKNOWN, 6965 } 6966 6967 /** 6968 * Defines the error code for download. 6969 * @enum {number} 6970 * @syscap SystemCapability.Web.Webview.Core 6971 * @atomicservice 6972 * @since 11 6973 */ 6974 /** 6975 * Defines the error code for download. 6976 * @enum {number} 6977 * @syscap SystemCapability.Web.Webview.Core 6978 * @crossplatform 6979 * @atomicservice 6980 * @since 18 6981 */ 6982 enum WebDownloadErrorCode { 6983 /** 6984 * Unknown error. 6985 * @syscap SystemCapability.Web.Webview.Core 6986 * @atomicservice 6987 * @since 11 6988 */ 6989 ERROR_UNKNOWN = 0, 6990 6991 /** 6992 * Generic file operation failure. 6993 * @syscap SystemCapability.Web.Webview.Core 6994 * @atomicservice 6995 * @since 11 6996 */ 6997 FILE_FAILED = 1, 6998 6999 /** 7000 * The file cannot be accessed due to certain restrictions. 7001 * @syscap SystemCapability.Web.Webview.Core 7002 * @atomicservice 7003 * @since 11 7004 */ 7005 FILE_ACCESS_DENIED = 2, 7006 7007 /** 7008 * There is not enough disk space. 7009 * @syscap SystemCapability.Web.Webview.Core 7010 * @atomicservice 7011 * @since 11 7012 */ 7013 FILE_NO_SPACE = 3, 7014 7015 /** 7016 * The file name is too long. 7017 * @syscap SystemCapability.Web.Webview.Core 7018 * @atomicservice 7019 * @since 11 7020 */ 7021 FILE_NAME_TOO_LONG = 5, 7022 7023 /** 7024 * The file is too large. 7025 * @syscap SystemCapability.Web.Webview.Core 7026 * @atomicservice 7027 * @since 11 7028 */ 7029 FILE_TOO_LARGE = 6, 7030 7031 /** 7032 * Some temporary problems occurred, such as not enough memory, files in use, and too many files open at the same time. 7033 * @syscap SystemCapability.Web.Webview.Core 7034 * @atomicservice 7035 * @since 11 7036 */ 7037 FILE_TRANSIENT_ERROR = 10, 7038 7039 /** 7040 * The file is blocked from accessing because of some local policy. 7041 * @syscap SystemCapability.Web.Webview.Core 7042 * @atomicservice 7043 * @since 11 7044 */ 7045 FILE_BLOCKED = 11, 7046 7047 /** 7048 * When trying to resume the download, Found that the file is not long enough, maybe the file no longer exists. 7049 * @syscap SystemCapability.Web.Webview.Core 7050 * @atomicservice 7051 * @since 11 7052 */ 7053 FILE_TOO_SHORT = 13, 7054 7055 /** 7056 * Hash mismatch. 7057 * @syscap SystemCapability.Web.Webview.Core 7058 * @atomicservice 7059 * @since 11 7060 */ 7061 FILE_HASH_MISMATCH = 14, 7062 7063 /** 7064 * The file already exists. 7065 * @syscap SystemCapability.Web.Webview.Core 7066 * @atomicservice 7067 * @since 11 7068 */ 7069 FILE_SAME_AS_SOURCE = 15, 7070 7071 /** 7072 * Generic network error. 7073 * @syscap SystemCapability.Web.Webview.Core 7074 * @atomicservice 7075 * @since 11 7076 */ 7077 NETWORK_FAILED = 20, 7078 7079 /** 7080 * The network operation timed out. 7081 * @syscap SystemCapability.Web.Webview.Core 7082 * @atomicservice 7083 * @since 11 7084 */ 7085 NETWORK_TIMEOUT = 21, 7086 7087 /** 7088 * The network was disconnected. 7089 * @syscap SystemCapability.Web.Webview.Core 7090 * @atomicservice 7091 * @since 11 7092 */ 7093 NETWORK_DISCONNECTED = 22, 7094 7095 /** 7096 * Server down. 7097 * @syscap SystemCapability.Web.Webview.Core 7098 * @atomicservice 7099 * @since 11 7100 */ 7101 NETWORK_SERVER_DOWN = 23, 7102 7103 /** 7104 * Invalid network requests,may redirect to unsupported scheme or an invalid URL. 7105 * @syscap SystemCapability.Web.Webview.Core 7106 * @atomicservice 7107 * @since 11 7108 */ 7109 NETWORK_INVALID_REQUEST = 24, 7110 7111 /** 7112 * The server returned a generic error. 7113 * @syscap SystemCapability.Web.Webview.Core 7114 * @atomicservice 7115 * @since 11 7116 */ 7117 SERVER_FAILED = 30, 7118 7119 /** 7120 * The server does not support range requests. 7121 * @syscap SystemCapability.Web.Webview.Core 7122 * @atomicservice 7123 * @since 11 7124 */ 7125 SERVER_NO_RANGE = 31, 7126 7127 /** 7128 * The server does not have the requested data. 7129 * @syscap SystemCapability.Web.Webview.Core 7130 * @atomicservice 7131 * @since 11 7132 */ 7133 SERVER_BAD_CONTENT = 33, 7134 7135 /** 7136 * The server does not allow the file to be downloaded. 7137 * @syscap SystemCapability.Web.Webview.Core 7138 * @atomicservice 7139 * @since 11 7140 */ 7141 SERVER_UNAUTHORIZED = 34, 7142 7143 /** 7144 * Server certificate error. 7145 * @syscap SystemCapability.Web.Webview.Core 7146 * @atomicservice 7147 * @since 11 7148 */ 7149 SERVER_CERT_PROBLEM = 35, 7150 7151 /** 7152 * Server access forbidden. 7153 * @syscap SystemCapability.Web.Webview.Core 7154 * @atomicservice 7155 * @since 11 7156 */ 7157 SERVER_FORBIDDEN = 36, 7158 7159 /** 7160 * Server unreachable. 7161 * @syscap SystemCapability.Web.Webview.Core 7162 * @atomicservice 7163 * @since 11 7164 */ 7165 SERVER_UNREACHABLE = 37, 7166 7167 /** 7168 * The received data does not match content-length. 7169 * @syscap SystemCapability.Web.Webview.Core 7170 * @atomicservice 7171 * @since 11 7172 */ 7173 SERVER_CONTENT_LENGTH_MISMATCH = 38, 7174 7175 /** 7176 * An unexpected cross-origin redirect happened. 7177 * @syscap SystemCapability.Web.Webview.Core 7178 * @atomicservice 7179 * @since 11 7180 */ 7181 SERVER_CROSS_ORIGIN_REDIRECT = 39, 7182 7183 /** 7184 * User cancel. 7185 * @syscap SystemCapability.Web.Webview.Core 7186 * @atomicservice 7187 * @since 11 7188 */ 7189 /** 7190 * User cancel. 7191 * @syscap SystemCapability.Web.Webview.Core 7192 * @crossplatform 7193 * @atomicservice 7194 * @since 18 7195 */ 7196 USER_CANCELED = 40, 7197 7198 /** 7199 * User shut down the application. 7200 * @syscap SystemCapability.Web.Webview.Core 7201 * @atomicservice 7202 * @since 11 7203 */ 7204 USER_SHUTDOWN = 41, 7205 7206 /** 7207 * Application crash. 7208 * @syscap SystemCapability.Web.Webview.Core 7209 * @atomicservice 7210 * @since 11 7211 */ 7212 CRASH = 50, 7213 } 7214 7215 /** 7216 * Represents a download task, You can use this object to operate the corresponding download task. 7217 * @syscap SystemCapability.Web.Webview.Core 7218 * @atomicservice 7219 * @since 11 7220 */ 7221 /** 7222 * Represents a download task, You can use this object to operate the corresponding download task. 7223 * @syscap SystemCapability.Web.Webview.Core 7224 * @crossplatform 7225 * @atomicservice 7226 * @since arkts {'1.1':'18', '1.2':'20'} 7227 * @arkts 1.1&1.2 7228 */ 7229 class WebDownloadItem { 7230 /** 7231 * Get guid. 7232 * @returns { string } - Returns the download's guid. 7233 * @syscap SystemCapability.Web.Webview.Core 7234 * @atomicservice 7235 * @since 11 7236 */ 7237 /** 7238 * Get guid. 7239 * @returns { string } - Returns the download's guid. 7240 * @syscap SystemCapability.Web.Webview.Core 7241 * @crossplatform 7242 * @atomicservice 7243 * @since 18 7244 */ 7245 getGuid(): string; 7246 7247 /** 7248 * Get current speed, in bytes per second. 7249 * @returns { number } - Returns the current download speed. 7250 * @syscap SystemCapability.Web.Webview.Core 7251 * @atomicservice 7252 * @since 11 7253 */ 7254 /** 7255 * Get current speed, in bytes per second. 7256 * @returns { number } - Returns the current download speed. 7257 * @syscap SystemCapability.Web.Webview.Core 7258 * @crossplatform 7259 * @atomicservice 7260 * @since 18 7261 */ 7262 getCurrentSpeed(): number; 7263 7264 /** 7265 * Get percent complete. 7266 * @returns { number } - Returns -1 if progress is unknown. 100 if the download is already complete. 7267 * @syscap SystemCapability.Web.Webview.Core 7268 * @atomicservice 7269 * @since 11 7270 */ 7271 /** 7272 * Get percent complete. 7273 * @returns { number } - Returns -1 if progress is unknown. 100 if the download is already complete. 7274 * @syscap SystemCapability.Web.Webview.Core 7275 * @crossplatform 7276 * @atomicservice 7277 * @since 18 7278 */ 7279 getPercentComplete(): number; 7280 7281 /** 7282 * Get total bytes. 7283 * @returns { number } - Returns the total bytes received, -1 if the total size is unknown. 7284 * @syscap SystemCapability.Web.Webview.Core 7285 * @atomicservice 7286 * @since 11 7287 */ 7288 /** 7289 * Get total bytes. 7290 * @returns { number } - Returns the total bytes received, -1 if the total size is unknown. 7291 * @syscap SystemCapability.Web.Webview.Core 7292 * @crossplatform 7293 * @atomicservice 7294 * @since 18 7295 */ 7296 getTotalBytes(): number; 7297 7298 /** 7299 * Get state of the web download. 7300 * @returns { WebDownloadState } - Returns the current download state. 7301 * @syscap SystemCapability.Web.Webview.Core 7302 * @atomicservice 7303 * @since 11 7304 */ 7305 /** 7306 * Get state of the web download. 7307 * @returns { WebDownloadState } - Returns the current download state. 7308 * @syscap SystemCapability.Web.Webview.Core 7309 * @crossplatform 7310 * @atomicservice 7311 * @since 18 7312 */ 7313 getState(): WebDownloadState; 7314 7315 /** 7316 * Get last error code of the web download. 7317 * @returns { WebDownloadErrorCode } - Returns the last error code. 7318 * @syscap SystemCapability.Web.Webview.Core 7319 * @atomicservice 7320 * @since 11 7321 */ 7322 /** 7323 * Get last error code of the web download. 7324 * @returns { WebDownloadErrorCode } - Returns the last error code. 7325 * @syscap SystemCapability.Web.Webview.Core 7326 * @crossplatform 7327 * @atomicservice 7328 * @since 18 7329 */ 7330 getLastErrorCode(): WebDownloadErrorCode; 7331 7332 /** 7333 * Get http method of the web download request. 7334 * @returns { string } - Returns the http request method. 7335 * @syscap SystemCapability.Web.Webview.Core 7336 * @atomicservice 7337 * @since 11 7338 */ 7339 /** 7340 * Get http method of the web download request. 7341 * @returns { string } - Returns the http request method. 7342 * @syscap SystemCapability.Web.Webview.Core 7343 * @crossplatform 7344 * @atomicservice 7345 * @since 18 7346 */ 7347 getMethod(): string; 7348 7349 /** 7350 * Get mime type of the web download. 7351 * @returns { string } - Returns the mimetype. 7352 * @syscap SystemCapability.Web.Webview.Core 7353 * @atomicservice 7354 * @since 11 7355 */ 7356 /** 7357 * Get mime type of the web download. 7358 * @returns { string } - Returns the mimetype. 7359 * @syscap SystemCapability.Web.Webview.Core 7360 * @crossplatform 7361 * @atomicservice 7362 * @since 18 7363 */ 7364 getMimeType(): string; 7365 7366 /** 7367 * Get url of the web download request. 7368 * @returns { string } - Returns the url. 7369 * @syscap SystemCapability.Web.Webview.Core 7370 * @atomicservice 7371 * @since 11 7372 */ 7373 /** 7374 * Get url of the web download request. 7375 * @returns { string } - Returns the url. 7376 * @syscap SystemCapability.Web.Webview.Core 7377 * @crossplatform 7378 * @atomicservice 7379 * @since arkts {'1.1':'18', '1.2':'20'} 7380 * @arkts 1.1&1.2 7381 */ 7382 getUrl(): string; 7383 7384 /** 7385 * Get suggested file name of the web download request. 7386 * @returns { string } - Returns the suggested file name. 7387 * @syscap SystemCapability.Web.Webview.Core 7388 * @atomicservice 7389 * @since 11 7390 */ 7391 /** 7392 * Get suggested file name of the web download request. 7393 * @returns { string } - Returns the suggested file name. 7394 * @syscap SystemCapability.Web.Webview.Core 7395 * @crossplatform 7396 * @atomicservice 7397 * @since 18 7398 */ 7399 getSuggestedFileName(): string; 7400 7401 /** 7402 * Start the web download. 7403 * Used in onBeforeDownload, If you want to start the current download, call this function. 7404 * @param { string } downloadPath - The content will be downloaded to this file. 7405 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 7406 * <br>2. Parameter verification failed. 7407 * @syscap SystemCapability.Web.Webview.Core 7408 * @atomicservice 7409 * @since 11 7410 */ 7411 /** 7412 * Start the web download. 7413 * Used in onBeforeDownload, If you want to start the current download, call this function. 7414 * @param { string } downloadPath - The content will be downloaded to this file. 7415 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 7416 * <br>2. Parameter verification failed. 7417 * @syscap SystemCapability.Web.Webview.Core 7418 * @crossplatform 7419 * @atomicservice 7420 * @since 18 7421 */ 7422 start(downloadPath: string): void; 7423 7424 /** 7425 * Cancel the web download. 7426 * @syscap SystemCapability.Web.Webview.Core 7427 * @atomicservice 7428 * @since 11 7429 */ 7430 /** 7431 * Cancel the web download. 7432 * @syscap SystemCapability.Web.Webview.Core 7433 * @crossplatform 7434 * @atomicservice 7435 * @since 18 7436 */ 7437 cancel(): void; 7438 7439 /** 7440 * Pause the web download. 7441 * @throws { BusinessError } 17100019 - The download task is not started yet. 7442 * @syscap SystemCapability.Web.Webview.Core 7443 * @atomicservice 7444 * @since 11 7445 */ 7446 /** 7447 * Pause the web download. 7448 * @throws { BusinessError } 17100019 - The download task is not started yet. 7449 * @syscap SystemCapability.Web.Webview.Core 7450 * @crossplatform 7451 * @atomicservice 7452 * @since 18 7453 */ 7454 pause(): void; 7455 7456 /** 7457 * Resume the web download. 7458 * Use WebDownloadManager.resumeDownload to resume deserialized downloads. 7459 * WebDownloadItem.resume is only used to resume the currently paused download. 7460 * @throws { BusinessError } 17100016 - The download task is not paused. 7461 * @syscap SystemCapability.Web.Webview.Core 7462 * @atomicservice 7463 * @since 11 7464 */ 7465 /** 7466 * Resume the web download. 7467 * Use WebDownloadManager.resumeDownload to resume deserialized downloads. 7468 * WebDownloadItem.resume is only used to resume the currently paused download. 7469 * @throws { BusinessError } 17100016 - The download task is not paused. 7470 * @syscap SystemCapability.Web.Webview.Core 7471 * @crossplatform 7472 * @atomicservice 7473 * @since 18 7474 */ 7475 resume(): void; 7476 7477 /** 7478 * Get received bytes. 7479 * @returns { number } - Returns the received bytes. 7480 * @syscap SystemCapability.Web.Webview.Core 7481 * @atomicservice 7482 * @since 11 7483 */ 7484 /** 7485 * Get received bytes. 7486 * @returns { number } - Returns the received bytes. 7487 * @syscap SystemCapability.Web.Webview.Core 7488 * @crossplatform 7489 * @atomicservice 7490 * @since 18 7491 */ 7492 getReceivedBytes(): number; 7493 7494 /** 7495 * Get full path of the web download. 7496 * @returns { string } - Returns the full path of the download. 7497 * @syscap SystemCapability.Web.Webview.Core 7498 * @atomicservice 7499 * @since 11 7500 */ 7501 /** 7502 * Get full path of the web download. 7503 * @returns { string } - Returns the full path of the download. 7504 * @syscap SystemCapability.Web.Webview.Core 7505 * @crossplatform 7506 * @atomicservice 7507 * @since 18 7508 */ 7509 getFullPath(): string; 7510 7511 /** 7512 * Serialize web download to typed array. 7513 * @returns { Uint8Array } - Returns the serialized data. 7514 * @syscap SystemCapability.Web.Webview.Core 7515 * @atomicservice 7516 * @since 11 7517 */ 7518 serialize(): Uint8Array; 7519 7520 /** 7521 * Deserialize web download from typed array. 7522 * @param { Uint8Array } serializedData - The serialized data. 7523 * @returns { WebDownloadItem } - Deserialize the serialized data into a WebDownloadItem. 7524 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 7525 * <br>2. Parameter verification failed. 7526 * @syscap SystemCapability.Web.Webview.Core 7527 * @atomicservice 7528 * @since 11 7529 */ 7530 static deserialize(serializedData: Uint8Array): WebDownloadItem; 7531 } 7532 7533 /** 7534 * The download state is notified through this delegate. 7535 * @syscap SystemCapability.Web.Webview.Core 7536 * @atomicservice 7537 * @since 11 7538 */ 7539 /** 7540 * The download state is notified through this delegate. 7541 * @syscap SystemCapability.Web.Webview.Core 7542 * @crossplatform 7543 * @atomicservice 7544 * @since arkts {'1.1':'18', '1.2':'20'} 7545 * @arkts 1.1&1.2 7546 */ 7547 class WebDownloadDelegate { 7548 /** 7549 * Callback will be triggered before web download start. 7550 * @param { Callback<WebDownloadItem> } callback - The callback of download will be start. 7551 * @syscap SystemCapability.Web.Webview.Core 7552 * @atomicservice 7553 * @since 11 7554 */ 7555 /** 7556 * Callback will be triggered before web download start. 7557 * @param { Callback<WebDownloadItem> } callback - The callback of download will be start. 7558 * @syscap SystemCapability.Web.Webview.Core 7559 * @crossplatform 7560 * @atomicservice 7561 * @since arkts {'1.1':'18', '1.2':'20'} 7562 * @arkts 1.1&1.2 7563 */ 7564 onBeforeDownload(callback: Callback<WebDownloadItem>): void; 7565 7566 /** 7567 * Callback will be triggered when web download is processing. 7568 * @param { Callback<WebDownloadItem> } callback - The callback of download did update. 7569 * @syscap SystemCapability.Web.Webview.Core 7570 * @atomicservice 7571 * @since 11 7572 */ 7573 /** 7574 * Callback will be triggered when web download is processing. 7575 * @param { Callback<WebDownloadItem> } callback - The callback of download did update. 7576 * @syscap SystemCapability.Web.Webview.Core 7577 * @crossplatform 7578 * @atomicservice 7579 * @since 18 7580 */ 7581 onDownloadUpdated(callback: Callback<WebDownloadItem>): void; 7582 7583 /** 7584 * Callback will be triggered when web download is completed. 7585 * @param { Callback<WebDownloadItem> } callback - The callback of download did finish. 7586 * @syscap SystemCapability.Web.Webview.Core 7587 * @atomicservice 7588 * @since 11 7589 */ 7590 /** 7591 * Callback will be triggered when web download is completed. 7592 * @param { Callback<WebDownloadItem> } callback - The callback of download did finish. 7593 * @syscap SystemCapability.Web.Webview.Core 7594 * @crossplatform 7595 * @atomicservice 7596 * @since 18 7597 */ 7598 onDownloadFinish(callback: Callback<WebDownloadItem>): void; 7599 7600 /** 7601 * Callback will be triggered when web download is interrupted or canceled. 7602 * @param { Callback<WebDownloadItem> } callback - The callback of download did fail. 7603 * @syscap SystemCapability.Web.Webview.Core 7604 * @atomicservice 7605 * @since 11 7606 */ 7607 /** 7608 * Callback will be triggered when web download is interrupted or canceled. 7609 * @param { Callback<WebDownloadItem> } callback - The callback of download did fail. 7610 * @syscap SystemCapability.Web.Webview.Core 7611 * @crossplatform 7612 * @atomicservice 7613 * @since 18 7614 */ 7615 onDownloadFailed(callback: Callback<WebDownloadItem>): void; 7616 } 7617 7618 /** 7619 * You can trigger download manually through this interface, or resume failed or canceled downloads. 7620 * @syscap SystemCapability.Web.Webview.Core 7621 * @atomicservice 7622 * @since 11 7623 */ 7624 /** 7625 * You can trigger download manually through this interface, or resume failed or canceled downloads. 7626 * @syscap SystemCapability.Web.Webview.Core 7627 * @crossplatform 7628 * @atomicservice 7629 * @since 18 7630 */ 7631 class WebDownloadManager { 7632 /** 7633 * Set a delegate used to receive the progress of the download triggered from WebDownloadManager. 7634 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from WebDownloadManager. 7635 * @syscap SystemCapability.Web.Webview.Core 7636 * @atomicservice 7637 * @since 11 7638 */ 7639 /** 7640 * Set a delegate used to receive the progress of the download triggered from WebDownloadManager. 7641 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from WebDownloadManager. 7642 * @syscap SystemCapability.Web.Webview.Core 7643 * @crossplatform 7644 * @atomicservice 7645 * @since 18 7646 */ 7647 static setDownloadDelegate(delegate: WebDownloadDelegate): void; 7648 7649 /** 7650 * Resume the canceled or failed download. 7651 * @param { WebDownloadItem } webDownloadItem - Download that need to be resume. 7652 * @throws { BusinessError } 17100018 - No WebDownloadDelegate has been set yet. 7653 * @syscap SystemCapability.Web.Webview.Core 7654 * @atomicservice 7655 * @since 11 7656 */ 7657 static resumeDownload(webDownloadItem: WebDownloadItem): void; 7658 } 7659 7660 /** 7661 * The http body stream of the request. 7662 * 7663 * @syscap SystemCapability.Web.Webview.Core 7664 * @atomicservice 7665 * @since 12 7666 */ 7667 class WebHttpBodyStream { 7668 /** 7669 * Initialize data stream. 7670 * 7671 * @returns { Promise<void> } The promise of data stream is initialized. 7672 * @throws { BusinessError } 17100022 - Failed to initialize the HTTP body stream. 7673 * @syscap SystemCapability.Web.Webview.Core 7674 * @atomicservice 7675 * @since 12 7676 */ 7677 initialize(): Promise<void>; 7678 /** 7679 * Read the data stream to the buffer. 7680 * 7681 * @param { number } size - Read size. 7682 * @returns { Promise<ArrayBuffer> } Read array buffer of result. 7683 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7684 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 7685 * @syscap SystemCapability.Web.Webview.Core 7686 * @atomicservice 7687 * @since 12 7688 */ 7689 read(size: number): Promise<ArrayBuffer>; 7690 /** 7691 * Get the total size of the data stream. When data is chunked, always return zero. 7692 * 7693 * @returns { number } Return size of data stream size. 7694 * @syscap SystemCapability.Web.Webview.Core 7695 * @atomicservice 7696 * @since 12 7697 */ 7698 getSize(): number; 7699 /** 7700 * Get the current position of the data stream. 7701 * 7702 * @returns { number } Return position in post data stream. 7703 * @syscap SystemCapability.Web.Webview.Core 7704 * @atomicservice 7705 * @since 12 7706 */ 7707 getPosition(): number; 7708 /** 7709 * Whether data stream is chunked. 7710 * 7711 * @returns { boolean } Whether data stream is chunked. 7712 * @syscap SystemCapability.Web.Webview.Core 7713 * @atomicservice 7714 * @since 12 7715 */ 7716 isChunked(): boolean; 7717 /** 7718 * Whether all data stream has been consumed. For chunked uploads, 7719 * returns false until the first read attempt. 7720 * 7721 * @returns { boolean } Whether data stream has been consumed. 7722 * @syscap SystemCapability.Web.Webview.Core 7723 * @atomicservice 7724 * @since 12 7725 */ 7726 isEof(): boolean; 7727 /** 7728 * Returns true if the upload data in the stream is entirely in memory, and all read requests will succeed 7729 * synchronously. Expected to return false for chunked requests. 7730 * 7731 * @returns { boolean } Whether the data stream is in memory. 7732 * @syscap SystemCapability.Web.Webview.Core 7733 * @atomicservice 7734 * @since 12 7735 */ 7736 isInMemory(): boolean; 7737 } 7738 7739 /** 7740 * Defines the resource type of request. 7741 * @enum {number} 7742 * @syscap SystemCapability.Web.Webview.Core 7743 * @since 12 7744 */ 7745 enum WebResourceType { 7746 /** 7747 * Top level page. 7748 * 7749 * @syscap SystemCapability.Web.Webview.Core 7750 * @since 12 7751 */ 7752 MAIN_FRAME = 0, 7753 7754 /** 7755 * Frame or Iframe. 7756 * 7757 * @syscap SystemCapability.Web.Webview.Core 7758 * @since 12 7759 */ 7760 SUB_FRAME = 1, 7761 7762 /** 7763 * CSS stylesheet. 7764 * 7765 * @syscap SystemCapability.Web.Webview.Core 7766 * @since 12 7767 */ 7768 STYLE_SHEET = 2, 7769 7770 /** 7771 * External script. 7772 * 7773 * @syscap SystemCapability.Web.Webview.Core 7774 * @since 12 7775 */ 7776 SCRIPT = 3, 7777 7778 /** 7779 * Image (jpg/gif/png/etc). 7780 * 7781 * @syscap SystemCapability.Web.Webview.Core 7782 * @since 12 7783 */ 7784 IMAGE = 4, 7785 7786 /** 7787 * Font. 7788 * 7789 * @syscap SystemCapability.Web.Webview.Core 7790 * @since 12 7791 */ 7792 FONT_RESOURCE = 5, 7793 7794 /** 7795 * Some other subresource. This is the default type if the actual type is unknown. 7796 * 7797 * @syscap SystemCapability.Web.Webview.Core 7798 * @since 12 7799 */ 7800 SUB_RESOURCE = 6, 7801 7802 /** 7803 * Object (or embed) tag for a plugin, or a resource that a plugin requested. 7804 * 7805 * @syscap SystemCapability.Web.Webview.Core 7806 * @since 12 7807 */ 7808 OBJECT = 7, 7809 7810 /** 7811 * Media resource. 7812 * 7813 * @syscap SystemCapability.Web.Webview.Core 7814 * @since 12 7815 */ 7816 MEDIA = 8, 7817 7818 /** 7819 * Main resource of a dedicated worker. 7820 * 7821 * @syscap SystemCapability.Web.Webview.Core 7822 * @since 12 7823 */ 7824 WORKER = 9, 7825 7826 /** 7827 * Main resource of a shared worker. 7828 * 7829 * @syscap SystemCapability.Web.Webview.Core 7830 * @since 12 7831 */ 7832 SHARED_WORKER = 10, 7833 7834 /** 7835 * Explicitly requested prefetch. 7836 * 7837 * @syscap SystemCapability.Web.Webview.Core 7838 * @since 12 7839 */ 7840 PREFETCH = 11, 7841 7842 /** 7843 * Favicon. 7844 * 7845 * @syscap SystemCapability.Web.Webview.Core 7846 * @since 12 7847 */ 7848 FAVICON = 12, 7849 7850 /** 7851 * XMLHttpRequest. 7852 * 7853 * @syscap SystemCapability.Web.Webview.Core 7854 * @since 12 7855 */ 7856 XHR = 13, 7857 7858 /** 7859 * Ping request for <a ping>/sendBeacon. 7860 * 7861 * @syscap SystemCapability.Web.Webview.Core 7862 * @since 12 7863 */ 7864 PING = 14, 7865 7866 /** 7867 * The main resource of a service worker. 7868 * 7869 * @syscap SystemCapability.Web.Webview.Core 7870 * @since 12 7871 */ 7872 SERVICE_WORKER = 15, 7873 7874 /** 7875 * Report of Content Security Policy violations. 7876 * 7877 * @syscap SystemCapability.Web.Webview.Core 7878 * @since 12 7879 */ 7880 CSP_REPORT = 16, 7881 7882 /** 7883 * Resource that a plugin requested. 7884 * 7885 * @syscap SystemCapability.Web.Webview.Core 7886 * @since 12 7887 */ 7888 PLUGIN_RESOURCE = 17, 7889 7890 /** 7891 * A main-frame service worker navigation preload request. 7892 * 7893 * @syscap SystemCapability.Web.Webview.Core 7894 * @since 12 7895 */ 7896 NAVIGATION_PRELOAD_MAIN_FRAME = 19, 7897 7898 /** 7899 * A sub-frame service worker navigation preload request. 7900 * 7901 * @syscap SystemCapability.Web.Webview.Core 7902 * @since 12 7903 */ 7904 NAVIGATION_PRELOAD_SUB_FRAME = 20, 7905 } 7906 7907 /** 7908 * Defines the Web resource request used for scheme handler. 7909 * 7910 * @syscap SystemCapability.Web.Webview.Core 7911 * @atomicservice 7912 * @since 12 7913 */ 7914 class WebSchemeHandlerRequest { 7915 /** 7916 * Gets request headers. 7917 * 7918 * @returns { Array<WebHeader> } Return the request headers. 7919 * @syscap SystemCapability.Web.Webview.Core 7920 * @atomicservice 7921 * @since 12 7922 */ 7923 getHeader(): Array<WebHeader>; 7924 /** 7925 * Gets the request URL. 7926 * 7927 * @returns { string } Return the request URL. 7928 * @syscap SystemCapability.Web.Webview.Core 7929 * @atomicservice 7930 * @since 12 7931 */ 7932 getRequestUrl(): string; 7933 /** 7934 * Get request method. 7935 * 7936 * @returns { string } Return the request method. 7937 * @syscap SystemCapability.Web.Webview.Core 7938 * @atomicservice 7939 * @since 12 7940 */ 7941 getRequestMethod(): string; 7942 /** 7943 * Get referrer of request. 7944 * 7945 * @returns { string } Return referrer of request. 7946 * @syscap SystemCapability.Web.Webview.Core 7947 * @atomicservice 7948 * @since 12 7949 */ 7950 getReferrer(): string; 7951 /** 7952 * Check whether the request is for getting the main frame. 7953 * 7954 * @returns { boolean } Whether request is main frame. 7955 * @syscap SystemCapability.Web.Webview.Core 7956 * @atomicservice 7957 * @since 12 7958 */ 7959 isMainFrame(): boolean; 7960 /** 7961 * Check whether the request is associated with gesture. 7962 * 7963 * @returns { boolean } Whether request has user gesture. 7964 * @syscap SystemCapability.Web.Webview.Core 7965 * @atomicservice 7966 * @since 12 7967 */ 7968 hasGesture(): boolean; 7969 /** 7970 * Get http body stream. 7971 * 7972 * @returns { WebHttpBodyStream | null } Return http body stream. If request has no http body stream, return null. 7973 * @syscap SystemCapability.Web.Webview.Core 7974 * @atomicservice 7975 * @since 12 7976 */ 7977 getHttpBodyStream(): WebHttpBodyStream | null; 7978 /** 7979 * Get request's resource type. 7980 * 7981 * @returns { WebResourceType } Return the request's resource type. 7982 * @syscap SystemCapability.Web.Webview.Core 7983 * @since 12 7984 */ 7985 getRequestResourceType(): WebResourceType; 7986 /** 7987 * Gets the URL of frame which trigger this request. 7988 * 7989 * @returns { string } Return the URL of frame which trigger this request. 7990 * @syscap SystemCapability.Web.Webview.Core 7991 * @since 12 7992 */ 7993 getFrameUrl(): string; 7994 } 7995 7996 /** 7997 * Defines the Web resource response used for scheme handler. 7998 * 7999 * @syscap SystemCapability.Web.Webview.Core 8000 * @atomicservice 8001 * @since arkts {'1.1':'12', '1.2':'20'} 8002 * @arkts 1.1&1.2 8003 */ 8004 class WebSchemeHandlerResponse { 8005 /** 8006 * Constructor. 8007 * 8008 * @syscap SystemCapability.Web.Webview.Core 8009 * @atomicservice 8010 * @since arkts {'1.1':'12', '1.2':'20'} 8011 * @arkts 1.1&1.2 8012 */ 8013 constructor(); 8014 /** 8015 * Set the resolved URL after redirects or changed as a result of HSTS. 8016 * 8017 * @param { string } url - Set response url for redirects. 8018 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 8019 * @syscap SystemCapability.Web.Webview.Core 8020 * @atomicservice 8021 * @since arkts {'1.1':'12', '1.2':'20'} 8022 * @arkts 1.1&1.2 8023 */ 8024 setUrl(url: string): void; 8025 /** 8026 * Get the resolved URL after redirects or changed as a result of HSTS. 8027 * 8028 * @returns { string } Return response url for redirects. 8029 * @syscap SystemCapability.Web.Webview.Core 8030 * @atomicservice 8031 * @since arkts {'1.1':'12', '1.2':'20'} 8032 * @arkts 1.1&1.2 8033 */ 8034 getUrl(): string; 8035 /** 8036 * Set net error code. 8037 * @param { WebNetErrorList } code - Set net error code. 8038 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 8039 * <br>2. Incorrect parameter types. 8040 * @syscap SystemCapability.Web.Webview.Core 8041 * @atomicservice 8042 * @since 12 8043 */ 8044 setNetErrorCode(code: WebNetErrorList): void; 8045 /** 8046 * Get net error code. 8047 * 8048 * @returns { WebNetErrorList } Return response error code. 8049 * @syscap SystemCapability.Web.Webview.Core 8050 * @atomicservice 8051 * @since 12 8052 */ 8053 getNetErrorCode(): WebNetErrorList; 8054 /** 8055 * Set http status code. 8056 * 8057 * @param { number } code - Http status code. 8058 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 8059 * @syscap SystemCapability.Web.Webview.Core 8060 * @atomicservice 8061 * @since 12 8062 */ 8063 setStatus(code: number): void; 8064 /** 8065 * Get http status code. 8066 * 8067 * @returns { number } Return http status code. 8068 * @syscap SystemCapability.Web.Webview.Core 8069 * @atomicservice 8070 * @since 12 8071 */ 8072 getStatus(): number; 8073 /** 8074 * Set status text. 8075 * 8076 * @param { string } text - Status text. 8077 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 8078 * @syscap SystemCapability.Web.Webview.Core 8079 * @atomicservice 8080 * @since 12 8081 */ 8082 setStatusText(text: string): void; 8083 /** 8084 * Get status text. 8085 * 8086 * @returns { string } Return http status text. 8087 * @syscap SystemCapability.Web.Webview.Core 8088 * @atomicservice 8089 * @since 12 8090 */ 8091 getStatusText(): string; 8092 /** 8093 * Set mime type. 8094 * 8095 * @param { string } type - Mime type. 8096 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 8097 * @syscap SystemCapability.Web.Webview.Core 8098 * @atomicservice 8099 * @since 12 8100 */ 8101 setMimeType(type: string): void; 8102 /** 8103 * Get mime type. 8104 * 8105 * @returns { string } Return mime type of response. 8106 * @syscap SystemCapability.Web.Webview.Core 8107 * @atomicservice 8108 * @since 12 8109 */ 8110 getMimeType(): string; 8111 /** 8112 * Set the response encoding. 8113 * 8114 * @param { string } encoding - Encoding. 8115 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 8116 * @syscap SystemCapability.Web.Webview.Core 8117 * @atomicservice 8118 * @since 12 8119 */ 8120 setEncoding(encoding: string): void; 8121 /** 8122 * Get the response encoding. 8123 * 8124 * @returns { string } Return encoding of response. 8125 * @syscap SystemCapability.Web.Webview.Core 8126 * @atomicservice 8127 * @since 12 8128 */ 8129 getEncoding(): string; 8130 /** 8131 * Set response hander value by name. 8132 * 8133 * @param { string } name - Header name. 8134 * @param { string } value - Header value. 8135 * @param { boolean } overwrite - Whether to overwrite. 8136 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 8137 * <br>2. Incorrect parameter types. 8138 * @syscap SystemCapability.Web.Webview.Core 8139 * @atomicservice 8140 * @since 12 8141 */ 8142 setHeaderByName(name: string, value: string, overwrite: boolean): void; 8143 /** 8144 * Get the header value by name from the response. 8145 * 8146 * @param { string } name - Header name. 8147 * @returns { string } Return header value by name. 8148 * @syscap SystemCapability.Web.Webview.Core 8149 * @atomicservice 8150 * @since 12 8151 */ 8152 getHeaderByName(name: string): string 8153 } 8154 8155 /** 8156 * Used to intercept url requests. Response headers and body can be sent through 8157 * WebResourceHandler. 8158 * 8159 * @syscap SystemCapability.Web.Webview.Core 8160 * @atomicservice 8161 * @since 12 8162 */ 8163 class WebResourceHandler { 8164 /** 8165 * Pass response headers to intercepted requests. 8166 * 8167 * @param { WebSchemeHandlerResponse } response - Set response header to intercept. 8168 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 8169 * @throws { BusinessError } 17100021 - The resource handler is invalid. 8170 * @syscap SystemCapability.Web.Webview.Core 8171 * @atomicservice 8172 * @since 12 8173 */ 8174 didReceiveResponse(response: WebSchemeHandlerResponse): void; 8175 /** 8176 * Pass response body data to intercepted requests. 8177 * 8178 * @param { ArrayBuffer } data - Set response body to intercept. 8179 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 8180 * @throws { BusinessError } 17100021 - The resource handler is invalid. 8181 * @syscap SystemCapability.Web.Webview.Core 8182 * @atomicservice 8183 * @since 12 8184 */ 8185 didReceiveResponseBody(data: ArrayBuffer): void; 8186 /** 8187 * Notify that this request should be finished and there is no more data available. 8188 * 8189 * @throws { BusinessError } 17100021 - The resource handler is invalid. 8190 * @syscap SystemCapability.Web.Webview.Core 8191 * @atomicservice 8192 * @since 12 8193 */ 8194 didFinish(): void; 8195 /** 8196 * Notify that this request should be failed. 8197 * 8198 * @param { WebNetErrorList } code - Set response error code to intercept. 8199 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 8200 * @throws { BusinessError } 17100021 - The resource handler is invalid. 8201 * @syscap SystemCapability.Web.Webview.Core 8202 * @atomicservice 8203 * @since 12 8204 */ 8205 didFail(code: WebNetErrorList): void; 8206 /** 8207 * Notify that this request should be failed. 8208 * 8209 * @param { WebNetErrorList } code - Set response error code to intercept. 8210 * @param { boolean } completeIfNoResponse - If completeIfNoResponse is true, when DidFailWithError is called, if 8211 * DidReceiveResponse has not been called, a response is automatically 8212 * constructed and the current request is terminated. 8213 * @throws { BusinessError } 17100101 - The errorCode is either ARKWEB_NET_OK or outside the range of error codes 8214 * in WebNetErrorList. 8215 * @throws { BusinessError } 17100021 - The resource handler is invalid. 8216 * @syscap SystemCapability.Web.Webview.Core 8217 * @since 20 8218 */ 8219 didFail(code: WebNetErrorList, completeIfNoResponse: boolean): void; 8220 } 8221 8222 /** 8223 * This class is used to intercept requests for a specified scheme. 8224 * 8225 * @syscap SystemCapability.Web.Webview.Core 8226 * @atomicservice 8227 * @since 12 8228 */ 8229 class WebSchemeHandler { 8230 /** 8231 * Callback for handling the request. 8232 * 8233 * @param { function } callback - Callback of handling the request. If callback return false, 8234 * it means no interception. 8235 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 8236 * <br>2. Incorrect parameter types. 8237 * @syscap SystemCapability.Web.Webview.Core 8238 * @atomicservice 8239 * @since 12 8240 */ 8241 onRequestStart( 8242 callback: (request: WebSchemeHandlerRequest, handler: WebResourceHandler) => boolean): void; 8243 8244 /** 8245 * Callback when the request is completed. 8246 * 8247 * @param { Callback<WebSchemeHandlerRequest> } callback - Callback of request is completed. 8248 * @throws { BusinessError } 401 - Invalid input parameter. 8249 * @syscap SystemCapability.Web.Webview.Core 8250 * @atomicservice 8251 * @since 12 8252 */ 8253 onRequestStop(callback: Callback<WebSchemeHandlerRequest>): void; 8254 } 8255 8256 /** 8257 * Enum type supplied to {@link handleStatusChanged} for indicating the playback status. 8258 * @enum {number} 8259 * @syscap SystemCapability.Web.Webview.Core 8260 * @atomicservice 8261 * @since 12 8262 */ 8263 enum PlaybackStatus { 8264 /** 8265 * Player status is paused. 8266 * @syscap SystemCapability.Web.Webview.Core 8267 * @atomicservice 8268 * @since 12 8269 */ 8270 PAUSED = 0, 8271 /** 8272 * Player status is playing. 8273 * @syscap SystemCapability.Web.Webview.Core 8274 * @atomicservice 8275 * @since 12 8276 */ 8277 PLAYING, 8278 } 8279 8280 /** 8281 * Enum type supplied to {@link handleNetworkStateChanged} for indicating the native player network state. 8282 * @enum {number} 8283 * @syscap SystemCapability.Web.Webview.Core 8284 * @atomicservice 8285 * @since 12 8286 */ 8287 enum NetworkState { 8288 /** 8289 * Player does not do any download tasks. 8290 * @syscap SystemCapability.Web.Webview.Core 8291 * @atomicservice 8292 * @since 12 8293 */ 8294 EMPTY = 0, 8295 /** 8296 * Player downloads finished, waiting for next task. 8297 * @syscap SystemCapability.Web.Webview.Core 8298 * @atomicservice 8299 * @since 12 8300 */ 8301 IDLE, 8302 /** 8303 * Player is downloading contents. 8304 * @syscap SystemCapability.Web.Webview.Core 8305 * @atomicservice 8306 * @since 12 8307 */ 8308 LOADING, 8309 /** 8310 * Player downloads failed, due to network error. 8311 * @syscap SystemCapability.Web.Webview.Core 8312 * @atomicservice 8313 * @since 12 8314 */ 8315 NETWORK_ERROR 8316 } 8317 8318 /** 8319 * Enum type supplied to {@link handleReadyStateChanged} for indicating the native player network state. 8320 * @enum {number} 8321 * @syscap SystemCapability.Web.Webview.Core 8322 * @atomicservice 8323 * @since 12 8324 */ 8325 enum ReadyState { 8326 /** 8327 * Player hasn't downloaded anything. 8328 * @syscap SystemCapability.Web.Webview.Core 8329 * @atomicservice 8330 * @since 12 8331 */ 8332 HAVE_NOTHING = 0, 8333 /** 8334 * Player has downloaded metadata. 8335 * @syscap SystemCapability.Web.Webview.Core 8336 * @atomicservice 8337 * @since 12 8338 */ 8339 HAVE_METADATA, 8340 /** 8341 * Player has played all downloaded media data. 8342 * @syscap SystemCapability.Web.Webview.Core 8343 * @atomicservice 8344 * @since 12 8345 */ 8346 HAVE_CURRENT_DATA, 8347 /** 8348 * The buffered media data is not enough, and will cause jank. 8349 * @syscap SystemCapability.Web.Webview.Core 8350 * @atomicservice 8351 * @since 12 8352 */ 8353 HAVE_FUTURE_DATA, 8354 /** 8355 * The buffered media data is enough. 8356 * @syscap SystemCapability.Web.Webview.Core 8357 * @atomicservice 8358 * @since 12 8359 */ 8360 HAVE_ENOUGH_DATA, 8361 } 8362 8363 /** 8364 * Enum type supplied to {@link handleError} for indicating the error type of native media player. 8365 * @enum {number} 8366 * @syscap SystemCapability.Web.Webview.Core 8367 * @atomicservice 8368 * @since 12 8369 */ 8370 enum MediaError { 8371 /** 8372 * Network error 8373 * @syscap SystemCapability.Web.Webview.Core 8374 * @atomicservice 8375 * @since 12 8376 */ 8377 NETWORK_ERROR = 1, 8378 /** 8379 * Media format error, such as not a valid file. 8380 * @syscap SystemCapability.Web.Webview.Core 8381 * @atomicservice 8382 * @since 12 8383 */ 8384 FORMAT_ERROR, 8385 /** 8386 * Decode error, such as decoder doesn't support this format. 8387 * @syscap SystemCapability.Web.Webview.Core 8388 * @atomicservice 8389 * @since 12 8390 */ 8391 DECODE_ERROR 8392 } 8393 8394 /** 8395 * The native media player status handler. 8396 * Apps should use this class to handle native media player's status. 8397 * 8398 * @typedef NativeMediaPlayerHandler 8399 * @syscap SystemCapability.Web.Webview.Core 8400 * @atomicservice 8401 * @since 12 8402 */ 8403 interface NativeMediaPlayerHandler { 8404 8405 /** 8406 * Handle native media player playback status. 8407 * 8408 * @param { PlaybackStatus } status - Playback status of native media player. 8409 * @syscap SystemCapability.Web.Webview.Core 8410 * @atomicservice 8411 * @since 12 8412 */ 8413 handleStatusChanged(status: PlaybackStatus): void 8414 8415 /** 8416 * Handle native media player volume. 8417 * volume: float 8418 * value range: [0 - 1.0] 8419 * 8420 * @param { number } volume - Current volume of native media player. 8421 * @syscap SystemCapability.Web.Webview.Core 8422 * @atomicservice 8423 * @since 12 8424 */ 8425 handleVolumeChanged(volume: number): void 8426 8427 /** 8428 * Handle native media player muted status. 8429 * 8430 * @param { boolean } muted - Current mute status of native media player. 8431 * @syscap SystemCapability.Web.Webview.Core 8432 * @atomicservice 8433 * @since 12 8434 */ 8435 handleMutedChanged(muted: boolean): void 8436 8437 /** 8438 * Handle playback rate of native media player. 8439 * playbackRate: float 8440 * value range: [0 - infinity] 8441 * 8442 * @param { number } playbackRate - Current playback rate of native media player. 8443 * @syscap SystemCapability.Web.Webview.Core 8444 * @atomicservice 8445 * @since 12 8446 */ 8447 handlePlaybackRateChanged(playbackRate: number): void 8448 8449 /** 8450 * Handle duration time of media. 8451 * duration: float 8452 * value range: [0 - infinity] 8453 * 8454 * @param { number } duration - Duration time (in seconds) of media. 8455 * @syscap SystemCapability.Web.Webview.Core 8456 * @atomicservice 8457 * @since 12 8458 */ 8459 handleDurationChanged(duration: number): void 8460 8461 /** 8462 * Handle current playing time of media. 8463 * currentPlayTime: float 8464 * value range: [0 - duration] 8465 * 8466 * @param { number } currentPlayTime - Current playing time (in seconds) of media. 8467 * @syscap SystemCapability.Web.Webview.Core 8468 * @atomicservice 8469 * @since 12 8470 */ 8471 handleTimeUpdate(currentPlayTime: number): void 8472 8473 /** 8474 * Handle buffered end time of media. 8475 * bufferedEndTime: float 8476 * value range: [0 - duration] 8477 * 8478 * @param { number } bufferedEndTime - Buffered end time (in seconds) of media. 8479 * @syscap SystemCapability.Web.Webview.Core 8480 * @atomicservice 8481 * @since 12 8482 */ 8483 handleBufferedEndTimeChanged(bufferedEndTime: number): void 8484 8485 /** 8486 * Handle native player ended event. 8487 * 8488 * @syscap SystemCapability.Web.Webview.Core 8489 * @atomicservice 8490 * @since 12 8491 */ 8492 handleEnded(): void 8493 8494 /** 8495 * Handle network state of native media player. 8496 * 8497 * @param { NetworkState } state - Network state of native media player. 8498 * @syscap SystemCapability.Web.Webview.Core 8499 * @atomicservice 8500 * @since 12 8501 */ 8502 handleNetworkStateChanged(state: NetworkState): void 8503 8504 /** 8505 * Handle ready state of native media player. 8506 * 8507 * @param { ReadyState } state - Ready state of native media player. 8508 * @syscap SystemCapability.Web.Webview.Core 8509 * @atomicservice 8510 * @since 12 8511 */ 8512 handleReadyStateChanged(state: ReadyState): void 8513 8514 /** 8515 * Handle native media player fullscreen state changed event. 8516 * 8517 * @param { boolean } fullscreen - Fullscreen state of native media player. 8518 * @syscap SystemCapability.Web.Webview.Core 8519 * @atomicservice 8520 * @since 12 8521 */ 8522 handleFullscreenChanged(fullscreen: boolean): void 8523 8524 /** 8525 * Handle native media player seeking state. 8526 * 8527 * @syscap SystemCapability.Web.Webview.Core 8528 * @atomicservice 8529 * @since 12 8530 */ 8531 handleSeeking(): void 8532 8533 /** 8534 * Handle native media player seek finished state. 8535 * 8536 * @syscap SystemCapability.Web.Webview.Core 8537 * @atomicservice 8538 * @since 12 8539 */ 8540 handleSeekFinished(): void 8541 8542 /** 8543 * Handle native media player error event. 8544 * 8545 * @param { MediaError } error - Error type of native media player. 8546 * @param { string } errorMessage - Description of current error. 8547 * @syscap SystemCapability.Web.Webview.Core 8548 * @atomicservice 8549 * @since 12 8550 */ 8551 handleError(error: MediaError, errorMessage: string): void 8552 8553 /** 8554 * Handle size of video. 8555 * 8556 * @param { number } width - Width of video. 8557 * @param { number } height - Height of video. 8558 * @syscap SystemCapability.Web.Webview.Core 8559 * @atomicservice 8560 * @since 12 8561 */ 8562 handleVideoSizeChanged(width: number, height: number): void 8563 } 8564 8565 /** 8566 * The scenarios for suspending the media player. 8567 * @enum {number} 8568 * @syscap SystemCapability.Web.Webview.Core 8569 * @since 12 8570 */ 8571 enum SuspendType { 8572 /** 8573 * Page enters the BackForwardCache. 8574 * @syscap SystemCapability.Web.Webview.Core 8575 * @since 12 8576 */ 8577 ENTER_BACK_FORWARD_CACHE = 0, 8578 8579 /** 8580 * Page enters background. 8581 * @syscap SystemCapability.Web.Webview.Core 8582 * @since 12 8583 */ 8584 ENTER_BACKGROUND, 8585 8586 /** 8587 * Cleanup when the number of paused media player over limit. 8588 * @syscap SystemCapability.Web.Webview.Core 8589 * @since 12 8590 */ 8591 AUTO_CLEANUP 8592 } 8593 8594 /** 8595 * The bridge between web core and native media player. 8596 * Apps should implements this interface, and pass an instance to web core. 8597 * Then web core can control native media player by this bridge. 8598 * 8599 * @typedef NativeMediaPlayerBridge 8600 * @syscap SystemCapability.Web.Webview.Core 8601 * @atomicservice 8602 * @since 12 8603 */ 8604 interface NativeMediaPlayerBridge { 8605 /** 8606 * Notify native media player that the rect of video tag has changed. 8607 * 8608 * @param { number } x - The x position of video tag in web component. 8609 * @param { number } y - The y position of video tag in web component. 8610 * @param { number } width - The width of video tag. 8611 * @param { number } height - The height of video tag. 8612 * @syscap SystemCapability.Web.Webview.Core 8613 * @atomicservice 8614 * @since 12 8615 */ 8616 updateRect(x: number, y: number, width: number, height: number): void 8617 8618 /** 8619 * Request to play. 8620 * 8621 * @syscap SystemCapability.Web.Webview.Core 8622 * @atomicservice 8623 * @since 12 8624 */ 8625 play(): void 8626 8627 /** 8628 * Request to pause. 8629 * 8630 * @syscap SystemCapability.Web.Webview.Core 8631 * @atomicservice 8632 * @since 12 8633 */ 8634 pause(): void 8635 8636 /** 8637 * Request to fast forward / back forward to targetTime. 8638 * targetTime: float 8639 * value range: [0 - duration] 8640 * 8641 * @param { number } targetTime - The target time (in seconds) to FF/BF to. 8642 * @syscap SystemCapability.Web.Webview.Core 8643 * @atomicservice 8644 * @since 12 8645 */ 8646 seek(targetTime: number): void 8647 8648 /** 8649 * Request to change volume of native media player. 8650 * volume: float 8651 * value range: [0 - 1.0] 8652 * 8653 * @param { number } volume - The volume of native media player. 8654 * @syscap SystemCapability.Web.Webview.Core 8655 * @atomicservice 8656 * @since 12 8657 */ 8658 setVolume(volume: number): void 8659 8660 /** 8661 * Request to mute native media player. 8662 * 8663 * @param { boolean } muted - Should mute native media player. 8664 * @syscap SystemCapability.Web.Webview.Core 8665 * @atomicservice 8666 * @since 12 8667 */ 8668 setMuted(muted: boolean): void 8669 8670 /** 8671 * Request to change playback rate of native media player. 8672 * playbackRate: float 8673 * value range: [0 - 10.0] 8674 * 8675 * @param { number } playbackRate - The playback rate of native media player. 8676 * @syscap SystemCapability.Web.Webview.Core 8677 * @atomicservice 8678 * @since 12 8679 */ 8680 setPlaybackRate(playbackRate: number): void 8681 8682 /** 8683 * Request to release native media player. 8684 * 8685 * @syscap SystemCapability.Web.Webview.Core 8686 * @atomicservice 8687 * @since 12 8688 */ 8689 release(): void 8690 8691 /** 8692 * Request to enter fullscreen. 8693 * 8694 * @syscap SystemCapability.Web.Webview.Core 8695 * @atomicservice 8696 * @since 12 8697 */ 8698 enterFullscreen(): void 8699 8700 /** 8701 * Request to exit fullscreen. 8702 * 8703 * @syscap SystemCapability.Web.Webview.Core 8704 * @atomicservice 8705 * @since 12 8706 */ 8707 exitFullscreen(): void 8708 8709 /** 8710 * Resume the native media player. 8711 * 8712 * @syscap SystemCapability.Web.Webview.Core 8713 * @since 12 8714 */ 8715 resumePlayer?(): void 8716 8717 /** 8718 * Suspend to release native media player, not the NativeMediaPlayerBridge. The 8719 * embedder should save the status of player when release the native media player 8720 * through NativeMediaPlayerBridge. 8721 * 8722 * @param { SuspendType } type - The scenario for suspending the media player. 8723 * @syscap SystemCapability.Web.Webview.Core 8724 * @since 12 8725 */ 8726 suspendPlayer?(type: SuspendType): void 8727 } 8728 8729 /** 8730 * Enum type for indicating the media type of native media player. 8731 * @enum {number} 8732 * @syscap SystemCapability.Web.Webview.Core 8733 * @atomicservice 8734 * @since 12 8735 */ 8736 enum MediaType { 8737 /** 8738 * Media type is video. 8739 * @syscap SystemCapability.Web.Webview.Core 8740 * @atomicservice 8741 * @since 12 8742 */ 8743 VIDEO = 0, 8744 /** 8745 * Media type is audio. 8746 * @syscap SystemCapability.Web.Webview.Core 8747 * @atomicservice 8748 * @since 12 8749 */ 8750 AUDIO 8751 } 8752 8753 /** 8754 * Enum type for indicating the media source type of native media player. 8755 * @enum {number} 8756 * @syscap SystemCapability.Web.Webview.Core 8757 * @atomicservice 8758 * @since 12 8759 */ 8760 enum SourceType { 8761 /** 8762 * The type of media source is URL. 8763 * @syscap SystemCapability.Web.Webview.Core 8764 * @atomicservice 8765 * @since 12 8766 */ 8767 URL = 0, 8768 /** 8769 * The type of media source is blob. 8770 * @syscap SystemCapability.Web.Webview.Core 8771 * @atomicservice 8772 * @since 12 8773 */ 8774 MSE 8775 } 8776 8777 /** 8778 * Media source information. Uri and format. 8779 * 8780 * @syscap SystemCapability.Web.Webview.Core 8781 * @atomicservice 8782 * @since 12 8783 */ 8784 class MediaSourceInfo { 8785 /** 8786 * Source type, most time is URL. 8787 * @type { SourceType } 8788 * @syscap SystemCapability.Web.Webview.Core 8789 * @since 12 8790 */ 8791 type: SourceType; 8792 8793 /** 8794 * Media source, most time is Uri. 8795 * @type { string } 8796 * @syscap SystemCapability.Web.Webview.Core 8797 * @atomicservice 8798 * @since 12 8799 */ 8800 source: string; 8801 8802 /** 8803 * Media format, such as mp4, webm, m3u8 etc. 8804 * @type { string } 8805 * @syscap SystemCapability.Web.Webview.Core 8806 * @atomicservice 8807 * @since 12 8808 */ 8809 format: string; 8810 } 8811 8812 /** 8813 * Rectangle definition. 8814 * 8815 * @typedef RectEvent 8816 * @syscap SystemCapability.Web.Webview.Core 8817 * @since 12 8818 */ 8819 interface RectEvent { 8820 /** 8821 * X coordinator of top left point. 8822 * 8823 * @type { number } 8824 * @syscap SystemCapability.Web.Webview.Core 8825 * @since 12 8826 */ 8827 x: number; 8828 /** 8829 * Y coordinator of top left point. 8830 * 8831 * @type { number } 8832 * @syscap SystemCapability.Web.Webview.Core 8833 * @since 12 8834 */ 8835 y: number; 8836 /** 8837 * Width of this rectangle. 8838 * 8839 * @type { number } 8840 * @syscap SystemCapability.Web.Webview.Core 8841 * @since 12 8842 */ 8843 width: number; 8844 /** 8845 * Height of this rectangle. 8846 * 8847 * @type { number } 8848 * @syscap SystemCapability.Web.Webview.Core 8849 * @since 12 8850 */ 8851 height: number; 8852 } 8853 8854 /** 8855 * Surface information. 8856 * 8857 * @syscap SystemCapability.Web.Webview.Core 8858 * @atomicservice 8859 * @since 12 8860 */ 8861 class NativeMediaPlayerSurfaceInfo { 8862 /** 8863 * Id of surface. 8864 * @type { string } 8865 * @syscap SystemCapability.Web.Webview.Core 8866 * @atomicservice 8867 * @since 12 8868 */ 8869 id: string; 8870 8871 /** 8872 * Surface rect info. 8873 * @type { RectEvent } 8874 * @syscap SystemCapability.Web.Webview.Core 8875 * @since 12 8876 */ 8877 rect: RectEvent; 8878 } 8879 8880 /** 8881 * Enum type for indicating the preload type. 8882 * @enum {number} 8883 * @syscap SystemCapability.Web.Webview.Core 8884 * @atomicservice 8885 * @since 12 8886 */ 8887 enum Preload { 8888 /** 8889 * Doesn't do preload. 8890 * @syscap SystemCapability.Web.Webview.Core 8891 * @atomicservice 8892 * @since 12 8893 */ 8894 NONE = 0, 8895 /** 8896 * Only preload metadata. 8897 * @syscap SystemCapability.Web.Webview.Core 8898 * @atomicservice 8899 * @since 12 8900 */ 8901 METADATA, 8902 /** 8903 * Preload enough data to ensure playing is smooth. 8904 * @syscap SystemCapability.Web.Webview.Core 8905 * @atomicservice 8906 * @since 12 8907 */ 8908 AUTO 8909 } 8910 8911 /** 8912 * Media information. 8913 * 8914 * @typedef MediaInfo 8915 * @syscap SystemCapability.Web.Webview.Core 8916 * @atomicservice 8917 * @since 12 8918 */ 8919 interface MediaInfo { 8920 /** 8921 * Id of media element. 8922 * @type { string } 8923 * @syscap SystemCapability.Web.Webview.Core 8924 * @since 12 8925 */ 8926 embedID: string, 8927 /** 8928 * Media type : Video or Audio. 8929 * @type { MediaType } 8930 * @syscap SystemCapability.Web.Webview.Core 8931 * @atomicservice 8932 * @since 12 8933 */ 8934 mediaType: MediaType, 8935 /** 8936 * Media source list, player should choose an appropriate one to play. 8937 * @type { MediaSourceInfo[] } 8938 * @syscap SystemCapability.Web.Webview.Core 8939 * @atomicservice 8940 * @since 12 8941 */ 8942 mediaSrcList: MediaSourceInfo[], 8943 /** 8944 * Surface to render media content on. 8945 * @type { NativeMediaPlayerSurfaceInfo } 8946 * @syscap SystemCapability.Web.Webview.Core 8947 * @atomicservice 8948 * @since 12 8949 */ 8950 surfaceInfo: NativeMediaPlayerSurfaceInfo, 8951 /** 8952 * Should show media controls. 8953 * @type { boolean } 8954 * @syscap SystemCapability.Web.Webview.Core 8955 * @atomicservice 8956 * @since 12 8957 */ 8958 controlsShown: boolean, 8959 /** 8960 * Limit media controls items. 8961 * Such as 'nodownload', 'nofullscreen', 'noremoteplayback' 8962 * @type { string[] } 8963 * @syscap SystemCapability.Web.Webview.Core 8964 * @atomicservice 8965 * @since 12 8966 */ 8967 controlList: string[], 8968 /** 8969 * Player should be muted; 8970 * @type { boolean } 8971 * @syscap SystemCapability.Web.Webview.Core 8972 * @atomicservice 8973 * @since 12 8974 */ 8975 muted: boolean, 8976 /** 8977 * Player should show poster before media first frame shown. 8978 * @type { string } 8979 * @syscap SystemCapability.Web.Webview.Core 8980 * @atomicservice 8981 * @since 12 8982 */ 8983 posterUrl: string, 8984 /** 8985 * Preload type. 8986 * @type { Preload } 8987 * @syscap SystemCapability.Web.Webview.Core 8988 * @atomicservice 8989 * @since 12 8990 */ 8991 preload: Preload, 8992 /** 8993 * Header information of a media network request. 8994 * @type { Record<string, string> } 8995 * @syscap SystemCapability.Web.Webview.Core 8996 * @since 12 8997 */ 8998 headers: Record<string, string>, 8999 /** 9000 * The information list of attributes of media tag. 9001 * @type { Record<string, string> } 9002 * @syscap SystemCapability.Web.Webview.Core 9003 * @since 12 9004 */ 9005 attributes: Record<string, string>, 9006 } 9007 9008 /** 9009 * The callback of creating a native media player. 9010 * 9011 * @typedef { function } 9012 * @param { NativeMediaPlayerHandler } handler - callback information of onCreateNativeMediaPlayer. 9013 * @param { MediaInfo } mediaInfo - callback information of onCreateNativeMediaPlayer. 9014 * @returns { NativeMediaPlayerBridge } Returns whether the app takes over the media. 9015 * @syscap SystemCapability.Web.Webview.Core 9016 * @atomicservice 9017 * @since 12 9018 */ 9019 type CreateNativeMediaPlayerCallback = 9020 (handler: NativeMediaPlayerHandler, mediaInfo: MediaInfo) => NativeMediaPlayerBridge; 9021 9022 /** 9023 * This class is used to set adblock config. 9024 * @syscap SystemCapability.Web.Webview.Core 9025 * @atomicservice 9026 * @since 12 9027 */ 9028 class AdsBlockManager { 9029 /** 9030 * set Ads Block ruleset file, containing easylist rules. 9031 * @param {string} rulesFile - absolute file path contains app customized ads block rules. 9032 * @param {boolean} replace - (@code true)replace internal rules;(@code false) add to internal rules. 9033 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9034 * <br>2. Incorrect parameter types. 9035 * @syscap SystemCapability.Web.Webview.Core 9036 * @atomicservice 9037 * @since 12 9038 */ 9039 /** 9040 * set Ads Block ruleset file, containing easylist rules. 9041 * @param {string} rulesFile - absolute file path contains app customized ads block rules. 9042 * @param {boolean} replace - (@code true)replace internal rules;(@code false) add to internal rules. 9043 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9044 * <br>2. Incorrect parameter types. 9045 * @throws { BusinessError } 801 - Capability not supported. 9046 * @syscap SystemCapability.Web.Webview.Core 9047 * @atomicservice 9048 * @since 18 9049 */ 9050 static setAdsBlockRules(rulesFile: string, replace: boolean): void; 9051 9052 /** 9053 * Add items to Ads Block Disallow list. 9054 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 9055 * Ads Block will be disallowed for the web page. 9056 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9057 * <br>2. Incorrect parameter types. 9058 * @syscap SystemCapability.Web.Webview.Core 9059 * @atomicservice 9060 * @since 12 9061 */ 9062 /** 9063 * Add items to Ads Block Disallow list. 9064 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 9065 * Ads Block will be disallowed for the web page. 9066 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9067 * <br>2. Incorrect parameter types. 9068 * @throws { BusinessError } 801 - Capability not supported. 9069 * @syscap SystemCapability.Web.Webview.Core 9070 * @atomicservice 9071 * @since 18 9072 */ 9073 static addAdsBlockDisallowedList(domainSuffixes: Array<string>): void; 9074 9075 /** 9076 * Add items to Ads Block Allow list. 9077 * By default, ads block is allowed for all pages unless they are added to the 9078 * disallow list. The priority of allowlist is higher than the disallowlist. It is 9079 * used to re-enable ads block on the page that matches disallow list. 9080 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 9081 * Ads Block will be allowed for the web page. 9082 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9083 * <br>2. Incorrect parameter types. 9084 * @syscap SystemCapability.Web.Webview.Core 9085 * @atomicservice 9086 * @since 12 9087 */ 9088 /** 9089 * Add items to Ads Block Allow list. 9090 * By default, ads block is allowed for all pages unless they are added to the 9091 * disallow list. The priority of allowlist is higher than the disallowlist. It is 9092 * used to re-enable ads block on the page that matches disallow list. 9093 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 9094 * Ads Block will be allowed for the web page. 9095 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9096 * <br>2. Incorrect parameter types. 9097 * @throws { BusinessError } 801 - Capability not supported. 9098 * @syscap SystemCapability.Web.Webview.Core 9099 * @atomicservice 9100 * @since 18 9101 */ 9102 static addAdsBlockAllowedList(domainSuffixes: Array<string>): void; 9103 9104 /** 9105 * remove items from Ads Block Disallowed list. 9106 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from disallow list 9107 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9108 * <br>2. Incorrect parameter types. 9109 * @syscap SystemCapability.Web.Webview.Core 9110 * @atomicservice 9111 * @since 12 9112 */ 9113 /** 9114 * remove items from Ads Block Disallowed list. 9115 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from disallow list 9116 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9117 * <br>2. Incorrect parameter types. 9118 * @throws { BusinessError } 801 - Capability not supported. 9119 * @syscap SystemCapability.Web.Webview.Core 9120 * @atomicservice 9121 * @since 18 9122 */ 9123 static removeAdsBlockDisallowedList(domainSuffixes: Array<string>): void; 9124 9125 /** 9126 * remove items from Ads Block Allowed list. 9127 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from allow list 9128 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9129 * <br>2. Incorrect parameter types. 9130 * @syscap SystemCapability.Web.Webview.Core 9131 * @atomicservice 9132 * @since 12 9133 */ 9134 /** 9135 * remove items from Ads Block Allowed list. 9136 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from allow list 9137 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9138 * <br>2. Incorrect parameter types. 9139 * @throws { BusinessError } 801 - Capability not supported. 9140 * @syscap SystemCapability.Web.Webview.Core 9141 * @atomicservice 9142 * @since 18 9143 */ 9144 static removeAdsBlockAllowedList(domainSuffixes: Array<string>): void; 9145 9146 /** 9147 * clear Ads Block Disallowed list. 9148 * @syscap SystemCapability.Web.Webview.Core 9149 * @atomicservice 9150 * @since 12 9151 */ 9152 /** 9153 * clear Ads Block Disallowed list. 9154 * @throws { BusinessError } 801 - Capability not supported. 9155 * @syscap SystemCapability.Web.Webview.Core 9156 * @atomicservice 9157 * @since 18 9158 */ 9159 static clearAdsBlockDisallowedList(): void; 9160 9161 /** 9162 * clear Ads Block Allowed list. 9163 * @syscap SystemCapability.Web.Webview.Core 9164 * @atomicservice 9165 * @since 12 9166 */ 9167 /** 9168 * clear Ads Block Allowed list. 9169 * @throws { BusinessError } 801 - Capability not supported. 9170 * @syscap SystemCapability.Web.Webview.Core 9171 * @atomicservice 9172 * @since 18 9173 */ 9174 static clearAdsBlockAllowedList(): void; 9175 } 9176 9177 /** 9178 * This class is used to enable back forward cache supported features. 9179 * 9180 * @syscap SystemCapability.Web.Webview.Core 9181 * @since 12 9182 */ 9183 class BackForwardCacheSupportedFeatures { 9184 /** 9185 * Whether cache the pages that use native embed. 9186 * Default is false; 9187 * 9188 * @type { boolean } 9189 * @syscap SystemCapability.Web.Webview.Core 9190 * @since 12 9191 */ 9192 nativeEmbed: boolean; 9193 9194 /** 9195 * Whether cache the pages that use media take over. 9196 * Default is false; 9197 * 9198 * @type { boolean } 9199 * @syscap SystemCapability.Web.Webview.Core 9200 * @since 12 9201 */ 9202 mediaTakeOver: boolean; 9203 9204 /** 9205 * @syscap SystemCapability.Web.Webview.Core 9206 * @since 12 9207 */ 9208 constructor(); 9209 } 9210 9211 /** 9212 * This class is used to set back forward cache options. 9213 * 9214 * @syscap SystemCapability.Web.Webview.Core 9215 * @since 12 9216 */ 9217 class BackForwardCacheOptions { 9218 /** 9219 * Set the maximum size of pages that can cache. 9220 * Default is 1, max is 50. 9221 * 9222 * @type { number } 9223 * @syscap SystemCapability.Web.Webview.Core 9224 * @since 12 9225 */ 9226 size: number; 9227 9228 /** 9229 * Set the lifetime in seconds in the BackForwardCache. 9230 * Default is 600. 9231 * 9232 * @type { number } 9233 * @syscap SystemCapability.Web.Webview.Core 9234 * @since 12 9235 */ 9236 timeToLive: number; 9237 9238 /** 9239 * @syscap SystemCapability.Web.Webview.Core 9240 * @since 12 9241 */ 9242 constructor(); 9243 } 9244 9245 /** 9246 * Enum type supplied to {@link insertProxyRule} for indicating the scheme filter for proxy. 9247 * @enum { number } 9248 * @syscap SystemCapability.Web.Webview.Core 9249 * @since 15 9250 */ 9251 /** 9252 * Enum type supplied to {@link insertProxyRule} for indicating the scheme filter for proxy. 9253 * @enum { number } 9254 * @syscap SystemCapability.Web.Webview.Core 9255 * @atomicservice 9256 * @since 19 9257 */ 9258 enum ProxySchemeFilter { 9259 /** 9260 * This indicates all the schemes will use the proxy. 9261 * @syscap SystemCapability.Web.Webview.Core 9262 * @since 15 9263 */ 9264 /** 9265 * This indicates all the schemes will use the proxy. 9266 * @syscap SystemCapability.Web.Webview.Core 9267 * @atomicservice 9268 * @since 19 9269 */ 9270 MATCH_ALL_SCHEMES = 0, 9271 /** 9272 * This indicates only the HTTP requests will use the proxy. 9273 * @syscap SystemCapability.Web.Webview.Core 9274 * @since 15 9275 */ 9276 /** 9277 * This indicates only the HTTP requests will use the proxy. 9278 * @syscap SystemCapability.Web.Webview.Core 9279 * @atomicservice 9280 * @since 19 9281 */ 9282 MATCH_HTTP = 1, 9283 /** 9284 * This indicates only the HTTPS requests will use the proxy. 9285 * @syscap SystemCapability.Web.Webview.Core 9286 * @since 15 9287 */ 9288 /** 9289 * This indicates only the HTTPS requests will use the proxy. 9290 * @syscap SystemCapability.Web.Webview.Core 9291 * @atomicservice 9292 * @since 19 9293 */ 9294 MATCH_HTTPS = 2, 9295 } 9296 9297 /** 9298 * The ProxyConfig used by applyProxyOverride. 9299 * 9300 * @syscap SystemCapability.Web.Webview.Core 9301 * @since 15 9302 */ 9303 /** 9304 * The ProxyConfig used by applyProxyOverride. 9305 * 9306 * @syscap SystemCapability.Web.Webview.Core 9307 * @atomicservice 9308 * @since 19 9309 */ 9310 class ProxyConfig { 9311 /** 9312 * Insert a bypass rule that indicates URLs that should skip the override proxy and connect the server directly instead. 9313 * These maybe URLs or IP addresses and wildcards are supported. e.g. "*.example.com" means that requests to 9314 * "https://www.example.com" and "http://test.example.com" will connect the server directly. 9315 * 9316 * @param { string } bypassRule - The bypass rule. 9317 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9318 * <br>2. Incorrect parameter types. 9319 * @syscap SystemCapability.Web.Webview.Core 9320 * @since 15 9321 */ 9322 /** 9323 * Insert a bypass rule that indicates URLs that should skip the override proxy and connect the server directly instead. 9324 * These maybe URLs or IP addresses and wildcards are supported. e.g. "*.example.com" means that requests to 9325 * "https://www.example.com" and "http://test.example.com" will connect the server directly. 9326 * 9327 * @param { string } bypassRule - The bypass rule. 9328 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9329 * <br>2. Incorrect parameter types. 9330 * @syscap SystemCapability.Web.Webview.Core 9331 * @atomicservice 9332 * @since 19 9333 */ 9334 insertBypassRule(bypassRule: string): void; 9335 9336 /** 9337 * Insert a proxy rule that indicates URLs that match the schemeFilter will connect the server directly. 9338 * 9339 * @param { ProxySchemeFilter } schemeFilter - The scheme filter for this rule. 9340 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9341 * <br>2. Incorrect parameter types. 9342 * @syscap SystemCapability.Web.Webview.Core 9343 * @since 15 9344 */ 9345 /** 9346 * Insert a proxy rule that indicates URLs that match the schemeFilter will connect the server directly. 9347 * 9348 * @param { ProxySchemeFilter } schemeFilter - The scheme filter for this rule. 9349 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9350 * <br>2. Incorrect parameter types. 9351 * @syscap SystemCapability.Web.Webview.Core 9352 * @atomicservice 9353 * @since 19 9354 */ 9355 insertDirectRule(schemeFilter?: ProxySchemeFilter): void; 9356 9357 /** 9358 * Insert a proxy rule which indicates that requests matching the schemeFilter should use an override proxy, all requests will 9359 * use the proxy rule if schemeFilter is null. 9360 * 9361 * The format for proxy is [scheme://]host[:port]. Scheme is optional and must be HTTP, HTTPS, or SOCKS if present. Scheme defaults to HTTP. 9362 * Host is an IPv6 literal with brackets, an IPv4 literal or one or more labels seperated by a period. Port number is optional and defaults 9363 * to 80 for HTTP, 443 for HTTPS and 1080 for SOCKS. 9364 * 9365 * e.g. example.com host: example.com 9366 * https://example.com scheme: https host: example.com 9367 * example.com:8888 host: example.com port: 8888 9368 * https://example.com:8888 scheme:https host: example.com port:8888 9369 * 192.168.1.1 host: 192.168.1.1 9370 * 192.168.1.1:8888 host:192.168.1.1 port: 8888 9371 * [10:20:30:40:50:60:70:80] 9372 * 9373 * @param { string } proxyRule - The proxy rule. 9374 * @param { ProxySchemeFilter } schemeFilter - The scheme filter for this rule. 9375 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9376 * <br>2. Incorrect parameter types. 9377 * @syscap SystemCapability.Web.Webview.Core 9378 * @since 15 9379 */ 9380 /** 9381 * Insert a proxy rule which indicates that requests matching the schemeFilter should use an override proxy, all requests will 9382 * use the proxy rule if schemeFilter is null. 9383 * 9384 * The format for proxy is [scheme://]host[:port]. Scheme is optional and must be HTTP, HTTPS, or SOCKS if present. Scheme defaults to HTTP. 9385 * Host is an IPv6 literal with brackets, an IPv4 literal or one or more labels seperated by a period. Port number is optional and defaults 9386 * to 80 for HTTP, 443 for HTTPS and 1080 for SOCKS. 9387 * 9388 * e.g. example.com host: example.com 9389 * https://example.com scheme: https host: example.com 9390 * example.com:8888 host: example.com port: 8888 9391 * https://example.com:8888 scheme:https host: example.com port:8888 9392 * 192.168.1.1 host: 192.168.1.1 9393 * 192.168.1.1:8888 host:192.168.1.1 port: 8888 9394 * [10:20:30:40:50:60:70:80] 9395 * 9396 * @param { string } proxyRule - The proxy rule. 9397 * @param { ProxySchemeFilter } schemeFilter - The scheme filter for this rule. 9398 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9399 * <br>2. Incorrect parameter types. 9400 * @syscap SystemCapability.Web.Webview.Core 9401 * @atomicservice 9402 * @since 19 9403 */ 9404 insertProxyRule(proxyRule: string, schemeFilter?: ProxySchemeFilter): void; 9405 9406 /** 9407 * Hostnames without a period in them (and that are not IP literals) will skip the proxy and connect the server directly. 9408 * Examples: "abc", "local", "some-domain". 9409 * 9410 * @syscap SystemCapability.Web.Webview.Core 9411 * @since 15 9412 */ 9413 /** 9414 * Hostnames without a period in them (and that are not IP literals) will skip the proxy and connect the server directly. 9415 * Examples: "abc", "local", "some-domain". 9416 * 9417 * @syscap SystemCapability.Web.Webview.Core 9418 * @atomicservice 9419 * @since 19 9420 */ 9421 bypassHostnamesWithoutPeriod(): void; 9422 9423 /** 9424 * By default, certain hostnames implicitly bypass the proxy if they are link-local IPs, or localhost addresses. For instance 9425 * hostnames matching any of (non-exhaustive list): localhost *.localhost [::1] 127.0.0.1/8 169.254/16 [FE80::]/10 9426 * Call this function to override the default behavior and force localhost and link-local URLs to be sent through the proxy. 9427 * 9428 * @syscap SystemCapability.Web.Webview.Core 9429 * @since 15 9430 */ 9431 /** 9432 * By default, certain hostnames implicitly bypass the proxy if they are link-local IPs, or localhost addresses. For instance 9433 * hostnames matching any of (non-exhaustive list): localhost *.localhost [::1] 127.0.0.1/8 169.254/16 [FE80::]/10 9434 * Call this function to override the default behavior and force localhost and link-local URLs to be sent through the proxy. 9435 * 9436 * @syscap SystemCapability.Web.Webview.Core 9437 * @atomicservice 9438 * @since 19 9439 */ 9440 clearImplicitRules(): void; 9441 9442 /** 9443 * Reverse the bypass rules. 9444 * 9445 * If false all URLs will use proxy settings except URLs match the bypass rules. 9446 * If true only URLs in the bypass list will use proxy, and all other URLs will be connected to directly. 9447 * 9448 * @param { boolean } reverse - If reverse the bypass rule. 9449 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9450 * <br>2. Incorrect parameter types. 9451 * @syscap SystemCapability.Web.Webview.Core 9452 * @since 15 9453 */ 9454 /** 9455 * Reverse the bypass rules. 9456 * 9457 * If false all URLs will use proxy settings except URLs match the bypass rules. 9458 * If true only URLs in the bypass list will use proxy, and all other URLs will be connected to directly. 9459 * 9460 * @param { boolean } reverse - If reverse the bypass rule. 9461 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9462 * <br>2. Incorrect parameter types. 9463 * @syscap SystemCapability.Web.Webview.Core 9464 * @atomicservice 9465 * @since 19 9466 */ 9467 enableReverseBypass(reverse: boolean): void; 9468 9469 /** 9470 * Returns the bypass rules. 9471 * 9472 * @returns { Array<string> } The bypass rules. 9473 * @syscap SystemCapability.Web.Webview.Core 9474 * @since 15 9475 */ 9476 /** 9477 * Returns the bypass rules. 9478 * 9479 * @returns { Array<string> } The bypass rules. 9480 * @syscap SystemCapability.Web.Webview.Core 9481 * @atomicservice 9482 * @since 19 9483 */ 9484 getBypassRules(): Array<string>; 9485 9486 /** 9487 * Returns the proxy rules. 9488 * 9489 * @returns { Array<ProxyRule> } The proxy rules. 9490 * @syscap SystemCapability.Web.Webview.Core 9491 * @since 15 9492 */ 9493 /** 9494 * Returns the proxy rules. 9495 * 9496 * @returns { Array<ProxyRule> } The proxy rules. 9497 * @syscap SystemCapability.Web.Webview.Core 9498 * @atomicservice 9499 * @since 19 9500 */ 9501 getProxyRules(): Array<ProxyRule>; 9502 9503 /** 9504 * Returns if reverse bypass rules. 9505 * 9506 * @returns { boolean } If reverse bypass enabled. 9507 * @syscap SystemCapability.Web.Webview.Core 9508 * @since 15 9509 */ 9510 /** 9511 * Returns if reverse bypass rules. 9512 * 9513 * @returns { boolean } If reverse bypass enabled. 9514 * @syscap SystemCapability.Web.Webview.Core 9515 * @atomicservice 9516 * @since 19 9517 */ 9518 isReverseBypassEnabled(): boolean; 9519 } 9520 9521 /** 9522 * The ProxyRule used by insertProxyRule. 9523 * 9524 * @syscap SystemCapability.Web.Webview.Core 9525 * @since 15 9526 */ 9527 /** 9528 * The ProxyRule used by insertProxyRule. 9529 * 9530 * @syscap SystemCapability.Web.Webview.Core 9531 * @atomicservice 9532 * @since 19 9533 */ 9534 class ProxyRule { 9535 /** 9536 * Returns the scheme filter used for this rule. 9537 * 9538 * @returns { ProxySchemeFilter } The scheme filter used for this rule. 9539 * @syscap SystemCapability.Web.Webview.Core 9540 * @since 15 9541 */ 9542 /** 9543 * Returns the scheme filter used for this rule. 9544 * 9545 * @returns { ProxySchemeFilter } The scheme filter used for this rule. 9546 * @syscap SystemCapability.Web.Webview.Core 9547 * @atomicservice 9548 * @since 19 9549 */ 9550 getSchemeFilter(): ProxySchemeFilter; 9551 9552 /** 9553 * Returns the proxy URL. 9554 * 9555 * @returns { string } The proxy URL. 9556 * @syscap SystemCapability.Web.Webview.Core 9557 * @since 15 9558 */ 9559 /** 9560 * Returns the proxy URL. 9561 * 9562 * @returns { string } The proxy URL. 9563 * @syscap SystemCapability.Web.Webview.Core 9564 * @atomicservice 9565 * @since 19 9566 */ 9567 getUrl(): string; 9568 } 9569 9570 /** 9571 * The callback for proxy changed. 9572 * 9573 * @typedef { function } 9574 * @syscap SystemCapability.Web.Webview.Core 9575 * @since 15 9576 */ 9577 /** 9578 * The callback for proxy changed. 9579 * 9580 * @typedef { function } 9581 * @syscap SystemCapability.Web.Webview.Core 9582 * @atomicservice 9583 * @since 19 9584 */ 9585 type OnProxyConfigChangeCallback = () => void; 9586 9587 /** 9588 * This class is used for set proxy for ArkWeb. 9589 * 9590 * @syscap SystemCapability.Web.Webview.Core 9591 * @since 15 9592 */ 9593 /** 9594 * This class is used for set proxy for ArkWeb. 9595 * 9596 * @syscap SystemCapability.Web.Webview.Core 9597 * @atomicservice 9598 * @since 19 9599 */ 9600 class ProxyController { 9601 /** 9602 * Sets ProxyConfig which will be used by all Webs in the app. URLs that match patterns in the bypass list will connect the server directly. 9603 * Instead, the request will use the proxy specified by the config. Requests are not guaranteed to use the new proxy immediately; wait for 9604 * the listener before loading a page. This listener will be called on the UI thread. 9605 * Note: calling applyProxyOverride will cause any existing system wide setting to be ignored. 9606 * 9607 * @param { ProxyConfig } proxyConfig - The proxy config. 9608 * @param { OnProxyConfigChangeCallback } callback - Called when the proxy has been changed. 9609 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9610 * <br>2. Incorrect parameter types. 9611 * @syscap SystemCapability.Web.Webview.Core 9612 * @since 15 9613 */ 9614 /** 9615 * Sets ProxyConfig which will be used by all Webs in the app. URLs that match patterns in the bypass list will connect the server directly. 9616 * Instead, the request will use the proxy specified by the config. Requests are not guaranteed to use the new proxy immediately; wait for 9617 * the listener before loading a page. This listener will be called on the UI thread. 9618 * Note: calling applyProxyOverride will cause any existing system wide setting to be ignored. 9619 * 9620 * @param { ProxyConfig } proxyConfig - The proxy config. 9621 * @param { OnProxyConfigChangeCallback } callback - Called when the proxy has been changed. 9622 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9623 * <br>2. Incorrect parameter types. 9624 * @syscap SystemCapability.Web.Webview.Core 9625 * @atomicservice 9626 * @since 19 9627 */ 9628 static applyProxyOverride(proxyConfig: ProxyConfig, callback: OnProxyConfigChangeCallback): void; 9629 9630 /** 9631 * Remove the proxy config. Requests are not guaranteed to not use the proxy; Wait for the listener before loading a page. This listener 9632 * will be called on the UI thread. 9633 * 9634 * @param { OnProxyConfigChangeCallback } callback - Called when the proxy has been changed. 9635 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9636 * <br>2. Incorrect parameter types. 9637 * @syscap SystemCapability.Web.Webview.Core 9638 * @since 15 9639 */ 9640 /** 9641 * Remove the proxy config. Requests are not guaranteed to not use the proxy; Wait for the listener before loading a page. This listener 9642 * will be called on the UI thread. 9643 * 9644 * @param { OnProxyConfigChangeCallback } callback - Called when the proxy has been changed. 9645 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 9646 * <br>2. Incorrect parameter types. 9647 * @syscap SystemCapability.Web.Webview.Core 9648 * @atomicservice 9649 * @since 19 9650 */ 9651 static removeProxyOverride(callback: OnProxyConfigChangeCallback): void; 9652 } 9653 9654 /** 9655 * Enum type supplied to {@link SetWebDestroyMode} for indicating the web component destroy mode. 9656 * @enum { number } 9657 * @syscap SystemCapability.Web.Webview.Core 9658 * @since 20 9659 */ 9660 enum WebDestroyMode { 9661 /** 9662 * The normal destroy mode, when the web component triggers destroy, 9663 * the resources will be released at the appropriate time. 9664 * @syscap SystemCapability.Web.Webview.Core 9665 * @since 20 9666 */ 9667 NORMAL_MODE = 0, 9668 9669 /** 9670 * The fast destroy mode, when the web component triggers destroy, the resources will be immediately released. 9671 * @syscap SystemCapability.Web.Webview.Core 9672 * @since 20 9673 */ 9674 FAST_MODE = 1 9675 } 9676 9677} 9678 9679export default webview; 9680