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 21import { AsyncCallback, BusinessError } from './@ohos.base'; 22import { Callback } from './@ohos.base'; 23import cert from './@ohos.security.cert'; 24import image from './@ohos.multimedia.image'; 25import type print from './@ohos.print'; 26import { WebNetErrorList } from './@ohos.web.netErrorList'; 27 28/** 29 * This module provides the capability to manage web modules. 30 * 31 * @namespace webview 32 * @syscap SystemCapability.Web.Webview.Core 33 * @since 9 34 */ 35/** 36 * This module provides the capability to manage web modules. 37 * 38 * @namespace webview 39 * @syscap SystemCapability.Web.Webview.Core 40 * @crossplatform 41 * @since 10 42 */ 43/** 44 * This module provides the capability to manage web modules. 45 * 46 * @namespace webview 47 * @syscap SystemCapability.Web.Webview.Core 48 * @crossplatform 49 * @atomicservice 50 * @since 11 51 */ 52declare namespace webview { 53 /** 54 * Defines the Web's request/response header. 55 * 56 * @interface WebHeader 57 * @syscap SystemCapability.Web.Webview.Core 58 * @since 9 59 */ 60 /** 61 * Defines the Web's request/response header. 62 * 63 * @interface WebHeader 64 * @syscap SystemCapability.Web.Webview.Core 65 * @crossplatform 66 * @since 10 67 */ 68 /** 69 * Defines the Web's request/response header. 70 * 71 * @interface WebHeader 72 * @syscap SystemCapability.Web.Webview.Core 73 * @crossplatform 74 * @atomicservice 75 * @since 11 76 */ 77 /** 78 * Defines the Web's request/response header. 79 * 80 * @typedef WebHeader 81 * @syscap SystemCapability.Web.Webview.Core 82 * @crossplatform 83 * @atomicservice 84 * @since 12 85 */ 86 interface WebHeader { 87 /** 88 * Gets the key of the request/response header. 89 * @syscap SystemCapability.Web.Webview.Core 90 * @since 9 91 */ 92 /** 93 * Gets the key of the request/response header. 94 * @syscap SystemCapability.Web.Webview.Core 95 * @crossplatform 96 * @since 10 97 */ 98 /** 99 * Gets the key of the request/response header. 100 * @type { string } 101 * @syscap SystemCapability.Web.Webview.Core 102 * @crossplatform 103 * @atomicservice 104 * @since 11 105 */ 106 headerKey: string; 107 108 /** 109 * Gets the value of the request/response header. 110 * @syscap SystemCapability.Web.Webview.Core 111 * @since 9 112 */ 113 /** 114 * Gets the value of the request/response header. 115 * @syscap SystemCapability.Web.Webview.Core 116 * @crossplatform 117 * @since 10 118 */ 119 /** 120 * Gets the value of the request/response header. 121 * @type { string } 122 * @syscap SystemCapability.Web.Webview.Core 123 * @crossplatform 124 * @atomicservice 125 * @since 11 126 */ 127 headerValue: string; 128 } 129 130 /** 131 * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. 132 * @enum {number} 133 * @syscap SystemCapability.Web.Webview.Core 134 * @since 9 135 */ 136 /** 137 * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. 138 * @enum {number} 139 * @syscap SystemCapability.Web.Webview.Core 140 * @atomicservice 141 * @since 11 142 */ 143 enum WebHitTestType { 144 /** 145 * The edit text. 146 * @syscap SystemCapability.Web.Webview.Core 147 * @since 9 148 */ 149 /** 150 * The edit text. 151 * @syscap SystemCapability.Web.Webview.Core 152 * @atomicservice 153 * @since 11 154 */ 155 EditText, 156 157 /** 158 * The email address. 159 * @syscap SystemCapability.Web.Webview.Core 160 * @since 9 161 */ 162 /** 163 * The email address. 164 * @syscap SystemCapability.Web.Webview.Core 165 * @atomicservice 166 * @since 11 167 */ 168 Email, 169 170 /** 171 * The HTML::a tag with src=http. 172 * @syscap SystemCapability.Web.Webview.Core 173 * @since 9 174 */ 175 /** 176 * The HTML::a tag with src=http. 177 * @syscap SystemCapability.Web.Webview.Core 178 * @atomicservice 179 * @since 11 180 */ 181 HttpAnchor, 182 183 /** 184 * The HTML::a tag with src=http + HTML::img. 185 * @syscap SystemCapability.Web.Webview.Core 186 * @since 9 187 */ 188 /** 189 * The HTML::a tag with src=http + HTML::img. 190 * @syscap SystemCapability.Web.Webview.Core 191 * @atomicservice 192 * @since 11 193 */ 194 HttpAnchorImg, 195 196 /** 197 * The HTML::img tag. 198 * @syscap SystemCapability.Web.Webview.Core 199 * @since 9 200 */ 201 /** 202 * The HTML::img tag. 203 * @syscap SystemCapability.Web.Webview.Core 204 * @atomicservice 205 * @since 11 206 */ 207 Img, 208 209 /** 210 * The map address. 211 * @syscap SystemCapability.Web.Webview.Core 212 * @since 9 213 */ 214 /** 215 * The map address. 216 * @syscap SystemCapability.Web.Webview.Core 217 * @atomicservice 218 * @since 11 219 */ 220 Map, 221 222 /** 223 * The phone number. 224 * @syscap SystemCapability.Web.Webview.Core 225 * @since 9 226 */ 227 /** 228 * The phone number. 229 * @syscap SystemCapability.Web.Webview.Core 230 * @atomicservice 231 * @since 11 232 */ 233 Phone, 234 235 /** 236 * Other unknown HitTest. 237 * @syscap SystemCapability.Web.Webview.Core 238 * @since 9 239 */ 240 /** 241 * Other unknown HitTest. 242 * @syscap SystemCapability.Web.Webview.Core 243 * @atomicservice 244 * @since 11 245 */ 246 Unknown 247 } 248 249 /** 250 * Defines the mode for using HttpDns. 251 * @enum {number} 252 * @syscap SystemCapability.Web.Webview.Core 253 * @since 10 254 */ 255 /** 256 * Defines the mode for using HttpDns. 257 * @enum {number} 258 * @syscap SystemCapability.Web.Webview.Core 259 * @atomicservice 260 * @since 11 261 */ 262 enum SecureDnsMode { 263 /** 264 * Do not use HttpDns, can be used to revoke previously used HttpDns configuration. 265 * @syscap SystemCapability.Web.Webview.Core 266 * @since 10 267 */ 268 /** 269 * Do not use HttpDns, can be used to revoke previously used HttpDns configuration. 270 * @syscap SystemCapability.Web.Webview.Core 271 * @atomicservice 272 * @since 11 273 */ 274 OFF = 0, 275 /** 276 * By default, the user-settings of HttpDns is used for dns resolution, and if it fails, 277 * the system dns is used for resolution. 278 * @syscap SystemCapability.Web.Webview.Core 279 * @since 10 280 */ 281 /** 282 * By default, the user-settings of HttpDns is used for dns resolution, and if it fails, 283 * the system dns is used for resolution. 284 * @syscap SystemCapability.Web.Webview.Core 285 * @atomicservice 286 * @since 11 287 */ 288 AUTO = 1, 289 /** 290 * Use the user-settings of HttpDns for dns resolution. If it fails, it will not 291 * fall back to the system dns, which will directly cause the page to fail to load. 292 * @syscap SystemCapability.Web.Webview.Core 293 * @since 10 294 */ 295 /** 296 * Use the user-settings of HttpDns for dns resolution. If it fails, it will not 297 * fall back to the system dns, which will directly cause the page to fail to load. 298 * @syscap SystemCapability.Web.Webview.Core 299 * @atomicservice 300 * @since 11 301 */ 302 SECURE_ONLY = 2, 303 } 304 305 /** 306 * Defines the security level for the page. 307 * 308 * @enum {number} 309 * @syscap SystemCapability.Web.Webview.Core 310 * @atomicservice 311 * @since 11 312 */ 313 enum SecurityLevel { 314 /** 315 * Unable to determine whether it is safe or not, the non-http/https protocol used. 316 * 317 * @syscap SystemCapability.Web.Webview.Core 318 * @atomicservice 319 * @since 11 320 */ 321 NONE = 0, 322 323 /** 324 * Indicates the HTTPS protocol used by the page and the authentication is successful. 325 * 326 * @syscap SystemCapability.Web.Webview.Core 327 * @atomicservice 328 * @since 11 329 */ 330 SECURE = 1, 331 332 /** 333 * The page is insecure. For example, the HTTP protocol is used or the HTTPS protocol 334 * is used but use an legacy TLS version. 335 * 336 * @syscap SystemCapability.Web.Webview.Core 337 * @atomicservice 338 * @since 11 339 */ 340 WARNING = 2, 341 342 /** 343 * Attempted HTTPS and failed, the authentication is failed. 344 * 345 * @syscap SystemCapability.Web.Webview.Core 346 * @atomicservice 347 * @since 11 348 */ 349 DANGEROUS = 3, 350 } 351 352 /** 353 * The playback status of all audio and video. 354 * @enum {number} 355 * @syscap SystemCapability.Web.Webview.Core 356 * @atomicservice 357 * @since 12 358 */ 359 enum MediaPlaybackState { 360 /** 361 * No audio or video currently. 362 * @syscap SystemCapability.Web.Webview.Core 363 * @atomicservice 364 * @since 12 365 */ 366 NONE = 0, 367 368 /** 369 * All audio and video are playing. 370 * @syscap SystemCapability.Web.Webview.Core 371 * @atomicservice 372 * @since 12 373 */ 374 PLAYING = 1, 375 376 /** 377 * All audio and video are paused. 378 * @syscap SystemCapability.Web.Webview.Core 379 * @atomicservice 380 * @since 12 381 */ 382 PAUSED = 2, 383 384 /** 385 * All audio and video are stopped. 386 * @syscap SystemCapability.Web.Webview.Core 387 * @atomicservice 388 * @since 12 389 */ 390 STOPPED = 3 391 } 392 393 /** 394 * The memory pressure level that can be set. 395 * @enum {number} 396 * @syscap SystemCapability.Web.Webview.Core 397 * @atomicservice 398 * @since 14 399 */ 400 enum PressureLevel { 401 /** 402 * Modules are advised to free buffers that are cheap to re-allocate and not immediately needed. 403 * @syscap SystemCapability.Web.Webview.Core 404 * @atomicservice 405 * @since 14 406 */ 407 MEMORY_PRESSURE_LEVEL_MODERATE = 1, 408 409 /** 410 * At this level, modules are advised to free all possible memory. 411 * @syscap SystemCapability.Web.Webview.Core 412 * @atomicservice 413 * @since 14 414 */ 415 MEMORY_PRESSURE_LEVEL_CRITICAL = 2 416 } 417 418 /** 419 * Defines the hit test value, related to {@link getHitTestValue} method. 420 * 421 * @interface HitTestValue 422 * @syscap SystemCapability.Web.Webview.Core 423 * @since 9 424 */ 425 /** 426 * Defines the hit test value, related to {@link getHitTestValue} method. 427 * 428 * @interface HitTestValue 429 * @syscap SystemCapability.Web.Webview.Core 430 * @atomicservice 431 * @since 11 432 */ 433 /** 434 * Defines the hit test value, related to {@link getHitTestValue} method. 435 * 436 * @typedef HitTestValue 437 * @syscap SystemCapability.Web.Webview.Core 438 * @atomicservice 439 * @since 12 440 */ 441 interface HitTestValue { 442 443 /** 444 * Get the hit test type. 445 * 446 * @syscap SystemCapability.Web.Webview.Core 447 * @since 9 448 */ 449 /** 450 * Get the hit test type. 451 * 452 * @type { WebHitTestType } 453 * @syscap SystemCapability.Web.Webview.Core 454 * @atomicservice 455 * @since 11 456 */ 457 type: WebHitTestType; 458 459 /** 460 * Get the hit test extra data. 461 * 462 * @syscap SystemCapability.Web.Webview.Core 463 * @since 9 464 */ 465 /** 466 * Get the hit test extra data. 467 * 468 * @type { string } 469 * @syscap SystemCapability.Web.Webview.Core 470 * @atomicservice 471 * @since 11 472 */ 473 extra: string; 474 } 475 476 /** 477 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 478 * 479 * @interface WebCustomScheme 480 * @syscap SystemCapability.Web.Webview.Core 481 * @since 9 482 */ 483 /** 484 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 485 * 486 * @interface WebCustomScheme 487 * @syscap SystemCapability.Web.Webview.Core 488 * @atomicservice 489 * @since 11 490 */ 491 /** 492 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 493 * 494 * @typedef WebCustomScheme 495 * @syscap SystemCapability.Web.Webview.Core 496 * @atomicservice 497 * @since 12 498 */ 499 interface WebCustomScheme { 500 501 /** 502 * Name of the custom scheme. 503 * 504 * @syscap SystemCapability.Web.Webview.Core 505 * @since 9 506 */ 507 /** 508 * Name of the custom scheme. 509 * 510 * @type { string } 511 * @syscap SystemCapability.Web.Webview.Core 512 * @atomicservice 513 * @since 11 514 */ 515 schemeName: string; 516 517 /** 518 * Whether Cross-Origin Resource Sharing is supported. 519 * 520 * @syscap SystemCapability.Web.Webview.Core 521 * @since 9 522 */ 523 /** 524 * Whether Cross-Origin Resource Sharing is supported. 525 * 526 * @type { boolean } 527 * @syscap SystemCapability.Web.Webview.Core 528 * @atomicservice 529 * @since 11 530 */ 531 isSupportCORS: boolean; 532 533 /** 534 * Whether fetch request is supported. 535 * 536 * @syscap SystemCapability.Web.Webview.Core 537 * @since 9 538 */ 539 /** 540 * Whether fetch request is supported. 541 * 542 * @type { boolean } 543 * @syscap SystemCapability.Web.Webview.Core 544 * @atomicservice 545 * @since 11 546 */ 547 isSupportFetch: boolean; 548 549 /** 550 * If isStandard is true, the scheme will be handled as a standard scheme. The standard 551 * schemes needs to comply with the URL normalization and parsing rules defined in Section 3.1 of RFC 1738, 552 * which can be found in the http://www.ietf.org/rfc/rfc1738.txt. 553 * 554 * @type { ?boolean } 555 * @syscap SystemCapability.Web.Webview.Core 556 * @atomicservice 557 * @since 12 558 */ 559 isStandard?: boolean; 560 561 /** 562 * If isLocal is true, the same security rules as those applied to the "file" URL will be 563 * used to handle the scheme. 564 * 565 * @type { ?boolean } 566 * @syscap SystemCapability.Web.Webview.Core 567 * @atomicservice 568 * @since 12 569 */ 570 isLocal?: boolean; 571 572 /** 573 * If isDisplayIsolated is true, then the scheme can only be displayed from other content 574 * hosted using the same scheme. 575 * 576 * @type { ?boolean } 577 * @syscap SystemCapability.Web.Webview.Core 578 * @atomicservice 579 * @since 12 580 */ 581 isDisplayIsolated?: boolean; 582 583 /** 584 * If isSecure is true, the same security rules as those applied to the "https" URL will be 585 * used to handle the scheme. 586 * 587 * @type { ?boolean } 588 * @syscap SystemCapability.Web.Webview.Core 589 * @atomicservice 590 * @since 12 591 */ 592 isSecure?: boolean; 593 594 /** 595 * If isCspBypassing is true, then this scheme can bypass Content Security Policy (CSP) 596 * checks. In most cases, this value should not be true when isStandard is true. 597 * 598 * @type { ?boolean } 599 * @syscap SystemCapability.Web.Webview.Core 600 * @atomicservice 601 * @since 12 602 */ 603 isCspBypassing?: boolean; 604 605 /** 606 * If isCodeCacheSupported is true, then the js of this scheme can generate code cache. 607 * 608 * @type { ?boolean } 609 * @syscap SystemCapability.Web.Webview.Core 610 * @since 12 611 */ 612 isCodeCacheSupported?: boolean; 613 } 614 615 /** 616 * Defines the callback of createPdf, related to {@link createPDF} method. 617 * 618 * @syscap SystemCapability.Web.Webview.Core 619 * @atomicservice 620 * @since 14 621 */ 622 class PdfData { 623 /** 624 * Return the data stream generated by the webpage. 625 * 626 * @returns { Uint8Array } return pdf data. 627 * @syscap SystemCapability.Web.Webview.Core 628 * @atomicservice 629 * @since 14 630 */ 631 pdfArrayBuffer(): Uint8Array; 632 } 633 634 /** 635 * Defines the configuration of creating pdf, related to {@Link createPdf} method. 636 * 637 * @typedef PdfConfiguration 638 * @syscap SystemCapability.Web.Webview.Core 639 * @atomicservice 640 * @since 14 641 */ 642 interface PdfConfiguration { 643 /** 644 * Number of the width. 645 * 646 * @type { number } 647 * @syscap SystemCapability.Web.Webview.Core 648 * @atomicservice 649 * @since 14 650 */ 651 width: number; 652 653 /** 654 * Number of the height. 655 * 656 * @type { number } 657 * @syscap SystemCapability.Web.Webview.Core 658 * @atomicservice 659 * @since 14 660 */ 661 height: number; 662 663 /** 664 * Number of the marginTop. 665 * 666 * @type { number } 667 * @syscap SystemCapability.Web.Webview.Core 668 * @atomicservice 669 * @since 14 670 */ 671 marginTop: number; 672 673 /** 674 * Number of the marginBottom. 675 * 676 * @type { number } 677 * @syscap SystemCapability.Web.Webview.Core 678 * @atomicservice 679 * @since 14 680 */ 681 marginBottom: number; 682 683 /** 684 * Number of the marginRight. 685 * 686 * @type { number } 687 * @syscap SystemCapability.Web.Webview.Core 688 * @atomicservice 689 * @since 14 690 */ 691 marginRight: number; 692 693 /** 694 * Number of the marginLeft. 695 * 696 * @type { number } 697 * @syscap SystemCapability.Web.Webview.Core 698 * @atomicservice 699 * @since 14 700 */ 701 marginLeft: number; 702 703 /** 704 * Number of the scaling. 705 * 706 * @type { ?number } 707 * @syscap SystemCapability.Web.Webview.Core 708 * @atomicservice 709 * @since 14 710 */ 711 scale?: number; 712 713 /** 714 * Whether background should be printed when creating pdf. 715 * 716 * @type { ?boolean } 717 * @syscap SystemCapability.Web.Webview.Core 718 * @atomicservice 719 * @since 14 720 */ 721 shouldPrintBackground?: boolean; 722 } 723 724 /** 725 * Provides basic information of web storage. 726 * 727 * @interface WebStorageOrigin 728 * @syscap SystemCapability.Web.Webview.Core 729 * @since 9 730 */ 731 /** 732 * Provides basic information of web storage. 733 * 734 * @interface WebStorageOrigin 735 * @syscap SystemCapability.Web.Webview.Core 736 * @atomicservice 737 * @since 11 738 */ 739 /** 740 * Provides basic information of web storage. 741 * 742 * @typedef WebStorageOrigin 743 * @syscap SystemCapability.Web.Webview.Core 744 * @atomicservice 745 * @since 12 746 */ 747 interface WebStorageOrigin { 748 /** 749 * Url source. 750 * 751 * @syscap SystemCapability.Web.Webview.Core 752 * @since 9 753 */ 754 /** 755 * Url source. 756 * 757 * @type { string } 758 * @syscap SystemCapability.Web.Webview.Core 759 * @atomicservice 760 * @since 11 761 */ 762 origin: string; 763 /** 764 * Specify the amount of storage for the source. 765 * 766 * @syscap SystemCapability.Web.Webview.Core 767 * @since 9 768 */ 769 /** 770 * Specify the amount of storage for the source. 771 * 772 * @type { number } 773 * @syscap SystemCapability.Web.Webview.Core 774 * @atomicservice 775 * @since 11 776 */ 777 usage: number; 778 /** 779 * the callback of getOriginUsage. 780 * 781 * @syscap SystemCapability.Web.Webview.Core 782 * @since 9 783 */ 784 /** 785 * the callback of getOriginUsage. 786 * 787 * @type { number } 788 * @syscap SystemCapability.Web.Webview.Core 789 * @atomicservice 790 * @since 11 791 */ 792 quota: number; 793 } 794 795 /** 796 * Defines the Web's request info. 797 * 798 * @typedef RequestInfo 799 * @syscap SystemCapability.Web.Webview.Core 800 * @atomicservice 801 * @since 12 802 */ 803 interface RequestInfo { 804 /** 805 * Gets the url of the request. 806 * @type { string } 807 * @syscap SystemCapability.Web.Webview.Core 808 * @atomicservice 809 * @since 12 810 */ 811 url: string; 812 813 /** 814 * Gets the method of the request. 815 * @type { string } 816 * @syscap SystemCapability.Web.Webview.Core 817 * @atomicservice 818 * @since 12 819 */ 820 method: string; 821 822 /** 823 * Gets the form data of the request. 824 * @type { string } 825 * @syscap SystemCapability.Web.Webview.Core 826 * @atomicservice 827 * @since 12 828 */ 829 formData: string; 830 } 831 832 /** 833 * Defines the scroll offset of the webpage in view port, the unit is virtual pixel. 834 * Related to {@link getScrollOffset} method. 835 * 836 * @typedef ScrollOffset 837 * @syscap SystemCapability.Web.Webview.Core 838 * @atomicservice 839 * @since 13 840 */ 841 interface ScrollOffset { 842 /** 843 * Get the horizontal offset. 844 * @type { number } 845 * @syscap SystemCapability.Web.Webview.Core 846 * @atomicservice 847 * @since 13 848 */ 849 x: number; 850 851 /** 852 * Get the vertical offset. 853 * @type { number } 854 * @syscap SystemCapability.Web.Webview.Core 855 * @atomicservice 856 * @since 13 857 */ 858 y: number; 859 } 860 861 /** 862 * Subscribe to a callback of a specified type of web event once. 863 * 864 * @param {string} type Types of web event. 865 * @param {Callback<void>} callback Indicate callback used to receive the web event. 866 * 867 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 868 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 869 * @syscap SystemCapability.Web.Webview.Core 870 * @since 9 871 */ 872 /** 873 * Subscribe to a callback of a specified type of web event once. 874 * 875 * @param {string} type Types of web event. 876 * @param {Callback<void>} callback Indicate callback used to receive the web event. 877 * 878 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 879 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 880 * @syscap SystemCapability.Web.Webview.Core 881 * @atomicservice 882 * @since 11 883 */ 884 function once(type: string, callback: Callback<void>): void; 885 886 /** 887 * Provides methods for managing web storage.3 888 * 889 * @syscap SystemCapability.Web.Webview.Core 890 * @since 9 891 */ 892 /** 893 * Provides methods for managing web storage.3 894 * 895 * @syscap SystemCapability.Web.Webview.Core 896 * @atomicservice 897 * @since 11 898 */ 899 class WebStorage { 900 /** 901 * Delete all the storage data. 902 * 903 * @syscap SystemCapability.Web.Webview.Core 904 * @since 9 905 */ 906 /** 907 * Delete all the storage data. 908 * 909 * @param { boolean } incognito - {@code true} delete all the storage data in incognito mode; 910 * {@code false} otherwise. 911 * @syscap SystemCapability.Web.Webview.Core 912 * @atomicservice 913 * @since 11 914 */ 915 static deleteAllData(incognito?: boolean): void; 916 917 /** 918 * Delete the storage data with the origin. 919 * 920 * @param { string } origin - The origin which to be deleted. 921 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 922 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 923 * @throws { BusinessError } 17100011 - Invalid origin. 924 * @syscap SystemCapability.Web.Webview.Core 925 * @since 9 926 */ 927 /** 928 * Delete the storage data with the origin. 929 * 930 * @param { string } origin - The origin which to be deleted. 931 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 932 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 933 * @throws { BusinessError } 17100011 - Invalid origin. 934 * @syscap SystemCapability.Web.Webview.Core 935 * @atomicservice 936 * @since 11 937 */ 938 static deleteOrigin(origin: string): void; 939 940 /** 941 * Get current all the web storage origins. 942 * @returns { Promise<Array<WebStorageOrigin>> } - returns all the WebStorageOrigin. 943 * @throws { BusinessError } 401 - Invalid input parameter. 944 * @throws { BusinessError } 17100012 - Invalid web storage origin. 945 * @syscap SystemCapability.Web.Webview.Core 946 * @since 9 947 */ 948 /** 949 * Get current all the web storage origins. 950 * @returns { Promise<Array<WebStorageOrigin>> } - returns all the WebStorageOrigin. 951 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 952 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 953 * @throws { BusinessError } 17100012 - Invalid web storage origin. 954 * @syscap SystemCapability.Web.Webview.Core 955 * @atomicservice 956 * @since 11 957 */ 958 static getOrigins(): Promise<Array<WebStorageOrigin>>; 959 960 /** 961 * Get current all the web storage origins. 962 * @param { AsyncCallback<Array<WebStorageOrigin>> } callback - callback used to return all the WebStorageOrigin. 963 * @throws { BusinessError } 401 - Invalid input parameter. 964 * @throws { BusinessError } 17100012 - Invalid web storage origin. 965 * @syscap SystemCapability.Web.Webview.Core 966 * @since 9 967 */ 968 /** 969 * Get current all the web storage origins. 970 * @param { AsyncCallback<Array<WebStorageOrigin>> } callback - callback used to return all the WebStorageOrigin. 971 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 972 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 973 * @throws { BusinessError } 17100012 - Invalid web storage origin. 974 * @syscap SystemCapability.Web.Webview.Core 975 * @atomicservice 976 * @since 11 977 */ 978 static getOrigins(callback: AsyncCallback<Array<WebStorageOrigin>>): void; 979 980 /** 981 * Get the web storage quota with the origin. 982 * @param { string } origin - The origin which to be inquired. 983 * @returns { Promise<number> } - the promise returned by the function 984 * @throws { BusinessError } 401 - Invalid input parameter. 985 * @throws { BusinessError } 17100011 - Invalid origin. 986 * @syscap SystemCapability.Web.Webview.Core 987 * @since 9 988 */ 989 /** 990 * Get the web storage quota with the origin. 991 * @param { string } origin - The origin which to be inquired. 992 * @returns { Promise<number> } - the promise returned by the function 993 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 994 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 995 * @throws { BusinessError } 17100011 - Invalid origin. 996 * @syscap SystemCapability.Web.Webview.Core 997 * @atomicservice 998 * @since 11 999 */ 1000 static getOriginQuota(origin: string): Promise<number>; 1001 1002 /** 1003 * Get the web storage quota with the origin. 1004 * @param { string } origin - The origin which to be inquired. 1005 * @param { AsyncCallback<number> } callback - the callback of getOriginQuota. 1006 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1007 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1008 * @throws { BusinessError } 17100011 - Invalid origin. 1009 * @syscap SystemCapability.Web.Webview.Core 1010 * @since 9 1011 */ 1012 /** 1013 * Get the web storage quota with the origin. 1014 * @param { string } origin - The origin which to be inquired. 1015 * @param { AsyncCallback<number> } callback - the callback of getOriginQuota. 1016 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1017 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1018 * @throws { BusinessError } 17100011 - Invalid origin. 1019 * @syscap SystemCapability.Web.Webview.Core 1020 * @atomicservice 1021 * @since 11 1022 */ 1023 static getOriginQuota(origin: string, callback: AsyncCallback<number>): void; 1024 1025 /** 1026 * Get the web amount of storage with the origin. 1027 * @param { string } origin - The origin which to be inquired. 1028 * @returns { Promise<number> } - the promise returned by the function 1029 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1030 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1031 * @throws { BusinessError } 17100011 - Invalid origin. 1032 * @syscap SystemCapability.Web.Webview.Core 1033 * @since 9 1034 */ 1035 /** 1036 * Get the web amount of storage with the origin. 1037 * @param { string } origin - The origin which to be inquired. 1038 * @returns { Promise<number> } - the promise returned by the function 1039 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1040 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1041 * @throws { BusinessError } 17100011 - Invalid origin. 1042 * @syscap SystemCapability.Web.Webview.Core 1043 * @atomicservice 1044 * @since 11 1045 */ 1046 static getOriginUsage(origin: string): Promise<number>; 1047 1048 /** 1049 * Get the web amount of storage with the origin. 1050 * @param { string } origin - The origin which to be inquired. 1051 * @param { AsyncCallback<number> } callback - the callback of getOriginUsage. 1052 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1053 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1054 * @throws { BusinessError } 17100011 - Invalid origin. 1055 * @syscap SystemCapability.Web.Webview.Core 1056 * @since 9 1057 */ 1058 /** 1059 * Get the web amount of storage with the origin. 1060 * @param { string } origin - The origin which to be inquired. 1061 * @param { AsyncCallback<number> } callback - the callback of getOriginUsage. 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 * @atomicservice 1067 * @since 11 1068 */ 1069 static getOriginUsage(origin: string, callback: AsyncCallback<number>): void; 1070 } 1071 1072 /** 1073 * Provides methods for managing web database. 1074 * @syscap SystemCapability.Web.Webview.Core 1075 * @since 9 1076 */ 1077 /** 1078 * Provides methods for managing web database. 1079 * @syscap SystemCapability.Web.Webview.Core 1080 * @crossplatform 1081 * @atomicservice 1082 * @since 11 1083 */ 1084 class WebDataBase { 1085 /** 1086 * Get whether instances holds any http authentication credentials. 1087 * @returns { boolean } true if instances saved any http authentication credentials otherwise false. 1088 * @syscap SystemCapability.Web.Webview.Core 1089 * @since 9 1090 */ 1091 /** 1092 * Get whether instances holds any http authentication credentials. 1093 * @returns { boolean } true if instances saved any http authentication credentials otherwise false. 1094 * @syscap SystemCapability.Web.Webview.Core 1095 * @crossplatform 1096 * @atomicservice 1097 * @since 11 1098 */ 1099 static existHttpAuthCredentials(): boolean; 1100 1101 /** 1102 * Delete all http authentication credentials. 1103 * 1104 * @syscap SystemCapability.Web.Webview.Core 1105 * @since 9 1106 */ 1107 /** 1108 * Delete all http authentication credentials. 1109 * 1110 * @syscap SystemCapability.Web.Webview.Core 1111 * @crossplatform 1112 * @atomicservice 1113 * @since 11 1114 */ 1115 static deleteHttpAuthCredentials(): void; 1116 1117 /** 1118 * Get http authentication credentials. 1119 * @param { string } host - The host to which the credentials apply. 1120 * @param { string } realm - The realm to which the credentials apply. 1121 * @returns { Array<string> } Return an array containing username and password. 1122 * @throws { BusinessError } 401 - Invalid input parameter. 1123 * @syscap SystemCapability.Web.Webview.Core 1124 * @since 9 1125 */ 1126 /** 1127 * Get http authentication credentials. 1128 * @param { string } host - The host to which the credentials apply. 1129 * @param { string } realm - The realm to which the credentials apply. 1130 * @returns { Array<string> } Return an array containing username and password. 1131 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1132 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1133 * @syscap SystemCapability.Web.Webview.Core 1134 * @crossplatform 1135 * @atomicservice 1136 * @since 11 1137 */ 1138 static getHttpAuthCredentials(host: string, realm: string): Array<string>; 1139 1140 /** 1141 * Save http authentication credentials. 1142 * @param { string } host - The host to which the credentials apply. 1143 * @param { string } realm - The realm to which the credentials apply. 1144 * @param { string } username - The username. 1145 * @param { string } password - The password. 1146 * @throws { BusinessError } 401 - Invalid input parameter. 1147 * @syscap SystemCapability.Web.Webview.Core 1148 * @since 9 1149 */ 1150 /** 1151 * Save http authentication credentials. 1152 * @param { string } host - The host to which the credentials apply. 1153 * @param { string } realm - The realm to which the credentials apply. 1154 * @param { string } username - The username. 1155 * @param { string } password - The password. 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 * @syscap SystemCapability.Web.Webview.Core 1159 * @crossplatform 1160 * @atomicservice 1161 * @since 11 1162 */ 1163 static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; 1164 } 1165 1166 /** 1167 * Provides a method for managing web geographic location permissions. 1168 * @syscap SystemCapability.Web.Webview.Core 1169 * @since 9 1170 */ 1171 /** 1172 * Provides a method for managing web geographic location permissions. 1173 * @syscap SystemCapability.Web.Webview.Core 1174 * @atomicservice 1175 * @since 11 1176 */ 1177 class GeolocationPermissions { 1178 /** 1179 * Allow geolocation permissions for specifies source. 1180 * @param { string } origin - Url source. 1181 * @throws { BusinessError } 401 - Invalid input parameter. 1182 * @throws { BusinessError } 17100011 - Invalid origin. 1183 * @syscap SystemCapability.Web.Webview.Core 1184 * @since 9 1185 */ 1186 /** 1187 * Allow geolocation permissions for specifies source. 1188 * @param { string } origin - Url source. 1189 * @param { boolean } incognito - {@code true} Allow geolocation permissions for specifies source 1190 * in incognito mode; {@code false} otherwise. 1191 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1192 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1193 * @throws { BusinessError } 17100011 - Invalid origin. 1194 * @syscap SystemCapability.Web.Webview.Core 1195 * @atomicservice 1196 * @since 11 1197 */ 1198 static allowGeolocation(origin: string, incognito?: boolean): void; 1199 1200 /** 1201 * Delete geolocation permissions for specifies source. 1202 * @param { string } origin - Url source. 1203 * @throws { BusinessError } 401 - Invalid input parameter. 1204 * @throws { BusinessError } 17100011 - Invalid origin. 1205 * @syscap SystemCapability.Web.Webview.Core 1206 * @since 9 1207 */ 1208 /** 1209 * Delete geolocation permissions for specifies source. 1210 * @param { string } origin - Url source. 1211 * @param { boolean } incognito - {@code true} delete geolocation permissions for specifies source 1212 * in incognito mode; {@code false} otherwise. 1213 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1214 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1215 * @throws { BusinessError } 17100011 - Invalid origin. 1216 * @syscap SystemCapability.Web.Webview.Core 1217 * @atomicservice 1218 * @since 11 1219 */ 1220 static deleteGeolocation(origin: string, incognito?: boolean): void; 1221 1222 /** 1223 * Delete all geolocation permissions. 1224 * 1225 * @syscap SystemCapability.Web.Webview.Core 1226 * @since 9 1227 */ 1228 /** 1229 * Delete all geolocation permissions. 1230 * 1231 * @param { boolean } incognito - {@code true} delete all geolocation in incognito mode; 1232 * {@code false} otherwise. 1233 * @syscap SystemCapability.Web.Webview.Core 1234 * @atomicservice 1235 * @since 11 1236 */ 1237 static deleteAllGeolocation(incognito?: boolean): void; 1238 1239 /** 1240 * Gets the geolocation permission status of the specified source. 1241 * @param { string } origin - Url source. 1242 * @returns { Promise<boolean> } A Promise instance that obtains the permission 1243 * status of the specified source and obtains successfully, 1244 * true for authorization, false for access denial. Failed 1245 * to get, indicating that the permission status of the 1246 * specified source does not exist. 1247 * @throws { BusinessError } 401 - Invalid input parameter. 1248 * @throws { BusinessError } 17100011 - Invalid origin. 1249 * @syscap SystemCapability.Web.Webview.Core 1250 * @since 9 1251 */ 1252 /** 1253 * Gets the geolocation permission status of the specified source. 1254 * @param { string } origin - Url source. 1255 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 1256 * specified source in incognito mode; {@code false} otherwise. 1257 * @returns { Promise<boolean> } A Promise instance that obtains the permission 1258 * status of the specified source and obtains successfully, 1259 * true for authorization, false for access denial. Failed 1260 * to get, indicating that the permission status of the 1261 * specified source does not exist. 1262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1263 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1264 * @throws { BusinessError } 17100011 - Invalid origin. 1265 * @syscap SystemCapability.Web.Webview.Core 1266 * @atomicservice 1267 * @since 11 1268 */ 1269 static getAccessibleGeolocation(origin: string, incognito?: boolean): Promise<boolean>; 1270 1271 /** 1272 * Gets the geolocation permission status of the specified source. 1273 * @param { string } origin - Url source. 1274 * @param { AsyncCallback<boolean> } callback - Returns the geolocation permission status for 1275 * the specified source. Successful acquisition, 1276 * true means authorized, false means access is 1277 * denied. Failed to get, indicating that the 1278 * permission status of the specified source does 1279 * not exist. 1280 * @throws { BusinessError } 401 - Invalid input parameter. 1281 * @throws { BusinessError } 17100011 - Invalid origin. 1282 * @syscap SystemCapability.Web.Webview.Core 1283 * @since 9 1284 */ 1285 /** 1286 * Gets the geolocation permission status of the specified source. 1287 * @param { string } origin - Url source. 1288 * @param { AsyncCallback<boolean> } callback - Returns the geolocation permission status for 1289 * the specified source. Successful acquisition, 1290 * true means authorized, false means access is 1291 * denied. Failed to get, indicating that the 1292 * permission status of the specified source does 1293 * not exist. 1294 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 1295 * specified source in incognito mode; {@code false} otherwise. 1296 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1297 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1298 * @throws { BusinessError } 17100011 - Invalid origin. 1299 * @syscap SystemCapability.Web.Webview.Core 1300 * @atomicservice 1301 * @since 11 1302 */ 1303 static getAccessibleGeolocation(origin: string, callback: AsyncCallback<boolean>, incognito?: boolean): void; 1304 1305 /** 1306 * Get all stored geolocation permission url source. 1307 * 1308 * @returns { Promise<Array<string>> } A Promise instance that gets all source information about 1309 * the stored geolocation permission state. 1310 * @throws { BusinessError } 401 - Invalid input parameter. 1311 * @syscap SystemCapability.Web.Webview.Core 1312 * @since 9 1313 */ 1314 /** 1315 * Get all stored geolocation permission url source. 1316 * @param { boolean } incognito - {@code true} get all stored geolocation permission url source 1317 * in incognito mode; {@code false} otherwise. 1318 * @returns { Promise<Array<string>> } A Promise instance that gets all source information about 1319 * the stored geolocation permission state. 1320 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1321 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1322 * @syscap SystemCapability.Web.Webview.Core 1323 * @atomicservice 1324 * @since 11 1325 */ 1326 static getStoredGeolocation(incognito?: boolean): Promise<Array<string>>; 1327 1328 /** 1329 * Get all stored geolocation permission url source. 1330 * @param { AsyncCallback<Array<string>> } callback - Returns all source information for 1331 * stored geolocation permission states. 1332 * @throws { BusinessError } 401 - Invalid input parameter. 1333 * @syscap SystemCapability.Web.Webview.Core 1334 * @since 9 1335 */ 1336 /** 1337 * Get all stored geolocation permission url source. 1338 * @param { AsyncCallback<Array<string>> } callback - Returns all source information for 1339 * stored geolocation permission states. 1340 * @param { boolean } incognito - {@code true} gets all stored geolocation permission url 1341 * source in incognito mode; {@code false} otherwise. 1342 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1343 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1344 * @syscap SystemCapability.Web.Webview.Core 1345 * @atomicservice 1346 * @since 11 1347 */ 1348 static getStoredGeolocation(callback: AsyncCallback<Array<string>>, incognito?: boolean): void; 1349 } 1350 1351 /** 1352 * Provides methods for managing the web cookies. 1353 * 1354 * @syscap SystemCapability.Web.Webview.Core 1355 * @since 9 1356 */ 1357 /** 1358 * Provides methods for managing the web cookies. 1359 * 1360 * @syscap SystemCapability.Web.Webview.Core 1361 * @crossplatform 1362 * @atomicservice 1363 * @since 11 1364 */ 1365 class WebCookieManager { 1366 /** 1367 * Gets all cookies for the given URL. 1368 * 1369 * @param { string } url - The URL for which the cookies are requested. 1370 * @returns { string } - The cookie value for the given URL. 1371 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1372 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1373 * @throws { BusinessError } 17100002 - Invalid url. 1374 * @syscap SystemCapability.Web.Webview.Core 1375 * @since 9 1376 * @deprecated since 11 1377 * @useinstead ohos.web.webview.WebCookieManager#fetchCookieSync 1378 */ 1379 static getCookie(url: string): string; 1380 1381 /** 1382 * Gets all cookies for the given URL. 1383 * 1384 * @param { string } url - The URL for which the cookies are requested. 1385 * @param { boolean } incognito - {@code true} gets all cookies for the given URL 1386 * in incognito mode; {@code false} otherwise. 1387 * @returns { string } - The cookie value for the given URL. 1388 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1389 * <br>2. Incorrect parameter types. 1390 * @throws { BusinessError } 17100002 - Invalid url. 1391 * @syscap SystemCapability.Web.Webview.Core 1392 * @atomicservice 1393 * @since 11 1394 */ 1395 static fetchCookieSync(url: string, incognito?: boolean): string; 1396 1397 /** 1398 * Gets all cookies for the given URL Asynchronously. 1399 * 1400 * @param { string } url - The URL for which the cookies are requested. 1401 * @returns { Promise<string> } - A promise resolved after the cookies of given URL have been gotten. 1402 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1403 * <br>2. Incorrect parameter types. 1404 * @throws { BusinessError } 17100002 - Invalid url. 1405 * @syscap SystemCapability.Web.Webview.Core 1406 * @crossplatform 1407 * @atomicservice 1408 * @since 11 1409 */ 1410 static fetchCookie(url: string): Promise<string>; 1411 1412 /** 1413 * Gets all cookies for the given URL Asynchronously. 1414 * 1415 * @param { string } url - The URL for which the cookies are requested. 1416 * @param { boolean } incognito - {@code true} gets all cookies for the given URL 1417 * in incognito mode; {@code false} otherwise. 1418 * @returns { Promise<string> } - A promise resolved after the cookies of given URL have been gotten. 1419 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1420 * <br>2. Incorrect parameter types. 1421 * @throws { BusinessError } 17100002 - Invalid url. 1422 * @syscap SystemCapability.Web.Webview.Core 1423 * @since 14 1424 */ 1425 static fetchCookie(url: string, incognito: boolean): Promise<string>; 1426 1427 /** 1428 * Gets all cookies for the given URL Asynchronously. 1429 * 1430 * @param { string } url - The URL for which the cookies are requested. 1431 * @param { AsyncCallback<string> } callback - Called after the cookies of given URL have been gotten. 1432 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1433 * <br>2. Incorrect parameter types. 1434 * @throws { BusinessError } 17100002 - Invalid url. 1435 * @syscap SystemCapability.Web.Webview.Core 1436 * @crossplatform 1437 * @atomicservice 1438 * @since 11 1439 */ 1440 static fetchCookie(url: string, callback: AsyncCallback<string>): void; 1441 1442 /** 1443 * Set a single cookie (key-value pair) for the given URL. 1444 * 1445 * @param { string } url - The URL for which the cookie is to be set. 1446 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1447 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1448 * <br>2. Incorrect parameter types. 1449 * @throws { BusinessError } 17100002 - Invalid url. 1450 * @throws { BusinessError } 17100005 - Invalid cookie value. 1451 * @syscap SystemCapability.Web.Webview.Core 1452 * @since 9 1453 * @deprecated since 11 1454 * @useinstead ohos.web.webview.WebCookieManager#configCookieSync 1455 */ 1456 static setCookie(url: string, value: string): void; 1457 1458 /** 1459 * Set a single cookie (key-value pair) for the given URL. 1460 * 1461 * @param { string } url - The URL for which the cookie is to be set. 1462 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1463 * @param { boolean } incognito - {@code true} set a single cookie (key-value pair) for the given URL 1464 * in incognito mode; {@code false} otherwise. 1465 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1466 * <br>2. Incorrect parameter types. 1467 * @throws { BusinessError } 17100002 - Invalid url. 1468 * @throws { BusinessError } 17100005 - Invalid cookie value. 1469 * @syscap SystemCapability.Web.Webview.Core 1470 * @atomicservice 1471 * @since 11 1472 */ 1473 static configCookieSync(url: string, value: string, incognito?: boolean): void; 1474 1475 /** 1476 * Set a single cookie (key-value pair) for the given URL. 1477 * 1478 * @param { string } url - The URL for which the cookie is to be set. 1479 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1480 * @param { boolean } incognito - {@code true} set a single cookie (key-value pair) for the given URL 1481 * in incognito mode; {@code false} otherwise. 1482 * @param { boolean } includeHttpOnly - {@code true} HTTP-only cookies can also be overwritten; 1483 * {@code false} otherwise. 1484 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1485 * <br>2. Incorrect parameter types. 1486 * @throws { BusinessError } 17100002 - Invalid url. 1487 * @throws { BusinessError } 17100005 - Invalid cookie value. 1488 * @syscap SystemCapability.Web.Webview.Core 1489 * @since 14 1490 */ 1491 static configCookieSync(url: string, value: string, incognito: boolean, includeHttpOnly: boolean): void; 1492 1493 /** 1494 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1495 * 1496 * @param { string } url - The URL for which the cookie is to be set. 1497 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1498 * @returns { Promise<void> } - A promise resolved after the cookies of given URL have been set. 1499 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1500 * <br>2. Incorrect parameter types. 1501 * @throws { BusinessError } 17100002 - Invalid url. 1502 * @throws { BusinessError } 17100005 - Invalid cookie value. 1503 * @syscap SystemCapability.Web.Webview.Core 1504 * @crossplatform 1505 * @atomicservice 1506 * @since 11 1507 */ 1508 static configCookie(url: string, value: string): Promise<void>; 1509 1510 /** 1511 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1512 * 1513 * @param { string } url - The URL for which the cookie is to be set. 1514 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1515 * @param { boolean } incognito - {@code true} set a single cookie (key-value pair) for the given URL 1516 * in incognito mode; {@code false} otherwise. 1517 * @param { boolean } includeHttpOnly - {@code true} HTTP-only cookies can also be overwritten; 1518 * {@code false} otherwise. 1519 * @returns { Promise<void> } - A promise resolved after the cookies of given URL have been set. 1520 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1521 * <br>2. Incorrect parameter types. 1522 * @throws { BusinessError } 17100002 - Invalid url. 1523 * @throws { BusinessError } 17100005 - Invalid cookie value. 1524 * @syscap SystemCapability.Web.Webview.Core 1525 * @since 14 1526 */ 1527 static configCookie(url: string, value: string, incognito: boolean, includeHttpOnly: boolean): Promise<void>; 1528 1529 /** 1530 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1531 * 1532 * @param { string } url - The URL for which the cookie is to be set. 1533 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1534 * @param { AsyncCallback<void> } callback - Called after the cookies have been set. 1535 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1536 * <br>2. Incorrect parameter types. 1537 * @throws { BusinessError } 17100002 - Invalid url. 1538 * @throws { BusinessError } 17100005 - Invalid cookie value. 1539 * @syscap SystemCapability.Web.Webview.Core 1540 * @crossplatform 1541 * @atomicservice 1542 * @since 11 1543 */ 1544 static configCookie(url: string, value: string, callback: AsyncCallback<void>): void; 1545 1546 /** 1547 * Save the cookies Asynchronously. 1548 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1549 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1550 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1551 * @syscap SystemCapability.Web.Webview.Core 1552 * @since 9 1553 */ 1554 /** 1555 * Save the cookies Asynchronously. 1556 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1557 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1558 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1559 * @syscap SystemCapability.Web.Webview.Core 1560 * @atomicservice 1561 * @since 11 1562 */ 1563 static saveCookieAsync(): Promise<void>; 1564 1565 /** 1566 * Save the cookies Asynchronously. 1567 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1568 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1569 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1570 * @syscap SystemCapability.Web.Webview.Core 1571 * @since 9 1572 */ 1573 /** 1574 * Save the cookies Asynchronously. 1575 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1576 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1577 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1578 * @syscap SystemCapability.Web.Webview.Core 1579 * @atomicservice 1580 * @since 11 1581 */ 1582 static saveCookieAsync(callback: AsyncCallback<void>): void; 1583 1584 /** 1585 * Get whether the instance can send and accept cookies. 1586 * 1587 * @returns { boolean } True if the instance can send and accept cookies else false. 1588 * @syscap SystemCapability.Web.Webview.Core 1589 * @since 9 1590 */ 1591 /** 1592 * Get whether the instance can send and accept cookies. 1593 * 1594 * @returns { boolean } True if the instance can send and accept cookies else false. 1595 * @syscap SystemCapability.Web.Webview.Core 1596 * @atomicservice 1597 * @since 11 1598 */ 1599 static isCookieAllowed(): boolean; 1600 1601 /** 1602 * Set whether the instance should send and accept cookies. 1603 * By default this is set to be true. 1604 * 1605 * @param { boolean } accept - Whether the instance should send and accept cookies. 1606 * @throws { BusinessError } 401 - Invalid input parameter. 1607 * @syscap SystemCapability.Web.Webview.Core 1608 * @since 9 1609 */ 1610 /** 1611 * Set whether the instance should send and accept cookies. 1612 * By default this is set to be true. 1613 * 1614 * @param { boolean } accept - Whether the instance should send and accept cookies. 1615 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1616 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1617 * @syscap SystemCapability.Web.Webview.Core 1618 * @atomicservice 1619 * @since 11 1620 */ 1621 static putAcceptCookieEnabled(accept: boolean): void; 1622 1623 /** 1624 * Get whether the instance can send and accept thirdparty cookies. 1625 * 1626 * @returns { boolean } True if the instance can send and accept thirdparty cookies else false. 1627 * @syscap SystemCapability.Web.Webview.Core 1628 * @since 9 1629 */ 1630 /** 1631 * Get whether the instance can send and accept thirdparty cookies. 1632 * 1633 * @returns { boolean } True if the instance can send and accept thirdparty cookies else false. 1634 * @syscap SystemCapability.Web.Webview.Core 1635 * @atomicservice 1636 * @since 11 1637 */ 1638 static isThirdPartyCookieAllowed(): boolean; 1639 1640 /** 1641 * Set whether the instance should send and accept thirdparty cookies. 1642 * By default this is set to be false. 1643 * 1644 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 1645 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1646 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1647 * @syscap SystemCapability.Web.Webview.Core 1648 * @since 9 1649 */ 1650 /** 1651 * Set whether the instance should send and accept thirdparty cookies. 1652 * By default this is set to be false. 1653 * 1654 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 1655 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1656 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1657 * @syscap SystemCapability.Web.Webview.Core 1658 * @atomicservice 1659 * @since 11 1660 */ 1661 static putAcceptThirdPartyCookieEnabled(accept: boolean): void; 1662 1663 /** 1664 * Check whether exists any cookies. 1665 * 1666 * @returns { boolean } True if exists more than one cookie else false; 1667 * @syscap SystemCapability.Web.Webview.Core 1668 * @since 9 1669 */ 1670 /** 1671 * Check whether exists any cookies. 1672 * 1673 * @param { boolean } incognito - {@code true} check whether exists any cookies. 1674 * in incognito mode; {@code false} otherwise. 1675 * @returns { boolean } True if exists more than one cookie else false; 1676 * @syscap SystemCapability.Web.Webview.Core 1677 * @atomicservice 1678 * @since 11 1679 */ 1680 static existCookie(incognito?: boolean): boolean; 1681 1682 /** 1683 * Remove all cookies. 1684 * @syscap SystemCapability.Web.Webview.Core 1685 * @since 9 1686 * @deprecated since 11 1687 * @useinstead ohos.web.webview.WebCookieManager#clearAllCookiesSync 1688 */ 1689 static deleteEntireCookie(): void; 1690 1691 /** 1692 * Remove all cookies. 1693 * 1694 * @param { boolean } incognito - {@code true} remove all cookies in incognito mode; 1695 * {@code false} otherwise. 1696 * @syscap SystemCapability.Web.Webview.Core 1697 * @atomicservice 1698 * @since 11 1699 */ 1700 static clearAllCookiesSync(incognito?: boolean): void; 1701 1702 /** 1703 * Remove all cookies Asynchronously. 1704 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 1705 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1706 * @syscap SystemCapability.Web.Webview.Core 1707 * @crossplatform 1708 * @atomicservice 1709 * @since 11 1710 */ 1711 static clearAllCookies(): Promise<void>; 1712 1713 /** 1714 * Remove all cookies Asynchronously. 1715 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 1716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1717 * <br>2. Incorrect parameter types. 1718 * @syscap SystemCapability.Web.Webview.Core 1719 * @crossplatform 1720 * @atomicservice 1721 * @since 11 1722 */ 1723 static clearAllCookies(callback: AsyncCallback<void>): void; 1724 1725 /** 1726 * Delete the session cookies. 1727 * @syscap SystemCapability.Web.Webview.Core 1728 * @since 9 1729 * @deprecated since 11 1730 * @useinstead ohos.web.webview.WebCookieManager#clearSessionCookieSync 1731 */ 1732 static deleteSessionCookie(): void; 1733 1734 /** 1735 * Delete the session cookies. 1736 * @syscap SystemCapability.Web.Webview.Core 1737 * @atomicservice 1738 * @since 11 1739 */ 1740 static clearSessionCookieSync(): void; 1741 1742 /** 1743 * Delete the session cookies Asynchronously. 1744 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 1745 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1746 * @syscap SystemCapability.Web.Webview.Core 1747 * @atomicservice 1748 * @since 11 1749 */ 1750 static clearSessionCookie(): Promise<void>; 1751 1752 /** 1753 * Delete the session cookies Asynchronously. 1754 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 1755 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1756 * <br>2. Incorrect parameter types. 1757 * @syscap SystemCapability.Web.Webview.Core 1758 * @atomicservice 1759 * @since 11 1760 */ 1761 static clearSessionCookie(callback: AsyncCallback<void>): void; 1762 } 1763 1764 /** 1765 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 1766 * 1767 * @enum {number} 1768 * @syscap SystemCapability.Web.Webview.Core 1769 * @since 10 1770 */ 1771 /** 1772 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 1773 * 1774 * @enum {number} 1775 * @syscap SystemCapability.Web.Webview.Core 1776 * @atomicservice 1777 * @since 11 1778 */ 1779 enum WebMessageType { 1780 /** 1781 * Unsupported data type. 1782 * 1783 * @syscap SystemCapability.Web.Webview.Core 1784 * @since 10 1785 */ 1786 /** 1787 * Unsupported data type. 1788 * 1789 * @syscap SystemCapability.Web.Webview.Core 1790 * @atomicservice 1791 * @since 11 1792 */ 1793 NOT_SUPPORT, 1794 1795 /** 1796 * The string data type. 1797 * 1798 * @syscap SystemCapability.Web.Webview.Core 1799 * @since 10 1800 */ 1801 /** 1802 * The string data type. 1803 * 1804 * @syscap SystemCapability.Web.Webview.Core 1805 * @atomicservice 1806 * @since 11 1807 */ 1808 STRING, 1809 1810 /** 1811 * The number data type. 1812 * 1813 * @syscap SystemCapability.Web.Webview.Core 1814 * @since 10 1815 */ 1816 /** 1817 * The number data type. 1818 * 1819 * @syscap SystemCapability.Web.Webview.Core 1820 * @atomicservice 1821 * @since 11 1822 */ 1823 NUMBER, 1824 1825 /** 1826 * The boolean data type. 1827 * 1828 * @syscap SystemCapability.Web.Webview.Core 1829 * @since 10 1830 */ 1831 /** 1832 * The boolean data type. 1833 * 1834 * @syscap SystemCapability.Web.Webview.Core 1835 * @atomicservice 1836 * @since 11 1837 */ 1838 BOOLEAN, 1839 1840 /** 1841 * The arraybuffer data type. 1842 * 1843 * @syscap SystemCapability.Web.Webview.Core 1844 * @since 10 1845 */ 1846 /** 1847 * The arraybuffer data type. 1848 * 1849 * @syscap SystemCapability.Web.Webview.Core 1850 * @atomicservice 1851 * @since 11 1852 */ 1853 ARRAY_BUFFER, 1854 1855 /** 1856 * The array data type. 1857 * 1858 * @syscap SystemCapability.Web.Webview.Core 1859 * @since 10 1860 */ 1861 /** 1862 * The array data type. 1863 * 1864 * @syscap SystemCapability.Web.Webview.Core 1865 * @atomicservice 1866 * @since 11 1867 */ 1868 ARRAY, 1869 1870 /** 1871 * The error data type. 1872 * 1873 * @syscap SystemCapability.Web.Webview.Core 1874 * @since 10 1875 */ 1876 /** 1877 * The error data type. 1878 * 1879 * @syscap SystemCapability.Web.Webview.Core 1880 * @atomicservice 1881 * @since 11 1882 */ 1883 ERROR 1884 } 1885 1886 /** 1887 * The message received or sent from web message port. 1888 * 1889 * @syscap SystemCapability.Web.Webview.Core 1890 * @since 10 1891 */ 1892 /** 1893 * The message received or sent from web message port. 1894 * 1895 * @syscap SystemCapability.Web.Webview.Core 1896 * @atomicservice 1897 * @since 11 1898 */ 1899 class WebMessageExt { 1900 /** 1901 * Get the type of the web message. 1902 * @returns { WebMessageType } - Returns data of WebMessageType type 1903 * @syscap SystemCapability.Web.Webview.Core 1904 * @since 10 1905 */ 1906 /** 1907 * Get the type of the web message. 1908 * @returns { WebMessageType } - Returns data of WebMessageType type 1909 * @syscap SystemCapability.Web.Webview.Core 1910 * @atomicservice 1911 * @since 11 1912 */ 1913 getType(): WebMessageType; 1914 1915 /** 1916 * Get the string value of the web message. 1917 * @returns { string } - Returns data of string type 1918 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1919 * 1920 * @syscap SystemCapability.Web.Webview.Core 1921 * @since 10 1922 */ 1923 /** 1924 * Get the string value of the web message. 1925 * @returns { string } - Returns data of string type 1926 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1927 * 1928 * @syscap SystemCapability.Web.Webview.Core 1929 * @atomicservice 1930 * @since 11 1931 */ 1932 getString(): string; 1933 1934 /** 1935 * Get the number value of the web message. 1936 * @returns { number } - Returns data of number type 1937 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1938 * 1939 * @syscap SystemCapability.Web.Webview.Core 1940 * @since 10 1941 */ 1942 /** 1943 * Get the number value of the web message. 1944 * @returns { number } - Returns data of number type 1945 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1946 * 1947 * @syscap SystemCapability.Web.Webview.Core 1948 * @atomicservice 1949 * @since 11 1950 */ 1951 getNumber(): number; 1952 1953 /** 1954 * Get the boolean value of the web message. 1955 * @returns { boolean } - Returns data of Boolean type 1956 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1957 * 1958 * @syscap SystemCapability.Web.Webview.Core 1959 * @since 10 1960 */ 1961 /** 1962 * Get the boolean value of the web message. 1963 * @returns { boolean } - Returns data of Boolean type 1964 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1965 * 1966 * @syscap SystemCapability.Web.Webview.Core 1967 * @atomicservice 1968 * @since 11 1969 */ 1970 getBoolean(): boolean; 1971 1972 /** 1973 * Get the array buffer value of the web message. 1974 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 1975 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1976 * 1977 * @syscap SystemCapability.Web.Webview.Core 1978 * @since 10 1979 */ 1980 /** 1981 * Get the array buffer value of the web message. 1982 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 1983 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1984 * 1985 * @syscap SystemCapability.Web.Webview.Core 1986 * @atomicservice 1987 * @since 11 1988 */ 1989 getArrayBuffer(): ArrayBuffer; 1990 1991 /** 1992 * Get the array value of the web message. 1993 * @returns { Array<string | number | boolean> } - Returns data of Array type 1994 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1995 * 1996 * @syscap SystemCapability.Web.Webview.Core 1997 * @since 10 1998 */ 1999 /** 2000 * Get the array value of the web message. 2001 * @returns { Array<string | number | boolean> } - Returns data of Array type 2002 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2003 * 2004 * @syscap SystemCapability.Web.Webview.Core 2005 * @atomicservice 2006 * @since 11 2007 */ 2008 getArray(): Array<string | number | boolean>; 2009 2010 /** 2011 * Get the error value of the web message. 2012 * @returns { Error } - Returns data of Error type 2013 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2014 * 2015 * @syscap SystemCapability.Web.Webview.Core 2016 * @since 10 2017 */ 2018 /** 2019 * Get the error value of the web message. 2020 * @returns { Error } - Returns data of Error type 2021 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2022 * 2023 * @syscap SystemCapability.Web.Webview.Core 2024 * @atomicservice 2025 * @since 11 2026 */ 2027 getError(): Error; 2028 2029 /** 2030 * Set the type of the web message. 2031 * @param { WebMessageType } type - set WebMessageType type data 2032 * @throws { BusinessError } 401 - Invalid input parameter. 2033 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2034 * 2035 * @syscap SystemCapability.Web.Webview.Core 2036 * @since 10 2037 */ 2038 /** 2039 * Set the type of the web message. 2040 * @param { WebMessageType } type - set WebMessageType type data 2041 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2042 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2043 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2044 * 2045 * @syscap SystemCapability.Web.Webview.Core 2046 * @atomicservice 2047 * @since 11 2048 */ 2049 setType(type: WebMessageType): void; 2050 2051 /** 2052 * Set the string value of the web message. 2053 * @param { string } message - set string type data 2054 * @throws { BusinessError } 401 - Invalid input parameter. 2055 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2056 * 2057 * @syscap SystemCapability.Web.Webview.Core 2058 * @since 10 2059 */ 2060 /** 2061 * Set the string value of the web message. 2062 * @param { string } message - set string type data 2063 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2064 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2065 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2066 * 2067 * @syscap SystemCapability.Web.Webview.Core 2068 * @atomicservice 2069 * @since 11 2070 */ 2071 setString(message: string): void; 2072 2073 /** 2074 * Set the number value of the web message. 2075 * @param { number } message - set number type data 2076 * @throws { BusinessError } 401 - Invalid input parameter. 2077 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2078 * 2079 * @syscap SystemCapability.Web.Webview.Core 2080 * @since 10 2081 */ 2082 /** 2083 * Set the number value of the web message. 2084 * @param { number } message - set number type data 2085 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2086 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2087 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2088 * 2089 * @syscap SystemCapability.Web.Webview.Core 2090 * @atomicservice 2091 * @since 11 2092 */ 2093 setNumber(message: number): void; 2094 2095 /** 2096 * Set the boolean value of the web message. 2097 * @param { boolean } message - set boolean type data 2098 * @throws { BusinessError } 401 - Invalid input parameter. 2099 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2100 * 2101 * @syscap SystemCapability.Web.Webview.Core 2102 * @since 10 2103 */ 2104 /** 2105 * Set the boolean value of the web message. 2106 * @param { boolean } message - set boolean type data 2107 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2108 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2109 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2110 * 2111 * @syscap SystemCapability.Web.Webview.Core 2112 * @atomicservice 2113 * @since 11 2114 */ 2115 setBoolean(message: boolean): void; 2116 2117 /** 2118 * Set the array buffer value of the web message. 2119 * @param { ArrayBuffer } message - set ArrayBuffer type data 2120 * @throws { BusinessError } 401 - Invalid input parameter. 2121 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2122 * 2123 * @syscap SystemCapability.Web.Webview.Core 2124 * @since 10 2125 */ 2126 /** 2127 * Set the array buffer value of the web message. 2128 * @param { ArrayBuffer } message - set ArrayBuffer type data 2129 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2130 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2131 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2132 * 2133 * @syscap SystemCapability.Web.Webview.Core 2134 * @atomicservice 2135 * @since 11 2136 */ 2137 setArrayBuffer(message: ArrayBuffer): void; 2138 2139 /** 2140 * Set the array value of the web message. 2141 * @param { Array<string | number | boolean> } message - set Array type data 2142 * @throws { BusinessError } 401 - Invalid input parameter. 2143 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2144 * @syscap SystemCapability.Web.Webview.Core 2145 * @since 10 2146 */ 2147 /** 2148 * Set the array value of the web message. 2149 * @param { Array<string | number | boolean> } message - set Array type data 2150 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2151 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2152 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2153 * @syscap SystemCapability.Web.Webview.Core 2154 * @atomicservice 2155 * @since 11 2156 */ 2157 setArray(message: Array<string | number | boolean>): void; 2158 2159 /** 2160 * Set the error value of the web message. 2161 * @param { Error } message - set Error type data 2162 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2163 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2164 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2165 * 2166 * @syscap SystemCapability.Web.Webview.Core 2167 * @since 10 2168 */ 2169 /** 2170 * Set the error value of the web message. 2171 * @param { Error } message - set Error type data 2172 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2173 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2174 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2175 * 2176 * @syscap SystemCapability.Web.Webview.Core 2177 * @atomicservice 2178 * @since 11 2179 */ 2180 setError(message: Error): void; 2181 } 2182 2183 /** 2184 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 2185 * 2186 * @syscap SystemCapability.Web.Webview.Core 2187 * @since 9 2188 */ 2189 /** 2190 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 2191 * 2192 * @typedef { ArrayBuffer | string } 2193 * @syscap SystemCapability.Web.Webview.Core 2194 * @atomicservice 2195 * @since 11 2196 */ 2197 type WebMessage = ArrayBuffer | string; 2198 /** 2199 * Define html web message port. 2200 * @interface WebMessagePort 2201 * @syscap SystemCapability.Web.Webview.Core 2202 * @since 9 2203 */ 2204 /** 2205 * Define html web message port. 2206 * @interface WebMessagePort 2207 * @syscap SystemCapability.Web.Webview.Core 2208 * @crossplatform 2209 * @atomicservice 2210 * @since 11 2211 */ 2212 /** 2213 * Define html web message port. 2214 * @typedef WebMessagePort 2215 * @syscap SystemCapability.Web.Webview.Core 2216 * @crossplatform 2217 * @atomicservice 2218 * @since 12 2219 */ 2220 interface WebMessagePort { 2221 /** 2222 * The flag indicates whether more formats are supported than string and array buffers. 2223 * 2224 * @syscap SystemCapability.Web.Webview.Core 2225 * @since 10 2226 */ 2227 /** 2228 * The flag indicates whether more formats are supported than string and array buffers. 2229 * 2230 * @type { ?boolean } 2231 * @syscap SystemCapability.Web.Webview.Core 2232 * @atomicservice 2233 * @since 11 2234 */ 2235 isExtentionType?: boolean; 2236 2237 /** 2238 * Close port. 2239 * @syscap SystemCapability.Web.Webview.Core 2240 * @since 9 2241 */ 2242 /** 2243 * Close port. 2244 * @syscap SystemCapability.Web.Webview.Core 2245 * @crossplatform 2246 * @atomicservice 2247 * @since 11 2248 */ 2249 close(): void; 2250 2251 /** 2252 * Post a message to other port. 2253 * @param { WebMessage } message - Message to send. 2254 * @throws { BusinessError } 401 - Invalid input parameter. 2255 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2256 * @syscap SystemCapability.Web.Webview.Core 2257 * @since 9 2258 */ 2259 /** 2260 * Post a message to other port. 2261 * @param { WebMessage } message - Message to send. 2262 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2263 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2264 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2265 * @syscap SystemCapability.Web.Webview.Core 2266 * @crossplatform 2267 * @atomicservice 2268 * @since 11 2269 */ 2270 postMessageEvent(message: WebMessage): void; 2271 2272 /** 2273 * Receive message from other port. 2274 * @param { function } callback - Callback function for receiving messages. 2275 * @throws { BusinessError } 401 - Invalid input parameter. 2276 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2277 * @syscap SystemCapability.Web.Webview.Core 2278 * @since 9 2279 */ 2280 /** 2281 * Receive message from other port. 2282 * @param { function } callback - Callback function for receiving messages. 2283 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2284 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2285 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2286 * @syscap SystemCapability.Web.Webview.Core 2287 * @crossplatform 2288 * @atomicservice 2289 * @since 11 2290 */ 2291 onMessageEvent(callback: (result: WebMessage) => void): void; 2292 2293 /** 2294 * Post a message to other port. 2295 * @param { WebMessageExt } message - Message to send. 2296 * @throws { BusinessError } 401 - Invalid input parameter. 2297 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2298 * @syscap SystemCapability.Web.Webview.Core 2299 * @since 10 2300 */ 2301 /** 2302 * Post a message to other port. 2303 * @param { WebMessageExt } message - Message to send. 2304 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2305 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2306 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2307 * @syscap SystemCapability.Web.Webview.Core 2308 * @atomicservice 2309 * @since 11 2310 */ 2311 postMessageEventExt(message: WebMessageExt): void; 2312 2313 /** 2314 * Receive message from other port. 2315 * @param { function } callback - Callback function for receiving messages. 2316 * @throws { BusinessError } 401 - Invalid input parameter. 2317 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2318 * @syscap SystemCapability.Web.Webview.Core 2319 * @since 10 2320 */ 2321 /** 2322 * Receive message from other port. 2323 * @param { function } callback - Callback function for receiving messages. 2324 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2325 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2326 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2327 * @syscap SystemCapability.Web.Webview.Core 2328 * @atomicservice 2329 * @since 11 2330 */ 2331 onMessageEventExt(callback: (result: WebMessageExt) => void): void; 2332 } 2333 2334 /** 2335 * Provides information for history item in BackForwardList. 2336 * @interface HistoryItem 2337 * @syscap SystemCapability.Web.Webview.Core 2338 * @since 9 2339 */ 2340 /** 2341 * Provides information for history item in BackForwardList. 2342 * @interface HistoryItem 2343 * @syscap SystemCapability.Web.Webview.Core 2344 * @crossplatform 2345 * @atomicservice 2346 * @since 11 2347 */ 2348 /** 2349 * Provides information for history item in BackForwardList. 2350 * @typedef HistoryItem 2351 * @syscap SystemCapability.Web.Webview.Core 2352 * @crossplatform 2353 * @atomicservice 2354 * @since 12 2355 */ 2356 interface HistoryItem { 2357 /** 2358 * Pixelmap of icon. 2359 * @syscap SystemCapability.Web.Webview.Core 2360 * @since 9 2361 */ 2362 /** 2363 * Pixelmap of icon. 2364 * @type { image.PixelMap } 2365 * @syscap SystemCapability.Web.Webview.Core 2366 * @atomicservice 2367 * @since 11 2368 */ 2369 icon: image.PixelMap; 2370 2371 /** 2372 * Url of this history item. 2373 * @syscap SystemCapability.Web.Webview.Core 2374 * @since 9 2375 */ 2376 /** 2377 * Url of this history item. 2378 * @type { string } 2379 * @syscap SystemCapability.Web.Webview.Core 2380 * @crossplatform 2381 * @atomicservice 2382 * @since 11 2383 */ 2384 historyUrl: string; 2385 2386 /** 2387 * Original request url of this history item. 2388 * @syscap SystemCapability.Web.Webview.Core 2389 * @since 9 2390 */ 2391 /** 2392 * Original request url of this history item. 2393 * @type { string } 2394 * @syscap SystemCapability.Web.Webview.Core 2395 * @crossplatform 2396 * @atomicservice 2397 * @since 11 2398 */ 2399 historyRawUrl: string; 2400 2401 /** 2402 * Title of this history item. 2403 * @syscap SystemCapability.Web.Webview.Core 2404 * @since 9 2405 */ 2406 /** 2407 * Title of this history item. 2408 * @type { string } 2409 * @syscap SystemCapability.Web.Webview.Core 2410 * @crossplatform 2411 * @atomicservice 2412 * @since 11 2413 */ 2414 title: string; 2415 } 2416 2417 /** 2418 * Provides back and forward history list information method. related to {@link HistoryItem}. 2419 * @interface BackForwardList 2420 * @syscap SystemCapability.Web.Webview.Core 2421 * @since 9 2422 */ 2423 /** 2424 * Provides back and forward history list information method. related to {@link HistoryItem}. 2425 * @interface BackForwardList 2426 * @syscap SystemCapability.Web.Webview.Core 2427 * @crossplatform 2428 * @atomicservice 2429 * @since 11 2430 */ 2431 /** 2432 * Provides back and forward history list information method. related to {@link HistoryItem}. 2433 * @typedef BackForwardList 2434 * @syscap SystemCapability.Web.Webview.Core 2435 * @crossplatform 2436 * @atomicservice 2437 * @since 12 2438 */ 2439 interface BackForwardList { 2440 /** 2441 * Current index in BackForwardList. 2442 * @syscap SystemCapability.Web.Webview.Core 2443 * @since 9 2444 */ 2445 /** 2446 * Current index in BackForwardList. 2447 * @type { number } 2448 * @syscap SystemCapability.Web.Webview.Core 2449 * @crossplatform 2450 * @atomicservice 2451 * @since 11 2452 */ 2453 currentIndex: number; 2454 2455 /** 2456 * Size of in BackForwardList. 2457 * @syscap SystemCapability.Web.Webview.Core 2458 * @since 9 2459 */ 2460 /** 2461 * Size of in BackForwardList. 2462 * @type { number } 2463 * @syscap SystemCapability.Web.Webview.Core 2464 * @crossplatform 2465 * @atomicservice 2466 * @since 11 2467 */ 2468 size: number; 2469 2470 /** 2471 * Get history entry at given index. 2472 * 2473 * @param { number } index Index of back forward list entry. 2474 * @returns { HistoryItem } HistoryItem at given index in back forward list. 2475 * @throws { BusinessError } 401 - Invalid input parameter. 2476 * @syscap SystemCapability.Web.Webview.Core 2477 * @since 9 2478 */ 2479 /** 2480 * Get history entry at given index. 2481 * 2482 * @param { number } index Index of back forward list entry. 2483 * @returns { HistoryItem } HistoryItem at given index in back forward list. 2484 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2485 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2486 * @syscap SystemCapability.Web.Webview.Core 2487 * @crossplatform 2488 * @atomicservice 2489 * @since 11 2490 */ 2491 getItemAtIndex(index: number): HistoryItem; 2492 } 2493 2494 /** 2495 * Defines the snapshot info. 2496 * 2497 * @typedef SnapshotInfo 2498 * @syscap SystemCapability.Web.Webview.Core 2499 * @atomicservice 2500 * @since 12 2501 */ 2502 interface SnapshotInfo { 2503 /** 2504 * Id of the snapshot. 2505 * 2506 * @type { ?string } 2507 * @syscap SystemCapability.Web.Webview.Core 2508 * @atomicservice 2509 * @since 12 2510 */ 2511 id?: string; 2512 2513 /** 2514 * Size of the web. 2515 * 2516 * @type { ?SizeOptions } 2517 * @syscap SystemCapability.Web.Webview.Core 2518 * @atomicservice 2519 * @since 12 2520 */ 2521 size?: SizeOptions; 2522 } 2523 2524 /** 2525 * Defines the snapshot result. 2526 * 2527 * @typedef SnapshotResult 2528 * @syscap SystemCapability.Web.Webview.Core 2529 * @atomicservice 2530 * @since 12 2531 */ 2532 interface SnapshotResult { 2533 /** 2534 * Id of the snapshot. 2535 * 2536 * @type { ?string } 2537 * @syscap SystemCapability.Web.Webview.Core 2538 * @atomicservice 2539 * @since 12 2540 */ 2541 id?: string; 2542 2543 /** 2544 * The status of the snapshot. 2545 * 2546 * @type { ?boolean } 2547 * @syscap SystemCapability.Web.Webview.Core 2548 * @atomicservice 2549 * @since 12 2550 */ 2551 status?: boolean; 2552 2553 /** 2554 * Size of the web. 2555 * 2556 * @type { ?SizeOptions } 2557 * @syscap SystemCapability.Web.Webview.Core 2558 * @atomicservice 2559 * @since 12 2560 */ 2561 size?: SizeOptions; 2562 2563 /** 2564 * The image in PixelMap format. 2565 * 2566 * @type { ?image.PixelMap } 2567 * @syscap SystemCapability.Web.Webview.Core 2568 * @atomicservice 2569 * @since 12 2570 */ 2571 imagePixelMap?: image.PixelMap; 2572 } 2573 /** 2574 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 2575 * @enum {number} 2576 * @syscap SystemCapability.Web.Webview.Core 2577 * @since 10 2578 */ 2579 /** 2580 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 2581 * @enum {number} 2582 * @syscap SystemCapability.Web.Webview.Core 2583 * @atomicservice 2584 * @since 11 2585 */ 2586 enum JsMessageType { 2587 /** 2588 * Unsupported data type. 2589 * @syscap SystemCapability.Web.Webview.Core 2590 * @since 10 2591 */ 2592 /** 2593 * Unsupported data type. 2594 * @syscap SystemCapability.Web.Webview.Core 2595 * @atomicservice 2596 * @since 11 2597 */ 2598 NOT_SUPPORT, 2599 2600 /** 2601 * The string data type. 2602 * @syscap SystemCapability.Web.Webview.Core 2603 * @since 10 2604 */ 2605 /** 2606 * The string data type. 2607 * @syscap SystemCapability.Web.Webview.Core 2608 * @atomicservice 2609 * @since 11 2610 */ 2611 STRING, 2612 2613 /** 2614 * The number data type. 2615 * @syscap SystemCapability.Web.Webview.Core 2616 * @since 10 2617 */ 2618 /** 2619 * The number data type. 2620 * @syscap SystemCapability.Web.Webview.Core 2621 * @atomicservice 2622 * @since 11 2623 */ 2624 NUMBER, 2625 2626 /** 2627 * The boolean data type. 2628 * @syscap SystemCapability.Web.Webview.Core 2629 * @since 10 2630 */ 2631 /** 2632 * The boolean data type. 2633 * @syscap SystemCapability.Web.Webview.Core 2634 * @atomicservice 2635 * @since 11 2636 */ 2637 BOOLEAN, 2638 2639 /** 2640 * The arraybuffer data type. 2641 * @syscap SystemCapability.Web.Webview.Core 2642 * @since 10 2643 */ 2644 /** 2645 * The arraybuffer data type. 2646 * @syscap SystemCapability.Web.Webview.Core 2647 * @atomicservice 2648 * @since 11 2649 */ 2650 ARRAY_BUFFER, 2651 2652 /** 2653 * The array data type. 2654 * @syscap SystemCapability.Web.Webview.Core 2655 * @since 10 2656 */ 2657 /** 2658 * The array data type. 2659 * @syscap SystemCapability.Web.Webview.Core 2660 * @atomicservice 2661 * @since 11 2662 */ 2663 ARRAY 2664 } 2665 2666 /** 2667 * The message for indicating the of result of JavaScript code execution. 2668 * @syscap SystemCapability.Web.Webview.Core 2669 * @since 10 2670 */ 2671 /** 2672 * The message for indicating the of result of JavaScript code execution. 2673 * @syscap SystemCapability.Web.Webview.Core 2674 * @atomicservice 2675 * @since 11 2676 */ 2677 class JsMessageExt { 2678 /** 2679 * Get the type of the JavaScript code execution result. 2680 * @returns { JsMessageType } - Returns data of JsMessageType type 2681 * @syscap SystemCapability.Web.Webview.Core 2682 * @since 10 2683 */ 2684 /** 2685 * Get the type of the JavaScript code execution result. 2686 * @returns { JsMessageType } - Returns data of JsMessageType type 2687 * @syscap SystemCapability.Web.Webview.Core 2688 * @atomicservice 2689 * @since 11 2690 */ 2691 getType(): JsMessageType; 2692 2693 /** 2694 * Get the string value of the JavaScript code execution result. 2695 * @returns { string } - Returns data of string type 2696 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2697 * @syscap SystemCapability.Web.Webview.Core 2698 * @since 10 2699 */ 2700 /** 2701 * Get the string value of the JavaScript code execution result. 2702 * @returns { string } - Returns data of string type 2703 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2704 * @syscap SystemCapability.Web.Webview.Core 2705 * @atomicservice 2706 * @since 11 2707 */ 2708 getString(): string; 2709 2710 /** 2711 * Get the number value of the JavaScript code execution result. 2712 * @returns { number } - Returns data of number type 2713 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2714 * @syscap SystemCapability.Web.Webview.Core 2715 * @since 10 2716 */ 2717 /** 2718 * Get the number value of the JavaScript code execution result. 2719 * @returns { number } - Returns data of number type 2720 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2721 * @syscap SystemCapability.Web.Webview.Core 2722 * @atomicservice 2723 * @since 11 2724 */ 2725 getNumber(): number; 2726 2727 /** 2728 * Get the boolean value of the JavaScript code execution result. 2729 * @returns { boolean } - Returns data of Boolean type 2730 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2731 * @syscap SystemCapability.Web.Webview.Core 2732 * @since 10 2733 */ 2734 /** 2735 * Get the boolean value of the JavaScript code execution result. 2736 * @returns { boolean } - Returns data of Boolean type 2737 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2738 * @syscap SystemCapability.Web.Webview.Core 2739 * @atomicservice 2740 * @since 11 2741 */ 2742 getBoolean(): boolean; 2743 2744 /** 2745 * Get the array buffer value of the JavaScript code execution result. 2746 * @returns { ArrayBuffer } - Returns data of ArrayBuffer 2747 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2748 * @syscap SystemCapability.Web.Webview.Core 2749 * @since 10 2750 */ 2751 /** 2752 * Get the array buffer value of the JavaScript code execution result. 2753 * @returns { ArrayBuffer } - Returns data of ArrayBuffer 2754 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2755 * @syscap SystemCapability.Web.Webview.Core 2756 * @atomicservice 2757 * @since 11 2758 */ 2759 getArrayBuffer(): ArrayBuffer; 2760 2761 /** 2762 * Get the array value of the the JavaScript code execution result. 2763 * @returns { Array<string | number | boolean> } - Returns data of Array type 2764 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2765 * @syscap SystemCapability.Web.Webview.Core 2766 * @since 10 2767 */ 2768 /** 2769 * Get the array value of the the JavaScript code execution result. 2770 * @returns { Array<string | number | boolean> } - Returns data of Array type 2771 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2772 * @syscap SystemCapability.Web.Webview.Core 2773 * @atomicservice 2774 * @since 11 2775 */ 2776 getArray(): Array<string | number | boolean>; 2777 } 2778 2779 /** 2780 * Defines the render process mode. 2781 * 2782 * @enum {number} 2783 * @syscap SystemCapability.Web.Webview.Core 2784 * @atomicservice 2785 * @since 12 2786 */ 2787 enum RenderProcessMode { 2788 /** 2789 * Indicates the ArkWeb operates in single render process mode, which is the default value for 2790 * mobile devices. 2791 * 2792 * @syscap SystemCapability.Web.Webview.Core 2793 * @atomicservice 2794 * @since 12 2795 */ 2796 SINGLE = 0, 2797 2798 /** 2799 * Indicates the ArkWeb operates in multiple render process mode. 2800 * 2801 * @syscap SystemCapability.Web.Webview.Core 2802 * @atomicservice 2803 * @since 12 2804 */ 2805 MULTIPLE, 2806 } 2807 2808 /** 2809 * Options of generating code cache 2810 * @typedef CacheOptions 2811 * @syscap SystemCapability.Web.Webview.Core 2812 * @since 12 2813 */ 2814 interface CacheOptions { 2815 /** 2816 * Response headers used to configure the validation key of code cache. 2817 * Currently only support E-Tag and Last-Modified. 2818 * 2819 * @type { Array<WebHeader> } 2820 * @syscap SystemCapability.Web.Webview.Core 2821 * @since 12 2822 */ 2823 responseHeaders: Array<WebHeader>; 2824 } 2825 2826 /** 2827 * Enum type supplied to {@link OfflineResourceMap} for indicating the type of resource. 2828 * @enum {number} 2829 * @syscap SystemCapability.Web.Webview.Core 2830 * @since 12 2831 */ 2832 enum OfflineResourceType { 2833 /** 2834 * Image resource 2835 * 2836 * @syscap SystemCapability.Web.Webview.Core 2837 * @since 12 2838 */ 2839 IMAGE, 2840 2841 /** 2842 * CSS resource 2843 * 2844 * @syscap SystemCapability.Web.Webview.Core 2845 * @since 12 2846 */ 2847 CSS, 2848 2849 /** 2850 * Classic javascript resource 2851 * 2852 * @syscap SystemCapability.Web.Webview.Core 2853 * @since 12 2854 */ 2855 CLASSIC_JS, 2856 2857 /** 2858 * Module javascript resource 2859 * 2860 * @syscap SystemCapability.Web.Webview.Core 2861 * @since 12 2862 */ 2863 MODULE_JS 2864 } 2865 2866 /** 2867 * Define offline resource's content and info. 2868 * @typedef OfflineResourceMap 2869 * @syscap SystemCapability.Web.Webview.Core 2870 * @since 12 2871 */ 2872 interface OfflineResourceMap { 2873 /** 2874 * Url list of resource. Url of urlList must be HTTP/HTTPS protocol and no longer than 2048. 2875 * 2876 * @type { Array<string> } 2877 * @syscap SystemCapability.Web.Webview.Core 2878 * @since 12 2879 */ 2880 urlList: Array<string>, 2881 2882 /** 2883 * Arraybuffer of resource. Size must less than 10Mb and cannot be empty. 2884 * 2885 * @type { Uint8Array } 2886 * @syscap SystemCapability.Web.Webview.Core 2887 * @since 12 2888 */ 2889 resource: Uint8Array, 2890 2891 /** 2892 * Response headers of resource. 2893 * 2894 * @type { Array<WebHeader> } 2895 * @syscap SystemCapability.Web.Webview.Core 2896 * @since 12 2897 */ 2898 responseHeaders: Array<WebHeader>, 2899 2900 /** 2901 * Resource type 2902 * 2903 * @type { OfflineResourceType } 2904 * @syscap SystemCapability.Web.Webview.Core 2905 * @since 12 2906 */ 2907 type: OfflineResourceType 2908 } 2909 2910 /** 2911 * Enum type supplied to {@link setScrollable} for indicating the type of scroll. 2912 * 2913 * @enum { number } 2914 * @syscap SystemCapability.Web.Webview.Core 2915 * @since 12 2916 */ 2917 enum ScrollType { 2918 /** 2919 * Indicates scrolling the web page through scroll event, include touch screen, touch pad, and mouse wheel. 2920 * 2921 * @syscap SystemCapability.Web.Webview.Core 2922 * @since 12 2923 */ 2924 EVENT 2925 } 2926 2927 /** 2928 * Provides methods for controlling the web controller. 2929 * @syscap SystemCapability.Web.Webview.Core 2930 * @since 9 2931 */ 2932 /** 2933 * Provides methods for controlling the web controller. 2934 * @syscap SystemCapability.Web.Webview.Core 2935 * @crossplatform 2936 * @since 10 2937 */ 2938 /** 2939 * Provides methods for controlling the web controller. 2940 * @syscap SystemCapability.Web.Webview.Core 2941 * @crossplatform 2942 * @atomicservice 2943 * @since 11 2944 */ 2945 class WebviewController { 2946 /** 2947 * A constructor used to create a WebviewController object. 2948 * 2949 * @param { string } [webTag] - specified the name of the web component, Empty by default. 2950 * @syscap SystemCapability.Web.Webview.Core 2951 * @atomicservice 2952 * @since 11 2953 */ 2954 constructor(webTag?: string); 2955 2956 /** 2957 * Initialize the web engine before loading the Web components. 2958 * This is a global static API that must be called on the UI thread, and it will have no effect if any 2959 * Web components are loaded. 2960 * @syscap SystemCapability.Web.Webview.Core 2961 * @since 9 2962 */ 2963 /** 2964 * Initialize the web engine before loading the Web components. 2965 * This is a global static API that must be called on the UI thread, and it will have no effect if any 2966 * Web components are loaded. 2967 * @syscap SystemCapability.Web.Webview.Core 2968 * @atomicservice 2969 * @since 11 2970 */ 2971 static initializeWebEngine(): void; 2972 2973 /** 2974 * Set web engine to use HttpDns server to resolve dns. 2975 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 2976 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 2977 * Must be https protocol and only allow one server to be configured. 2978 * @throws { BusinessError } 401 - Invalid input parameter. 2979 * @syscap SystemCapability.Web.Webview.Core 2980 * @since 10 2981 */ 2982 /** 2983 * Set web engine to use HttpDns server to resolve dns. 2984 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 2985 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 2986 * Must be https protocol and only allow one server to be configured. 2987 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2988 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 2989 * @syscap SystemCapability.Web.Webview.Core 2990 * @atomicservice 2991 * @since 11 2992 */ 2993 static setHttpDns(secureDnsMode: SecureDnsMode, secureDnsConfig: string): void; 2994 2995 /** 2996 * Enables debugging of web contents. 2997 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 2998 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2999 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3000 * @syscap SystemCapability.Web.Webview.Core 3001 * @since 9 3002 */ 3003 /** 3004 * Enables debugging of web contents. 3005 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 3006 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3007 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3008 * @syscap SystemCapability.Web.Webview.Core 3009 * @atomicservice 3010 * @since 11 3011 */ 3012 static setWebDebuggingAccess(webDebuggingAccess: boolean): void; 3013 3014 /** 3015 * Enable the ability to check website security risks. 3016 * Illegal and fraudulent websites are mandatory enabled and can't be disabled by this function. 3017 * @param { boolean } enable - {@code true} enable check the website security risks; {@code false} otherwise. 3018 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3019 * <br>2. Incorrect parameter types. 3020 * @syscap SystemCapability.Web.Webview.Core 3021 * @atomicservice 3022 * @since 11 3023 */ 3024 enableSafeBrowsing(enable: boolean): void; 3025 3026 /** 3027 * Get whether checking website security risks is enabled. 3028 * @returns { boolean } True if enable the ability to check website security risks else false. 3029 * @syscap SystemCapability.Web.Webview.Core 3030 * @atomicservice 3031 * @since 11 3032 */ 3033 isSafeBrowsingEnabled(): boolean; 3034 3035 /** 3036 * Checks whether the web page can go forward. 3037 * @returns { boolean } True if the web page can go forward else false. 3038 * @throws { BusinessError } 17100001 - Init error. 3039 * The WebviewController must be associated with a Web component. 3040 * @syscap SystemCapability.Web.Webview.Core 3041 * @since 9 3042 */ 3043 /** 3044 * Checks whether the web page can go forward. 3045 * @returns { boolean } True if the web page can go forward else false. 3046 * @throws { BusinessError } 17100001 - Init error. 3047 * The WebviewController must be associated with a Web component. 3048 * @syscap SystemCapability.Web.Webview.Core 3049 * @crossplatform 3050 * @atomicservice 3051 * @since 11 3052 */ 3053 accessForward(): boolean; 3054 3055 /** 3056 * Checks whether the web page can go back. 3057 * @returns { boolean } True if the web page can go back else false. 3058 * @throws { BusinessError } 17100001 - Init error. 3059 * The WebviewController must be associated with a Web component. 3060 * @syscap SystemCapability.Web.Webview.Core 3061 * @since 9 3062 */ 3063 /** 3064 * Checks whether the web page can go back. 3065 * @returns { boolean } True if the web page can go back else false. 3066 * @throws { BusinessError } 17100001 - Init error. 3067 * The WebviewController must be associated with a Web component. 3068 * @syscap SystemCapability.Web.Webview.Core 3069 * @crossplatform 3070 * @atomicservice 3071 * @since 11 3072 */ 3073 accessBackward(): boolean; 3074 3075 /** 3076 * Checks whether the web page can go back or forward the given number of steps. 3077 * 3078 * @param { number } step - The number of steps. 3079 * @returns { boolean } True if the web page can go back else false. 3080 * @throws { BusinessError } 401 - Invalid input parameter. 3081 * @throws { BusinessError } 17100001 - Init error. 3082 * The WebviewController must be associated with a Web component. 3083 * @syscap SystemCapability.Web.Webview.Core 3084 * @since 9 3085 */ 3086 /** 3087 * Checks whether the web page can go back or forward the given number of steps. 3088 * 3089 * @param { number } step - The number of steps. 3090 * @returns { boolean } True if the web page can go back else false. 3091 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3092 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3093 * @throws { BusinessError } 17100001 - Init error. 3094 * The WebviewController must be associated with a Web component. 3095 * @syscap SystemCapability.Web.Webview.Core 3096 * @crossplatform 3097 * @atomicservice 3098 * @since 11 3099 */ 3100 accessStep(step: number): boolean; 3101 3102 /** 3103 * Goes forward in the history of the web page. 3104 * 3105 * @throws { BusinessError } 17100001 - Init error. 3106 * The WebviewController must be associated with a Web component. 3107 * @syscap SystemCapability.Web.Webview.Core 3108 * @since 9 3109 */ 3110 /** 3111 * Goes forward in the history of the web page. 3112 * 3113 * @throws { BusinessError } 17100001 - Init error. 3114 * The WebviewController must be associated with a Web component. 3115 * @syscap SystemCapability.Web.Webview.Core 3116 * @crossplatform 3117 * @atomicservice 3118 * @since 11 3119 */ 3120 forward(): void; 3121 3122 /** 3123 * Goes back in the history of the web page. 3124 * 3125 * @throws { BusinessError } 17100001 - Init error. 3126 * The WebviewController must be associated with a Web component. 3127 * @syscap SystemCapability.Web.Webview.Core 3128 * @since 9 3129 */ 3130 /** 3131 * Goes back in the history of the web page. 3132 * 3133 * @throws { BusinessError } 17100001 - Init error. 3134 * The WebviewController must be associated with a Web component. 3135 * @syscap SystemCapability.Web.Webview.Core 3136 * @crossplatform 3137 * @atomicservice 3138 * @since 11 3139 */ 3140 backward(): void; 3141 3142 /** 3143 * Clears the history in the Web. 3144 * 3145 * @throws { BusinessError } 17100001 - Init error. 3146 * The WebviewController must be associated with a Web component. 3147 * @syscap SystemCapability.Web.Webview.Core 3148 * @since 9 3149 */ 3150 /** 3151 * Clears the history in the Web. 3152 * 3153 * @throws { BusinessError } 17100001 - Init error. 3154 * The WebviewController must be associated with a Web component. 3155 * @syscap SystemCapability.Web.Webview.Core 3156 * @crossplatform 3157 * @atomicservice 3158 * @since 11 3159 */ 3160 clearHistory(): void; 3161 3162 /** 3163 * Let the Web active. 3164 * 3165 * @throws { BusinessError } 17100001 - Init error. 3166 * The WebviewController must be associated with a Web component. 3167 * @syscap SystemCapability.Web.Webview.Core 3168 * @since 9 3169 */ 3170 /** 3171 * Let the Web active. 3172 * 3173 * @throws { BusinessError } 17100001 - Init error. 3174 * The WebviewController must be associated with a Web component. 3175 * @syscap SystemCapability.Web.Webview.Core 3176 * @atomicservice 3177 * @since 11 3178 */ 3179 onActive(): void; 3180 3181 /** 3182 * Let the Web inactive. 3183 * 3184 * @throws { BusinessError } 17100001 - Init error. 3185 * The WebviewController must be associated with a Web component. 3186 * @syscap SystemCapability.Web.Webview.Core 3187 * @since 9 3188 */ 3189 /** 3190 * Let the Web inactive. 3191 * 3192 * @throws { BusinessError } 17100001 - Init error. 3193 * The WebviewController must be associated with a Web component. 3194 * @syscap SystemCapability.Web.Webview.Core 3195 * @atomicservice 3196 * @since 11 3197 */ 3198 onInactive(): void; 3199 3200 /** 3201 * Refreshes the current URL. 3202 * 3203 * @throws { BusinessError } 17100001 - Init error. 3204 * The WebviewController must be associated with a Web component. 3205 * @syscap SystemCapability.Web.Webview.Core 3206 * @since 9 3207 */ 3208 /** 3209 * Refreshes the current URL. 3210 * 3211 * @throws { BusinessError } 17100001 - Init error. 3212 * The WebviewController must be associated with a Web component. 3213 * @syscap SystemCapability.Web.Webview.Core 3214 * @crossplatform 3215 * @atomicservice 3216 * @since 11 3217 */ 3218 refresh(): void; 3219 3220 /** 3221 * Loads the data or URL. 3222 * 3223 * @param { string } data - A string encoded according to "Base64" or "URL". 3224 * @param { string } mimeType - Media type. For example: "text/html". 3225 * @param { string } encoding - Encoding type. For example: "UTF-8". 3226 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 3227 * which is assigned to window.origin by the Web component. 3228 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 3229 * history records to realize the back and forth function. 3230 * This property is invalid when baseUrl is empty. 3231 * @throws { BusinessError } 401 - Invalid input parameter. 3232 * @throws { BusinessError } 17100001 - Init error. 3233 * The WebviewController must be associated with a Web component. 3234 * @throws { BusinessError } 17100002 - Invalid url. 3235 * @syscap SystemCapability.Web.Webview.Core 3236 * @since 9 3237 */ 3238 /** 3239 * Loads the data or URL. 3240 * 3241 * @param { string } data - A string encoded according to "Base64" or "URL". 3242 * @param { string } mimeType - Media type. For example: "text/html". 3243 * @param { string } encoding - Encoding type. For example: "UTF-8". 3244 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 3245 * which is assigned to window.origin by the Web component. 3246 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 3247 * history records to realize the back and forth function. 3248 * This property is invalid when baseUrl is empty. 3249 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3250 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3251 * @throws { BusinessError } 17100001 - Init error. 3252 * The WebviewController must be associated with a Web component. 3253 * @syscap SystemCapability.Web.Webview.Core 3254 * @crossplatform 3255 * @atomicservice 3256 * @since 11 3257 */ 3258 loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string): void; 3259 3260 /** 3261 * Loads the data or URL. 3262 * 3263 * @param { string | Resource } url - The URL to load. 3264 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 3265 * @throws { BusinessError } 401 - Invalid input parameter. 3266 * @throws { BusinessError } 17100001 - Init error. 3267 * The WebviewController must be associated with a Web component. 3268 * @throws { BusinessError } 17100002 - Invalid url. 3269 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3270 * @syscap SystemCapability.Web.Webview.Core 3271 * @since 9 3272 */ 3273 /** 3274 * Loads the data or URL. 3275 * 3276 * @param { string | Resource } url - The URL to load. 3277 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 3278 * @throws { BusinessError } 401 - Invalid input parameter. 3279 * @throws { BusinessError } 17100001 - Init error. 3280 * The WebviewController must be associated with a Web component. 3281 * @throws { BusinessError } 17100002 - Invalid url. 3282 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3283 * @syscap SystemCapability.Web.Webview.Core 3284 * @crossplatform 3285 * @since 10 3286 */ 3287 /** 3288 * Loads the data or URL. 3289 * 3290 * @param { string | Resource } url - The URL to load. 3291 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 3292 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3293 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3294 * @throws { BusinessError } 17100001 - Init error. 3295 * The WebviewController must be associated with a Web component. 3296 * @throws { BusinessError } 17100002 - Invalid url. 3297 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3298 * @syscap SystemCapability.Web.Webview.Core 3299 * @crossplatform 3300 * @atomicservice 3301 * @since 11 3302 */ 3303 loadUrl(url: string | Resource, headers?: Array<WebHeader>): void; 3304 3305 /** 3306 * Gets the type of HitTest. 3307 * @returns { WebHitTestType } The type of HitTest. 3308 * @throws { BusinessError } 17100001 - Init error. 3309 * The WebviewController must be associated with a Web component. 3310 * @syscap SystemCapability.Web.Webview.Core 3311 * @since 9 3312 */ 3313 /** 3314 * Gets the type of HitTest. 3315 * @returns { WebHitTestType } The type of HitTest. 3316 * @throws { BusinessError } 17100001 - Init error. 3317 * The WebviewController must be associated with a Web component. 3318 * @syscap SystemCapability.Web.Webview.Core 3319 * @atomicservice 3320 * @since 11 3321 */ 3322 getHitTest(): WebHitTestType; 3323 3324 /** 3325 * Stores the current page as a web archive. 3326 * 3327 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3328 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3329 * stored by the file name of baseName. If true, the file name is 3330 * automatically generated based on the current URL and stored in the file 3331 * directory of baseName. 3332 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 3333 * will either be the filename under which the file was stored, or empty 3334 * if storing the file failed. 3335 * @throws { BusinessError } 401 - Invalid input parameter. 3336 * @throws { BusinessError } 17100001 - Init error. 3337 * The WebviewController must be associated with a Web component. 3338 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3339 * @syscap SystemCapability.Web.Webview.Core 3340 * @since 9 3341 */ 3342 /** 3343 * Stores the current page as a web archive. 3344 * 3345 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3346 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3347 * stored by the file name of baseName. If true, the file name is 3348 * automatically generated based on the current URL and stored in the file 3349 * directory of baseName. 3350 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 3351 * will either be the filename under which the file was stored, or empty 3352 * if storing the file failed. 3353 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3354 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 3355 * @throws { BusinessError } 17100001 - Init error. 3356 * The WebviewController must be associated with a Web component. 3357 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3358 * @syscap SystemCapability.Web.Webview.Core 3359 * @atomicservice 3360 * @since 11 3361 */ 3362 storeWebArchive(baseName: string, autoName: boolean): Promise<string>; 3363 3364 /** 3365 * Stores the current page as a web archive. 3366 * 3367 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3368 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3369 * stored by the file name of baseName. If true, the file name is 3370 * automatically generated based on the current URL and stored in the file 3371 * directory of baseName. 3372 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 3373 * will either be the filename under which the file was stored, 3374 * or empty if storing the file failed. 3375 * @throws { BusinessError } 401 - Invalid input parameter. 3376 * @throws { BusinessError } 17100001 - Init error. 3377 * The WebviewController must be associated with a Web component. 3378 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3379 * @syscap SystemCapability.Web.Webview.Core 3380 * @since 9 3381 */ 3382 /** 3383 * Stores the current page as a web archive. 3384 * 3385 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3386 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3387 * stored by the file name of baseName. If true, the file name is 3388 * automatically generated based on the current URL and stored in the file 3389 * directory of baseName. 3390 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 3391 * will either be the filename under which the file was stored, 3392 * or empty if storing the file failed. 3393 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3394 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 3395 * @throws { BusinessError } 17100001 - Init error. 3396 * The WebviewController must be associated with a Web component. 3397 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3398 * @syscap SystemCapability.Web.Webview.Core 3399 * @atomicservice 3400 * @since 11 3401 */ 3402 storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback<string>): void; 3403 3404 /** 3405 * Let the Web zoom by. 3406 * 3407 * @param { number } factor - The zoom factor. 3408 * @throws { BusinessError } 401 - Invalid input parameter. 3409 * @throws { BusinessError } 17100001 - Init error. 3410 * The WebviewController must be associated with a Web component. 3411 * @throws { BusinessError } 17100004 - Function not enabled. 3412 * @syscap SystemCapability.Web.Webview.Core 3413 * @since 9 3414 */ 3415 /** 3416 * Let the Web zoom by. 3417 * 3418 * @param { number } factor - The zoom factor. 3419 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3420 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3421 * @throws { BusinessError } 17100001 - Init error. 3422 * The WebviewController must be associated with a Web component. 3423 * @throws { BusinessError } 17100004 - Function not enabled. 3424 * @syscap SystemCapability.Web.Webview.Core 3425 * @crossplatform 3426 * @atomicservice 3427 * @since 11 3428 */ 3429 zoom(factor: number): void; 3430 3431 /** 3432 * Let the Web zoom in. 3433 * 3434 * @throws { BusinessError } 17100001 - Init error. 3435 * The WebviewController must be associated with a Web component. 3436 * @throws { BusinessError } 17100004 - Function not enabled. 3437 * @syscap SystemCapability.Web.Webview.Core 3438 * @since 9 3439 */ 3440 /** 3441 * Let the Web zoom in. 3442 * 3443 * @throws { BusinessError } 17100001 - Init error. 3444 * The WebviewController must be associated with a Web component. 3445 * @throws { BusinessError } 17100004 - Function not enabled. 3446 * @syscap SystemCapability.Web.Webview.Core 3447 * @atomicservice 3448 * @since 11 3449 */ 3450 zoomIn(): void; 3451 3452 /** 3453 * Let the Web zoom out. 3454 * 3455 * @throws { BusinessError } 17100001 - Init error. 3456 * The WebviewController must be associated with a Web component. 3457 * @throws { BusinessError } 17100004 - Function not enabled. 3458 * @syscap SystemCapability.Web.Webview.Core 3459 * @since 9 3460 */ 3461 /** 3462 * Let the Web zoom out. 3463 * 3464 * @throws { BusinessError } 17100001 - Init error. 3465 * The WebviewController must be associated with a Web component. 3466 * @throws { BusinessError } 17100004 - Function not enabled. 3467 * @syscap SystemCapability.Web.Webview.Core 3468 * @atomicservice 3469 * @since 11 3470 */ 3471 zoomOut(): void; 3472 3473 /** 3474 * Gets the hit test value of HitTest. 3475 * @returns { HitTestValue } Return the element information of the clicked area. 3476 * @throws { BusinessError } 17100001 - Init error. 3477 * The WebviewController must be associated with a Web component. 3478 * @syscap SystemCapability.Web.Webview.Core 3479 * @since 9 3480 */ 3481 /** 3482 * Gets the hit test value of HitTest. 3483 * @returns { HitTestValue } Return the element information of the clicked area. 3484 * @throws { BusinessError } 17100001 - Init error. 3485 * The WebviewController must be associated with a Web component. 3486 * @syscap SystemCapability.Web.Webview.Core 3487 * @atomicservice 3488 * @since 11 3489 */ 3490 getHitTestValue(): HitTestValue; 3491 3492 /** 3493 * Gets the id for the current Web. 3494 * @returns { number } Returns the index value of the current Web component. 3495 * @throws { BusinessError } 17100001 - Init error. 3496 * The WebviewController must be associated with a Web component. 3497 * @syscap SystemCapability.Web.Webview.Core 3498 * @since 9 3499 */ 3500 /** 3501 * Gets the id for the current Web. 3502 * @returns { number } Returns the index value of the current Web component. 3503 * @throws { BusinessError } 17100001 - Init error. 3504 * The WebviewController must be associated with a Web component. 3505 * @syscap SystemCapability.Web.Webview.Core 3506 * @atomicservice 3507 * @since 11 3508 */ 3509 getWebId(): number; 3510 3511 /** 3512 * Gets the default user agent. 3513 * @returns { string } Return user agent information. 3514 * @throws { BusinessError } 17100001 - Init error. 3515 * The WebviewController must be associated with a Web component. 3516 * @syscap SystemCapability.Web.Webview.Core 3517 * @since 9 3518 */ 3519 /** 3520 * Gets the default user agent. 3521 * @returns { string } Return user agent information. 3522 * @throws { BusinessError } 17100001 - Init error. 3523 * The WebviewController must be associated with a Web component. 3524 * @syscap SystemCapability.Web.Webview.Core 3525 * @atomicservice 3526 * @since 11 3527 */ 3528 getUserAgent(): string; 3529 3530 /** 3531 * Gets the title of current Web page. 3532 * @returns { string } Return to File Selector Title. 3533 * @throws { BusinessError } 17100001 - Init error. 3534 * The WebviewController must be associated with a Web component. 3535 * @syscap SystemCapability.Web.Webview.Core 3536 * @since 9 3537 */ 3538 /** 3539 * Gets the title of current Web page. 3540 * @returns { string } Return to File Selector Title. 3541 * @throws { BusinessError } 17100001 - Init error. 3542 * The WebviewController must be associated with a Web component. 3543 * @syscap SystemCapability.Web.Webview.Core 3544 * @crossplatform 3545 * @atomicservice 3546 * @since 11 3547 */ 3548 getTitle(): string; 3549 3550 /** 3551 * Gets the content height of current Web page. 3552 * @returns { number } Returns the page height of the current page. 3553 * @throws { BusinessError } 17100001 - Init error. 3554 * The WebviewController must be associated with a Web component. 3555 * @syscap SystemCapability.Web.Webview.Core 3556 * @since 9 3557 */ 3558 /** 3559 * Gets the content height of current Web page. 3560 * @returns { number } Returns the page height of the current page. 3561 * @throws { BusinessError } 17100001 - Init error. 3562 * The WebviewController must be associated with a Web component. 3563 * @syscap SystemCapability.Web.Webview.Core 3564 * @crossplatform 3565 * @atomicservice 3566 * @since 11 3567 */ 3568 getPageHeight(): number; 3569 3570 /** 3571 * Goes forward or back backOrForward in the history of the web page. 3572 * 3573 * @param { number } step - Steps to go forward or backward. 3574 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3575 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3576 * @throws { BusinessError } 17100001 - Init error. 3577 * The WebviewController must be associated with a Web component. 3578 * @syscap SystemCapability.Web.Webview.Core 3579 * @since 9 3580 */ 3581 /** 3582 * Goes forward or back backOrForward in the history of the web page. 3583 * 3584 * @param { number } step - Steps to go forward or backward. 3585 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3586 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3587 * @throws { BusinessError } 17100001 - Init error. 3588 * The WebviewController must be associated with a Web component. 3589 * @syscap SystemCapability.Web.Webview.Core 3590 * @crossplatform 3591 * @atomicservice 3592 * @since 11 3593 */ 3594 backOrForward(step: number): void; 3595 3596 /** 3597 * Gets the request focus. 3598 * 3599 * @throws { BusinessError } 17100001 - Init error. 3600 * The WebviewController must be associated with a Web component. 3601 * @syscap SystemCapability.Web.Webview.Core 3602 * @since 9 3603 */ 3604 /** 3605 * Gets the request focus. 3606 * 3607 * @throws { BusinessError } 17100001 - Init error. 3608 * The WebviewController must be associated with a Web component. 3609 * @syscap SystemCapability.Web.Webview.Core 3610 * @atomicservice 3611 * @since 11 3612 */ 3613 requestFocus(): void; 3614 3615 /** 3616 * Create web message ports 3617 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 3618 * those ports to communication with html pages. 3619 * @throws { BusinessError } 17100001 - Init error. 3620 * The WebviewController must be associated with a Web component. 3621 * @syscap SystemCapability.Web.Webview.Core 3622 * @since 9 3623 */ 3624 /** 3625 * Create web message ports 3626 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 3627 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 3628 * those ports to communication with html pages. 3629 * @throws { BusinessError } 401 - Invalid input parameter. 3630 * @throws { BusinessError } 17100001 - Init error. 3631 * The WebviewController must be associated with a Web component. 3632 * @syscap SystemCapability.Web.Webview.Core 3633 * @since 10 3634 */ 3635 /** 3636 * Create web message ports 3637 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 3638 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 3639 * those ports to communication with html pages. 3640 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3641 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3642 * @throws { BusinessError } 17100001 - Init error. 3643 * The WebviewController must be associated with a Web component. 3644 * @syscap SystemCapability.Web.Webview.Core 3645 * @crossplatform 3646 * @atomicservice 3647 * @since 11 3648 */ 3649 createWebMessagePorts(isExtentionType?: boolean): Array<WebMessagePort>; 3650 3651 /** 3652 * Post web message port to html 3653 * 3654 * @param { string } name - Data name information to send. 3655 * @param { Array<WebMessagePort> } ports - Port number array information to send. 3656 * @param { string } uri - URI to receive this information. 3657 * @throws { BusinessError } 401 - Invalid input parameter. 3658 * @throws { BusinessError } 17100001 - Init error. 3659 * The WebviewController must be associated with a Web component. 3660 * @syscap SystemCapability.Web.Webview.Core 3661 * @since 9 3662 */ 3663 /** 3664 * Post web message port to html 3665 * 3666 * @param { string } name - Data name information to send. 3667 * @param { Array<WebMessagePort> } ports - Port number array information to send. 3668 * @param { string } uri - URI to receive this information. 3669 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3670 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3671 * @throws { BusinessError } 17100001 - Init error. 3672 * The WebviewController must be associated with a Web component. 3673 * @syscap SystemCapability.Web.Webview.Core 3674 * @crossplatform 3675 * @atomicservice 3676 * @since 11 3677 */ 3678 postMessage(name: string, ports: Array<WebMessagePort>, uri: string): void; 3679 3680 /** 3681 * Stops the current load. 3682 * 3683 * @throws { BusinessError } 17100001 - Init error. 3684 * The WebviewController must be associated with a Web component. 3685 * @syscap SystemCapability.Web.Webview.Core 3686 * @since 9 3687 */ 3688 /** 3689 * Stops the current load. 3690 * 3691 * @throws { BusinessError } 17100001 - Init error. 3692 * The WebviewController must be associated with a Web component. 3693 * @syscap SystemCapability.Web.Webview.Core 3694 * @crossplatform 3695 * @atomicservice 3696 * @since 11 3697 */ 3698 stop(): void; 3699 3700 /** 3701 * Registers the JavaScript object and method list. 3702 * 3703 * @param { object } object - Application side JavaScript objects participating in registration. 3704 * @param { string } name - The name of the registered object, which is consistent with the 3705 * object name called in the window. 3706 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 3707 * in the registration. 3708 * @throws { BusinessError } 401 - Invalid input parameter. 3709 * @throws { BusinessError } 17100001 - Init error. 3710 * The WebviewController must be associated with a Web component. 3711 * @syscap SystemCapability.Web.Webview.Core 3712 * @since 9 3713 */ 3714 /** 3715 * Registers the JavaScript object and method list. 3716 * 3717 * @param { object } object - Application side JavaScript objects participating in registration. 3718 * @param { string } name - The name of the registered object, which is consistent with the 3719 * object name called in the window. 3720 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 3721 * in the registration. 3722 * @throws { BusinessError } 401 - Invalid input parameter. 3723 * @throws { BusinessError } 17100001 - Init error. 3724 * The WebviewController must be associated with a Web component. 3725 * @syscap SystemCapability.Web.Webview.Core 3726 * @atomicservice 3727 * @since 11 3728 */ 3729 /** 3730 * Registers the JavaScript object and method list. 3731 * 3732 * @param { object } object - Application side JavaScript objects participating in registration. 3733 * @param { string } name - The name of the registered object, which is consistent with the 3734 * object name called in the window. 3735 * @param { Array<string> } methodList - The method of the application side JavaScript object participating 3736 * in the registration. 3737 * @param { Array<string> } [asyncMethodList] - The async method of the application side JavaScript object 3738 * participating in the registration. 3739 * @param { string } [permission] - permission configuration defining web page URLs that can access JavaScriptProxy methods. 3740 * The configuration can be defined at two levels, object level and method level. 3741 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3742 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3743 * @throws { BusinessError } 17100001 - Init error. 3744 * The WebviewController must be associated with a Web component. 3745 * @syscap SystemCapability.Web.Webview.Core 3746 * @atomicservice 3747 * @since 12 3748 */ 3749 registerJavaScriptProxy(object: object, name: string, methodList: Array<string>, 3750 asyncMethodList?: Array<string>, permission?: string): void; 3751 3752 /** 3753 * Deletes a registered JavaScript object with given name. 3754 * 3755 * @param { string } name - The name of a registered JavaScript object to be deleted. 3756 * @throws { BusinessError } 401 - Invalid input parameter. 3757 * @throws { BusinessError } 17100001 - Init error. 3758 * The WebviewController must be associated with a Web component. 3759 * @throws { BusinessError } 17100008 - Failed to delete JavaScriptProxy because it does not exist. 3760 * @syscap SystemCapability.Web.Webview.Core 3761 * @since 9 3762 */ 3763 /** 3764 * Deletes a registered JavaScript object with given name. 3765 * 3766 * @param { string } name - The name of a registered JavaScript object to be deleted. 3767 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3768 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3769 * @throws { BusinessError } 17100001 - Init error. 3770 * The WebviewController must be associated with a Web component. 3771 * @throws { BusinessError } 17100008 - Failed to delete JavaScriptProxy because it does not exist. 3772 * @syscap SystemCapability.Web.Webview.Core 3773 * @atomicservice 3774 * @since 11 3775 */ 3776 deleteJavaScriptRegister(name: string): void; 3777 3778 /** 3779 * Search all instances of 'searchString' on the page and highlights them, 3780 * result will be notify through callback onSearchResultReceive. 3781 * 3782 * @param { string } searchString - String to be search. 3783 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3784 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3785 * @throws { BusinessError } 17100001 - Init error. 3786 * The WebviewController must be associated with a Web component. 3787 * @syscap SystemCapability.Web.Webview.Core 3788 * @since 9 3789 */ 3790 /** 3791 * Search all instances of 'searchString' on the page and highlights them, 3792 * result will be notify through callback onSearchResultReceive. 3793 * 3794 * @param { string } searchString - String to be search. 3795 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3796 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3797 * @throws { BusinessError } 17100001 - Init error. 3798 * The WebviewController must be associated with a Web component. 3799 * @syscap SystemCapability.Web.Webview.Core 3800 * @atomicservice 3801 * @since 11 3802 */ 3803 searchAllAsync(searchString: string): void; 3804 3805 /** 3806 * Clears the highlighting surrounding text matches created by searchAllAsync. 3807 * 3808 * @throws { BusinessError } 17100001 - Init error. 3809 * The WebviewController must be associated with a Web component. 3810 * @syscap SystemCapability.Web.Webview.Core 3811 * @since 9 3812 */ 3813 /** 3814 * Clears the highlighting surrounding text matches created by searchAllAsync. 3815 * 3816 * @throws { BusinessError } 17100001 - Init error. 3817 * The WebviewController must be associated with a Web component. 3818 * @syscap SystemCapability.Web.Webview.Core 3819 * @atomicservice 3820 * @since 11 3821 */ 3822 clearMatches(): void; 3823 3824 /** 3825 * Highlights and scrolls to the next match search. 3826 * 3827 * @param { boolean } forward - Step of search is back or forward. 3828 * @throws { BusinessError } 401 - Invalid input parameter. 3829 * @throws { BusinessError } 17100001 - Init error. 3830 * The WebviewController must be associated with a Web component. 3831 * @syscap SystemCapability.Web.Webview.Core 3832 * @since 9 3833 */ 3834 /** 3835 * Highlights and scrolls to the next match search. 3836 * 3837 * @param { boolean } forward - Step of search is back or forward. 3838 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3839 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3840 * @throws { BusinessError } 17100001 - Init error. 3841 * The WebviewController must be associated with a Web component. 3842 * @syscap SystemCapability.Web.Webview.Core 3843 * @atomicservice 3844 * @since 11 3845 */ 3846 searchNext(forward: boolean): void; 3847 3848 /** 3849 * Clears the ssl cache in the Web. 3850 * 3851 * @throws { BusinessError } 17100001 - Init error. 3852 * The WebviewController must be associated with a Web component. 3853 * @syscap SystemCapability.Web.Webview.Core 3854 * @since 9 3855 */ 3856 /** 3857 * Clears the ssl cache in the Web. 3858 * 3859 * @throws { BusinessError } 17100001 - Init error. 3860 * The WebviewController must be associated with a Web component. 3861 * @syscap SystemCapability.Web.Webview.Core 3862 * @atomicservice 3863 * @since 11 3864 */ 3865 clearSslCache(): void; 3866 3867 /** 3868 * Clears the client authentication certificate cache in the Web. 3869 * 3870 * @throws { BusinessError } 17100001 - Init error. 3871 * The WebviewController must be associated with a Web component. 3872 * @syscap SystemCapability.Web.Webview.Core 3873 * @since 9 3874 */ 3875 /** 3876 * Clears the client authentication certificate cache in the Web. 3877 * 3878 * @throws { BusinessError } 17100001 - Init error. 3879 * The WebviewController must be associated with a Web component. 3880 * @syscap SystemCapability.Web.Webview.Core 3881 * @atomicservice 3882 * @since 11 3883 */ 3884 clearClientAuthenticationCache(): void; 3885 3886 /** 3887 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3888 * 3889 * @param { string } script - JavaScript Script. 3890 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 3891 * This parameter will be the result of JavaScript script execution. 3892 * If the JavaScript script fails to execute or has no return value, 3893 * null will be returned. 3894 * @throws { BusinessError } 401 - Invalid input parameter. 3895 * @throws { BusinessError } 17100001 - Init error. 3896 * The WebviewController must be associated with a Web component. 3897 * @syscap SystemCapability.Web.Webview.Core 3898 * @since 9 3899 */ 3900 /** 3901 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3902 * 3903 * @param { string } script - JavaScript Script. 3904 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 3905 * This parameter will be the result of JavaScript script execution. 3906 * If the JavaScript script fails to execute or has no return value, 3907 * null will be returned. 3908 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3909 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3910 * @throws { BusinessError } 17100001 - Init error. 3911 * The WebviewController must be associated with a Web component. 3912 * @syscap SystemCapability.Web.Webview.Core 3913 * @crossplatform 3914 * @atomicservice 3915 * @since 11 3916 */ 3917 runJavaScript(script: string): Promise<string>; 3918 3919 /** 3920 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3921 * 3922 * @param { string } script - JavaScript Script. 3923 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 3924 * @throws { BusinessError } 401 - Invalid input parameter. 3925 * @throws { BusinessError } 17100001 - Init error. 3926 * The WebviewController must be associated with a Web component. 3927 * @syscap SystemCapability.Web.Webview.Core 3928 * @since 9 3929 */ 3930 /** 3931 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3932 * 3933 * @param { string } script - JavaScript Script. 3934 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 3935 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3936 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3937 * @throws { BusinessError } 17100001 - Init error. 3938 * The WebviewController must be associated with a Web component. 3939 * @syscap SystemCapability.Web.Webview.Core 3940 * @crossplatform 3941 * @atomicservice 3942 * @since 11 3943 */ 3944 runJavaScript(script: string, callback: AsyncCallback<string>): void; 3945 3946 /** 3947 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3948 * 3949 * @param { string } script - JavaScript Script. 3950 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3951 * This parameter will be the result of JavaScript script execution. 3952 * If the JavaScript script fails to execute or has no return value, 3953 * a none type value will be returned. 3954 * @throws { BusinessError } 401 - Invalid input parameter. 3955 * @throws { BusinessError } 17100001 - Init error. 3956 * The WebviewController must be associated with a Web component. 3957 * @syscap SystemCapability.Web.Webview.Core 3958 * @since 10 3959 */ 3960 /** 3961 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3962 * 3963 * @param { string } script - JavaScript Script. 3964 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3965 * This parameter will be the result of JavaScript script execution. 3966 * If the JavaScript script fails to execute or has no return value, 3967 * a none type value will be returned. 3968 * @throws { BusinessError } 401 - Invalid input parameter. 3969 * @throws { BusinessError } 17100001 - Init error. 3970 * The WebviewController must be associated with a Web component. 3971 * @syscap SystemCapability.Web.Webview.Core 3972 * @atomicservice 3973 * @since 11 3974 */ 3975 /** 3976 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3977 * 3978 * @param { string | ArrayBuffer } script - JavaScript Script. 3979 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3980 * This parameter will be the result of JavaScript script execution. 3981 * If the JavaScript script fails to execute or has no return value, 3982 * a none type value will be returned. 3983 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3984 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3985 * @throws { BusinessError } 17100001 - Init error. 3986 * The WebviewController must be associated with a Web component. 3987 * @syscap SystemCapability.Web.Webview.Core 3988 * @atomicservice 3989 * @since 12 3990 */ 3991 runJavaScriptExt(script: string | ArrayBuffer): Promise<JsMessageExt>; 3992 3993 /** 3994 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3995 * 3996 * @param { string } script - JavaScript Script. 3997 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 3998 * @throws { BusinessError } 401 - Invalid input parameter. 3999 * @throws { BusinessError } 17100001 - Init error. 4000 * The WebviewController must be associated with a Web component. 4001 * @syscap SystemCapability.Web.Webview.Core 4002 * @since 10 4003 */ 4004 /** 4005 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4006 * 4007 * @param { string } script - JavaScript Script. 4008 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 4009 * @throws { BusinessError } 401 - Invalid input parameter. 4010 * @throws { BusinessError } 17100001 - Init error. 4011 * The WebviewController must be associated with a Web component. 4012 * @syscap SystemCapability.Web.Webview.Core 4013 * @atomicservice 4014 * @since 11 4015 */ 4016 /** 4017 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4018 * 4019 * @param { string | ArrayBuffer } script - JavaScript Script. 4020 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 4021 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4022 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4023 * @throws { BusinessError } 17100001 - Init error. 4024 * The WebviewController must be associated with a Web component. 4025 * @syscap SystemCapability.Web.Webview.Core 4026 * @atomicservice 4027 * @since 12 4028 */ 4029 runJavaScriptExt(script: string | ArrayBuffer, callback: AsyncCallback<JsMessageExt>): void; 4030 4031 /** 4032 * Execute createPdf code in the context of the currently displayed page and return the result. 4033 * 4034 * @param { PdfConfiguration } configuration - createPdf configuration. 4035 * @param { AsyncCallback<PdfData> } callback - Callbacks execute createPdf results. 4036 * @throws { BusinessError } 401 - Invalid input parameter. 4037 * @throws { BusinessError } 17100001 - Init error. 4038 * The WebviewController must be associated with a Web component. 4039 * @syscap SystemCapability.Web.Webview.Core 4040 * @atomicservice 4041 * @since 14 4042 */ 4043 createPdf(configuration: PdfConfiguration, callback: AsyncCallback<PdfData>): void; 4044 4045 /** 4046 * Execute createPdf code in the context of the currently displayed page and return the result. 4047 * 4048 * @param { PdfConfiguration } configuration - createPdf configuration. 4049 * @returns { Promise<PdfData> } A promise is solved after the createPdf is executed. 4050 * This parameter will be the result of createPdf execution. 4051 * If the createPdf fails to execute or has no return value, 4052 * a none type value will be returned. 4053 * @throws { BusinessError } 401 - Invalid input parameter. 4054 * @throws { BusinessError } 17100001 - Init error. 4055 * The WebviewController must be associated with a Web component. 4056 * @syscap SystemCapability.Web.Webview.Core 4057 * @atomicservice 4058 * @since 14 4059 */ 4060 createPdf(configuration: PdfConfiguration): Promise<PdfData>; 4061 4062 /** 4063 * Gets the url of current Web page. 4064 * @returns { string } Return the url of the current page. 4065 * @throws { BusinessError } 17100001 - Init error. 4066 * The WebviewController must be associated with a Web component. 4067 * @syscap SystemCapability.Web.Webview.Core 4068 * @since 9 4069 */ 4070 /** 4071 * Gets the url of current Web page. 4072 * @returns { string } Return the url of the current page. 4073 * @throws { BusinessError } 17100001 - Init error. 4074 * The WebviewController must be associated with a Web component. 4075 * @syscap SystemCapability.Web.Webview.Core 4076 * @crossplatform 4077 * @atomicservice 4078 * @since 11 4079 */ 4080 getUrl(): string; 4081 4082 /** 4083 * Scroll the contents of this Webview up by half the view size. 4084 * 4085 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 4086 * the page content will scroll up half the size of the viewframe, 4087 * and when set to true, it will jump to the top of the page. 4088 * @throws { BusinessError } 401 - Invalid input parameter. 4089 * @throws { BusinessError } 17100001 - Init error. 4090 * The WebviewController must be associated with a Web component. 4091 * @syscap SystemCapability.Web.Webview.Core 4092 * @since 9 4093 */ 4094 /** 4095 * Scroll the contents of this Webview up by half the view size. 4096 * 4097 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 4098 * the page content will scroll up half the size of the viewframe, 4099 * and when set to true, it will jump to the top of the page. 4100 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4101 * <br>2. Incorrect parameter types. 4102 * @throws { BusinessError } 17100001 - Init error. 4103 * The WebviewController must be associated with a Web component. 4104 * @syscap SystemCapability.Web.Webview.Core 4105 * @atomicservice 4106 * @since 11 4107 */ 4108 pageUp(top: boolean): void; 4109 4110 /** 4111 * Scroll the contents of this Webview down by half the view size. 4112 * 4113 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 4114 * the page content will scroll up half the size of the viewframe, 4115 * and when set to true, it will jump to the top of the page. 4116 * @throws { BusinessError } 401 - Invalid input parameter. 4117 * @throws { BusinessError } 17100001 - Init error. 4118 * The WebviewController must be associated with a Web component. 4119 * @syscap SystemCapability.Web.Webview.Core 4120 * @since 9 4121 */ 4122 /** 4123 * Scroll the contents of this Webview down by half the view size. 4124 * 4125 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 4126 * the page content will scroll up half the size of the viewframe, 4127 * and when set to true, it will jump to the top of the page. 4128 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4129 * <br>2. Incorrect parameter types. 4130 * @throws { BusinessError } 17100001 - Init error. 4131 * The WebviewController must be associated with a Web component. 4132 * @syscap SystemCapability.Web.Webview.Core 4133 * @atomicservice 4134 * @since 11 4135 */ 4136 pageDown(bottom: boolean): void; 4137 4138 /** 4139 * Gets the original url of current Web page. 4140 * @returns { string } Return the original url of the current page. 4141 * @throws { BusinessError } 17100001 - Init error. 4142 * The WebviewController must be associated with a Web component. 4143 * @syscap SystemCapability.Web.Webview.Core 4144 * @since 9 4145 */ 4146 /** 4147 * Gets the original url of current Web page. 4148 * @returns { string } Return the original url of the current page. 4149 * @throws { BusinessError } 17100001 - Init error. 4150 * The WebviewController must be associated with a Web component. 4151 * @syscap SystemCapability.Web.Webview.Core 4152 * @atomicservice 4153 * @since 11 4154 */ 4155 getOriginalUrl(): string; 4156 4157 /** 4158 * Gets the favicon of current Web page. 4159 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 4160 * @throws { BusinessError } 17100001 - Init error. 4161 * The WebviewController must be associated with a Web component. 4162 * @syscap SystemCapability.Web.Webview.Core 4163 * @since 9 4164 */ 4165 /** 4166 * Gets the favicon of current Web page. 4167 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 4168 * @throws { BusinessError } 17100001 - Init error. 4169 * The WebviewController must be associated with a Web component. 4170 * @syscap SystemCapability.Web.Webview.Core 4171 * @atomicservice 4172 * @since 11 4173 */ 4174 getFavicon(): image.PixelMap; 4175 4176 /** 4177 * Put network state for web. Which is used to set window.navigator.onLine property in 4178 * JavaScript. 4179 * @param { boolean } enable - Whether enable window.navigator.onLine. 4180 * @throws { BusinessError } 401 - Invalid input parameter. 4181 * @throws { BusinessError } 17100001 - Init error. 4182 * The WebviewController must be associated with a Web component. 4183 * @syscap SystemCapability.Web.Webview.Core 4184 * @since 9 4185 */ 4186 /** 4187 * Put network state for web. Which is used to set window.navigator.onLine property in 4188 * JavaScript. 4189 * @param { boolean } enable - Whether enable window.navigator.onLine. 4190 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4191 * <br>2. Incorrect parameter types. 4192 * @throws { BusinessError } 17100001 - Init error. 4193 * The WebviewController must be associated with a Web component. 4194 * @syscap SystemCapability.Web.Webview.Core 4195 * @atomicservice 4196 * @since 11 4197 */ 4198 setNetworkAvailable(enable: boolean): void; 4199 4200 /** 4201 * Query if current document has image. 4202 * 4203 * @returns { Promise<boolean> } A promise resolved after query image has finished. 4204 * @throws { BusinessError } 401 - Invalid input parameter. 4205 * @throws { BusinessError } 17100001 - Init error. 4206 * The WebviewController must be associated with a Web component. 4207 * @syscap SystemCapability.Web.Webview.Core 4208 * @since 9 4209 */ 4210 /** 4211 * Query if current document has image. 4212 * 4213 * @returns { Promise<boolean> } A promise resolved after query image has finished. 4214 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4215 * @throws { BusinessError } 17100001 - Init error. 4216 * The WebviewController must be associated with a Web component. 4217 * @syscap SystemCapability.Web.Webview.Core 4218 * @atomicservice 4219 * @since 11 4220 */ 4221 hasImage(): Promise<boolean>; 4222 4223 /** 4224 * Query if current document has image. 4225 * 4226 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 4227 * @throws { BusinessError } 401 - Invalid input parameter. 4228 * @throws { BusinessError } 17100001 - Init error. 4229 * The WebviewController must be associated with a Web component. 4230 * @syscap SystemCapability.Web.Webview.Core 4231 * @since 9 4232 */ 4233 /** 4234 * Query if current document has image. 4235 * 4236 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 4237 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4238 * <br>2. Incorrect parameter types. 4239 * @throws { BusinessError } 17100001 - Init error. 4240 * The WebviewController must be associated with a Web component. 4241 * @syscap SystemCapability.Web.Webview.Core 4242 * @atomicservice 4243 * @since 11 4244 */ 4245 hasImage(callback: AsyncCallback<boolean>): void; 4246 4247 /** 4248 * Get back forward stack list from current webview. 4249 * @returns { BackForwardList } Back forward list for current webview. 4250 * @throws { BusinessError } 17100001 - Init error. 4251 * The WebviewController must be associated with a Web component. 4252 * @syscap SystemCapability.Web.Webview.Core 4253 * @since 9 4254 */ 4255 /** 4256 * Get back forward stack list from current webview. 4257 * @returns { BackForwardList } Back forward list for current webview. 4258 * @throws { BusinessError } 17100001 - Init error. 4259 * The WebviewController must be associated with a Web component. 4260 * @syscap SystemCapability.Web.Webview.Core 4261 * @crossplatform 4262 * @atomicservice 4263 * @since 11 4264 */ 4265 getBackForwardEntries(): BackForwardList; 4266 4267 /** 4268 * Remove resource cache in application. So this method will remove all cache for all web components in the 4269 * same application. 4270 * 4271 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 4272 * in ram. 4273 * @throws { BusinessError } 401 - Invalid input parameter. 4274 * @throws { BusinessError } 17100001 - Init error. 4275 * The WebviewController must be associated with a Web component. 4276 * @syscap SystemCapability.Web.Webview.Core 4277 * @since 9 4278 */ 4279 /** 4280 * Remove resource cache in application. So this method will remove all cache for all web components in the 4281 * same application. 4282 * 4283 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 4284 * in ram. 4285 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4286 * <br>2. Incorrect parameter types. 4287 * @throws { BusinessError } 17100001 - Init error. 4288 * The WebviewController must be associated with a Web component. 4289 * @syscap SystemCapability.Web.Webview.Core 4290 * @crossplatform 4291 * @atomicservice 4292 * @since 11 4293 */ 4294 removeCache(clearRom: boolean): void; 4295 4296 /** 4297 * Scroll to the position. 4298 * 4299 * @param { number } x - the x of the position. 4300 * @param { number } y - the y of the position. 4301 * @throws { BusinessError } 401 - Invalid input parameter. 4302 * @throws { BusinessError } 17100001 - Init error. 4303 * The WebviewController must be associated with a Web component. 4304 * @syscap SystemCapability.Web.Webview.Core 4305 * @since 9 4306 */ 4307 /** 4308 * Scroll to the position. 4309 * 4310 * @param { number } x - the x of the position. 4311 * @param { number } y - the y of the position. 4312 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4313 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4314 * @throws { BusinessError } 17100001 - Init error. 4315 * The WebviewController must be associated with a Web component. 4316 * @syscap SystemCapability.Web.Webview.Core 4317 * @crossplatform 4318 * @atomicservice 4319 * @since 11 4320 */ 4321 /** 4322 * Scroll to the position. 4323 * 4324 * @param { number } x - the x of the position. 4325 * @param { number } y - the y of the position. 4326 * @param { number } duration - the scroll animation duration. Unit: millisecond. 4327 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4328 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4329 * @throws { BusinessError } 17100001 - Init error. 4330 * The WebviewController must be associated with a Web component. 4331 * @syscap SystemCapability.Web.Webview.Core 4332 * @crossplatform 4333 * @atomicservice 4334 * @since 14 4335 */ 4336 scrollTo(x: number, y: number, duration?: number): void; 4337 4338 /** 4339 * Scroll by the delta position. 4340 * 4341 * @param { number } deltaX - the delta x of the position. 4342 * @param { number } deltaY - the delta y of the position. 4343 * @throws { BusinessError } 401 - Invalid input parameter. 4344 * @throws { BusinessError } 17100001 - Init error. 4345 * The WebviewController must be associated with a Web component. 4346 * @syscap SystemCapability.Web.Webview.Core 4347 * @since 9 4348 */ 4349 /** 4350 * Scroll by the delta position. 4351 * 4352 * @param { number } deltaX - the delta x of the position. 4353 * @param { number } deltaY - the delta y of the position. 4354 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4355 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4356 * @throws { BusinessError } 17100001 - Init error. 4357 * The WebviewController must be associated with a Web component. 4358 * @syscap SystemCapability.Web.Webview.Core 4359 * @crossplatform 4360 * @atomicservice 4361 * @since 11 4362 */ 4363 /** 4364 * Scroll by the delta position. 4365 * 4366 * @param { number } deltaX - the delta x of the position. 4367 * @param { number } deltaY - the delta y of the position. 4368 * @param { number } duration - the scroll animation duration. Unit: millisecond. 4369 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4370 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4371 * @throws { BusinessError } 17100001 - Init error. 4372 * The WebviewController must be associated with a Web component. 4373 * @syscap SystemCapability.Web.Webview.Core 4374 * @crossplatform 4375 * @atomicservice 4376 * @since 14 4377 */ 4378 scrollBy(deltaX: number, deltaY: number, duration?: number): void; 4379 4380 /** 4381 * Slide by the speed. 4382 * 4383 * @param { number } vx - the x speed of the speed. 4384 * @param { number } vy - the y speed of the speed. 4385 * @throws { BusinessError } 401 - Invalid input parameter. 4386 * @throws { BusinessError } 17100001 - Init error. 4387 * The WebviewController must be associated with a Web component. 4388 * @syscap SystemCapability.Web.Webview.Core 4389 * @since 9 4390 */ 4391 /** 4392 * Slide by the speed. 4393 * 4394 * @param { number } vx - the x speed of the speed. 4395 * @param { number } vy - the y speed of the speed. 4396 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4397 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 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 slideScroll(vx: number, vy: number): void; 4405 4406 /** 4407 * Serialize the access stack of the web, that is, the history of access. 4408 * @returns { Uint8Array } Web access stack after serialization. 4409 * @throws { BusinessError } 17100001 - Init error. 4410 * The WebviewController must be associated with a Web component. 4411 * @syscap SystemCapability.Web.Webview.Core 4412 * @since 9 4413 */ 4414 /** 4415 * Serialize the access stack of the web, that is, the history of access. 4416 * @returns { Uint8Array } Web access stack after serialization. 4417 * @throws { BusinessError } 17100001 - Init error. 4418 * The WebviewController must be associated with a Web component. 4419 * @syscap SystemCapability.Web.Webview.Core 4420 * @atomicservice 4421 * @since 11 4422 */ 4423 serializeWebState(): Uint8Array; 4424 4425 /** 4426 * Restoring the web access stack, that is, the history of access. 4427 * @param { Uint8Array } state - Web access stack after serialization. 4428 * @throws { BusinessError } 401 - Invalid input parameter. 4429 * @throws { BusinessError } 17100001 - Init error. 4430 * The WebviewController must be associated with a Web component. 4431 * @syscap SystemCapability.Web.Webview.Core 4432 * @since 9 4433 */ 4434 /** 4435 * Restoring the web access stack, that is, the history of access. 4436 * @param { Uint8Array } state - Web access stack after serialization. 4437 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4438 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4439 * @throws { BusinessError } 17100001 - Init error. 4440 * The WebviewController must be associated with a Web component. 4441 * @syscap SystemCapability.Web.Webview.Core 4442 * @atomicservice 4443 * @since 11 4444 */ 4445 restoreWebState(state: Uint8Array): void; 4446 4447 /** 4448 * Set whether the Web custom scheme supports cross domain and fetch requests. 4449 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 4450 * @throws { BusinessError } 401 - Invalid input parameter. 4451 * @syscap SystemCapability.Web.Webview.Core 4452 * @since 9 4453 */ 4454 /** 4455 * Set whether the Web custom scheme supports cross domain and fetch requests. 4456 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 4457 * @throws { BusinessError } 401 - Invalid input parameter. 4458 * @syscap SystemCapability.Web.Webview.Core 4459 * @atomicservice 4460 * @since 11 4461 */ 4462 /** 4463 * Register Web custom schemes. 4464 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 4465 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4466 * <br>2. Incorrect parameter types. 4467 * @throws { BusinessError } 17100020 - Failed to register custom schemes. 4468 * @syscap SystemCapability.Web.Webview.Core 4469 * @atomicservice 4470 * @since 12 4471 */ 4472 static customizeSchemes(schemes: Array<WebCustomScheme>): void; 4473 4474 /** 4475 * Get certificate for the current website. 4476 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 4477 * @throws { BusinessError } 17100001 - Init error. 4478 * The WebviewController must be associated with a web component. 4479 * @syscap SystemCapability.Web.Webview.Core 4480 * @since 10 4481 */ 4482 /** 4483 * Get certificate for the current website. 4484 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 4485 * @throws { BusinessError } 17100001 - Init error. 4486 * The WebviewController must be associated with a web component. 4487 * @syscap SystemCapability.Web.Webview.Core 4488 * @atomicservice 4489 * @since 11 4490 */ 4491 getCertificate(): Promise<Array<cert.X509Cert>>; 4492 4493 /** 4494 * Get certificate for the current website. 4495 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 4496 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4497 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4498 * @throws { BusinessError } 17100001 - Init error. 4499 * The WebviewController must be associated with a web component. 4500 * @syscap SystemCapability.Web.Webview.Core 4501 * @since 10 4502 */ 4503 /** 4504 * Get certificate for the current website. 4505 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 4506 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4507 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4508 * @throws { BusinessError } 17100001 - Init error. 4509 * The WebviewController must be associated with a web component. 4510 * @syscap SystemCapability.Web.Webview.Core 4511 * @atomicservice 4512 * @since 11 4513 */ 4514 getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void; 4515 4516 /** 4517 * Set audio muted. 4518 * @param { boolean } mute - Set the audio muted or not. 4519 * @throws { BusinessError } 401 - Invalid input parameter. 4520 * @throws { BusinessError } 17100001 - Init error. 4521 * The WebviewController must be associated with a Web component. 4522 * @syscap SystemCapability.Web.Webview.Core 4523 * @since 10 4524 */ 4525 /** 4526 * Set audio muted. 4527 * @param { boolean } mute - Set the audio muted or not. 4528 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4529 * <br>2. Incorrect parameter types. 4530 * @throws { BusinessError } 17100001 - Init error. 4531 * The WebviewController must be associated with a Web component. 4532 * @syscap SystemCapability.Web.Webview.Core 4533 * @atomicservice 4534 * @since 11 4535 */ 4536 setAudioMuted(mute: boolean): void; 4537 4538 /** 4539 * Prefetch the resources required by the page, but will not execute js or render the page. 4540 * @param { string } url - Which url to preresolve/preconnect. 4541 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 4542 * @throws { BusinessError } 17100001 - Init error. 4543 * The WebviewController must be associated with a Web component. 4544 * @throws { BusinessError } 17100002 - Invalid url. 4545 * @syscap SystemCapability.Web.Webview.Core 4546 * @since 10 4547 */ 4548 /** 4549 * Prefetch the resources required by the page, but will not execute js or render the page. 4550 * @param { string } url - Which url to preresolve/preconnect. 4551 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 4552 * @throws { BusinessError } 17100001 - Init error. 4553 * The WebviewController must be associated with a Web component. 4554 * @throws { BusinessError } 17100002 - Invalid url. 4555 * @syscap SystemCapability.Web.Webview.Core 4556 * @atomicservice 4557 * @since 11 4558 */ 4559 prefetchPage(url: string, additionalHeaders?: Array<WebHeader>): void; 4560 4561 /** 4562 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 4563 * @param { string } url - Which url to preresolve/preconnect. 4564 * @param { boolean } preconnectable - Indicates whether to preconnect. 4565 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 4566 * @throws { BusinessError } 17100002 - Invalid url. 4567 * @throws { BusinessError } 171000013 - The number of preconnect sockets is invalid. 4568 * @syscap SystemCapability.Web.Webview.Core 4569 * @since 10 4570 */ 4571 /** 4572 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 4573 * @param { string } url - Which url to preresolve/preconnect. 4574 * @param { boolean } preconnectable - Indicates whether to preconnect. 4575 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 4576 * @throws { BusinessError } 17100002 - Invalid url. 4577 * @throws { BusinessError } 171000013 - The number of preconnect sockets is invalid. 4578 * @syscap SystemCapability.Web.Webview.Core 4579 * @atomicservice 4580 * @since 11 4581 */ 4582 static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void; 4583 4584 /** 4585 * Set custom user agent. 4586 * @param { string } userAgent - User custom agent information. 4587 * @throws { BusinessError } 401 - Invalid input parameter. 4588 * @throws { BusinessError } 17100001 - Init error. 4589 * The WebviewController must be associated with a Web component. 4590 * @syscap SystemCapability.Web.Webview.Core 4591 * @since 10 4592 */ 4593 /** 4594 * Set custom user agent. 4595 * @param { string } userAgent - User custom agent information. 4596 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4597 * <br>2. Incorrect parameter types. 4598 * @throws { BusinessError } 17100001 - Init error. 4599 * The WebviewController must be associated with a Web component. 4600 * @syscap SystemCapability.Web.Webview.Core 4601 * @crossplatform 4602 * @atomicservice 4603 * @since 11 4604 */ 4605 setCustomUserAgent(userAgent: string): void; 4606 4607 /** 4608 * Get custom user agent. 4609 * @returns { string } Get custom User agent information. 4610 * @throws { BusinessError } 17100001 - Init error. 4611 * The WebviewController must be associated with a Web component. 4612 * @syscap SystemCapability.Web.Webview.Core 4613 * @since 10 4614 */ 4615 /** 4616 * Get custom user agent. 4617 * @returns { string } Get custom User agent information. 4618 * @throws { BusinessError } 17100001 - Init error. 4619 * The WebviewController must be associated with a Web component. 4620 * @syscap SystemCapability.Web.Webview.Core 4621 * @crossplatform 4622 * @atomicservice 4623 * @since 11 4624 */ 4625 getCustomUserAgent(): string; 4626 4627 /** 4628 * Set web engine socket connection timeout. 4629 * @param { number } timeout - Socket connection timeout. 4630 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4631 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 4632 * @syscap SystemCapability.Web.Webview.Core 4633 * @atomicservice 4634 * @since 11 4635 */ 4636 static setConnectionTimeout(timeout: number): void; 4637 4638 /** 4639 * Set delegate for download. 4640 * Used to notify the progress of the download triggered from web. 4641 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from web. 4642 * @throws { BusinessError } 17100001 - Init error. 4643 * The WebviewController must be associated with a Web component. 4644 * @syscap SystemCapability.Web.Webview.Core 4645 * @atomicservice 4646 * @since 11 4647 */ 4648 setDownloadDelegate(delegate: WebDownloadDelegate): void; 4649 4650 /** 4651 * Start a download. 4652 * @param { string } url - The download url. 4653 * @throws { BusinessError } 17100001 - Init error. 4654 * The WebviewController must be associated with a Web component. 4655 * @throws { BusinessError } 17100002 - Invalid url. 4656 * @syscap SystemCapability.Web.Webview.Core 4657 * @atomicservice 4658 * @since 11 4659 */ 4660 startDownload(url: string): void; 4661 4662 /** 4663 * Loads the URL use "POST" method with post data. 4664 * 4665 * @param { string } url - Request the URL use "POST" method. 4666 * @param { ArrayBuffer } postData - This data will passed to "POST" request. 4667 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4668 * <br>2. Incorrect parameter types. 4669 * @throws { BusinessError } 17100001 - Init error. 4670 * The WebviewController must be associated with a Web component. 4671 * @throws { BusinessError } 17100002 - Invalid url. 4672 * @syscap SystemCapability.Web.Webview.Core 4673 * @atomicservice 4674 * @since 11 4675 */ 4676 postUrl(url: string, postData: ArrayBuffer): void; 4677 4678 /** 4679 * Create the Web Print Document Adapter. 4680 * @param { string } jobName - The name of the currently printed document. 4681 * @returns { print.PrintDocumentAdapter } Return the Print Document Adapter. 4682 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4683 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4684 * @throws { BusinessError } 17100001 - Init error. 4685 * The WebviewController must be associated with a Web component. 4686 * @syscap SystemCapability.Web.Webview.Core 4687 * @since 11 4688 */ 4689 createWebPrintDocumentAdapter(jobName: string): print.PrintDocumentAdapter; 4690 4691 /** 4692 * Get the security level of the current page. 4693 * 4694 * @returns { SecurityLevel } the security level of current page. 4695 * @throws { BusinessError } 17100001 - Init error. 4696 * The WebviewController must be associated with a Web component. 4697 * @syscap SystemCapability.Web.Webview.Core 4698 * @atomicservice 4699 * @since 11 4700 */ 4701 getSecurityLevel(): SecurityLevel; 4702 4703 /** 4704 * Whether the incognito mode is set. 4705 * 4706 * @returns { boolean } {@code true} has been set the incognito mode; {@code false} otherwise. 4707 * @throws { BusinessError } 17100001 - Init error. 4708 * The WebviewController must be associated with a Web component. 4709 * @syscap SystemCapability.Web.Webview.Core 4710 * @atomicservice 4711 * @since 11 4712 */ 4713 isIncognitoMode(): boolean; 4714 4715 /** 4716 * Set whether scroll is allowed 4717 * 4718 * @param { boolean } enable - Set whether scrolling is allowed 4719 * @param { ScrollType } type - Enable scrolling type 4720 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4721 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4722 * @throws { BusinessError } 17100001 - Init error. 4723 * The WebviewController must be associated with a Web component. 4724 * @syscap SystemCapability.Web.Webview.Core 4725 * @atomicservice 4726 * @since 12 4727 */ 4728 setScrollable(enable: boolean, type?: ScrollType): void; 4729 4730 /** 4731 * Get whether scrolling is allowed. 4732 * @returns { boolean } Get scrolling is allowed information. 4733 * @throws { BusinessError } 17100001 - Init error. 4734 * The WebviewController must be associated with a Web component. 4735 * @syscap SystemCapability.Web.Webview.Core 4736 * @atomicservice 4737 * @since 12 4738 */ 4739 getScrollable(): boolean; 4740 4741 /** 4742 * Set whether print web page background. 4743 * 4744 * @param { boolean } enable - Set whether print web page background 4745 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4746 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4747 * @throws { BusinessError } 17100001 - Init error. 4748 * The WebviewController must be associated with a Web component. 4749 * @syscap SystemCapability.Web.Webview.Core 4750 * @atomicservice 4751 * @since 12 4752 */ 4753 setPrintBackground(enable: boolean): void; 4754 4755 /** 4756 * Get whether print web page background. 4757 * @returns { boolean } Get whether print web page background. 4758 * @throws { BusinessError } 17100001 - Init error. 4759 * The WebviewController must be associated with a Web component. 4760 * @syscap SystemCapability.Web.Webview.Core 4761 * @atomicservice 4762 * @since 12 4763 */ 4764 getPrintBackground(): boolean; 4765 4766 /** 4767 * Get the url of the last frame that calls the JavaScriptProxy. 4768 * This should be called on the UI thread. 4769 * 4770 * @returns { string } The url of the last frame that calls the JavaScriptProxy. 4771 * @throws { BusinessError } 17100001 - Init error. 4772 * The WebviewController must be associated with a Web component. 4773 * @syscap SystemCapability.Web.Webview.Core 4774 * @atomicservice 4775 * @since 12 4776 */ 4777 getLastJavascriptProxyCallingFrameUrl(): string; 4778 4779 /** 4780 * Start current camera. 4781 * 4782 * @throws { BusinessError } 17100001 - Init error. 4783 * The WebviewController must be associated with a Web component. 4784 * @syscap SystemCapability.Web.Webview.Core 4785 * @atomicservice 4786 * @since 12 4787 */ 4788 startCamera(): void; 4789 4790 /** 4791 * Stop current camera. 4792 * 4793 * @throws { BusinessError } 17100001 - Init error. 4794 * The WebviewController must be associated with a Web component. 4795 * @syscap SystemCapability.Web.Webview.Core 4796 * @atomicservice 4797 * @since 12 4798 */ 4799 stopCamera(): void; 4800 4801 /** 4802 * Close current camera. 4803 * 4804 * @throws { BusinessError } 17100001 - Init error. 4805 * The WebviewController must be associated with a Web component. 4806 * @syscap SystemCapability.Web.Webview.Core 4807 * @atomicservice 4808 * @since 12 4809 */ 4810 closeCamera(): void; 4811 4812 /** 4813 * Pauses all layout, parsing, and JavaScript timers for all WebViews. 4814 * 4815 * @throws { BusinessError } 17100001 - Init error. 4816 * The WebviewController must be associated with a Web component. 4817 * @syscap SystemCapability.Web.Webview.Core 4818 * @atomicservice 4819 * @since 12 4820 */ 4821 static pauseAllTimers(): void; 4822 4823 /** 4824 * Resumes all layout, parsing, and JavaScript timers for all WebViews. 4825 * 4826 * @throws { BusinessError } 17100001 - Init error. 4827 * The WebviewController must be associated with a Web component. 4828 * @syscap SystemCapability.Web.Webview.Core 4829 * @atomicservice 4830 * @since 12 4831 */ 4832 static resumeAllTimers(): void; 4833 4834 /** 4835 * Stop all audio and video playback on the web page. 4836 * 4837 * @throws { BusinessError } 17100001 - Init error. 4838 * The WebviewController must be associated with a Web component. 4839 * @syscap SystemCapability.Web.Webview.Core 4840 * @atomicservice 4841 * @since 12 4842 */ 4843 stopAllMedia(): void; 4844 4845 /** 4846 * Restart playback of all audio and video on the web page. 4847 * 4848 * @throws { BusinessError } 17100001 - Init error. 4849 * The WebviewController must be associated with a Web component. 4850 * @syscap SystemCapability.Web.Webview.Core 4851 * @atomicservice 4852 * @since 12 4853 */ 4854 resumeAllMedia(): void; 4855 4856 /** 4857 * Pause all audio and video playback on the web page. 4858 * 4859 * @throws { BusinessError } 17100001 - Init error. 4860 * The WebviewController must be associated with a Web component. 4861 * @syscap SystemCapability.Web.Webview.Core 4862 * @atomicservice 4863 * @since 12 4864 */ 4865 pauseAllMedia(): void; 4866 4867 /** 4868 * Close fullscreen video. 4869 * 4870 * @throws { BusinessError } 17100001 - Init error. 4871 * The WebviewController must be associated with a Web component. 4872 * @syscap SystemCapability.Web.Webview.Core 4873 * @atomicservice 4874 * @since 12 4875 */ 4876 closeAllMediaPresentations(): void; 4877 4878 /** 4879 * View the playback status of all audio and video on the web page. 4880 * 4881 * @returns { MediaPlaybackState } The playback status of all audio and video. 4882 * @throws { BusinessError } 17100001 - Init error. 4883 * The WebviewController must be associated with a Web component. 4884 * @syscap SystemCapability.Web.Webview.Core 4885 * @atomicservice 4886 * @since 12 4887 */ 4888 getMediaPlaybackState(): MediaPlaybackState; 4889 4890 /** 4891 * Set web scheme handler for specific scheme. This is only used for related web component. 4892 * 4893 * @param { string } scheme - String value for url scheme. 4894 * @param { WebSchemeHandler } handler - Web scheme handler. 4895 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 4896 * @throws { BusinessError } 17100001 - Init error. 4897 * The WebviewController must be associated with a Web component. 4898 * @syscap SystemCapability.Web.Webview.Core 4899 * @atomicservice 4900 * @since 12 4901 */ 4902 setWebSchemeHandler(scheme: string, handler: WebSchemeHandler): void; 4903 4904 /** 4905 * Clear all web scheme handlers for related web component. 4906 * @throws { BusinessError } 17100001 - Init error. 4907 * The WebviewController must be associated with a Web component. 4908 * @syscap SystemCapability.Web.Webview.Core 4909 * @atomicservice 4910 * @since 12 4911 */ 4912 clearWebSchemeHandler(): void; 4913 4914 /** 4915 * Set web scheme handler for specific scheme. This is used for service worker. 4916 * @param { string } scheme - String value for url scheme. 4917 * @param { WebSchemeHandler } handler - Web scheme handler. 4918 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 4919 * @syscap SystemCapability.Web.Webview.Core 4920 * @atomicservice 4921 * @since 12 4922 */ 4923 static setServiceWorkerWebSchemeHandler(scheme: string, handler: WebSchemeHandler): void; 4924 4925 /** 4926 * Clear all web service worker scheme handlers. 4927 * @syscap SystemCapability.Web.Webview.Core 4928 * @atomicservice 4929 * @since 12 4930 */ 4931 static clearServiceWorkerWebSchemeHandler(): void; 4932 4933 /** 4934 * Enable the ability to use Intelligent Tracking Prevention; default is disabled. 4935 * 4936 * @param { boolean } enable {@code true} enable Intelligent Tracking Prevention; {@code false} otherwise. 4937 * @throws { BusinessError } 17100001 - Init error. 4938 * The WebviewController must be associated with a Web component. 4939 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4940 * <br>2. Incorrect parameter types. 4941 * @syscap SystemCapability.Web.Webview.Core 4942 * @atomicservice 4943 * @since 12 4944 */ 4945 enableIntelligentTrackingPrevention(enable: boolean): void; 4946 4947 /** 4948 * Get whether Intelligent Tracking Prevention is enabled. 4949 * 4950 * @returns { boolean } True if enable the Intelligent Tracking Prevention; else false. 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 12 4956 */ 4957 isIntelligentTrackingPreventionEnabled(): boolean; 4958 4959 /** 4960 * Add bypassing hosts for Intelligent Tracking Prevention. 4961 * 4962 * @param { Array<string> } hostList - Hosts that bypass the Intelligent Tracking Prevention. 4963 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4964 * <br>2. Incorrect parameter types. 4965 * @syscap SystemCapability.Web.Webview.Core 4966 * @atomicservice 4967 * @since 12 4968 */ 4969 static addIntelligentTrackingPreventionBypassingList(hostList: Array<string>): void; 4970 4971 /** 4972 * Remove bypassing hosts for Intelligent Tracking Prevention. 4973 * 4974 * @param { Array<string> } hostList - Hosts needs to remove from bypass list. 4975 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4976 * <br>2. Incorrect parameter types. 4977 * @syscap SystemCapability.Web.Webview.Core 4978 * @atomicservice 4979 * @since 12 4980 */ 4981 static removeIntelligentTrackingPreventionBypassingList(hostList: Array<string>): void; 4982 4983 /** 4984 * Clear bypassing hosts for Intelligent Tracking Prevention. 4985 * 4986 * @syscap SystemCapability.Web.Webview.Core 4987 * @atomicservice 4988 * @since 12 4989 */ 4990 static clearIntelligentTrackingPreventionBypassingList(): void; 4991 4992 /** 4993 * Get the default user agent. 4994 * 4995 * @returns {string} The default user agent string. 4996 * @syscap SystemCapability.Web.Webview.Core 4997 * @since 14 4998 */ 4999 static getDefaultUserAgent(): string; 5000 5001 /** 5002 * Register a callback to intercept web pages playing media. 5003 * 5004 * @param { CreateNativeMediaPlayerCallback } callback - Called everytime when web pages try to play media. 5005 * @syscap SystemCapability.Web.Webview.Core 5006 * @atomicservice 5007 * @since 12 5008 */ 5009 onCreateNativeMediaPlayer(callback: CreateNativeMediaPlayerCallback): void; 5010 5011 /** 5012 * Set enable overall web caching 5013 * 5014 * @syscap SystemCapability.Web.Webview.Core 5015 * @atomicservice 5016 * @since 12 5017 */ 5018 static enableWholeWebPageDrawing(): void; 5019 5020 /** 5021 * Web page snapshot. 5022 * 5023 * @param { SnapshotInfo } info - The snapshot info. 5024 * @param { AsyncCallback<SnapshotResult> } callback - the callback of snapshot. 5025 * @syscap SystemCapability.Web.Webview.Core 5026 * @atomicservice 5027 * @since 12 5028 */ 5029 webPageSnapshot(info: SnapshotInfo, callback: AsyncCallback<SnapshotResult>): void; 5030 5031 /** 5032 * Prefetch the resources request and save it to the memory cache. Only support post request and its Content-Type 5033 * is application/x-www-form-urlencoded now. 5034 * You can prefetch no more than 6 resources. If you want to prefetch the seventh resource, you can clear one of 5035 * the prefetched resources that you won't use any more. Otherwise the oldest resource you prefetched will be 5036 * cleared. 5037 * @param { RequestInfo } request - The information of the request. 5038 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the request. 5039 * @param { string } [cacheKey] - The key for memory cache. Default value is the url of the request. 5040 * Only support number and letters. 5041 * @param { number } [cacheValidTime] - The valid time of the cache for request, ranges greater than 0. 5042 * The unit is second. Default value is 300s. 5043 * The value of cacheValidTime must between 1 and 2147483647. 5044 * @throws { BusinessError } 401 - Invalid input parameter.Possible causes: 1. Mandatory parameters are left unspecified. 5045 * 2. Incorrect parameter types. 3. Parameter verification failed. 5046 * @throws { BusinessError } 17100002 - Invalid url. 5047 * @syscap SystemCapability.Web.Webview.Core 5048 * @atomicservice 5049 * @since 12 5050 */ 5051 static prefetchResource(request: RequestInfo, additionalHeaders?: Array<WebHeader>, cacheKey?: string, 5052 cacheValidTime?: number): void; 5053 5054 /** 5055 * Clear the resource that you prefetch to the memory cache using API{@link prefetchResource}. 5056 * @param { Array<string> } cacheKeyList - The keys for memory cache. 5057 * The key in cacheKeyList only support number and letters. 5058 * @syscap SystemCapability.Web.Webview.Core 5059 * @atomicservice 5060 * @since 12 5061 */ 5062 static clearPrefetchedResource(cacheKeyList: Array<string>): void; 5063 5064 /** 5065 * Set render process mode of the ArkWeb. 5066 * 5067 * @param { RenderProcessMode } mode - The render process mode for the ArkWeb. 5068 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5069 * <br>2. Incorrect parameter types. 5070 * @syscap SystemCapability.Web.Webview.Core 5071 * @atomicservice 5072 * @since 12 5073 */ 5074 static setRenderProcessMode(mode: RenderProcessMode): void; 5075 5076 /** 5077 * Get render process mode of the ArkWeb. 5078 * 5079 * @returns { RenderProcessMode } mode - The render process mode of the ArkWeb. 5080 * @syscap SystemCapability.Web.Webview.Core 5081 * @atomicservice 5082 * @since 12 5083 */ 5084 static getRenderProcessMode(): RenderProcessMode; 5085 5086 /** 5087 * Terminate render process associated with this controller of the ArkWeb. 5088 * 5089 * @returns { boolean } true if it was possible to terminate the render process, otherwise false. 5090 * Calling this on a not yet started, or an already terminated render will have no effect. 5091 * @throws { BusinessError } 17100001 - Init error. 5092 * The WebviewController must be associated with a Web component. 5093 * @syscap SystemCapability.Web.Webview.Core 5094 * @since 12 5095 */ 5096 terminateRenderProcess(): boolean; 5097 5098 /** 5099 * Compile javascript and generate code cache. 5100 * @param { string } url - Url of the javascript. Only support HTTP/HTTPS protocol and length no longer than 2048. 5101 * @param { string | Uint8Array } script - Javascript source code. script must not be empty. 5102 * @param { CacheOptions } cacheOptions - Generate code cache option. 5103 * @returns { Promise<number> } - The promise returned by the function. 5104 * 0 means generate code cache successfully, -1 means internal error. 5105 * @throws { BusinessError } 401 - Invalid input parameter. 5106 * Possible causes: 1. Mandatory parameters are left unspecified. 5107 * 2. Incorrect parameter types. 3. Parameter verification failed. 5108 * @throws { BusinessError } 17100001 - Init error. 5109 * The WebviewController must be associated with a Web component. 5110 * @syscap SystemCapability.Web.Webview.Core 5111 * @since 12 5112 */ 5113 precompileJavaScript(url: string, script: string | Uint8Array, cacheOptions: CacheOptions): Promise<number>; 5114 5115 /** 5116 * Set IP address for host name. 5117 * 5118 * @param { string } hostName - Which host name to be resolved. 5119 * @param { string } address - Resolved IP address. 5120 * @param { number } aliveTime - The validity seconds for resolve cache. 5121 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5122 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5123 * @syscap SystemCapability.Web.Webview.Core 5124 * @atomicservice 5125 * @since 12 5126 */ 5127 static setHostIP(hostName: string, address: string, aliveTime: number): void; 5128 5129 /** 5130 * Clear the host name IP address. 5131 * 5132 * @param { string } hostName - Which host name to be cleared. 5133 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5134 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5135 * @syscap SystemCapability.Web.Webview.Core 5136 * @atomicservice 5137 * @since 12 5138 */ 5139 static clearHostIP(hostName: string): void; 5140 5141 /** 5142 * Warmup the registered service worker associated the url. 5143 * @param { string } url - The url. 5144 * @throws { BusinessError } 17100002 - Invalid url. 5145 * @syscap SystemCapability.Web.Webview.Core 5146 * @atomicservice 5147 * @since 12 5148 */ 5149 static warmupServiceWorker(url: string): void; 5150 5151 /** 5152 * Inject offline resources into cache. 5153 * 5154 * @param { Array<OfflineResourceMap> } resourceMaps - Array of offline resource info maps. 5155 * The count of array must between 1 and 30. 5156 * @throws { BusinessError } 401 - Invalid input parameter. 5157 * Possible causes: 1. Mandatory parameters are left unspecified. 5158 * 2. Incorrect parameter types. 3. Parameter verification failed. 5159 * @throws { BusinessError } 17100001 - Init error. 5160 * The WebviewController must be associated with a Web component. 5161 * @throws { BusinessError } 17100002 - Invalid url. 5162 * @syscap SystemCapability.Web.Webview.Core 5163 * @since 12 5164 */ 5165 injectOfflineResources(resourceMaps: Array<OfflineResourceMap>): void; 5166 5167 /** 5168 * Enable the ability to block Ads, disabled by default. 5169 * 5170 * @param { boolean } enable {@code true} Enable Ads block; {@code false} otherwise. 5171 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5172 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5173 * @throws { BusinessError } 17100001 - Init error. 5174 * The WebviewController must be associated with a Web component. 5175 * @syscap SystemCapability.Web.Webview.Core 5176 * @atomicservice 5177 * @since 12 5178 */ 5179 enableAdsBlock(enable: boolean): void; 5180 5181 /** 5182 * Get whether Ads block is enabled. 5183 * 5184 * @returns { boolean } True if the ability of AdsBlock is enabled; else false. 5185 * @syscap SystemCapability.Web.Webview.Core 5186 * @atomicservice 5187 * @since 12 5188 */ 5189 isAdsBlockEnabled(): boolean; 5190 5191 /** 5192 * Get whether Ads block is enabled for current Webpage. 5193 * 5194 * @returns { boolean } True if the ability of AdsBlock is enabled for current Webpage; else false. 5195 * @syscap SystemCapability.Web.Webview.Core 5196 * @atomicservice 5197 * @since 12 5198 */ 5199 isAdsBlockEnabledForCurPage(): boolean; 5200 5201 /** 5202 * Get the ID of the surface created by ArkWeb. This ID can be used for web page screenshots. 5203 * 5204 * @returns { string } The ID of the surface created by ArkWeb. 5205 * @syscap SystemCapability.Web.Webview.Core 5206 * @atomicservice 5207 * @since 12 5208 */ 5209 getSurfaceId(): string; 5210 5211 /** 5212 * Set the URL trust list for the ArkWeb. 5213 * When the URL trust list has been set, only the URLs in the list can be accessed. 5214 * 5215 * @param { string } urlTrustList - the URL trust list in JSON format. 5216 * An empty string means that all URLs are allowed to access. 5217 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5218 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5219 * @throws { BusinessError } 17100001 - Init error. 5220 * The WebviewController must be associated with a Web component. 5221 * @syscap SystemCapability.Web.Webview.Core 5222 * @atomicservice 5223 * @since 12 5224 */ 5225 setUrlTrustList(urlTrustList: string): void; 5226 5227 /** 5228 * Set a path list, allowing cross-origin request access any origin when the file scheme URLs access resources in this 5229 * path list. Also, When the path list is set, the file scheme URLs only allow access to resources within the path list. 5230 * Path in the path list must meet one of the following path formats(sub path and module name must be provided): 5231 * 5232 * 1. App bundle resource directory, like "/data/storage/el1/bundle/entry/resource/resfile". 5233 * You can get resource directory using Context.resourceDir in AbilityKit. 5234 * 2. A sub path of app files directory, like "/data/storage/el2/base/files/example/" 5235 * or "/data/storage/el2/base/haps/entry/files/example". 5236 * You can get app files directory using Context.filesDir in AbilityKit. 5237 * 5238 * @param { Array<string> } pathList - The path list allow universal access. 5239 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5240 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5241 * @throws { BusinessError } 17100001 - Init error. 5242 * The WebviewController must be associated with a Web component. 5243 * @syscap SystemCapability.Web.Webview.Core 5244 * @since 12 5245 */ 5246 setPathAllowingUniversalAccess(pathList: Array<string>): void; 5247 5248 /** 5249 * Trim memory by different memory pressure level. 5250 * 5251 * @param { PressureLevel } level - The memory pressure level for the ArkWeb. 5252 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5253 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5254 * @syscap SystemCapability.Web.Webview.Core 5255 * @atomicservice 5256 * @since 14 5257 */ 5258 static trimMemoryByPressureLevel(level: PressureLevel): void; 5259 5260 /** 5261 * Enable the BackForwardCache and indicate features that are allowed to enter BackForwardCache. 5262 * Default is disabled. 5263 * 5264 * @param { BackForwardCacheSupportedFeatures } features - The features that supports BackForwardCache. 5265 * @syscap SystemCapability.Web.Webview.Core 5266 * @since 12 5267 */ 5268 static enableBackForwardCache(features: BackForwardCacheSupportedFeatures): void; 5269 5270 /** 5271 * Configure the BackForwardCache. 5272 * 5273 * @param { BackForwardCacheOptions } options - The configuration of BackForwardCache. 5274 * @throws { BusinessError } 17100001 - Init error. 5275 * The WebviewController must be associated with a Web component. 5276 * @syscap SystemCapability.Web.Webview.Core 5277 * @since 12 5278 */ 5279 setBackForwardCacheOptions(options: BackForwardCacheOptions): void; 5280 5281 /** 5282 * Get the scroll offset of the webpage in view port, the coordinates of the top left corner of the view port are X: 0, Y: 0. 5283 * And the unit is virtual pixel. 5284 * 5285 * @returns { ScrollOffset } scroll offset 5286 * @syscap SystemCapability.Web.Webview.Core 5287 * @atomicservice 5288 * @since 13 5289 */ 5290 getScrollOffset(): ScrollOffset; 5291 5292 /** 5293 * Scrolls by the specified delta position and returns a result indicating whether the scrolling operation was successful or not. 5294 * 5295 * @param { number } deltaX - the delta x of the position. 5296 * @param { number } deltaY - the delta y of the position. 5297 * @returns { boolean } true if the scroll operation is successful, otherwise false. 5298 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5299 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5300 * @throws { BusinessError } 17100001 - Init error. 5301 * The WebviewController must be associated with a Web component. 5302 * @syscap SystemCapability.Web.Webview.Core 5303 * @since 12 5304 */ 5305 scrollByWithResult(deltaX: number, deltaY: number): boolean; 5306 } 5307 5308 /** 5309 * Defines the state for download. 5310 * @enum {number} 5311 * @syscap SystemCapability.Web.Webview.Core 5312 * @atomicservice 5313 * @since 11 5314 */ 5315 enum WebDownloadState { 5316 /** 5317 * The web download is in progress. 5318 * @syscap SystemCapability.Web.Webview.Core 5319 * @atomicservice 5320 * @since 11 5321 */ 5322 IN_PROGRESS = 0, 5323 5324 /** 5325 * The web download has been completed. 5326 * @syscap SystemCapability.Web.Webview.Core 5327 * @atomicservice 5328 * @since 11 5329 */ 5330 COMPLETED, 5331 5332 /** 5333 * The web download was canceled. 5334 * @syscap SystemCapability.Web.Webview.Core 5335 * @atomicservice 5336 * @since 11 5337 */ 5338 CANCELED, 5339 5340 /** 5341 * The web download was interrupted. 5342 * @syscap SystemCapability.Web.Webview.Core 5343 * @atomicservice 5344 * @since 11 5345 */ 5346 INTERRUPTED, 5347 5348 /** 5349 * The web download is pending. 5350 * @syscap SystemCapability.Web.Webview.Core 5351 * @atomicservice 5352 * @since 11 5353 */ 5354 PENDING, 5355 5356 /** 5357 * The web download has been paused. 5358 * @syscap SystemCapability.Web.Webview.Core 5359 * @atomicservice 5360 * @since 11 5361 */ 5362 PAUSED, 5363 5364 /** 5365 * Unknown state. 5366 * @syscap SystemCapability.Web.Webview.Core 5367 * @atomicservice 5368 * @since 11 5369 */ 5370 UNKNOWN, 5371 } 5372 5373 /** 5374 * Defines the error code for download. 5375 * @enum {number} 5376 * @syscap SystemCapability.Web.Webview.Core 5377 * @atomicservice 5378 * @since 11 5379 */ 5380 enum WebDownloadErrorCode { 5381 /** 5382 * Unknown error. 5383 * @syscap SystemCapability.Web.Webview.Core 5384 * @atomicservice 5385 * @since 11 5386 */ 5387 ERROR_UNKNOWN = 0, 5388 5389 /** 5390 * Generic file operation failure. 5391 * @syscap SystemCapability.Web.Webview.Core 5392 * @atomicservice 5393 * @since 11 5394 */ 5395 FILE_FAILED = 1, 5396 5397 /** 5398 * The file cannot be accessed due to certain restrictions. 5399 * @syscap SystemCapability.Web.Webview.Core 5400 * @atomicservice 5401 * @since 11 5402 */ 5403 FILE_ACCESS_DENIED = 2, 5404 5405 /** 5406 * There is not enough disk space. 5407 * @syscap SystemCapability.Web.Webview.Core 5408 * @atomicservice 5409 * @since 11 5410 */ 5411 FILE_NO_SPACE = 3, 5412 5413 /** 5414 * The file name is too long. 5415 * @syscap SystemCapability.Web.Webview.Core 5416 * @atomicservice 5417 * @since 11 5418 */ 5419 FILE_NAME_TOO_LONG = 5, 5420 5421 /** 5422 * The file is too large. 5423 * @syscap SystemCapability.Web.Webview.Core 5424 * @atomicservice 5425 * @since 11 5426 */ 5427 FILE_TOO_LARGE = 6, 5428 5429 /** 5430 * Some temporary problems occurred, such as not enough memory, files in use, and too many files open at the same time. 5431 * @syscap SystemCapability.Web.Webview.Core 5432 * @atomicservice 5433 * @since 11 5434 */ 5435 FILE_TRANSIENT_ERROR = 10, 5436 5437 /** 5438 * The file is blocked from accessing because of some local policy. 5439 * @syscap SystemCapability.Web.Webview.Core 5440 * @atomicservice 5441 * @since 11 5442 */ 5443 FILE_BLOCKED = 11, 5444 5445 /** 5446 * When trying to resume the download, Found that the file is not long enough, maybe the file no longer exists. 5447 * @syscap SystemCapability.Web.Webview.Core 5448 * @atomicservice 5449 * @since 11 5450 */ 5451 FILE_TOO_SHORT = 13, 5452 5453 /** 5454 * Hash mismatch. 5455 * @syscap SystemCapability.Web.Webview.Core 5456 * @atomicservice 5457 * @since 11 5458 */ 5459 FILE_HASH_MISMATCH = 14, 5460 5461 /** 5462 * The file already exists. 5463 * @syscap SystemCapability.Web.Webview.Core 5464 * @atomicservice 5465 * @since 11 5466 */ 5467 FILE_SAME_AS_SOURCE = 15, 5468 5469 /** 5470 * Generic network error. 5471 * @syscap SystemCapability.Web.Webview.Core 5472 * @atomicservice 5473 * @since 11 5474 */ 5475 NETWORK_FAILED = 20, 5476 5477 /** 5478 * The network operation timed out. 5479 * @syscap SystemCapability.Web.Webview.Core 5480 * @atomicservice 5481 * @since 11 5482 */ 5483 NETWORK_TIMEOUT = 21, 5484 5485 /** 5486 * The network was disconnected. 5487 * @syscap SystemCapability.Web.Webview.Core 5488 * @atomicservice 5489 * @since 11 5490 */ 5491 NETWORK_DISCONNECTED = 22, 5492 5493 /** 5494 * Server down. 5495 * @syscap SystemCapability.Web.Webview.Core 5496 * @atomicservice 5497 * @since 11 5498 */ 5499 NETWORK_SERVER_DOWN = 23, 5500 5501 /** 5502 * Invalid network requests,may redirect to unsupported scheme or an invalid URL. 5503 * @syscap SystemCapability.Web.Webview.Core 5504 * @atomicservice 5505 * @since 11 5506 */ 5507 NETWORK_INVALID_REQUEST = 24, 5508 5509 /** 5510 * The server returned a generic error. 5511 * @syscap SystemCapability.Web.Webview.Core 5512 * @atomicservice 5513 * @since 11 5514 */ 5515 SERVER_FAILED = 30, 5516 5517 /** 5518 * The server does not support range requests. 5519 * @syscap SystemCapability.Web.Webview.Core 5520 * @atomicservice 5521 * @since 11 5522 */ 5523 SERVER_NO_RANGE = 31, 5524 5525 /** 5526 * The server does not have the requested data. 5527 * @syscap SystemCapability.Web.Webview.Core 5528 * @atomicservice 5529 * @since 11 5530 */ 5531 SERVER_BAD_CONTENT = 33, 5532 5533 /** 5534 * The server does not allow the file to be downloaded. 5535 * @syscap SystemCapability.Web.Webview.Core 5536 * @atomicservice 5537 * @since 11 5538 */ 5539 SERVER_UNAUTHORIZED = 34, 5540 5541 /** 5542 * Server certificate error. 5543 * @syscap SystemCapability.Web.Webview.Core 5544 * @atomicservice 5545 * @since 11 5546 */ 5547 SERVER_CERT_PROBLEM = 35, 5548 5549 /** 5550 * Server access forbidden. 5551 * @syscap SystemCapability.Web.Webview.Core 5552 * @atomicservice 5553 * @since 11 5554 */ 5555 SERVER_FORBIDDEN = 36, 5556 5557 /** 5558 * Server unreachable. 5559 * @syscap SystemCapability.Web.Webview.Core 5560 * @atomicservice 5561 * @since 11 5562 */ 5563 SERVER_UNREACHABLE = 37, 5564 5565 /** 5566 * The received data does not match content-length. 5567 * @syscap SystemCapability.Web.Webview.Core 5568 * @atomicservice 5569 * @since 11 5570 */ 5571 SERVER_CONTENT_LENGTH_MISMATCH = 38, 5572 5573 /** 5574 * An unexpected cross-origin redirect happened. 5575 * @syscap SystemCapability.Web.Webview.Core 5576 * @atomicservice 5577 * @since 11 5578 */ 5579 SERVER_CROSS_ORIGIN_REDIRECT = 39, 5580 5581 /** 5582 * User cancel. 5583 * @syscap SystemCapability.Web.Webview.Core 5584 * @atomicservice 5585 * @since 11 5586 */ 5587 USER_CANCELED = 40, 5588 5589 /** 5590 * User shut down the application. 5591 * @syscap SystemCapability.Web.Webview.Core 5592 * @atomicservice 5593 * @since 11 5594 */ 5595 USER_SHUTDOWN = 41, 5596 5597 /** 5598 * Application crash. 5599 * @syscap SystemCapability.Web.Webview.Core 5600 * @atomicservice 5601 * @since 11 5602 */ 5603 CRASH = 50, 5604 } 5605 5606 /** 5607 * Represents a download task, You can use this object to operate the corresponding download task. 5608 * @syscap SystemCapability.Web.Webview.Core 5609 * @atomicservice 5610 * @since 11 5611 */ 5612 class WebDownloadItem { 5613 /** 5614 * Get guid. 5615 * @returns { string } - Returns the download's guid. 5616 * @syscap SystemCapability.Web.Webview.Core 5617 * @atomicservice 5618 * @since 11 5619 */ 5620 getGuid(): string; 5621 5622 /** 5623 * Get current speed, in bytes per second. 5624 * @returns { number } - Returns the current download speed. 5625 * @syscap SystemCapability.Web.Webview.Core 5626 * @atomicservice 5627 * @since 11 5628 */ 5629 getCurrentSpeed(): number; 5630 5631 /** 5632 * Get percent complete. 5633 * @returns { number } - Returns -1 if progress is unknown. 100 if the download is already complete. 5634 * @syscap SystemCapability.Web.Webview.Core 5635 * @atomicservice 5636 * @since 11 5637 */ 5638 getPercentComplete(): number; 5639 5640 /** 5641 * Get total bytes. 5642 * @returns { number } - Returns the total bytes received, -1 if the total size is unknown. 5643 * @syscap SystemCapability.Web.Webview.Core 5644 * @atomicservice 5645 * @since 11 5646 */ 5647 getTotalBytes(): number; 5648 5649 /** 5650 * Get state of the web download. 5651 * @returns { WebDownloadState } - Returns the current download state. 5652 * @syscap SystemCapability.Web.Webview.Core 5653 * @atomicservice 5654 * @since 11 5655 */ 5656 getState(): WebDownloadState; 5657 5658 /** 5659 * Get last error code of the web download. 5660 * @returns { WebDownloadErrorCode } - Returns the last error code. 5661 * @syscap SystemCapability.Web.Webview.Core 5662 * @atomicservice 5663 * @since 11 5664 */ 5665 getLastErrorCode(): WebDownloadErrorCode; 5666 5667 /** 5668 * Get http method of the web download request. 5669 * @returns { string } - Returns the http request method. 5670 * @syscap SystemCapability.Web.Webview.Core 5671 * @atomicservice 5672 * @since 11 5673 */ 5674 getMethod(): string; 5675 5676 /** 5677 * Get mime type of the web download. 5678 * @returns { string } - Returns the mimetype. 5679 * @syscap SystemCapability.Web.Webview.Core 5680 * @atomicservice 5681 * @since 11 5682 */ 5683 getMimeType(): string; 5684 5685 /** 5686 * Get url of the web download request. 5687 * @returns { string } - Returns the url. 5688 * @syscap SystemCapability.Web.Webview.Core 5689 * @atomicservice 5690 * @since 11 5691 */ 5692 getUrl(): string; 5693 5694 /** 5695 * Get suggested file name of the web download request. 5696 * @returns { string } - Returns the suggested file name. 5697 * @syscap SystemCapability.Web.Webview.Core 5698 * @atomicservice 5699 * @since 11 5700 */ 5701 getSuggestedFileName(): string; 5702 5703 /** 5704 * Start the web download. 5705 * Used in onBeforeDownload, If you want to start the current download, call this function. 5706 * @param { string } downloadPath - The content will be downloaded to this file. 5707 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 5708 * <br>2. Parameter verification failed. 5709 * @syscap SystemCapability.Web.Webview.Core 5710 * @atomicservice 5711 * @since 11 5712 */ 5713 start(downloadPath: string): void; 5714 5715 /** 5716 * Cancel the web download. 5717 * @syscap SystemCapability.Web.Webview.Core 5718 * @atomicservice 5719 * @since 11 5720 */ 5721 cancel(): void; 5722 5723 /** 5724 * Pause the web download. 5725 * @throws { BusinessError } 17100019 - The download task is not started yet. 5726 * @syscap SystemCapability.Web.Webview.Core 5727 * @atomicservice 5728 * @since 11 5729 */ 5730 pause(): void; 5731 5732 /** 5733 * Resume the web download. 5734 * Use WebDownloadManager.resumeDownload to resume deserialized downloads. 5735 * WebDownloadItem.resume is only used to resume the currently paused download. 5736 * @throws { BusinessError } 17100016 - The download task is not paused. 5737 * @syscap SystemCapability.Web.Webview.Core 5738 * @atomicservice 5739 * @since 11 5740 */ 5741 resume(): void; 5742 5743 /** 5744 * Get received bytes. 5745 * @returns { number } - Returns the received bytes. 5746 * @syscap SystemCapability.Web.Webview.Core 5747 * @atomicservice 5748 * @since 11 5749 */ 5750 getReceivedBytes(): number; 5751 5752 /** 5753 * Get full path of the web download. 5754 * @returns { string } - Returns the full path of the download. 5755 * @syscap SystemCapability.Web.Webview.Core 5756 * @atomicservice 5757 * @since 11 5758 */ 5759 getFullPath(): string; 5760 5761 /** 5762 * Serialize web download to typed array. 5763 * @returns { Uint8Array } - Returns the serialized data. 5764 * @syscap SystemCapability.Web.Webview.Core 5765 * @atomicservice 5766 * @since 11 5767 */ 5768 serialize(): Uint8Array; 5769 5770 /** 5771 * Deserialize web download from typed array. 5772 * @param { Uint8Array } serializedData - The serialized data. 5773 * @returns { WebDownloadItem } - Deserialize the serialized data into a WebDownloadItem. 5774 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 5775 * <br>2. Parameter verification failed. 5776 * @syscap SystemCapability.Web.Webview.Core 5777 * @atomicservice 5778 * @since 11 5779 */ 5780 static deserialize(serializedData: Uint8Array): WebDownloadItem; 5781 } 5782 5783 /** 5784 * The download state is notified through this delegate. 5785 * @syscap SystemCapability.Web.Webview.Core 5786 * @atomicservice 5787 * @since 11 5788 */ 5789 class WebDownloadDelegate { 5790 /** 5791 * Callback will be triggered before web download start. 5792 * @param { Callback<WebDownloadItem> } callback - The callback of download will be start. 5793 * @syscap SystemCapability.Web.Webview.Core 5794 * @atomicservice 5795 * @since 11 5796 */ 5797 onBeforeDownload(callback: Callback<WebDownloadItem>): void; 5798 5799 /** 5800 * Callback will be triggered when web download is processing. 5801 * @param { Callback<WebDownloadItem> } callback - The callback of download did update. 5802 * @syscap SystemCapability.Web.Webview.Core 5803 * @atomicservice 5804 * @since 11 5805 */ 5806 onDownloadUpdated(callback: Callback<WebDownloadItem>): void; 5807 5808 /** 5809 * Callback will be triggered when web download is completed. 5810 * @param { Callback<WebDownloadItem> } callback - The callback of download did finish. 5811 * @syscap SystemCapability.Web.Webview.Core 5812 * @atomicservice 5813 * @since 11 5814 */ 5815 onDownloadFinish(callback: Callback<WebDownloadItem>): void; 5816 5817 /** 5818 * Callback will be triggered when web download is interrupted or canceled. 5819 * @param { Callback<WebDownloadItem> } callback - The callback of download did fail. 5820 * @syscap SystemCapability.Web.Webview.Core 5821 * @atomicservice 5822 * @since 11 5823 */ 5824 onDownloadFailed(callback: Callback<WebDownloadItem>): void; 5825 } 5826 5827 /** 5828 * You can trigger download manually through this interface, or resume failed or canceled downloads. 5829 * @syscap SystemCapability.Web.Webview.Core 5830 * @atomicservice 5831 * @since 11 5832 */ 5833 class WebDownloadManager { 5834 /** 5835 * Set a delegate used to receive the progress of the download triggered from WebDownloadManager. 5836 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from WebDownloadManager. 5837 * @syscap SystemCapability.Web.Webview.Core 5838 * @atomicservice 5839 * @since 11 5840 */ 5841 static setDownloadDelegate(delegate: WebDownloadDelegate): void; 5842 5843 /** 5844 * Resume the canceled or failed download. 5845 * @param { WebDownloadItem } webDownloadItem - Download that need to be resume. 5846 * @throws { BusinessError } 17100018 - No WebDownloadDelegate has been set yet. 5847 * @syscap SystemCapability.Web.Webview.Core 5848 * @atomicservice 5849 * @since 11 5850 */ 5851 static resumeDownload(webDownloadItem: WebDownloadItem): void; 5852 } 5853 5854 /** 5855 * The http body stream of the request. 5856 * 5857 * @syscap SystemCapability.Web.Webview.Core 5858 * @atomicservice 5859 * @since 12 5860 */ 5861 class WebHttpBodyStream { 5862 /** 5863 * Initialize data stream. 5864 * 5865 * @returns { Promise<void> } The promise of data stream is initialized. 5866 * @throws { BusinessError } 17100022 - Failed to initialize the HTTP body stream. 5867 * @syscap SystemCapability.Web.Webview.Core 5868 * @atomicservice 5869 * @since 12 5870 */ 5871 initialize(): Promise<void>; 5872 /** 5873 * Read the data stream to the buffer. 5874 * 5875 * @param { number } size - Read size. 5876 * @returns { Promise<ArrayBuffer> } Read array buffer of result. 5877 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5878 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5879 * @syscap SystemCapability.Web.Webview.Core 5880 * @atomicservice 5881 * @since 12 5882 */ 5883 read(size: number): Promise<ArrayBuffer>; 5884 /** 5885 * Get the total size of the data stream. When data is chunked, always return zero. 5886 * 5887 * @returns { number } Return size of data stream size. 5888 * @syscap SystemCapability.Web.Webview.Core 5889 * @atomicservice 5890 * @since 12 5891 */ 5892 getSize(): number; 5893 /** 5894 * Get the current position of the data stream. 5895 * 5896 * @returns { number } Return position in post data stream. 5897 * @syscap SystemCapability.Web.Webview.Core 5898 * @atomicservice 5899 * @since 12 5900 */ 5901 getPosition(): number; 5902 /** 5903 * Whether data stream is chunked. 5904 * 5905 * @returns { boolean } Whether data stream is chunked. 5906 * @syscap SystemCapability.Web.Webview.Core 5907 * @atomicservice 5908 * @since 12 5909 */ 5910 isChunked(): boolean; 5911 /** 5912 * Whether all data stream has been consumed. For chunked uploads, 5913 * returns false until the first read attempt. 5914 * 5915 * @returns { boolean } Whether data stream has been consumed. 5916 * @syscap SystemCapability.Web.Webview.Core 5917 * @atomicservice 5918 * @since 12 5919 */ 5920 isEof(): boolean; 5921 /** 5922 * Returns true if the upload data in the stream is entirely in memory, and all read requests will succeed 5923 * synchronously. Expected to return false for chunked requests. 5924 * 5925 * @returns { boolean } Whether the data stream is in memory. 5926 * @syscap SystemCapability.Web.Webview.Core 5927 * @atomicservice 5928 * @since 12 5929 */ 5930 isInMemory(): boolean; 5931 } 5932 5933 /** 5934 * Defines the resource type of request. 5935 * @enum {number} 5936 * @syscap SystemCapability.Web.Webview.Core 5937 * @since 12 5938 */ 5939 enum WebResourceType { 5940 /** 5941 * Top level page. 5942 * 5943 * @syscap SystemCapability.Web.Webview.Core 5944 * @since 12 5945 */ 5946 MAIN_FRAME = 0, 5947 5948 /** 5949 * Frame or Iframe. 5950 * 5951 * @syscap SystemCapability.Web.Webview.Core 5952 * @since 12 5953 */ 5954 SUB_FRAME = 1, 5955 5956 /** 5957 * CSS stylesheet. 5958 * 5959 * @syscap SystemCapability.Web.Webview.Core 5960 * @since 12 5961 */ 5962 STYLE_SHEET = 2, 5963 5964 /** 5965 * External script. 5966 * 5967 * @syscap SystemCapability.Web.Webview.Core 5968 * @since 12 5969 */ 5970 SCRIPT = 3, 5971 5972 /** 5973 * Image (jpg/gif/png/etc). 5974 * 5975 * @syscap SystemCapability.Web.Webview.Core 5976 * @since 12 5977 */ 5978 IMAGE = 4, 5979 5980 /** 5981 * Font. 5982 * 5983 * @syscap SystemCapability.Web.Webview.Core 5984 * @since 12 5985 */ 5986 FONT_RESOURCE = 5, 5987 5988 /** 5989 * Some other subresource. This is the default type if the actual type is unknown. 5990 * 5991 * @syscap SystemCapability.Web.Webview.Core 5992 * @since 12 5993 */ 5994 SUB_RESOURCE = 6, 5995 5996 /** 5997 * Object (or embed) tag for a plugin, or a resource that a plugin requested. 5998 * 5999 * @syscap SystemCapability.Web.Webview.Core 6000 * @since 12 6001 */ 6002 OBJECT = 7, 6003 6004 /** 6005 * Media resource. 6006 * 6007 * @syscap SystemCapability.Web.Webview.Core 6008 * @since 12 6009 */ 6010 MEDIA = 8, 6011 6012 /** 6013 * Main resource of a dedicated worker. 6014 * 6015 * @syscap SystemCapability.Web.Webview.Core 6016 * @since 12 6017 */ 6018 WORKER = 9, 6019 6020 /** 6021 * Main resource of a shared worker. 6022 * 6023 * @syscap SystemCapability.Web.Webview.Core 6024 * @since 12 6025 */ 6026 SHARED_WORKER = 10, 6027 6028 /** 6029 * Explicitly requested prefetch. 6030 * 6031 * @syscap SystemCapability.Web.Webview.Core 6032 * @since 12 6033 */ 6034 PREFETCH = 11, 6035 6036 /** 6037 * Favicon. 6038 * 6039 * @syscap SystemCapability.Web.Webview.Core 6040 * @since 12 6041 */ 6042 FAVICON = 12, 6043 6044 /** 6045 * XMLHttpRequest. 6046 * 6047 * @syscap SystemCapability.Web.Webview.Core 6048 * @since 12 6049 */ 6050 XHR = 13, 6051 6052 /** 6053 * Ping request for <a ping>/sendBeacon. 6054 * 6055 * @syscap SystemCapability.Web.Webview.Core 6056 * @since 12 6057 */ 6058 PING = 14, 6059 6060 /** 6061 * The main resource of a service worker. 6062 * 6063 * @syscap SystemCapability.Web.Webview.Core 6064 * @since 12 6065 */ 6066 SERVICE_WORKER = 15, 6067 6068 /** 6069 * Report of Content Security Policy violations. 6070 * 6071 * @syscap SystemCapability.Web.Webview.Core 6072 * @since 12 6073 */ 6074 CSP_REPORT = 16, 6075 6076 /** 6077 * Resource that a plugin requested. 6078 * 6079 * @syscap SystemCapability.Web.Webview.Core 6080 * @since 12 6081 */ 6082 PLUGIN_RESOURCE = 17, 6083 6084 /** 6085 * A main-frame service worker navigation preload request. 6086 * 6087 * @syscap SystemCapability.Web.Webview.Core 6088 * @since 12 6089 */ 6090 NAVIGATION_PRELOAD_MAIN_FRAME = 19, 6091 6092 /** 6093 * A sub-frame service worker navigation preload request. 6094 * 6095 * @syscap SystemCapability.Web.Webview.Core 6096 * @since 12 6097 */ 6098 NAVIGATION_PRELOAD_SUB_FRAME = 20, 6099 } 6100 6101 /** 6102 * Defines the Web resource request used for scheme handler. 6103 * 6104 * @syscap SystemCapability.Web.Webview.Core 6105 * @atomicservice 6106 * @since 12 6107 */ 6108 class WebSchemeHandlerRequest { 6109 /** 6110 * Gets request headers. 6111 * 6112 * @returns { Array<WebHeader> } Return the request headers. 6113 * @syscap SystemCapability.Web.Webview.Core 6114 * @atomicservice 6115 * @since 12 6116 */ 6117 getHeader(): Array<WebHeader>; 6118 /** 6119 * Gets the request URL. 6120 * 6121 * @returns { string } Return the request URL. 6122 * @syscap SystemCapability.Web.Webview.Core 6123 * @atomicservice 6124 * @since 12 6125 */ 6126 getRequestUrl(): string; 6127 /** 6128 * Get request method. 6129 * 6130 * @returns { string } Return the request method. 6131 * @syscap SystemCapability.Web.Webview.Core 6132 * @atomicservice 6133 * @since 12 6134 */ 6135 getRequestMethod(): string; 6136 /** 6137 * Get referrer of request. 6138 * 6139 * @returns { string } Return referrer of request. 6140 * @syscap SystemCapability.Web.Webview.Core 6141 * @atomicservice 6142 * @since 12 6143 */ 6144 getReferrer(): string; 6145 /** 6146 * Check whether the request is for getting the main frame. 6147 * 6148 * @returns { boolean } Whether request is main frame. 6149 * @syscap SystemCapability.Web.Webview.Core 6150 * @atomicservice 6151 * @since 12 6152 */ 6153 isMainFrame(): boolean; 6154 /** 6155 * Check whether the request is associated with gesture. 6156 * 6157 * @returns { boolean } Whether request has user gesture. 6158 * @syscap SystemCapability.Web.Webview.Core 6159 * @atomicservice 6160 * @since 12 6161 */ 6162 hasGesture(): boolean; 6163 /** 6164 * Get http body stream. 6165 * 6166 * @returns { WebHttpBodyStream | null } Return http body stream. If request has no http body stream, return null. 6167 * @syscap SystemCapability.Web.Webview.Core 6168 * @atomicservice 6169 * @since 12 6170 */ 6171 getHttpBodyStream(): WebHttpBodyStream | null; 6172 /** 6173 * Get request's resource type. 6174 * 6175 * @returns { WebResourceType } Return the request's resource type. 6176 * @syscap SystemCapability.Web.Webview.Core 6177 * @since 12 6178 */ 6179 getRequestResourceType(): WebResourceType; 6180 /** 6181 * Gets the URL of frame which trigger this request. 6182 * 6183 * @returns { string } Return the URL of frame which trigger this request. 6184 * @syscap SystemCapability.Web.Webview.Core 6185 * @since 12 6186 */ 6187 getFrameUrl(): string; 6188 } 6189 6190 /** 6191 * Defines the Web resource response used for scheme handler. 6192 * 6193 * @syscap SystemCapability.Web.Webview.Core 6194 * @atomicservice 6195 * @since 12 6196 */ 6197 class WebSchemeHandlerResponse { 6198 /** 6199 * Constructor. 6200 * 6201 * @syscap SystemCapability.Web.Webview.Core 6202 * @atomicservice 6203 * @since 12 6204 */ 6205 constructor(); 6206 /** 6207 * Set the resolved URL after redirects or changed as a result of HSTS. 6208 * 6209 * @param { string } url - Set response url for redirects. 6210 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6211 * @syscap SystemCapability.Web.Webview.Core 6212 * @atomicservice 6213 * @since 12 6214 */ 6215 setUrl(url: string): void; 6216 /** 6217 * Get the resolved URL after redirects or changed as a result of HSTS. 6218 * 6219 * @returns { string } Return response url for redirects. 6220 * @syscap SystemCapability.Web.Webview.Core 6221 * @atomicservice 6222 * @since 12 6223 */ 6224 getUrl(): string; 6225 /** 6226 * Set net error code. 6227 * @param { WebNetErrorList } code - Set net error code. 6228 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6229 * <br>2. Incorrect parameter types. 6230 * @syscap SystemCapability.Web.Webview.Core 6231 * @atomicservice 6232 * @since 12 6233 */ 6234 setNetErrorCode(code: WebNetErrorList): void; 6235 /** 6236 * Get net error code. 6237 * 6238 * @returns { WebNetErrorList } Return response error code. 6239 * @syscap SystemCapability.Web.Webview.Core 6240 * @atomicservice 6241 * @since 12 6242 */ 6243 getNetErrorCode(): WebNetErrorList; 6244 /** 6245 * Set http status code. 6246 * 6247 * @param { number } code - Http status code. 6248 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6249 * @syscap SystemCapability.Web.Webview.Core 6250 * @atomicservice 6251 * @since 12 6252 */ 6253 setStatus(code: number): void; 6254 /** 6255 * Get http status code. 6256 * 6257 * @returns { number } Return http status code. 6258 * @syscap SystemCapability.Web.Webview.Core 6259 * @atomicservice 6260 * @since 12 6261 */ 6262 getStatus(): number; 6263 /** 6264 * Set status text. 6265 * 6266 * @param { string } text - Status text. 6267 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6268 * @syscap SystemCapability.Web.Webview.Core 6269 * @atomicservice 6270 * @since 12 6271 */ 6272 setStatusText(text: string): void; 6273 /** 6274 * Get status text. 6275 * 6276 * @returns { string } Return http status text. 6277 * @syscap SystemCapability.Web.Webview.Core 6278 * @atomicservice 6279 * @since 12 6280 */ 6281 getStatusText(): string; 6282 /** 6283 * Set mime type. 6284 * 6285 * @param { string } type - Mime type. 6286 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6287 * @syscap SystemCapability.Web.Webview.Core 6288 * @atomicservice 6289 * @since 12 6290 */ 6291 setMimeType(type: string): void; 6292 /** 6293 * Get mime type. 6294 * 6295 * @returns { string } Return mime type of response. 6296 * @syscap SystemCapability.Web.Webview.Core 6297 * @atomicservice 6298 * @since 12 6299 */ 6300 getMimeType(): string; 6301 /** 6302 * Set the response encoding. 6303 * 6304 * @param { string } encoding - Encoding. 6305 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6306 * @syscap SystemCapability.Web.Webview.Core 6307 * @atomicservice 6308 * @since 12 6309 */ 6310 setEncoding(encoding: string): void; 6311 /** 6312 * Get the response encoding. 6313 * 6314 * @returns { string } Return encoding of response. 6315 * @syscap SystemCapability.Web.Webview.Core 6316 * @atomicservice 6317 * @since 12 6318 */ 6319 getEncoding(): string; 6320 /** 6321 * Set response hander value by name. 6322 * 6323 * @param { string } name - Header name. 6324 * @param { string } value - Header value. 6325 * @param { boolean } overwrite - Whether to overwrite. 6326 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6327 * <br>2. Incorrect parameter types. 6328 * @syscap SystemCapability.Web.Webview.Core 6329 * @atomicservice 6330 * @since 12 6331 */ 6332 setHeaderByName(name: string, value: string, overwrite: boolean): void; 6333 /** 6334 * Get the header value by name from the response. 6335 * 6336 * @param { string } name - Header name. 6337 * @returns { string } Return header value by name. 6338 * @syscap SystemCapability.Web.Webview.Core 6339 * @atomicservice 6340 * @since 12 6341 */ 6342 getHeaderByName(name: string): string 6343 } 6344 6345 /** 6346 * Used to intercept url requests. Response headers and body can be sent through 6347 * WebResourceHandler. 6348 * 6349 * @syscap SystemCapability.Web.Webview.Core 6350 * @atomicservice 6351 * @since 12 6352 */ 6353 class WebResourceHandler { 6354 /** 6355 * Pass response headers to intercepted requests. 6356 * 6357 * @param { WebSchemeHandlerResponse } response - Set response header to intercept. 6358 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6359 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6360 * @syscap SystemCapability.Web.Webview.Core 6361 * @atomicservice 6362 * @since 12 6363 */ 6364 didReceiveResponse(response: WebSchemeHandlerResponse): void; 6365 /** 6366 * Pass response body data to intercepted requests. 6367 * 6368 * @param { ArrayBuffer } data - Set response body to intercept. 6369 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6370 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6371 * @syscap SystemCapability.Web.Webview.Core 6372 * @atomicservice 6373 * @since 12 6374 */ 6375 didReceiveResponseBody(data: ArrayBuffer): void; 6376 /** 6377 * Notify that this request should be finished and there is no more data available. 6378 * 6379 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6380 * @syscap SystemCapability.Web.Webview.Core 6381 * @atomicservice 6382 * @since 12 6383 */ 6384 didFinish(): void; 6385 /** 6386 * Notify that this request should be failed. 6387 * 6388 * @param { WebNetErrorList } code - Set response error code to intercept. 6389 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6390 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6391 * @syscap SystemCapability.Web.Webview.Core 6392 * @atomicservice 6393 * @since 12 6394 */ 6395 didFail(code: WebNetErrorList): void; 6396 } 6397 6398 /** 6399 * This class is used to intercept requests for a specified scheme. 6400 * 6401 * @syscap SystemCapability.Web.Webview.Core 6402 * @atomicservice 6403 * @since 12 6404 */ 6405 class WebSchemeHandler { 6406 /** 6407 * Callback for handling the request. 6408 * 6409 * @param { function } callback - Callback of handling the request. If callback return false, 6410 * it means no interception. 6411 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6412 * <br>2. Incorrect parameter types. 6413 * @syscap SystemCapability.Web.Webview.Core 6414 * @atomicservice 6415 * @since 12 6416 */ 6417 onRequestStart( 6418 callback: (request: WebSchemeHandlerRequest, handler: WebResourceHandler) => boolean): void; 6419 6420 /** 6421 * Callback when the request is completed. 6422 * 6423 * @param { Callback<WebSchemeHandlerRequest> } callback - Callback of request is completed. 6424 * @throws { BusinessError } 401 - Invalid input parameter. 6425 * @syscap SystemCapability.Web.Webview.Core 6426 * @atomicservice 6427 * @since 12 6428 */ 6429 onRequestStop(callback: Callback<WebSchemeHandlerRequest>): void; 6430 } 6431 6432 /** 6433 * Enum type supplied to {@link handleStatusChanged} for indicating the playback status. 6434 * @enum {number} 6435 * @syscap SystemCapability.Web.Webview.Core 6436 * @atomicservice 6437 * @since 12 6438 */ 6439 enum PlaybackStatus { 6440 /** 6441 * Player status is paused. 6442 * @syscap SystemCapability.Web.Webview.Core 6443 * @atomicservice 6444 * @since 12 6445 */ 6446 PAUSED = 0, 6447 /** 6448 * Player status is playing. 6449 * @syscap SystemCapability.Web.Webview.Core 6450 * @atomicservice 6451 * @since 12 6452 */ 6453 PLAYING, 6454 } 6455 6456 /** 6457 * Enum type supplied to {@link handleNetworkStateChanged} for indicating the native player network state. 6458 * @enum {number} 6459 * @syscap SystemCapability.Web.Webview.Core 6460 * @atomicservice 6461 * @since 12 6462 */ 6463 enum NetworkState { 6464 /** 6465 * Player does not do any download tasks. 6466 * @syscap SystemCapability.Web.Webview.Core 6467 * @atomicservice 6468 * @since 12 6469 */ 6470 EMPTY = 0, 6471 /** 6472 * Player downloads finished, waiting for next task. 6473 * @syscap SystemCapability.Web.Webview.Core 6474 * @atomicservice 6475 * @since 12 6476 */ 6477 IDLE, 6478 /** 6479 * Player is downloading contents. 6480 * @syscap SystemCapability.Web.Webview.Core 6481 * @atomicservice 6482 * @since 12 6483 */ 6484 LOADING, 6485 /** 6486 * Player downloads failed, due to network error. 6487 * @syscap SystemCapability.Web.Webview.Core 6488 * @atomicservice 6489 * @since 12 6490 */ 6491 NETWORK_ERROR 6492 } 6493 6494 /** 6495 * Enum type supplied to {@link handleReadyStateChanged} for indicating the native player network state. 6496 * @enum {number} 6497 * @syscap SystemCapability.Web.Webview.Core 6498 * @atomicservice 6499 * @since 12 6500 */ 6501 enum ReadyState { 6502 /** 6503 * Player hasn't downloaded anything. 6504 * @syscap SystemCapability.Web.Webview.Core 6505 * @atomicservice 6506 * @since 12 6507 */ 6508 HAVE_NOTHING = 0, 6509 /** 6510 * Player has downloaded metadata. 6511 * @syscap SystemCapability.Web.Webview.Core 6512 * @atomicservice 6513 * @since 12 6514 */ 6515 HAVE_METADATA, 6516 /** 6517 * Player has played all downloaded media data. 6518 * @syscap SystemCapability.Web.Webview.Core 6519 * @atomicservice 6520 * @since 12 6521 */ 6522 HAVE_CURRENT_DATA, 6523 /** 6524 * The buffered media data is not enough, and will cause jank. 6525 * @syscap SystemCapability.Web.Webview.Core 6526 * @atomicservice 6527 * @since 12 6528 */ 6529 HAVE_FUTURE_DATA, 6530 /** 6531 * The buffered media data is enough. 6532 * @syscap SystemCapability.Web.Webview.Core 6533 * @atomicservice 6534 * @since 12 6535 */ 6536 HAVE_ENOUGH_DATA, 6537 } 6538 6539 /** 6540 * Enum type supplied to {@link handleError} for indicating the error type of native media player. 6541 * @enum {number} 6542 * @syscap SystemCapability.Web.Webview.Core 6543 * @atomicservice 6544 * @since 12 6545 */ 6546 enum MediaError { 6547 /** 6548 * Network error 6549 * @syscap SystemCapability.Web.Webview.Core 6550 * @atomicservice 6551 * @since 12 6552 */ 6553 NETWORK_ERROR = 1, 6554 /** 6555 * Media format error, such as not a valid file. 6556 * @syscap SystemCapability.Web.Webview.Core 6557 * @atomicservice 6558 * @since 12 6559 */ 6560 FORMAT_ERROR, 6561 /** 6562 * Decode error, such as decoder doesn't support this format. 6563 * @syscap SystemCapability.Web.Webview.Core 6564 * @atomicservice 6565 * @since 12 6566 */ 6567 DECODE_ERROR 6568 } 6569 6570 /** 6571 * The native media player status handler. 6572 * Apps should use this class to handle native media player's status. 6573 * 6574 * @typedef NativeMediaPlayerHandler 6575 * @syscap SystemCapability.Web.Webview.Core 6576 * @atomicservice 6577 * @since 12 6578 */ 6579 interface NativeMediaPlayerHandler { 6580 6581 /** 6582 * Handle native media player playback status. 6583 * 6584 * @param { PlaybackStatus } status - Playback status of native media player. 6585 * @syscap SystemCapability.Web.Webview.Core 6586 * @atomicservice 6587 * @since 12 6588 */ 6589 handleStatusChanged(status: PlaybackStatus): void 6590 6591 /** 6592 * Handle native media player volume. 6593 * volume: float 6594 * value range: [0 - 1.0] 6595 * 6596 * @param { number } volume - Current volume of native media player. 6597 * @syscap SystemCapability.Web.Webview.Core 6598 * @atomicservice 6599 * @since 12 6600 */ 6601 handleVolumeChanged(volume: number): void 6602 6603 /** 6604 * Handle native media player muted status. 6605 * 6606 * @param { boolean } muted - Current mute status of native media player. 6607 * @syscap SystemCapability.Web.Webview.Core 6608 * @atomicservice 6609 * @since 12 6610 */ 6611 handleMutedChanged(muted: boolean): void 6612 6613 /** 6614 * Handle playback rate of native media player. 6615 * playbackRate: float 6616 * value range: [0 - infinity] 6617 * 6618 * @param { number } playbackRate - Current playback rate of native media player. 6619 * @syscap SystemCapability.Web.Webview.Core 6620 * @atomicservice 6621 * @since 12 6622 */ 6623 handlePlaybackRateChanged(playbackRate: number): void 6624 6625 /** 6626 * Handle duration time of media. 6627 * duration: float 6628 * value range: [0 - infinity] 6629 * 6630 * @param { number } duration - Duration time (in seconds) of media. 6631 * @syscap SystemCapability.Web.Webview.Core 6632 * @atomicservice 6633 * @since 12 6634 */ 6635 handleDurationChanged(duration: number): void 6636 6637 /** 6638 * Handle current playing time of media. 6639 * currentPlayTime: float 6640 * value range: [0 - duration] 6641 * 6642 * @param { number } currentPlayTime - Current playing time (in seconds) of media. 6643 * @syscap SystemCapability.Web.Webview.Core 6644 * @atomicservice 6645 * @since 12 6646 */ 6647 handleTimeUpdate(currentPlayTime: number): void 6648 6649 /** 6650 * Handle buffered end time of media. 6651 * bufferedEndTime: float 6652 * value range: [0 - duration] 6653 * 6654 * @param { number } bufferedEndTime - Buffered end time (in seconds) of media. 6655 * @syscap SystemCapability.Web.Webview.Core 6656 * @atomicservice 6657 * @since 12 6658 */ 6659 handleBufferedEndTimeChanged(bufferedEndTime: number): void 6660 6661 /** 6662 * Handle native player ended event. 6663 * 6664 * @syscap SystemCapability.Web.Webview.Core 6665 * @atomicservice 6666 * @since 12 6667 */ 6668 handleEnded(): void 6669 6670 /** 6671 * Handle network state of native media player. 6672 * 6673 * @param { NetworkState } state - Network state of native media player. 6674 * @syscap SystemCapability.Web.Webview.Core 6675 * @atomicservice 6676 * @since 12 6677 */ 6678 handleNetworkStateChanged(state: NetworkState): void 6679 6680 /** 6681 * Handle ready state of native media player. 6682 * 6683 * @param { ReadyState } state - Ready state of native media player. 6684 * @syscap SystemCapability.Web.Webview.Core 6685 * @atomicservice 6686 * @since 12 6687 */ 6688 handleReadyStateChanged(state: ReadyState): void 6689 6690 /** 6691 * Handle native media player fullscreen state changed event. 6692 * 6693 * @param { boolean } fullscreen - Fullscreen state of native media player. 6694 * @syscap SystemCapability.Web.Webview.Core 6695 * @atomicservice 6696 * @since 12 6697 */ 6698 handleFullscreenChanged(fullscreen: boolean): void 6699 6700 /** 6701 * Handle native media player seeking state. 6702 * 6703 * @syscap SystemCapability.Web.Webview.Core 6704 * @atomicservice 6705 * @since 12 6706 */ 6707 handleSeeking(): void 6708 6709 /** 6710 * Handle native media player seek finished state. 6711 * 6712 * @syscap SystemCapability.Web.Webview.Core 6713 * @atomicservice 6714 * @since 12 6715 */ 6716 handleSeekFinished(): void 6717 6718 /** 6719 * Handle native media player error event. 6720 * 6721 * @param { MediaError } error - Error type of native media player. 6722 * @param { string } errorMessage - Description of current error. 6723 * @syscap SystemCapability.Web.Webview.Core 6724 * @atomicservice 6725 * @since 12 6726 */ 6727 handleError(error: MediaError, errorMessage: string): void 6728 6729 /** 6730 * Handle size of video. 6731 * 6732 * @param { number } width - Width of video. 6733 * @param { number } height - Height of video. 6734 * @syscap SystemCapability.Web.Webview.Core 6735 * @atomicservice 6736 * @since 12 6737 */ 6738 handleVideoSizeChanged(width: number, height: number): void 6739 } 6740 6741 /** 6742 * The scenarios for suspending the media player. 6743 * @enum {number} 6744 * @syscap SystemCapability.Web.Webview.Core 6745 * @since 12 6746 */ 6747 enum SuspendType { 6748 /** 6749 * Page enters the BackForwardCache. 6750 * @syscap SystemCapability.Web.Webview.Core 6751 * @since 12 6752 */ 6753 ENTER_BACK_FORWARD_CACHE = 0, 6754 6755 /** 6756 * Page enters background. 6757 * @syscap SystemCapability.Web.Webview.Core 6758 * @since 12 6759 */ 6760 ENTER_BACKGROUND, 6761 6762 /** 6763 * Cleanup when the number of paused media player over limit. 6764 * @syscap SystemCapability.Web.Webview.Core 6765 * @since 12 6766 */ 6767 AUTO_CLEANUP 6768 } 6769 6770 /** 6771 * The bridge between web core and native media player. 6772 * Apps should implements this interface, and pass an instance to web core. 6773 * Then web core can control native media player by this bridge. 6774 * 6775 * @typedef NativeMediaPlayerBridge 6776 * @syscap SystemCapability.Web.Webview.Core 6777 * @atomicservice 6778 * @since 12 6779 */ 6780 interface NativeMediaPlayerBridge { 6781 /** 6782 * Notify native media player that the rect of video tag has changed. 6783 * 6784 * @param { number } x - The x position of video tag in web component. 6785 * @param { number } y - The y position of video tag in web component. 6786 * @param { number } width - The width of video tag. 6787 * @param { number } height - The height of video tag. 6788 * @syscap SystemCapability.Web.Webview.Core 6789 * @atomicservice 6790 * @since 12 6791 */ 6792 updateRect(x: number, y: number, width: number, height: number): void 6793 6794 /** 6795 * Request to play. 6796 * 6797 * @syscap SystemCapability.Web.Webview.Core 6798 * @atomicservice 6799 * @since 12 6800 */ 6801 play(): void 6802 6803 /** 6804 * Request to pause. 6805 * 6806 * @syscap SystemCapability.Web.Webview.Core 6807 * @atomicservice 6808 * @since 12 6809 */ 6810 pause(): void 6811 6812 /** 6813 * Request to fast forward / back forward to targetTime. 6814 * targetTime: float 6815 * value range: [0 - duration] 6816 * 6817 * @param { number } targetTime - The target time (in seconds) to FF/BF to. 6818 * @syscap SystemCapability.Web.Webview.Core 6819 * @atomicservice 6820 * @since 12 6821 */ 6822 seek(targetTime: number): void 6823 6824 /** 6825 * Request to change volume of native media player. 6826 * volume: float 6827 * value range: [0 - 1.0] 6828 * 6829 * @param { number } volume - The volume of native media player. 6830 * @syscap SystemCapability.Web.Webview.Core 6831 * @atomicservice 6832 * @since 12 6833 */ 6834 setVolume(volume: number): void 6835 6836 /** 6837 * Request to mute native media player. 6838 * 6839 * @param { boolean } muted - Should mute native media player. 6840 * @syscap SystemCapability.Web.Webview.Core 6841 * @atomicservice 6842 * @since 12 6843 */ 6844 setMuted(muted: boolean): void 6845 6846 /** 6847 * Request to change playback rate of native media player. 6848 * playbackRate: float 6849 * value range: [0 - 10.0] 6850 * 6851 * @param { number } playbackRate - The playback rate of native media player. 6852 * @syscap SystemCapability.Web.Webview.Core 6853 * @atomicservice 6854 * @since 12 6855 */ 6856 setPlaybackRate(playbackRate: number): void 6857 6858 /** 6859 * Request to release native media player. 6860 * 6861 * @syscap SystemCapability.Web.Webview.Core 6862 * @atomicservice 6863 * @since 12 6864 */ 6865 release(): void 6866 6867 /** 6868 * Request to enter fullscreen. 6869 * 6870 * @syscap SystemCapability.Web.Webview.Core 6871 * @atomicservice 6872 * @since 12 6873 */ 6874 enterFullscreen(): void 6875 6876 /** 6877 * Request to exit fullscreen. 6878 * 6879 * @syscap SystemCapability.Web.Webview.Core 6880 * @atomicservice 6881 * @since 12 6882 */ 6883 exitFullscreen(): void 6884 6885 /** 6886 * Resume the native media player. 6887 * 6888 * @syscap SystemCapability.Web.Webview.Core 6889 * @since 12 6890 */ 6891 resumePlayer?(): void 6892 6893 /** 6894 * Suspend to release native media player, not the NativeMediaPlayerBridge. The 6895 * embedder should save the status of player when release the native media player 6896 * through NativeMediaPlayerBridge. 6897 * 6898 * @param { SuspendType } type - The scenario for suspending the media player. 6899 * @syscap SystemCapability.Web.Webview.Core 6900 * @since 12 6901 */ 6902 suspendPlayer?(type: SuspendType): void 6903 } 6904 6905 /** 6906 * Enum type for indicating the media type of native media player. 6907 * @enum {number} 6908 * @syscap SystemCapability.Web.Webview.Core 6909 * @atomicservice 6910 * @since 12 6911 */ 6912 enum MediaType { 6913 /** 6914 * Media type is video. 6915 * @syscap SystemCapability.Web.Webview.Core 6916 * @atomicservice 6917 * @since 12 6918 */ 6919 VIDEO = 0, 6920 /** 6921 * Media type is audio. 6922 * @syscap SystemCapability.Web.Webview.Core 6923 * @atomicservice 6924 * @since 12 6925 */ 6926 AUDIO 6927 } 6928 6929 /** 6930 * Enum type for indicating the media source type of native media player. 6931 * @enum {number} 6932 * @syscap SystemCapability.Web.Webview.Core 6933 * @atomicservice 6934 * @since 12 6935 */ 6936 enum SourceType { 6937 /** 6938 * Source type is URL. 6939 * @syscap SystemCapability.Web.Webview.Core 6940 * @atomicservice 6941 * @since 12 6942 */ 6943 URL = 0, 6944 /** 6945 * Source type is blob. 6946 * @syscap SystemCapability.Web.Webview.Core 6947 * @atomicservice 6948 * @since 12 6949 */ 6950 MSE 6951 } 6952 6953 /** 6954 * Media source information. Uri and format. 6955 * 6956 * @syscap SystemCapability.Web.Webview.Core 6957 * @atomicservice 6958 * @since 12 6959 */ 6960 class MediaSourceInfo { 6961 /** 6962 * Source type, most time is URL. 6963 * @type { SourceType } 6964 * @syscap SystemCapability.Web.Webview.Core 6965 * @since 12 6966 */ 6967 type: SourceType; 6968 6969 /** 6970 * Media source, most time is Uri. 6971 * @type { string } 6972 * @syscap SystemCapability.Web.Webview.Core 6973 * @atomicservice 6974 * @since 12 6975 */ 6976 source: string; 6977 6978 /** 6979 * Media format, such as mp4, webm, m3u8 etc. 6980 * @type { string } 6981 * @syscap SystemCapability.Web.Webview.Core 6982 * @atomicservice 6983 * @since 12 6984 */ 6985 format: string; 6986 } 6987 6988 /** 6989 * Rectangle definition. 6990 * 6991 * @typedef RectEvent 6992 * @syscap SystemCapability.Web.Webview.Core 6993 * @since 12 6994 */ 6995 interface RectEvent { 6996 /** 6997 * X coordinator of top left point. 6998 * 6999 * @type { number } 7000 * @syscap SystemCapability.Web.Webview.Core 7001 * @since 12 7002 */ 7003 x: number; 7004 /** 7005 * Y coordinator of top left point. 7006 * 7007 * @type { number } 7008 * @syscap SystemCapability.Web.Webview.Core 7009 * @since 12 7010 */ 7011 y: number; 7012 /** 7013 * Width of this rectangle. 7014 * 7015 * @type { number } 7016 * @syscap SystemCapability.Web.Webview.Core 7017 * @since 12 7018 */ 7019 width: number; 7020 /** 7021 * Height of this rectangle. 7022 * 7023 * @type { number } 7024 * @syscap SystemCapability.Web.Webview.Core 7025 * @since 12 7026 */ 7027 height: number; 7028 } 7029 7030 /** 7031 * Surface information. 7032 * 7033 * @syscap SystemCapability.Web.Webview.Core 7034 * @atomicservice 7035 * @since 12 7036 */ 7037 class NativeMediaPlayerSurfaceInfo { 7038 /** 7039 * Id of surface. 7040 * @type { string } 7041 * @syscap SystemCapability.Web.Webview.Core 7042 * @atomicservice 7043 * @since 12 7044 */ 7045 id: string; 7046 7047 /** 7048 * Surface rect info. 7049 * @type { RectEvent } 7050 * @syscap SystemCapability.Web.Webview.Core 7051 * @since 12 7052 */ 7053 rect: RectEvent; 7054 } 7055 7056 /** 7057 * Enum type for indicating the preload type. 7058 * @enum {number} 7059 * @syscap SystemCapability.Web.Webview.Core 7060 * @atomicservice 7061 * @since 12 7062 */ 7063 enum Preload { 7064 /** 7065 * Doesn't do preload. 7066 * @syscap SystemCapability.Web.Webview.Core 7067 * @atomicservice 7068 * @since 12 7069 */ 7070 NONE = 0, 7071 /** 7072 * Only preload metadata. 7073 * @syscap SystemCapability.Web.Webview.Core 7074 * @atomicservice 7075 * @since 12 7076 */ 7077 METADATA, 7078 /** 7079 * Preload enough data to ensure playing is smooth. 7080 * @syscap SystemCapability.Web.Webview.Core 7081 * @atomicservice 7082 * @since 12 7083 */ 7084 AUTO 7085 } 7086 7087 /** 7088 * Media information. 7089 * 7090 * @typedef MediaInfo 7091 * @syscap SystemCapability.Web.Webview.Core 7092 * @atomicservice 7093 * @since 12 7094 */ 7095 interface MediaInfo { 7096 /** 7097 * Id of media element. 7098 * @type { string } 7099 * @syscap SystemCapability.Web.Webview.Core 7100 * @since 12 7101 */ 7102 embedID: string, 7103 /** 7104 * Media type : Video or Audio. 7105 * @type { MediaType } 7106 * @syscap SystemCapability.Web.Webview.Core 7107 * @atomicservice 7108 * @since 12 7109 */ 7110 mediaType: MediaType, 7111 /** 7112 * Media source list, player should choose an appropriate one to play. 7113 * @type { MediaSourceInfo[] } 7114 * @syscap SystemCapability.Web.Webview.Core 7115 * @atomicservice 7116 * @since 12 7117 */ 7118 mediaSrcList: MediaSourceInfo[], 7119 /** 7120 * Surface to render media content on. 7121 * @type { NativeMediaPlayerSurfaceInfo } 7122 * @syscap SystemCapability.Web.Webview.Core 7123 * @atomicservice 7124 * @since 12 7125 */ 7126 surfaceInfo: NativeMediaPlayerSurfaceInfo, 7127 /** 7128 * Should show media controls. 7129 * @type { boolean } 7130 * @syscap SystemCapability.Web.Webview.Core 7131 * @atomicservice 7132 * @since 12 7133 */ 7134 controlsShown: boolean, 7135 /** 7136 * Limit media controls items. 7137 * Such as 'nodownload', 'nofullscreen', 'noremoteplayback' 7138 * @type { string[] } 7139 * @syscap SystemCapability.Web.Webview.Core 7140 * @atomicservice 7141 * @since 12 7142 */ 7143 controlList: string[], 7144 /** 7145 * Player should be muted; 7146 * @type { boolean } 7147 * @syscap SystemCapability.Web.Webview.Core 7148 * @atomicservice 7149 * @since 12 7150 */ 7151 muted: boolean, 7152 /** 7153 * Player should show poster before media first frame shown. 7154 * @type { string } 7155 * @syscap SystemCapability.Web.Webview.Core 7156 * @atomicservice 7157 * @since 12 7158 */ 7159 posterUrl: string, 7160 /** 7161 * Preload type. 7162 * @type { Preload } 7163 * @syscap SystemCapability.Web.Webview.Core 7164 * @atomicservice 7165 * @since 12 7166 */ 7167 preload: Preload, 7168 /** 7169 * Header information of a media network request. 7170 * @type { Record<string, string> } 7171 * @syscap SystemCapability.Web.Webview.Core 7172 * @since 12 7173 */ 7174 headers: Record<string, string>, 7175 /** 7176 * The information list of attributes of media tag. 7177 * @type { Record<string, string> } 7178 * @syscap SystemCapability.Web.Webview.Core 7179 * @since 12 7180 */ 7181 attributes: Record<string, string>, 7182 } 7183 7184 /** 7185 * The callback of creating a native media player. 7186 * 7187 * @typedef { function } 7188 * @param { NativeMediaPlayerHandler } handler - callback information of onCreateNativeMediaPlayer. 7189 * @param { MediaInfo } mediaInfo - callback information of onCreateNativeMediaPlayer. 7190 * @returns { NativeMediaPlayerBridge } Returns whether the app takes over the media. 7191 * @syscap SystemCapability.Web.Webview.Core 7192 * @atomicservice 7193 * @since 12 7194 */ 7195 type CreateNativeMediaPlayerCallback = 7196 (handler: NativeMediaPlayerHandler, mediaInfo: MediaInfo) => NativeMediaPlayerBridge; 7197 7198 /** 7199 * This class is used to set adblock config. 7200 * @syscap SystemCapability.Web.Webview.Core 7201 * @atomicservice 7202 * @since 12 7203 */ 7204 class AdsBlockManager { 7205 /** 7206 * set Ads Block ruleset file, containing easylist rules. 7207 * @param {string} rulesFile - absolute file path contains app customized ads block rules. 7208 * @param {boolean} replace - (@code true)replace internal rules;(@code false) add to internal rules. 7209 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7210 * <br>2. Incorrect parameter types. 7211 * @syscap SystemCapability.Web.Webview.Core 7212 * @atomicservice 7213 * @since 12 7214 */ 7215 static setAdsBlockRules(rulesFile: string, replace: boolean): void; 7216 7217 /** 7218 * Add items to Ads Block Disallow list. 7219 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 7220 * Ads Block will be disallowed for the web page. 7221 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7222 * <br>2. Incorrect parameter types. 7223 * @syscap SystemCapability.Web.Webview.Core 7224 * @atomicservice 7225 * @since 12 7226 */ 7227 static addAdsBlockDisallowedList(domainSuffixes: Array<string>): void; 7228 7229 /** 7230 * Add items to Ads Block Allow list. 7231 * By default, ads block is allowed for all pages unless they are added to the 7232 * disallow list. The priority of allowlist is higher than the disallowlist. It is 7233 * used to re-enable ads block on the page that matches disallow list. 7234 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 7235 * Ads Block will be allowed for the web page. 7236 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7237 * <br>2. Incorrect parameter types. 7238 * @syscap SystemCapability.Web.Webview.Core 7239 * @atomicservice 7240 * @since 12 7241 */ 7242 static addAdsBlockAllowedList(domainSuffixes: Array<string>): void; 7243 7244 /** 7245 * remove items from Ads Block Disallowed list. 7246 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from disallow list 7247 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7248 * <br>2. Incorrect parameter types. 7249 * @syscap SystemCapability.Web.Webview.Core 7250 * @atomicservice 7251 * @since 12 7252 */ 7253 static removeAdsBlockDisallowedList(domainSuffixes: Array<string>): void; 7254 7255 /** 7256 * remove items from Ads Block Allowed list. 7257 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from allow list 7258 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7259 * <br>2. Incorrect parameter types. 7260 * @syscap SystemCapability.Web.Webview.Core 7261 * @atomicservice 7262 * @since 12 7263 */ 7264 static removeAdsBlockAllowedList(domainSuffixes: Array<string>): void; 7265 7266 /** 7267 * clear Ads Block Disallowed list. 7268 * @syscap SystemCapability.Web.Webview.Core 7269 * @atomicservice 7270 * @since 12 7271 */ 7272 static clearAdsBlockDisallowedList(): void; 7273 7274 /** 7275 * clear Ads Block Allowed list. 7276 * @syscap SystemCapability.Web.Webview.Core 7277 * @atomicservice 7278 * @since 12 7279 */ 7280 static clearAdsBlockAllowedList(): void; 7281 } 7282 7283 /** 7284 * This class is used to enable back forward cache supported features. 7285 * 7286 * @syscap SystemCapability.Web.Webview.Core 7287 * @since 12 7288 */ 7289 class BackForwardCacheSupportedFeatures { 7290 /** 7291 * Whether cache the pages that use native embed. 7292 * Default is false; 7293 * 7294 * @type { boolean } 7295 * @syscap SystemCapability.Web.Webview.Core 7296 * @since 12 7297 */ 7298 nativeEmbed: boolean; 7299 7300 /** 7301 * Whether cache the pages that use media take over. 7302 * Default is false; 7303 * 7304 * @type { boolean } 7305 * @syscap SystemCapability.Web.Webview.Core 7306 * @since 12 7307 */ 7308 mediaTakeOver: boolean; 7309 7310 /** 7311 * @syscap SystemCapability.Web.Webview.Core 7312 * @since 12 7313 */ 7314 constructor(); 7315 } 7316 7317 /** 7318 * This class is used to set back forward cache options. 7319 * 7320 * @syscap SystemCapability.Web.Webview.Core 7321 * @since 12 7322 */ 7323 class BackForwardCacheOptions { 7324 /** 7325 * Set the maximum size of pages that can cache. 7326 * Default is 1, max is 50. 7327 * 7328 * @type { number } 7329 * @syscap SystemCapability.Web.Webview.Core 7330 * @since 12 7331 */ 7332 size: number; 7333 7334 /** 7335 * Set the lifetime in seconds in the BackForwardCache. 7336 * Default is 600. 7337 * 7338 * @type { number } 7339 * @syscap SystemCapability.Web.Webview.Core 7340 * @since 12 7341 */ 7342 timeToLive: number; 7343 7344 /** 7345 * @syscap SystemCapability.Web.Webview.Core 7346 * @since 12 7347 */ 7348 constructor(); 7349 } 7350 7351} 7352 7353export default webview; 7354