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 synchronously. 1548 * @syscap SystemCapability.Web.Webview.Core 1549 * @since 15 1550 */ 1551 static saveCookieSync(): void; 1552 1553 /** 1554 * Save the cookies Asynchronously. 1555 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1556 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1557 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1558 * @syscap SystemCapability.Web.Webview.Core 1559 * @since 9 1560 */ 1561 /** 1562 * Save the cookies Asynchronously. 1563 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1564 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1565 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1566 * @syscap SystemCapability.Web.Webview.Core 1567 * @atomicservice 1568 * @since 11 1569 */ 1570 static saveCookieAsync(): Promise<void>; 1571 1572 /** 1573 * Save the cookies Asynchronously. 1574 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1575 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1576 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1577 * @syscap SystemCapability.Web.Webview.Core 1578 * @since 9 1579 */ 1580 /** 1581 * Save the cookies Asynchronously. 1582 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1583 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1584 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1585 * @syscap SystemCapability.Web.Webview.Core 1586 * @atomicservice 1587 * @since 11 1588 */ 1589 static saveCookieAsync(callback: AsyncCallback<void>): void; 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 * @since 9 1597 */ 1598 /** 1599 * Get whether the instance can send and accept cookies. 1600 * 1601 * @returns { boolean } True if the instance can send and accept cookies else false. 1602 * @syscap SystemCapability.Web.Webview.Core 1603 * @atomicservice 1604 * @since 11 1605 */ 1606 static isCookieAllowed(): boolean; 1607 1608 /** 1609 * Set whether the instance should send and accept cookies. 1610 * By default this is set to be true. 1611 * 1612 * @param { boolean } accept - Whether the instance should send and accept cookies. 1613 * @throws { BusinessError } 401 - Invalid input parameter. 1614 * @syscap SystemCapability.Web.Webview.Core 1615 * @since 9 1616 */ 1617 /** 1618 * Set whether the instance should send and accept cookies. 1619 * By default this is set to be true. 1620 * 1621 * @param { boolean } accept - Whether the instance should send and accept cookies. 1622 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1623 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1624 * @syscap SystemCapability.Web.Webview.Core 1625 * @atomicservice 1626 * @since 11 1627 */ 1628 static putAcceptCookieEnabled(accept: boolean): void; 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 * @since 9 1636 */ 1637 /** 1638 * Get whether the instance can send and accept thirdparty cookies. 1639 * 1640 * @returns { boolean } True if the instance can send and accept thirdparty cookies else false. 1641 * @syscap SystemCapability.Web.Webview.Core 1642 * @atomicservice 1643 * @since 11 1644 */ 1645 static isThirdPartyCookieAllowed(): boolean; 1646 1647 /** 1648 * Set whether the instance should send and accept thirdparty cookies. 1649 * By default this is set to be false. 1650 * 1651 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 1652 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1653 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1654 * @syscap SystemCapability.Web.Webview.Core 1655 * @since 9 1656 */ 1657 /** 1658 * Set whether the instance should send and accept thirdparty cookies. 1659 * By default this is set to be false. 1660 * 1661 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 1662 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1663 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 1664 * @syscap SystemCapability.Web.Webview.Core 1665 * @atomicservice 1666 * @since 11 1667 */ 1668 static putAcceptThirdPartyCookieEnabled(accept: boolean): void; 1669 1670 /** 1671 * Check whether exists any cookies. 1672 * 1673 * @returns { boolean } True if exists more than one cookie else false; 1674 * @syscap SystemCapability.Web.Webview.Core 1675 * @since 9 1676 */ 1677 /** 1678 * Check whether exists any cookies. 1679 * 1680 * @param { boolean } incognito - {@code true} check whether exists any cookies. 1681 * in incognito mode; {@code false} otherwise. 1682 * @returns { boolean } True if exists more than one cookie else false; 1683 * @syscap SystemCapability.Web.Webview.Core 1684 * @atomicservice 1685 * @since 11 1686 */ 1687 static existCookie(incognito?: boolean): boolean; 1688 1689 /** 1690 * Remove all cookies. 1691 * @syscap SystemCapability.Web.Webview.Core 1692 * @since 9 1693 * @deprecated since 11 1694 * @useinstead ohos.web.webview.WebCookieManager#clearAllCookiesSync 1695 */ 1696 static deleteEntireCookie(): void; 1697 1698 /** 1699 * Remove all cookies. 1700 * 1701 * @param { boolean } incognito - {@code true} remove all cookies in incognito mode; 1702 * {@code false} otherwise. 1703 * @syscap SystemCapability.Web.Webview.Core 1704 * @atomicservice 1705 * @since 11 1706 */ 1707 static clearAllCookiesSync(incognito?: boolean): void; 1708 1709 /** 1710 * Remove all cookies Asynchronously. 1711 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 1712 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1713 * @syscap SystemCapability.Web.Webview.Core 1714 * @crossplatform 1715 * @atomicservice 1716 * @since 11 1717 */ 1718 static clearAllCookies(): Promise<void>; 1719 1720 /** 1721 * Remove all cookies Asynchronously. 1722 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 1723 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1724 * <br>2. Incorrect parameter types. 1725 * @syscap SystemCapability.Web.Webview.Core 1726 * @crossplatform 1727 * @atomicservice 1728 * @since 11 1729 */ 1730 static clearAllCookies(callback: AsyncCallback<void>): void; 1731 1732 /** 1733 * Delete the session cookies. 1734 * @syscap SystemCapability.Web.Webview.Core 1735 * @since 9 1736 * @deprecated since 11 1737 * @useinstead ohos.web.webview.WebCookieManager#clearSessionCookieSync 1738 */ 1739 static deleteSessionCookie(): void; 1740 1741 /** 1742 * Delete the session cookies. 1743 * @syscap SystemCapability.Web.Webview.Core 1744 * @atomicservice 1745 * @since 11 1746 */ 1747 static clearSessionCookieSync(): void; 1748 1749 /** 1750 * Delete the session cookies Asynchronously. 1751 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 1752 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1753 * @syscap SystemCapability.Web.Webview.Core 1754 * @atomicservice 1755 * @since 11 1756 */ 1757 static clearSessionCookie(): Promise<void>; 1758 1759 /** 1760 * Delete the session cookies Asynchronously. 1761 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 1762 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 1763 * <br>2. Incorrect parameter types. 1764 * @syscap SystemCapability.Web.Webview.Core 1765 * @atomicservice 1766 * @since 11 1767 */ 1768 static clearSessionCookie(callback: AsyncCallback<void>): void; 1769 } 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 * @since 10 1777 */ 1778 /** 1779 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 1780 * 1781 * @enum {number} 1782 * @syscap SystemCapability.Web.Webview.Core 1783 * @atomicservice 1784 * @since 11 1785 */ 1786 enum WebMessageType { 1787 /** 1788 * Unsupported data type. 1789 * 1790 * @syscap SystemCapability.Web.Webview.Core 1791 * @since 10 1792 */ 1793 /** 1794 * Unsupported data type. 1795 * 1796 * @syscap SystemCapability.Web.Webview.Core 1797 * @atomicservice 1798 * @since 11 1799 */ 1800 NOT_SUPPORT, 1801 1802 /** 1803 * The string data type. 1804 * 1805 * @syscap SystemCapability.Web.Webview.Core 1806 * @since 10 1807 */ 1808 /** 1809 * The string data type. 1810 * 1811 * @syscap SystemCapability.Web.Webview.Core 1812 * @atomicservice 1813 * @since 11 1814 */ 1815 STRING, 1816 1817 /** 1818 * The number data type. 1819 * 1820 * @syscap SystemCapability.Web.Webview.Core 1821 * @since 10 1822 */ 1823 /** 1824 * The number data type. 1825 * 1826 * @syscap SystemCapability.Web.Webview.Core 1827 * @atomicservice 1828 * @since 11 1829 */ 1830 NUMBER, 1831 1832 /** 1833 * The boolean data type. 1834 * 1835 * @syscap SystemCapability.Web.Webview.Core 1836 * @since 10 1837 */ 1838 /** 1839 * The boolean data type. 1840 * 1841 * @syscap SystemCapability.Web.Webview.Core 1842 * @atomicservice 1843 * @since 11 1844 */ 1845 BOOLEAN, 1846 1847 /** 1848 * The arraybuffer data type. 1849 * 1850 * @syscap SystemCapability.Web.Webview.Core 1851 * @since 10 1852 */ 1853 /** 1854 * The arraybuffer data type. 1855 * 1856 * @syscap SystemCapability.Web.Webview.Core 1857 * @atomicservice 1858 * @since 11 1859 */ 1860 ARRAY_BUFFER, 1861 1862 /** 1863 * The array data type. 1864 * 1865 * @syscap SystemCapability.Web.Webview.Core 1866 * @since 10 1867 */ 1868 /** 1869 * The array data type. 1870 * 1871 * @syscap SystemCapability.Web.Webview.Core 1872 * @atomicservice 1873 * @since 11 1874 */ 1875 ARRAY, 1876 1877 /** 1878 * The error data type. 1879 * 1880 * @syscap SystemCapability.Web.Webview.Core 1881 * @since 10 1882 */ 1883 /** 1884 * The error data type. 1885 * 1886 * @syscap SystemCapability.Web.Webview.Core 1887 * @atomicservice 1888 * @since 11 1889 */ 1890 ERROR 1891 } 1892 1893 /** 1894 * The message received or sent from web message port. 1895 * 1896 * @syscap SystemCapability.Web.Webview.Core 1897 * @since 10 1898 */ 1899 /** 1900 * The message received or sent from web message port. 1901 * 1902 * @syscap SystemCapability.Web.Webview.Core 1903 * @atomicservice 1904 * @since 11 1905 */ 1906 class WebMessageExt { 1907 /** 1908 * Get the type of the web message. 1909 * @returns { WebMessageType } - Returns data of WebMessageType type 1910 * @syscap SystemCapability.Web.Webview.Core 1911 * @since 10 1912 */ 1913 /** 1914 * Get the type of the web message. 1915 * @returns { WebMessageType } - Returns data of WebMessageType type 1916 * @syscap SystemCapability.Web.Webview.Core 1917 * @atomicservice 1918 * @since 11 1919 */ 1920 getType(): WebMessageType; 1921 1922 /** 1923 * Get the string value of the web message. 1924 * @returns { string } - Returns data of string type 1925 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1926 * 1927 * @syscap SystemCapability.Web.Webview.Core 1928 * @since 10 1929 */ 1930 /** 1931 * Get the string value of the web message. 1932 * @returns { string } - Returns data of string type 1933 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1934 * 1935 * @syscap SystemCapability.Web.Webview.Core 1936 * @atomicservice 1937 * @since 11 1938 */ 1939 getString(): string; 1940 1941 /** 1942 * Get the number value of the web message. 1943 * @returns { number } - Returns data of number type 1944 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1945 * 1946 * @syscap SystemCapability.Web.Webview.Core 1947 * @since 10 1948 */ 1949 /** 1950 * Get the number value of the web message. 1951 * @returns { number } - Returns data of number type 1952 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1953 * 1954 * @syscap SystemCapability.Web.Webview.Core 1955 * @atomicservice 1956 * @since 11 1957 */ 1958 getNumber(): number; 1959 1960 /** 1961 * Get the boolean value of the web message. 1962 * @returns { boolean } - Returns data of Boolean type 1963 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1964 * 1965 * @syscap SystemCapability.Web.Webview.Core 1966 * @since 10 1967 */ 1968 /** 1969 * Get the boolean value of the web message. 1970 * @returns { boolean } - Returns data of Boolean type 1971 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1972 * 1973 * @syscap SystemCapability.Web.Webview.Core 1974 * @atomicservice 1975 * @since 11 1976 */ 1977 getBoolean(): boolean; 1978 1979 /** 1980 * Get the array buffer value of the web message. 1981 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 1982 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1983 * 1984 * @syscap SystemCapability.Web.Webview.Core 1985 * @since 10 1986 */ 1987 /** 1988 * Get the array buffer value of the web message. 1989 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 1990 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 1991 * 1992 * @syscap SystemCapability.Web.Webview.Core 1993 * @atomicservice 1994 * @since 11 1995 */ 1996 getArrayBuffer(): ArrayBuffer; 1997 1998 /** 1999 * Get the array value of the web message. 2000 * @returns { Array<string | number | boolean> } - Returns data of Array type 2001 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2002 * 2003 * @syscap SystemCapability.Web.Webview.Core 2004 * @since 10 2005 */ 2006 /** 2007 * Get the array value of the web message. 2008 * @returns { Array<string | number | boolean> } - Returns data of Array type 2009 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2010 * 2011 * @syscap SystemCapability.Web.Webview.Core 2012 * @atomicservice 2013 * @since 11 2014 */ 2015 getArray(): Array<string | number | boolean>; 2016 2017 /** 2018 * Get the error value of the web message. 2019 * @returns { Error } - Returns data of Error type 2020 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2021 * 2022 * @syscap SystemCapability.Web.Webview.Core 2023 * @since 10 2024 */ 2025 /** 2026 * Get the error value of the web message. 2027 * @returns { Error } - Returns data of Error type 2028 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2029 * 2030 * @syscap SystemCapability.Web.Webview.Core 2031 * @atomicservice 2032 * @since 11 2033 */ 2034 getError(): Error; 2035 2036 /** 2037 * Set the type of the web message. 2038 * @param { WebMessageType } type - set WebMessageType type data 2039 * @throws { BusinessError } 401 - Invalid input parameter. 2040 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2041 * 2042 * @syscap SystemCapability.Web.Webview.Core 2043 * @since 10 2044 */ 2045 /** 2046 * Set the type of the web message. 2047 * @param { WebMessageType } type - set WebMessageType type data 2048 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2049 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2050 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2051 * 2052 * @syscap SystemCapability.Web.Webview.Core 2053 * @atomicservice 2054 * @since 11 2055 */ 2056 setType(type: WebMessageType): void; 2057 2058 /** 2059 * Set the string value of the web message. 2060 * @param { string } message - set string type data 2061 * @throws { BusinessError } 401 - Invalid input parameter. 2062 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2063 * 2064 * @syscap SystemCapability.Web.Webview.Core 2065 * @since 10 2066 */ 2067 /** 2068 * Set the string value of the web message. 2069 * @param { string } message - set string type data 2070 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2071 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2072 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2073 * 2074 * @syscap SystemCapability.Web.Webview.Core 2075 * @atomicservice 2076 * @since 11 2077 */ 2078 setString(message: string): void; 2079 2080 /** 2081 * Set the number value of the web message. 2082 * @param { number } message - set number type data 2083 * @throws { BusinessError } 401 - Invalid input parameter. 2084 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2085 * 2086 * @syscap SystemCapability.Web.Webview.Core 2087 * @since 10 2088 */ 2089 /** 2090 * Set the number value of the web message. 2091 * @param { number } message - set number type data 2092 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2093 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2094 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2095 * 2096 * @syscap SystemCapability.Web.Webview.Core 2097 * @atomicservice 2098 * @since 11 2099 */ 2100 setNumber(message: number): void; 2101 2102 /** 2103 * Set the boolean value of the web message. 2104 * @param { boolean } message - set boolean type data 2105 * @throws { BusinessError } 401 - Invalid input parameter. 2106 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2107 * 2108 * @syscap SystemCapability.Web.Webview.Core 2109 * @since 10 2110 */ 2111 /** 2112 * Set the boolean value of the web message. 2113 * @param { boolean } message - set boolean type data 2114 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2115 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2116 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2117 * 2118 * @syscap SystemCapability.Web.Webview.Core 2119 * @atomicservice 2120 * @since 11 2121 */ 2122 setBoolean(message: boolean): void; 2123 2124 /** 2125 * Set the array buffer value of the web message. 2126 * @param { ArrayBuffer } message - set ArrayBuffer type data 2127 * @throws { BusinessError } 401 - Invalid input parameter. 2128 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2129 * 2130 * @syscap SystemCapability.Web.Webview.Core 2131 * @since 10 2132 */ 2133 /** 2134 * Set the array buffer value of the web message. 2135 * @param { ArrayBuffer } message - set ArrayBuffer type data 2136 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2137 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2138 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2139 * 2140 * @syscap SystemCapability.Web.Webview.Core 2141 * @atomicservice 2142 * @since 11 2143 */ 2144 setArrayBuffer(message: ArrayBuffer): void; 2145 2146 /** 2147 * Set the array value of the web message. 2148 * @param { Array<string | number | boolean> } message - set Array type data 2149 * @throws { BusinessError } 401 - Invalid input parameter. 2150 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2151 * @syscap SystemCapability.Web.Webview.Core 2152 * @since 10 2153 */ 2154 /** 2155 * Set the array value of the web message. 2156 * @param { Array<string | number | boolean> } message - set Array type data 2157 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2158 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2159 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2160 * @syscap SystemCapability.Web.Webview.Core 2161 * @atomicservice 2162 * @since 11 2163 */ 2164 setArray(message: Array<string | number | boolean>): void; 2165 2166 /** 2167 * Set the error value of the web message. 2168 * @param { Error } message - set Error type data 2169 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2170 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2171 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2172 * 2173 * @syscap SystemCapability.Web.Webview.Core 2174 * @since 10 2175 */ 2176 /** 2177 * Set the error value of the web message. 2178 * @param { Error } message - set Error type data 2179 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2180 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2181 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2182 * 2183 * @syscap SystemCapability.Web.Webview.Core 2184 * @atomicservice 2185 * @since 11 2186 */ 2187 setError(message: Error): void; 2188 } 2189 2190 /** 2191 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 2192 * 2193 * @syscap SystemCapability.Web.Webview.Core 2194 * @since 9 2195 */ 2196 /** 2197 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 2198 * 2199 * @typedef { ArrayBuffer | string } 2200 * @syscap SystemCapability.Web.Webview.Core 2201 * @atomicservice 2202 * @since 11 2203 */ 2204 type WebMessage = ArrayBuffer | string; 2205 /** 2206 * Define html web message port. 2207 * @interface WebMessagePort 2208 * @syscap SystemCapability.Web.Webview.Core 2209 * @since 9 2210 */ 2211 /** 2212 * Define html web message port. 2213 * @interface WebMessagePort 2214 * @syscap SystemCapability.Web.Webview.Core 2215 * @crossplatform 2216 * @atomicservice 2217 * @since 11 2218 */ 2219 /** 2220 * Define html web message port. 2221 * @typedef WebMessagePort 2222 * @syscap SystemCapability.Web.Webview.Core 2223 * @crossplatform 2224 * @atomicservice 2225 * @since 12 2226 */ 2227 interface WebMessagePort { 2228 /** 2229 * The flag indicates whether more formats are supported than string and array buffers. 2230 * 2231 * @syscap SystemCapability.Web.Webview.Core 2232 * @since 10 2233 */ 2234 /** 2235 * The flag indicates whether more formats are supported than string and array buffers. 2236 * 2237 * @type { ?boolean } 2238 * @syscap SystemCapability.Web.Webview.Core 2239 * @atomicservice 2240 * @since 11 2241 */ 2242 isExtentionType?: boolean; 2243 2244 /** 2245 * Close port. 2246 * @syscap SystemCapability.Web.Webview.Core 2247 * @since 9 2248 */ 2249 /** 2250 * Close port. 2251 * @syscap SystemCapability.Web.Webview.Core 2252 * @crossplatform 2253 * @atomicservice 2254 * @since 11 2255 */ 2256 close(): void; 2257 2258 /** 2259 * Post a message to other port. 2260 * @param { WebMessage } message - Message to send. 2261 * @throws { BusinessError } 401 - Invalid input parameter. 2262 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2263 * @syscap SystemCapability.Web.Webview.Core 2264 * @since 9 2265 */ 2266 /** 2267 * Post a message to other port. 2268 * @param { WebMessage } message - Message to send. 2269 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2270 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2271 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2272 * @syscap SystemCapability.Web.Webview.Core 2273 * @crossplatform 2274 * @atomicservice 2275 * @since 11 2276 */ 2277 postMessageEvent(message: WebMessage): void; 2278 2279 /** 2280 * Receive message from other port. 2281 * @param { function } callback - Callback function for receiving messages. 2282 * @throws { BusinessError } 401 - Invalid input parameter. 2283 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2284 * @syscap SystemCapability.Web.Webview.Core 2285 * @since 9 2286 */ 2287 /** 2288 * Receive message from other port. 2289 * @param { function } callback - Callback function for receiving messages. 2290 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2291 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2292 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2293 * @syscap SystemCapability.Web.Webview.Core 2294 * @crossplatform 2295 * @atomicservice 2296 * @since 11 2297 */ 2298 onMessageEvent(callback: (result: WebMessage) => void): void; 2299 2300 /** 2301 * Post a message to other port. 2302 * @param { WebMessageExt } message - Message to send. 2303 * @throws { BusinessError } 401 - Invalid input parameter. 2304 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2305 * @syscap SystemCapability.Web.Webview.Core 2306 * @since 10 2307 */ 2308 /** 2309 * Post a message to other port. 2310 * @param { WebMessageExt } message - Message to send. 2311 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2312 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2313 * @throws { BusinessError } 17100010 - Failed to post messages through the port. 2314 * @syscap SystemCapability.Web.Webview.Core 2315 * @atomicservice 2316 * @since 11 2317 */ 2318 postMessageEventExt(message: WebMessageExt): void; 2319 2320 /** 2321 * Receive message from other port. 2322 * @param { function } callback - Callback function for receiving messages. 2323 * @throws { BusinessError } 401 - Invalid input parameter. 2324 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2325 * @syscap SystemCapability.Web.Webview.Core 2326 * @since 10 2327 */ 2328 /** 2329 * Receive message from other port. 2330 * @param { function } callback - Callback function for receiving messages. 2331 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2332 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2333 * @throws { BusinessError } 17100006 - Failed to register a message event for the port. 2334 * @syscap SystemCapability.Web.Webview.Core 2335 * @atomicservice 2336 * @since 11 2337 */ 2338 onMessageEventExt(callback: (result: WebMessageExt) => void): void; 2339 } 2340 2341 /** 2342 * Provides information for history item in BackForwardList. 2343 * @interface HistoryItem 2344 * @syscap SystemCapability.Web.Webview.Core 2345 * @since 9 2346 */ 2347 /** 2348 * Provides information for history item in BackForwardList. 2349 * @interface HistoryItem 2350 * @syscap SystemCapability.Web.Webview.Core 2351 * @crossplatform 2352 * @atomicservice 2353 * @since 11 2354 */ 2355 /** 2356 * Provides information for history item in BackForwardList. 2357 * @typedef HistoryItem 2358 * @syscap SystemCapability.Web.Webview.Core 2359 * @crossplatform 2360 * @atomicservice 2361 * @since 12 2362 */ 2363 interface HistoryItem { 2364 /** 2365 * Pixelmap of icon. 2366 * @syscap SystemCapability.Web.Webview.Core 2367 * @since 9 2368 */ 2369 /** 2370 * Pixelmap of icon. 2371 * @type { image.PixelMap } 2372 * @syscap SystemCapability.Web.Webview.Core 2373 * @atomicservice 2374 * @since 11 2375 */ 2376 icon: image.PixelMap; 2377 2378 /** 2379 * Url of this history item. 2380 * @syscap SystemCapability.Web.Webview.Core 2381 * @since 9 2382 */ 2383 /** 2384 * Url of this history item. 2385 * @type { string } 2386 * @syscap SystemCapability.Web.Webview.Core 2387 * @crossplatform 2388 * @atomicservice 2389 * @since 11 2390 */ 2391 historyUrl: string; 2392 2393 /** 2394 * Original request url of this history item. 2395 * @syscap SystemCapability.Web.Webview.Core 2396 * @since 9 2397 */ 2398 /** 2399 * Original request url of this history item. 2400 * @type { string } 2401 * @syscap SystemCapability.Web.Webview.Core 2402 * @crossplatform 2403 * @atomicservice 2404 * @since 11 2405 */ 2406 historyRawUrl: string; 2407 2408 /** 2409 * Title of this history item. 2410 * @syscap SystemCapability.Web.Webview.Core 2411 * @since 9 2412 */ 2413 /** 2414 * Title of this history item. 2415 * @type { string } 2416 * @syscap SystemCapability.Web.Webview.Core 2417 * @crossplatform 2418 * @atomicservice 2419 * @since 11 2420 */ 2421 title: string; 2422 } 2423 2424 /** 2425 * Provides back and forward history list information method. related to {@link HistoryItem}. 2426 * @interface BackForwardList 2427 * @syscap SystemCapability.Web.Webview.Core 2428 * @since 9 2429 */ 2430 /** 2431 * Provides back and forward history list information method. related to {@link HistoryItem}. 2432 * @interface BackForwardList 2433 * @syscap SystemCapability.Web.Webview.Core 2434 * @crossplatform 2435 * @atomicservice 2436 * @since 11 2437 */ 2438 /** 2439 * Provides back and forward history list information method. related to {@link HistoryItem}. 2440 * @typedef BackForwardList 2441 * @syscap SystemCapability.Web.Webview.Core 2442 * @crossplatform 2443 * @atomicservice 2444 * @since 12 2445 */ 2446 interface BackForwardList { 2447 /** 2448 * Current index in BackForwardList. 2449 * @syscap SystemCapability.Web.Webview.Core 2450 * @since 9 2451 */ 2452 /** 2453 * Current index in BackForwardList. 2454 * @type { number } 2455 * @syscap SystemCapability.Web.Webview.Core 2456 * @crossplatform 2457 * @atomicservice 2458 * @since 11 2459 */ 2460 currentIndex: number; 2461 2462 /** 2463 * Size of in BackForwardList. 2464 * @syscap SystemCapability.Web.Webview.Core 2465 * @since 9 2466 */ 2467 /** 2468 * Size of in BackForwardList. 2469 * @type { number } 2470 * @syscap SystemCapability.Web.Webview.Core 2471 * @crossplatform 2472 * @atomicservice 2473 * @since 11 2474 */ 2475 size: number; 2476 2477 /** 2478 * Get history entry at given index. 2479 * 2480 * @param { number } index Index of back forward list entry. 2481 * @returns { HistoryItem } HistoryItem at given index in back forward list. 2482 * @throws { BusinessError } 401 - Invalid input parameter. 2483 * @syscap SystemCapability.Web.Webview.Core 2484 * @since 9 2485 */ 2486 /** 2487 * Get history entry at given index. 2488 * 2489 * @param { number } index Index of back forward list entry. 2490 * @returns { HistoryItem } HistoryItem at given index in back forward list. 2491 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2492 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 2493 * @syscap SystemCapability.Web.Webview.Core 2494 * @crossplatform 2495 * @atomicservice 2496 * @since 11 2497 */ 2498 getItemAtIndex(index: number): HistoryItem; 2499 } 2500 2501 /** 2502 * Defines the snapshot info. 2503 * 2504 * @typedef SnapshotInfo 2505 * @syscap SystemCapability.Web.Webview.Core 2506 * @atomicservice 2507 * @since 12 2508 */ 2509 interface SnapshotInfo { 2510 /** 2511 * Id of the snapshot. 2512 * 2513 * @type { ?string } 2514 * @syscap SystemCapability.Web.Webview.Core 2515 * @atomicservice 2516 * @since 12 2517 */ 2518 id?: string; 2519 2520 /** 2521 * Size of the web. 2522 * 2523 * @type { ?SizeOptions } 2524 * @syscap SystemCapability.Web.Webview.Core 2525 * @atomicservice 2526 * @since 12 2527 */ 2528 size?: SizeOptions; 2529 } 2530 2531 /** 2532 * Defines the snapshot result. 2533 * 2534 * @typedef SnapshotResult 2535 * @syscap SystemCapability.Web.Webview.Core 2536 * @atomicservice 2537 * @since 12 2538 */ 2539 interface SnapshotResult { 2540 /** 2541 * Id of the snapshot. 2542 * 2543 * @type { ?string } 2544 * @syscap SystemCapability.Web.Webview.Core 2545 * @atomicservice 2546 * @since 12 2547 */ 2548 id?: string; 2549 2550 /** 2551 * The status of the snapshot. 2552 * 2553 * @type { ?boolean } 2554 * @syscap SystemCapability.Web.Webview.Core 2555 * @atomicservice 2556 * @since 12 2557 */ 2558 status?: boolean; 2559 2560 /** 2561 * Size of the web. 2562 * 2563 * @type { ?SizeOptions } 2564 * @syscap SystemCapability.Web.Webview.Core 2565 * @atomicservice 2566 * @since 12 2567 */ 2568 size?: SizeOptions; 2569 2570 /** 2571 * The image in PixelMap format. 2572 * 2573 * @type { ?image.PixelMap } 2574 * @syscap SystemCapability.Web.Webview.Core 2575 * @atomicservice 2576 * @since 12 2577 */ 2578 imagePixelMap?: image.PixelMap; 2579 } 2580 /** 2581 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 2582 * @enum {number} 2583 * @syscap SystemCapability.Web.Webview.Core 2584 * @since 10 2585 */ 2586 /** 2587 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 2588 * @enum {number} 2589 * @syscap SystemCapability.Web.Webview.Core 2590 * @atomicservice 2591 * @since 11 2592 */ 2593 enum JsMessageType { 2594 /** 2595 * Unsupported data type. 2596 * @syscap SystemCapability.Web.Webview.Core 2597 * @since 10 2598 */ 2599 /** 2600 * Unsupported data type. 2601 * @syscap SystemCapability.Web.Webview.Core 2602 * @atomicservice 2603 * @since 11 2604 */ 2605 NOT_SUPPORT, 2606 2607 /** 2608 * The string data type. 2609 * @syscap SystemCapability.Web.Webview.Core 2610 * @since 10 2611 */ 2612 /** 2613 * The string data type. 2614 * @syscap SystemCapability.Web.Webview.Core 2615 * @atomicservice 2616 * @since 11 2617 */ 2618 STRING, 2619 2620 /** 2621 * The number data type. 2622 * @syscap SystemCapability.Web.Webview.Core 2623 * @since 10 2624 */ 2625 /** 2626 * The number data type. 2627 * @syscap SystemCapability.Web.Webview.Core 2628 * @atomicservice 2629 * @since 11 2630 */ 2631 NUMBER, 2632 2633 /** 2634 * The boolean data type. 2635 * @syscap SystemCapability.Web.Webview.Core 2636 * @since 10 2637 */ 2638 /** 2639 * The boolean data type. 2640 * @syscap SystemCapability.Web.Webview.Core 2641 * @atomicservice 2642 * @since 11 2643 */ 2644 BOOLEAN, 2645 2646 /** 2647 * The arraybuffer data type. 2648 * @syscap SystemCapability.Web.Webview.Core 2649 * @since 10 2650 */ 2651 /** 2652 * The arraybuffer data type. 2653 * @syscap SystemCapability.Web.Webview.Core 2654 * @atomicservice 2655 * @since 11 2656 */ 2657 ARRAY_BUFFER, 2658 2659 /** 2660 * The array data type. 2661 * @syscap SystemCapability.Web.Webview.Core 2662 * @since 10 2663 */ 2664 /** 2665 * The array data type. 2666 * @syscap SystemCapability.Web.Webview.Core 2667 * @atomicservice 2668 * @since 11 2669 */ 2670 ARRAY 2671 } 2672 2673 /** 2674 * The message for indicating the of result of JavaScript code execution. 2675 * @syscap SystemCapability.Web.Webview.Core 2676 * @since 10 2677 */ 2678 /** 2679 * The message for indicating the of result of JavaScript code execution. 2680 * @syscap SystemCapability.Web.Webview.Core 2681 * @atomicservice 2682 * @since 11 2683 */ 2684 class JsMessageExt { 2685 /** 2686 * Get the type of the JavaScript code execution result. 2687 * @returns { JsMessageType } - Returns data of JsMessageType type 2688 * @syscap SystemCapability.Web.Webview.Core 2689 * @since 10 2690 */ 2691 /** 2692 * Get the type of the JavaScript code execution result. 2693 * @returns { JsMessageType } - Returns data of JsMessageType type 2694 * @syscap SystemCapability.Web.Webview.Core 2695 * @atomicservice 2696 * @since 11 2697 */ 2698 getType(): JsMessageType; 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 * @since 10 2706 */ 2707 /** 2708 * Get the string value of the JavaScript code execution result. 2709 * @returns { string } - Returns data of string type 2710 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2711 * @syscap SystemCapability.Web.Webview.Core 2712 * @atomicservice 2713 * @since 11 2714 */ 2715 getString(): string; 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 * @since 10 2723 */ 2724 /** 2725 * Get the number value of the JavaScript code execution result. 2726 * @returns { number } - Returns data of number type 2727 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2728 * @syscap SystemCapability.Web.Webview.Core 2729 * @atomicservice 2730 * @since 11 2731 */ 2732 getNumber(): number; 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 * @since 10 2740 */ 2741 /** 2742 * Get the boolean value of the JavaScript code execution result. 2743 * @returns { boolean } - Returns data of Boolean type 2744 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2745 * @syscap SystemCapability.Web.Webview.Core 2746 * @atomicservice 2747 * @since 11 2748 */ 2749 getBoolean(): boolean; 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 * @since 10 2757 */ 2758 /** 2759 * Get the array buffer value of the JavaScript code execution result. 2760 * @returns { ArrayBuffer } - Returns data of ArrayBuffer 2761 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2762 * @syscap SystemCapability.Web.Webview.Core 2763 * @atomicservice 2764 * @since 11 2765 */ 2766 getArrayBuffer(): ArrayBuffer; 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 * @since 10 2774 */ 2775 /** 2776 * Get the array value of the the JavaScript code execution result. 2777 * @returns { Array<string | number | boolean> } - Returns data of Array type 2778 * @throws { BusinessError } 17100014 - The type and value of the message do not match. 2779 * @syscap SystemCapability.Web.Webview.Core 2780 * @atomicservice 2781 * @since 11 2782 */ 2783 getArray(): Array<string | number | boolean>; 2784 } 2785 2786 /** 2787 * Defines the render process mode. 2788 * 2789 * @enum {number} 2790 * @syscap SystemCapability.Web.Webview.Core 2791 * @atomicservice 2792 * @since 12 2793 */ 2794 enum RenderProcessMode { 2795 /** 2796 * Indicates the ArkWeb operates in single render process mode, which is the default value for 2797 * mobile devices. 2798 * 2799 * @syscap SystemCapability.Web.Webview.Core 2800 * @atomicservice 2801 * @since 12 2802 */ 2803 SINGLE = 0, 2804 2805 /** 2806 * Indicates the ArkWeb operates in multiple render process mode. 2807 * 2808 * @syscap SystemCapability.Web.Webview.Core 2809 * @atomicservice 2810 * @since 12 2811 */ 2812 MULTIPLE, 2813 } 2814 2815 /** 2816 * Options of generating code cache 2817 * @typedef CacheOptions 2818 * @syscap SystemCapability.Web.Webview.Core 2819 * @since 12 2820 */ 2821 interface CacheOptions { 2822 /** 2823 * Response headers used to configure the validation key of code cache. 2824 * Currently only support E-Tag and Last-Modified. 2825 * 2826 * @type { Array<WebHeader> } 2827 * @syscap SystemCapability.Web.Webview.Core 2828 * @since 12 2829 */ 2830 responseHeaders: Array<WebHeader>; 2831 } 2832 2833 /** 2834 * Enum type supplied to {@link OfflineResourceMap} for indicating the type of resource. 2835 * @enum {number} 2836 * @syscap SystemCapability.Web.Webview.Core 2837 * @since 12 2838 */ 2839 enum OfflineResourceType { 2840 /** 2841 * Image resource 2842 * 2843 * @syscap SystemCapability.Web.Webview.Core 2844 * @since 12 2845 */ 2846 IMAGE, 2847 2848 /** 2849 * CSS resource 2850 * 2851 * @syscap SystemCapability.Web.Webview.Core 2852 * @since 12 2853 */ 2854 CSS, 2855 2856 /** 2857 * Classic javascript resource 2858 * 2859 * @syscap SystemCapability.Web.Webview.Core 2860 * @since 12 2861 */ 2862 CLASSIC_JS, 2863 2864 /** 2865 * Module javascript resource 2866 * 2867 * @syscap SystemCapability.Web.Webview.Core 2868 * @since 12 2869 */ 2870 MODULE_JS 2871 } 2872 2873 /** 2874 * Define offline resource's content and info. 2875 * @typedef OfflineResourceMap 2876 * @syscap SystemCapability.Web.Webview.Core 2877 * @since 12 2878 */ 2879 interface OfflineResourceMap { 2880 /** 2881 * Url list of resource. Url of urlList must be HTTP/HTTPS protocol and no longer than 2048. 2882 * 2883 * @type { Array<string> } 2884 * @syscap SystemCapability.Web.Webview.Core 2885 * @since 12 2886 */ 2887 urlList: Array<string>, 2888 2889 /** 2890 * Arraybuffer of resource. Size must less than 10Mb and cannot be empty. 2891 * 2892 * @type { Uint8Array } 2893 * @syscap SystemCapability.Web.Webview.Core 2894 * @since 12 2895 */ 2896 resource: Uint8Array, 2897 2898 /** 2899 * Response headers of resource. 2900 * 2901 * @type { Array<WebHeader> } 2902 * @syscap SystemCapability.Web.Webview.Core 2903 * @since 12 2904 */ 2905 responseHeaders: Array<WebHeader>, 2906 2907 /** 2908 * Resource type 2909 * 2910 * @type { OfflineResourceType } 2911 * @syscap SystemCapability.Web.Webview.Core 2912 * @since 12 2913 */ 2914 type: OfflineResourceType 2915 } 2916 2917 /** 2918 * Enum type supplied to {@link setScrollable} for indicating the type of scroll. 2919 * 2920 * @enum { number } 2921 * @syscap SystemCapability.Web.Webview.Core 2922 * @since 12 2923 */ 2924 enum ScrollType { 2925 /** 2926 * Indicates scrolling the web page through scroll event, include touch screen, touch pad, and mouse wheel. 2927 * 2928 * @syscap SystemCapability.Web.Webview.Core 2929 * @since 12 2930 */ 2931 EVENT 2932 } 2933 2934 /** 2935 * Provides methods for controlling the web controller. 2936 * @syscap SystemCapability.Web.Webview.Core 2937 * @since 9 2938 */ 2939 /** 2940 * Provides methods for controlling the web controller. 2941 * @syscap SystemCapability.Web.Webview.Core 2942 * @crossplatform 2943 * @since 10 2944 */ 2945 /** 2946 * Provides methods for controlling the web controller. 2947 * @syscap SystemCapability.Web.Webview.Core 2948 * @crossplatform 2949 * @atomicservice 2950 * @since 11 2951 */ 2952 class WebviewController { 2953 /** 2954 * A constructor used to create a WebviewController object. 2955 * 2956 * @param { string } [webTag] - specified the name of the web component, Empty by default. 2957 * @syscap SystemCapability.Web.Webview.Core 2958 * @atomicservice 2959 * @since 11 2960 */ 2961 constructor(webTag?: string); 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 * @since 9 2969 */ 2970 /** 2971 * Initialize the web engine before loading the Web components. 2972 * This is a global static API that must be called on the UI thread, and it will have no effect if any 2973 * Web components are loaded. 2974 * @syscap SystemCapability.Web.Webview.Core 2975 * @atomicservice 2976 * @since 11 2977 */ 2978 static initializeWebEngine(): void; 2979 2980 /** 2981 * Set web engine to use HttpDns server to resolve dns. 2982 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 2983 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 2984 * Must be https protocol and only allow one server to be configured. 2985 * @throws { BusinessError } 401 - Invalid input parameter. 2986 * @syscap SystemCapability.Web.Webview.Core 2987 * @since 10 2988 */ 2989 /** 2990 * Set web engine to use HttpDns server to resolve dns. 2991 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 2992 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 2993 * Must be https protocol and only allow one server to be configured. 2994 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2995 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 2996 * @syscap SystemCapability.Web.Webview.Core 2997 * @atomicservice 2998 * @since 11 2999 */ 3000 static setHttpDns(secureDnsMode: SecureDnsMode, secureDnsConfig: string): void; 3001 3002 /** 3003 * Enables debugging of web contents. 3004 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 3005 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3006 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3007 * @syscap SystemCapability.Web.Webview.Core 3008 * @since 9 3009 */ 3010 /** 3011 * Enables debugging of web contents. 3012 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 3013 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3014 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3015 * @syscap SystemCapability.Web.Webview.Core 3016 * @atomicservice 3017 * @since 11 3018 */ 3019 static setWebDebuggingAccess(webDebuggingAccess: boolean): void; 3020 3021 /** 3022 * Enable the ability to check website security risks. 3023 * Illegal and fraudulent websites are mandatory enabled and can't be disabled by this function. 3024 * @param { boolean } enable - {@code true} enable check the website security risks; {@code false} otherwise. 3025 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3026 * <br>2. Incorrect parameter types. 3027 * @syscap SystemCapability.Web.Webview.Core 3028 * @atomicservice 3029 * @since 11 3030 */ 3031 enableSafeBrowsing(enable: boolean): void; 3032 3033 /** 3034 * Get whether checking website security risks is enabled. 3035 * @returns { boolean } True if enable the ability to check website security risks else false. 3036 * @syscap SystemCapability.Web.Webview.Core 3037 * @atomicservice 3038 * @since 11 3039 */ 3040 isSafeBrowsingEnabled(): boolean; 3041 3042 /** 3043 * Checks whether the web page can go forward. 3044 * @returns { boolean } True if the web page can go forward else false. 3045 * @throws { BusinessError } 17100001 - Init error. 3046 * The WebviewController must be associated with a Web component. 3047 * @syscap SystemCapability.Web.Webview.Core 3048 * @since 9 3049 */ 3050 /** 3051 * Checks whether the web page can go forward. 3052 * @returns { boolean } True if the web page can go forward else false. 3053 * @throws { BusinessError } 17100001 - Init error. 3054 * The WebviewController must be associated with a Web component. 3055 * @syscap SystemCapability.Web.Webview.Core 3056 * @crossplatform 3057 * @atomicservice 3058 * @since 11 3059 */ 3060 accessForward(): boolean; 3061 3062 /** 3063 * Checks whether the web page can go back. 3064 * @returns { boolean } True if the web page can go back else false. 3065 * @throws { BusinessError } 17100001 - Init error. 3066 * The WebviewController must be associated with a Web component. 3067 * @syscap SystemCapability.Web.Webview.Core 3068 * @since 9 3069 */ 3070 /** 3071 * Checks whether the web page can go back. 3072 * @returns { boolean } True if the web page can go back else false. 3073 * @throws { BusinessError } 17100001 - Init error. 3074 * The WebviewController must be associated with a Web component. 3075 * @syscap SystemCapability.Web.Webview.Core 3076 * @crossplatform 3077 * @atomicservice 3078 * @since 11 3079 */ 3080 accessBackward(): boolean; 3081 3082 /** 3083 * Checks whether the web page can go back or forward the given number of steps. 3084 * 3085 * @param { number } step - The number of steps. 3086 * @returns { boolean } True if the web page can go back else false. 3087 * @throws { BusinessError } 401 - Invalid input parameter. 3088 * @throws { BusinessError } 17100001 - Init error. 3089 * The WebviewController must be associated with a Web component. 3090 * @syscap SystemCapability.Web.Webview.Core 3091 * @since 9 3092 */ 3093 /** 3094 * Checks whether the web page can go back or forward the given number of steps. 3095 * 3096 * @param { number } step - The number of steps. 3097 * @returns { boolean } True if the web page can go back else false. 3098 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3099 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3100 * @throws { BusinessError } 17100001 - Init error. 3101 * The WebviewController must be associated with a Web component. 3102 * @syscap SystemCapability.Web.Webview.Core 3103 * @crossplatform 3104 * @atomicservice 3105 * @since 11 3106 */ 3107 accessStep(step: number): boolean; 3108 3109 /** 3110 * Goes forward in the history of the web page. 3111 * 3112 * @throws { BusinessError } 17100001 - Init error. 3113 * The WebviewController must be associated with a Web component. 3114 * @syscap SystemCapability.Web.Webview.Core 3115 * @since 9 3116 */ 3117 /** 3118 * Goes forward in the history of the web page. 3119 * 3120 * @throws { BusinessError } 17100001 - Init error. 3121 * The WebviewController must be associated with a Web component. 3122 * @syscap SystemCapability.Web.Webview.Core 3123 * @crossplatform 3124 * @atomicservice 3125 * @since 11 3126 */ 3127 forward(): void; 3128 3129 /** 3130 * Goes back in the history of the web page. 3131 * 3132 * @throws { BusinessError } 17100001 - Init error. 3133 * The WebviewController must be associated with a Web component. 3134 * @syscap SystemCapability.Web.Webview.Core 3135 * @since 9 3136 */ 3137 /** 3138 * Goes back in the history of the web page. 3139 * 3140 * @throws { BusinessError } 17100001 - Init error. 3141 * The WebviewController must be associated with a Web component. 3142 * @syscap SystemCapability.Web.Webview.Core 3143 * @crossplatform 3144 * @atomicservice 3145 * @since 11 3146 */ 3147 backward(): void; 3148 3149 /** 3150 * Clears the history in the Web. 3151 * 3152 * @throws { BusinessError } 17100001 - Init error. 3153 * The WebviewController must be associated with a Web component. 3154 * @syscap SystemCapability.Web.Webview.Core 3155 * @since 9 3156 */ 3157 /** 3158 * Clears the history in the Web. 3159 * 3160 * @throws { BusinessError } 17100001 - Init error. 3161 * The WebviewController must be associated with a Web component. 3162 * @syscap SystemCapability.Web.Webview.Core 3163 * @crossplatform 3164 * @atomicservice 3165 * @since 11 3166 */ 3167 clearHistory(): void; 3168 3169 /** 3170 * Let the Web active. 3171 * 3172 * @throws { BusinessError } 17100001 - Init error. 3173 * The WebviewController must be associated with a Web component. 3174 * @syscap SystemCapability.Web.Webview.Core 3175 * @since 9 3176 */ 3177 /** 3178 * Let the Web active. 3179 * 3180 * @throws { BusinessError } 17100001 - Init error. 3181 * The WebviewController must be associated with a Web component. 3182 * @syscap SystemCapability.Web.Webview.Core 3183 * @atomicservice 3184 * @since 11 3185 */ 3186 onActive(): void; 3187 3188 /** 3189 * Let the Web inactive. 3190 * 3191 * @throws { BusinessError } 17100001 - Init error. 3192 * The WebviewController must be associated with a Web component. 3193 * @syscap SystemCapability.Web.Webview.Core 3194 * @since 9 3195 */ 3196 /** 3197 * Let the Web inactive. 3198 * 3199 * @throws { BusinessError } 17100001 - Init error. 3200 * The WebviewController must be associated with a Web component. 3201 * @syscap SystemCapability.Web.Webview.Core 3202 * @atomicservice 3203 * @since 11 3204 */ 3205 onInactive(): void; 3206 3207 /** 3208 * Refreshes the current URL. 3209 * 3210 * @throws { BusinessError } 17100001 - Init error. 3211 * The WebviewController must be associated with a Web component. 3212 * @syscap SystemCapability.Web.Webview.Core 3213 * @since 9 3214 */ 3215 /** 3216 * Refreshes the current URL. 3217 * 3218 * @throws { BusinessError } 17100001 - Init error. 3219 * The WebviewController must be associated with a Web component. 3220 * @syscap SystemCapability.Web.Webview.Core 3221 * @crossplatform 3222 * @atomicservice 3223 * @since 11 3224 */ 3225 refresh(): void; 3226 3227 /** 3228 * Loads the data or URL. 3229 * 3230 * @param { string } data - A string encoded according to "Base64" or "URL". 3231 * @param { string } mimeType - Media type. For example: "text/html". 3232 * @param { string } encoding - Encoding type. For example: "UTF-8". 3233 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 3234 * which is assigned to window.origin by the Web component. 3235 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 3236 * history records to realize the back and forth function. 3237 * This property is invalid when baseUrl is empty. 3238 * @throws { BusinessError } 401 - Invalid input parameter. 3239 * @throws { BusinessError } 17100001 - Init error. 3240 * The WebviewController must be associated with a Web component. 3241 * @throws { BusinessError } 17100002 - Invalid url. 3242 * @syscap SystemCapability.Web.Webview.Core 3243 * @since 9 3244 */ 3245 /** 3246 * Loads the data or URL. 3247 * 3248 * @param { string } data - A string encoded according to "Base64" or "URL". 3249 * @param { string } mimeType - Media type. For example: "text/html". 3250 * @param { string } encoding - Encoding type. For example: "UTF-8". 3251 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 3252 * which is assigned to window.origin by the Web component. 3253 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 3254 * history records to realize the back and forth function. 3255 * This property is invalid when baseUrl is empty. 3256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3257 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3258 * @throws { BusinessError } 17100001 - Init error. 3259 * The WebviewController must be associated with a Web component. 3260 * @syscap SystemCapability.Web.Webview.Core 3261 * @crossplatform 3262 * @atomicservice 3263 * @since 11 3264 */ 3265 loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string): void; 3266 3267 /** 3268 * Loads the data or URL. 3269 * 3270 * @param { string | Resource } url - The URL to load. 3271 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 3272 * @throws { BusinessError } 401 - Invalid input parameter. 3273 * @throws { BusinessError } 17100001 - Init error. 3274 * The WebviewController must be associated with a Web component. 3275 * @throws { BusinessError } 17100002 - Invalid url. 3276 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3277 * @syscap SystemCapability.Web.Webview.Core 3278 * @since 9 3279 */ 3280 /** 3281 * Loads the data or URL. 3282 * 3283 * @param { string | Resource } url - The URL to load. 3284 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 3285 * @throws { BusinessError } 401 - Invalid input parameter. 3286 * @throws { BusinessError } 17100001 - Init error. 3287 * The WebviewController must be associated with a Web component. 3288 * @throws { BusinessError } 17100002 - Invalid url. 3289 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3290 * @syscap SystemCapability.Web.Webview.Core 3291 * @crossplatform 3292 * @since 10 3293 */ 3294 /** 3295 * Loads the data or URL. 3296 * 3297 * @param { string | Resource } url - The URL to load. 3298 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 3299 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3300 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3301 * @throws { BusinessError } 17100001 - Init error. 3302 * The WebviewController must be associated with a Web component. 3303 * @throws { BusinessError } 17100002 - Invalid url. 3304 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3305 * @syscap SystemCapability.Web.Webview.Core 3306 * @crossplatform 3307 * @atomicservice 3308 * @since 11 3309 */ 3310 loadUrl(url: string | Resource, headers?: Array<WebHeader>): void; 3311 3312 /** 3313 * Gets the type of HitTest. 3314 * @returns { WebHitTestType } The type of HitTest. 3315 * @throws { BusinessError } 17100001 - Init error. 3316 * The WebviewController must be associated with a Web component. 3317 * @syscap SystemCapability.Web.Webview.Core 3318 * @since 9 3319 */ 3320 /** 3321 * Gets the type of HitTest. 3322 * @returns { WebHitTestType } The type of HitTest. 3323 * @throws { BusinessError } 17100001 - Init error. 3324 * The WebviewController must be associated with a Web component. 3325 * @syscap SystemCapability.Web.Webview.Core 3326 * @atomicservice 3327 * @since 11 3328 */ 3329 getHitTest(): WebHitTestType; 3330 3331 /** 3332 * Stores the current page as a web archive. 3333 * 3334 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3335 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3336 * stored by the file name of baseName. If true, the file name is 3337 * automatically generated based on the current URL and stored in the file 3338 * directory of baseName. 3339 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 3340 * will either be the filename under which the file was stored, or empty 3341 * if storing the file failed. 3342 * @throws { BusinessError } 401 - Invalid input parameter. 3343 * @throws { BusinessError } 17100001 - Init error. 3344 * The WebviewController must be associated with a Web component. 3345 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3346 * @syscap SystemCapability.Web.Webview.Core 3347 * @since 9 3348 */ 3349 /** 3350 * Stores the current page as a web archive. 3351 * 3352 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3353 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3354 * stored by the file name of baseName. If true, the file name is 3355 * automatically generated based on the current URL and stored in the file 3356 * directory of baseName. 3357 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 3358 * will either be the filename under which the file was stored, or empty 3359 * if storing the file failed. 3360 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3361 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 3362 * @throws { BusinessError } 17100001 - Init error. 3363 * The WebviewController must be associated with a Web component. 3364 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3365 * @syscap SystemCapability.Web.Webview.Core 3366 * @atomicservice 3367 * @since 11 3368 */ 3369 storeWebArchive(baseName: string, autoName: boolean): Promise<string>; 3370 3371 /** 3372 * Stores the current page as a web archive. 3373 * 3374 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3375 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3376 * stored by the file name of baseName. If true, the file name is 3377 * automatically generated based on the current URL and stored in the file 3378 * directory of baseName. 3379 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 3380 * will either be the filename under which the file was stored, 3381 * or empty if storing the file failed. 3382 * @throws { BusinessError } 401 - Invalid input parameter. 3383 * @throws { BusinessError } 17100001 - Init error. 3384 * The WebviewController must be associated with a Web component. 3385 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3386 * @syscap SystemCapability.Web.Webview.Core 3387 * @since 9 3388 */ 3389 /** 3390 * Stores the current page as a web archive. 3391 * 3392 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 3393 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 3394 * stored by the file name of baseName. If true, the file name is 3395 * automatically generated based on the current URL and stored in the file 3396 * directory of baseName. 3397 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 3398 * will either be the filename under which the file was stored, 3399 * or empty if storing the file failed. 3400 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3401 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 3402 * @throws { BusinessError } 17100001 - Init error. 3403 * The WebviewController must be associated with a Web component. 3404 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 3405 * @syscap SystemCapability.Web.Webview.Core 3406 * @atomicservice 3407 * @since 11 3408 */ 3409 storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback<string>): void; 3410 3411 /** 3412 * Let the Web zoom by. 3413 * 3414 * @param { number } factor - The zoom factor. 3415 * @throws { BusinessError } 401 - Invalid input parameter. 3416 * @throws { BusinessError } 17100001 - Init error. 3417 * The WebviewController must be associated with a Web component. 3418 * @throws { BusinessError } 17100004 - Function not enabled. 3419 * @syscap SystemCapability.Web.Webview.Core 3420 * @since 9 3421 */ 3422 /** 3423 * Let the Web zoom by. 3424 * 3425 * @param { number } factor - The zoom factor. 3426 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3427 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3428 * @throws { BusinessError } 17100001 - Init error. 3429 * The WebviewController must be associated with a Web component. 3430 * @throws { BusinessError } 17100004 - Function not enabled. 3431 * @syscap SystemCapability.Web.Webview.Core 3432 * @crossplatform 3433 * @atomicservice 3434 * @since 11 3435 */ 3436 zoom(factor: number): void; 3437 3438 /** 3439 * Let the Web zoom in. 3440 * 3441 * @throws { BusinessError } 17100001 - Init error. 3442 * The WebviewController must be associated with a Web component. 3443 * @throws { BusinessError } 17100004 - Function not enabled. 3444 * @syscap SystemCapability.Web.Webview.Core 3445 * @since 9 3446 */ 3447 /** 3448 * Let the Web zoom in. 3449 * 3450 * @throws { BusinessError } 17100001 - Init error. 3451 * The WebviewController must be associated with a Web component. 3452 * @throws { BusinessError } 17100004 - Function not enabled. 3453 * @syscap SystemCapability.Web.Webview.Core 3454 * @atomicservice 3455 * @since 11 3456 */ 3457 zoomIn(): void; 3458 3459 /** 3460 * Let the Web zoom out. 3461 * 3462 * @throws { BusinessError } 17100001 - Init error. 3463 * The WebviewController must be associated with a Web component. 3464 * @throws { BusinessError } 17100004 - Function not enabled. 3465 * @syscap SystemCapability.Web.Webview.Core 3466 * @since 9 3467 */ 3468 /** 3469 * Let the Web zoom out. 3470 * 3471 * @throws { BusinessError } 17100001 - Init error. 3472 * The WebviewController must be associated with a Web component. 3473 * @throws { BusinessError } 17100004 - Function not enabled. 3474 * @syscap SystemCapability.Web.Webview.Core 3475 * @atomicservice 3476 * @since 11 3477 */ 3478 zoomOut(): void; 3479 3480 /** 3481 * Gets the hit test value of HitTest. 3482 * @returns { HitTestValue } Return the element information of the clicked area. 3483 * @throws { BusinessError } 17100001 - Init error. 3484 * The WebviewController must be associated with a Web component. 3485 * @syscap SystemCapability.Web.Webview.Core 3486 * @since 9 3487 */ 3488 /** 3489 * Gets the hit test value of HitTest. 3490 * @returns { HitTestValue } Return the element information of the clicked area. 3491 * @throws { BusinessError } 17100001 - Init error. 3492 * The WebviewController must be associated with a Web component. 3493 * @syscap SystemCapability.Web.Webview.Core 3494 * @atomicservice 3495 * @since 11 3496 */ 3497 getHitTestValue(): HitTestValue; 3498 3499 /** 3500 * Gets the id for the current Web. 3501 * @returns { number } Returns the index value of the current Web component. 3502 * @throws { BusinessError } 17100001 - Init error. 3503 * The WebviewController must be associated with a Web component. 3504 * @syscap SystemCapability.Web.Webview.Core 3505 * @since 9 3506 */ 3507 /** 3508 * Gets the id for the current Web. 3509 * @returns { number } Returns the index value of the current Web component. 3510 * @throws { BusinessError } 17100001 - Init error. 3511 * The WebviewController must be associated with a Web component. 3512 * @syscap SystemCapability.Web.Webview.Core 3513 * @atomicservice 3514 * @since 11 3515 */ 3516 getWebId(): number; 3517 3518 /** 3519 * Gets the default user agent. 3520 * @returns { string } Return user agent information. 3521 * @throws { BusinessError } 17100001 - Init error. 3522 * The WebviewController must be associated with a Web component. 3523 * @syscap SystemCapability.Web.Webview.Core 3524 * @since 9 3525 */ 3526 /** 3527 * Gets the default user agent. 3528 * @returns { string } Return user agent information. 3529 * @throws { BusinessError } 17100001 - Init error. 3530 * The WebviewController must be associated with a Web component. 3531 * @syscap SystemCapability.Web.Webview.Core 3532 * @atomicservice 3533 * @since 11 3534 */ 3535 getUserAgent(): string; 3536 3537 /** 3538 * Gets the title of current Web page. 3539 * @returns { string } Return to File Selector Title. 3540 * @throws { BusinessError } 17100001 - Init error. 3541 * The WebviewController must be associated with a Web component. 3542 * @syscap SystemCapability.Web.Webview.Core 3543 * @since 9 3544 */ 3545 /** 3546 * Gets the title of current Web page. 3547 * @returns { string } Return to File Selector Title. 3548 * @throws { BusinessError } 17100001 - Init error. 3549 * The WebviewController must be associated with a Web component. 3550 * @syscap SystemCapability.Web.Webview.Core 3551 * @crossplatform 3552 * @atomicservice 3553 * @since 11 3554 */ 3555 getTitle(): string; 3556 3557 /** 3558 * Gets the content height of current Web page. 3559 * @returns { number } Returns the page height of the current page. 3560 * @throws { BusinessError } 17100001 - Init error. 3561 * The WebviewController must be associated with a Web component. 3562 * @syscap SystemCapability.Web.Webview.Core 3563 * @since 9 3564 */ 3565 /** 3566 * Gets the content height of current Web page. 3567 * @returns { number } Returns the page height of the current page. 3568 * @throws { BusinessError } 17100001 - Init error. 3569 * The WebviewController must be associated with a Web component. 3570 * @syscap SystemCapability.Web.Webview.Core 3571 * @crossplatform 3572 * @atomicservice 3573 * @since 11 3574 */ 3575 getPageHeight(): number; 3576 3577 /** 3578 * Goes forward or back backOrForward in the history of the web page. 3579 * 3580 * @param { number } step - Steps to go forward or backward. 3581 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3582 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3583 * @throws { BusinessError } 17100001 - Init error. 3584 * The WebviewController must be associated with a Web component. 3585 * @syscap SystemCapability.Web.Webview.Core 3586 * @since 9 3587 */ 3588 /** 3589 * Goes forward or back backOrForward in the history of the web page. 3590 * 3591 * @param { number } step - Steps to go forward or backward. 3592 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3593 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3594 * @throws { BusinessError } 17100001 - Init error. 3595 * The WebviewController must be associated with a Web component. 3596 * @syscap SystemCapability.Web.Webview.Core 3597 * @crossplatform 3598 * @atomicservice 3599 * @since 11 3600 */ 3601 backOrForward(step: number): void; 3602 3603 /** 3604 * Gets the request focus. 3605 * 3606 * @throws { BusinessError } 17100001 - Init error. 3607 * The WebviewController must be associated with a Web component. 3608 * @syscap SystemCapability.Web.Webview.Core 3609 * @since 9 3610 */ 3611 /** 3612 * Gets the request focus. 3613 * 3614 * @throws { BusinessError } 17100001 - Init error. 3615 * The WebviewController must be associated with a Web component. 3616 * @syscap SystemCapability.Web.Webview.Core 3617 * @atomicservice 3618 * @since 11 3619 */ 3620 requestFocus(): void; 3621 3622 /** 3623 * Create web message ports 3624 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 3625 * those ports to communication with html pages. 3626 * @throws { BusinessError } 17100001 - Init error. 3627 * The WebviewController must be associated with a Web component. 3628 * @syscap SystemCapability.Web.Webview.Core 3629 * @since 9 3630 */ 3631 /** 3632 * Create web message ports 3633 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 3634 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 3635 * those ports to communication with html pages. 3636 * @throws { BusinessError } 401 - Invalid input parameter. 3637 * @throws { BusinessError } 17100001 - Init error. 3638 * The WebviewController must be associated with a Web component. 3639 * @syscap SystemCapability.Web.Webview.Core 3640 * @since 10 3641 */ 3642 /** 3643 * Create web message ports 3644 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 3645 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 3646 * those ports to communication with html pages. 3647 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3648 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3649 * @throws { BusinessError } 17100001 - Init error. 3650 * The WebviewController must be associated with a Web component. 3651 * @syscap SystemCapability.Web.Webview.Core 3652 * @crossplatform 3653 * @atomicservice 3654 * @since 11 3655 */ 3656 createWebMessagePorts(isExtentionType?: boolean): Array<WebMessagePort>; 3657 3658 /** 3659 * Post web message port to html 3660 * 3661 * @param { string } name - Data name information to send. 3662 * @param { Array<WebMessagePort> } ports - Port number array information to send. 3663 * @param { string } uri - URI to receive this information. 3664 * @throws { BusinessError } 401 - Invalid input parameter. 3665 * @throws { BusinessError } 17100001 - Init error. 3666 * The WebviewController must be associated with a Web component. 3667 * @syscap SystemCapability.Web.Webview.Core 3668 * @since 9 3669 */ 3670 /** 3671 * Post web message port to html 3672 * 3673 * @param { string } name - Data name information to send. 3674 * @param { Array<WebMessagePort> } ports - Port number array information to send. 3675 * @param { string } uri - URI to receive this information. 3676 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3677 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3678 * @throws { BusinessError } 17100001 - Init error. 3679 * The WebviewController must be associated with a Web component. 3680 * @syscap SystemCapability.Web.Webview.Core 3681 * @crossplatform 3682 * @atomicservice 3683 * @since 11 3684 */ 3685 postMessage(name: string, ports: Array<WebMessagePort>, uri: string): void; 3686 3687 /** 3688 * Stops the current load. 3689 * 3690 * @throws { BusinessError } 17100001 - Init error. 3691 * The WebviewController must be associated with a Web component. 3692 * @syscap SystemCapability.Web.Webview.Core 3693 * @since 9 3694 */ 3695 /** 3696 * Stops the current load. 3697 * 3698 * @throws { BusinessError } 17100001 - Init error. 3699 * The WebviewController must be associated with a Web component. 3700 * @syscap SystemCapability.Web.Webview.Core 3701 * @crossplatform 3702 * @atomicservice 3703 * @since 11 3704 */ 3705 stop(): void; 3706 3707 /** 3708 * Registers the JavaScript object and method list. 3709 * 3710 * @param { object } object - Application side JavaScript objects participating in registration. 3711 * @param { string } name - The name of the registered object, which is consistent with the 3712 * object name called in the window. 3713 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 3714 * in the registration. 3715 * @throws { BusinessError } 401 - Invalid input parameter. 3716 * @throws { BusinessError } 17100001 - Init error. 3717 * The WebviewController must be associated with a Web component. 3718 * @syscap SystemCapability.Web.Webview.Core 3719 * @since 9 3720 */ 3721 /** 3722 * Registers the JavaScript object and method list. 3723 * 3724 * @param { object } object - Application side JavaScript objects participating in registration. 3725 * @param { string } name - The name of the registered object, which is consistent with the 3726 * object name called in the window. 3727 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 3728 * in the registration. 3729 * @throws { BusinessError } 401 - Invalid input parameter. 3730 * @throws { BusinessError } 17100001 - Init error. 3731 * The WebviewController must be associated with a Web component. 3732 * @syscap SystemCapability.Web.Webview.Core 3733 * @atomicservice 3734 * @since 11 3735 */ 3736 /** 3737 * Registers the JavaScript object and method list. 3738 * 3739 * @param { object } object - Application side JavaScript objects participating in registration. 3740 * @param { string } name - The name of the registered object, which is consistent with the 3741 * object name called in the window. 3742 * @param { Array<string> } methodList - The method of the application side JavaScript object participating 3743 * in the registration. 3744 * @param { Array<string> } [asyncMethodList] - The async method of the application side JavaScript object 3745 * participating in the registration. 3746 * @param { string } [permission] - permission configuration defining web page URLs that can access JavaScriptProxy methods. 3747 * The configuration can be defined at two levels, object level and method level. 3748 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3749 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3750 * @throws { BusinessError } 17100001 - Init error. 3751 * The WebviewController must be associated with a Web component. 3752 * @syscap SystemCapability.Web.Webview.Core 3753 * @atomicservice 3754 * @since 12 3755 */ 3756 registerJavaScriptProxy(object: object, name: string, methodList: Array<string>, 3757 asyncMethodList?: Array<string>, permission?: string): void; 3758 3759 /** 3760 * Deletes a registered JavaScript object with given name. 3761 * 3762 * @param { string } name - The name of a registered JavaScript object to be deleted. 3763 * @throws { BusinessError } 401 - Invalid input parameter. 3764 * @throws { BusinessError } 17100001 - Init error. 3765 * The WebviewController must be associated with a Web component. 3766 * @throws { BusinessError } 17100008 - Failed to delete JavaScriptProxy because it does not exist. 3767 * @syscap SystemCapability.Web.Webview.Core 3768 * @since 9 3769 */ 3770 /** 3771 * Deletes a registered JavaScript object with given name. 3772 * 3773 * @param { string } name - The name of a registered JavaScript object to be deleted. 3774 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3775 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3776 * @throws { BusinessError } 17100001 - Init error. 3777 * The WebviewController must be associated with a Web component. 3778 * @throws { BusinessError } 17100008 - Failed to delete JavaScriptProxy because it does not exist. 3779 * @syscap SystemCapability.Web.Webview.Core 3780 * @atomicservice 3781 * @since 11 3782 */ 3783 deleteJavaScriptRegister(name: string): void; 3784 3785 /** 3786 * Search all instances of 'searchString' on the page and highlights them, 3787 * result will be notify through callback onSearchResultReceive. 3788 * 3789 * @param { string } searchString - String to be search. 3790 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3791 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3792 * @throws { BusinessError } 17100001 - Init error. 3793 * The WebviewController must be associated with a Web component. 3794 * @syscap SystemCapability.Web.Webview.Core 3795 * @since 9 3796 */ 3797 /** 3798 * Search all instances of 'searchString' on the page and highlights them, 3799 * result will be notify through callback onSearchResultReceive. 3800 * 3801 * @param { string } searchString - String to be search. 3802 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3803 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3804 * @throws { BusinessError } 17100001 - Init error. 3805 * The WebviewController must be associated with a Web component. 3806 * @syscap SystemCapability.Web.Webview.Core 3807 * @atomicservice 3808 * @since 11 3809 */ 3810 searchAllAsync(searchString: string): void; 3811 3812 /** 3813 * Clears the highlighting surrounding text matches created by searchAllAsync. 3814 * 3815 * @throws { BusinessError } 17100001 - Init error. 3816 * The WebviewController must be associated with a Web component. 3817 * @syscap SystemCapability.Web.Webview.Core 3818 * @since 9 3819 */ 3820 /** 3821 * Clears the highlighting surrounding text matches created by searchAllAsync. 3822 * 3823 * @throws { BusinessError } 17100001 - Init error. 3824 * The WebviewController must be associated with a Web component. 3825 * @syscap SystemCapability.Web.Webview.Core 3826 * @atomicservice 3827 * @since 11 3828 */ 3829 clearMatches(): void; 3830 3831 /** 3832 * Highlights and scrolls to the next match search. 3833 * 3834 * @param { boolean } forward - Step of search is back or forward. 3835 * @throws { BusinessError } 401 - Invalid input parameter. 3836 * @throws { BusinessError } 17100001 - Init error. 3837 * The WebviewController must be associated with a Web component. 3838 * @syscap SystemCapability.Web.Webview.Core 3839 * @since 9 3840 */ 3841 /** 3842 * Highlights and scrolls to the next match search. 3843 * 3844 * @param { boolean } forward - Step of search is back or forward. 3845 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3846 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3847 * @throws { BusinessError } 17100001 - Init error. 3848 * The WebviewController must be associated with a Web component. 3849 * @syscap SystemCapability.Web.Webview.Core 3850 * @atomicservice 3851 * @since 11 3852 */ 3853 searchNext(forward: boolean): void; 3854 3855 /** 3856 * Clears the ssl cache in the Web. 3857 * 3858 * @throws { BusinessError } 17100001 - Init error. 3859 * The WebviewController must be associated with a Web component. 3860 * @syscap SystemCapability.Web.Webview.Core 3861 * @since 9 3862 */ 3863 /** 3864 * Clears the ssl cache in the Web. 3865 * 3866 * @throws { BusinessError } 17100001 - Init error. 3867 * The WebviewController must be associated with a Web component. 3868 * @syscap SystemCapability.Web.Webview.Core 3869 * @atomicservice 3870 * @since 11 3871 */ 3872 clearSslCache(): void; 3873 3874 /** 3875 * Clears the client authentication certificate cache in the Web. 3876 * 3877 * @throws { BusinessError } 17100001 - Init error. 3878 * The WebviewController must be associated with a Web component. 3879 * @syscap SystemCapability.Web.Webview.Core 3880 * @since 9 3881 */ 3882 /** 3883 * Clears the client authentication certificate cache in the Web. 3884 * 3885 * @throws { BusinessError } 17100001 - Init error. 3886 * The WebviewController must be associated with a Web component. 3887 * @syscap SystemCapability.Web.Webview.Core 3888 * @atomicservice 3889 * @since 11 3890 */ 3891 clearClientAuthenticationCache(): void; 3892 3893 /** 3894 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3895 * 3896 * @param { string } script - JavaScript Script. 3897 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 3898 * This parameter will be the result of JavaScript script execution. 3899 * If the JavaScript script fails to execute or has no return value, 3900 * null will be returned. 3901 * @throws { BusinessError } 401 - Invalid input parameter. 3902 * @throws { BusinessError } 17100001 - Init error. 3903 * The WebviewController must be associated with a Web component. 3904 * @syscap SystemCapability.Web.Webview.Core 3905 * @since 9 3906 */ 3907 /** 3908 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3909 * 3910 * @param { string } script - JavaScript Script. 3911 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 3912 * This parameter will be the result of JavaScript script execution. 3913 * If the JavaScript script fails to execute or has no return value, 3914 * null will be returned. 3915 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3916 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3917 * @throws { BusinessError } 17100001 - Init error. 3918 * The WebviewController must be associated with a Web component. 3919 * @syscap SystemCapability.Web.Webview.Core 3920 * @crossplatform 3921 * @atomicservice 3922 * @since 11 3923 */ 3924 runJavaScript(script: string): Promise<string>; 3925 3926 /** 3927 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3928 * 3929 * @param { string } script - JavaScript Script. 3930 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 3931 * @throws { BusinessError } 401 - Invalid input parameter. 3932 * @throws { BusinessError } 17100001 - Init error. 3933 * The WebviewController must be associated with a Web component. 3934 * @syscap SystemCapability.Web.Webview.Core 3935 * @since 9 3936 */ 3937 /** 3938 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3939 * 3940 * @param { string } script - JavaScript Script. 3941 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 3942 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3943 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3944 * @throws { BusinessError } 17100001 - Init error. 3945 * The WebviewController must be associated with a Web component. 3946 * @syscap SystemCapability.Web.Webview.Core 3947 * @crossplatform 3948 * @atomicservice 3949 * @since 11 3950 */ 3951 runJavaScript(script: string, callback: AsyncCallback<string>): void; 3952 3953 /** 3954 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3955 * 3956 * @param { string } script - JavaScript Script. 3957 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3958 * This parameter will be the result of JavaScript script execution. 3959 * If the JavaScript script fails to execute or has no return value, 3960 * a none type value will be returned. 3961 * @throws { BusinessError } 401 - Invalid input parameter. 3962 * @throws { BusinessError } 17100001 - Init error. 3963 * The WebviewController must be associated with a Web component. 3964 * @syscap SystemCapability.Web.Webview.Core 3965 * @since 10 3966 */ 3967 /** 3968 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3969 * 3970 * @param { string } script - JavaScript Script. 3971 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3972 * This parameter will be the result of JavaScript script execution. 3973 * If the JavaScript script fails to execute or has no return value, 3974 * a none type value will be returned. 3975 * @throws { BusinessError } 401 - Invalid input parameter. 3976 * @throws { BusinessError } 17100001 - Init error. 3977 * The WebviewController must be associated with a Web component. 3978 * @syscap SystemCapability.Web.Webview.Core 3979 * @atomicservice 3980 * @since 11 3981 */ 3982 /** 3983 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3984 * 3985 * @param { string | ArrayBuffer } script - JavaScript Script. 3986 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3987 * This parameter will be the result of JavaScript script execution. 3988 * If the JavaScript script fails to execute or has no return value, 3989 * a none type value will be returned. 3990 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 3991 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 3992 * @throws { BusinessError } 17100001 - Init error. 3993 * The WebviewController must be associated with a Web component. 3994 * @syscap SystemCapability.Web.Webview.Core 3995 * @atomicservice 3996 * @since 12 3997 */ 3998 runJavaScriptExt(script: string | ArrayBuffer): Promise<JsMessageExt>; 3999 4000 /** 4001 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4002 * 4003 * @param { string } script - JavaScript Script. 4004 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 4005 * @throws { BusinessError } 401 - Invalid input parameter. 4006 * @throws { BusinessError } 17100001 - Init error. 4007 * The WebviewController must be associated with a Web component. 4008 * @syscap SystemCapability.Web.Webview.Core 4009 * @since 10 4010 */ 4011 /** 4012 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4013 * 4014 * @param { string } script - JavaScript Script. 4015 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 4016 * @throws { BusinessError } 401 - Invalid input parameter. 4017 * @throws { BusinessError } 17100001 - Init error. 4018 * The WebviewController must be associated with a Web component. 4019 * @syscap SystemCapability.Web.Webview.Core 4020 * @atomicservice 4021 * @since 11 4022 */ 4023 /** 4024 * Execute JavaScript code in the context of the currently displayed page, and return the result. 4025 * 4026 * @param { string | ArrayBuffer } script - JavaScript Script. 4027 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 4028 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4029 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4030 * @throws { BusinessError } 17100001 - Init error. 4031 * The WebviewController must be associated with a Web component. 4032 * @syscap SystemCapability.Web.Webview.Core 4033 * @atomicservice 4034 * @since 12 4035 */ 4036 runJavaScriptExt(script: string | ArrayBuffer, callback: AsyncCallback<JsMessageExt>): void; 4037 4038 /** 4039 * Execute createPdf code in the context of the currently displayed page and return the result. 4040 * 4041 * @param { PdfConfiguration } configuration - createPdf configuration. 4042 * @param { AsyncCallback<PdfData> } callback - Callbacks execute createPdf results. 4043 * @throws { BusinessError } 401 - Invalid input parameter. 4044 * @throws { BusinessError } 17100001 - Init error. 4045 * The WebviewController must be associated with a Web component. 4046 * @syscap SystemCapability.Web.Webview.Core 4047 * @atomicservice 4048 * @since 14 4049 */ 4050 createPdf(configuration: PdfConfiguration, callback: AsyncCallback<PdfData>): void; 4051 4052 /** 4053 * Execute createPdf code in the context of the currently displayed page and return the result. 4054 * 4055 * @param { PdfConfiguration } configuration - createPdf configuration. 4056 * @returns { Promise<PdfData> } A promise is solved after the createPdf is executed. 4057 * This parameter will be the result of createPdf execution. 4058 * If the createPdf fails to execute or has no return value, 4059 * a none type value will be returned. 4060 * @throws { BusinessError } 401 - Invalid input parameter. 4061 * @throws { BusinessError } 17100001 - Init error. 4062 * The WebviewController must be associated with a Web component. 4063 * @syscap SystemCapability.Web.Webview.Core 4064 * @atomicservice 4065 * @since 14 4066 */ 4067 createPdf(configuration: PdfConfiguration): Promise<PdfData>; 4068 4069 /** 4070 * Gets the url of current Web page. 4071 * @returns { string } Return the url of the current page. 4072 * @throws { BusinessError } 17100001 - Init error. 4073 * The WebviewController must be associated with a Web component. 4074 * @syscap SystemCapability.Web.Webview.Core 4075 * @since 9 4076 */ 4077 /** 4078 * Gets the url of current Web page. 4079 * @returns { string } Return the url of the current page. 4080 * @throws { BusinessError } 17100001 - Init error. 4081 * The WebviewController must be associated with a Web component. 4082 * @syscap SystemCapability.Web.Webview.Core 4083 * @crossplatform 4084 * @atomicservice 4085 * @since 11 4086 */ 4087 getUrl(): string; 4088 4089 /** 4090 * Scroll the contents of this Webview up by half the view size. 4091 * 4092 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 4093 * the page content will scroll up half the size of the viewframe, 4094 * and when set to true, it will jump to the top of the page. 4095 * @throws { BusinessError } 401 - Invalid input parameter. 4096 * @throws { BusinessError } 17100001 - Init error. 4097 * The WebviewController must be associated with a Web component. 4098 * @syscap SystemCapability.Web.Webview.Core 4099 * @since 9 4100 */ 4101 /** 4102 * Scroll the contents of this Webview up by half the view size. 4103 * 4104 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 4105 * the page content will scroll up half the size of the viewframe, 4106 * and when set to true, it will jump to the top of the page. 4107 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4108 * <br>2. Incorrect parameter types. 4109 * @throws { BusinessError } 17100001 - Init error. 4110 * The WebviewController must be associated with a Web component. 4111 * @syscap SystemCapability.Web.Webview.Core 4112 * @atomicservice 4113 * @since 11 4114 */ 4115 pageUp(top: boolean): void; 4116 4117 /** 4118 * Scroll the contents of this Webview down by half the view size. 4119 * 4120 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 4121 * the page content will scroll up half the size of the viewframe, 4122 * and when set to true, it will jump to the top of the page. 4123 * @throws { BusinessError } 401 - Invalid input parameter. 4124 * @throws { BusinessError } 17100001 - Init error. 4125 * The WebviewController must be associated with a Web component. 4126 * @syscap SystemCapability.Web.Webview.Core 4127 * @since 9 4128 */ 4129 /** 4130 * Scroll the contents of this Webview down by half the view size. 4131 * 4132 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 4133 * the page content will scroll up half the size of the viewframe, 4134 * and when set to true, it will jump to the top of the page. 4135 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4136 * <br>2. Incorrect parameter types. 4137 * @throws { BusinessError } 17100001 - Init error. 4138 * The WebviewController must be associated with a Web component. 4139 * @syscap SystemCapability.Web.Webview.Core 4140 * @atomicservice 4141 * @since 11 4142 */ 4143 pageDown(bottom: boolean): void; 4144 4145 /** 4146 * Gets the original url of current Web page. 4147 * @returns { string } Return the original url of the current page. 4148 * @throws { BusinessError } 17100001 - Init error. 4149 * The WebviewController must be associated with a Web component. 4150 * @syscap SystemCapability.Web.Webview.Core 4151 * @since 9 4152 */ 4153 /** 4154 * Gets the original url of current Web page. 4155 * @returns { string } Return the original url of the current page. 4156 * @throws { BusinessError } 17100001 - Init error. 4157 * The WebviewController must be associated with a Web component. 4158 * @syscap SystemCapability.Web.Webview.Core 4159 * @atomicservice 4160 * @since 11 4161 */ 4162 getOriginalUrl(): string; 4163 4164 /** 4165 * Gets the favicon of current Web page. 4166 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 4167 * @throws { BusinessError } 17100001 - Init error. 4168 * The WebviewController must be associated with a Web component. 4169 * @syscap SystemCapability.Web.Webview.Core 4170 * @since 9 4171 */ 4172 /** 4173 * Gets the favicon of current Web page. 4174 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 4175 * @throws { BusinessError } 17100001 - Init error. 4176 * The WebviewController must be associated with a Web component. 4177 * @syscap SystemCapability.Web.Webview.Core 4178 * @atomicservice 4179 * @since 11 4180 */ 4181 getFavicon(): image.PixelMap; 4182 4183 /** 4184 * Put network state for web. Which is used to set window.navigator.onLine property in 4185 * JavaScript. 4186 * @param { boolean } enable - Whether enable window.navigator.onLine. 4187 * @throws { BusinessError } 401 - Invalid input parameter. 4188 * @throws { BusinessError } 17100001 - Init error. 4189 * The WebviewController must be associated with a Web component. 4190 * @syscap SystemCapability.Web.Webview.Core 4191 * @since 9 4192 */ 4193 /** 4194 * Put network state for web. Which is used to set window.navigator.onLine property in 4195 * JavaScript. 4196 * @param { boolean } enable - Whether enable window.navigator.onLine. 4197 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4198 * <br>2. Incorrect parameter types. 4199 * @throws { BusinessError } 17100001 - Init error. 4200 * The WebviewController must be associated with a Web component. 4201 * @syscap SystemCapability.Web.Webview.Core 4202 * @atomicservice 4203 * @since 11 4204 */ 4205 setNetworkAvailable(enable: boolean): void; 4206 4207 /** 4208 * Query if current document has image. 4209 * 4210 * @returns { Promise<boolean> } A promise resolved after query image has finished. 4211 * @throws { BusinessError } 401 - Invalid input parameter. 4212 * @throws { BusinessError } 17100001 - Init error. 4213 * The WebviewController must be associated with a Web component. 4214 * @syscap SystemCapability.Web.Webview.Core 4215 * @since 9 4216 */ 4217 /** 4218 * Query if current document has image. 4219 * 4220 * @returns { Promise<boolean> } A promise resolved after query image has finished. 4221 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4222 * @throws { BusinessError } 17100001 - Init error. 4223 * The WebviewController must be associated with a Web component. 4224 * @syscap SystemCapability.Web.Webview.Core 4225 * @atomicservice 4226 * @since 11 4227 */ 4228 hasImage(): Promise<boolean>; 4229 4230 /** 4231 * Query if current document has image. 4232 * 4233 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 4234 * @throws { BusinessError } 401 - Invalid input parameter. 4235 * @throws { BusinessError } 17100001 - Init error. 4236 * The WebviewController must be associated with a Web component. 4237 * @syscap SystemCapability.Web.Webview.Core 4238 * @since 9 4239 */ 4240 /** 4241 * Query if current document has image. 4242 * 4243 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 4244 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4245 * <br>2. Incorrect parameter types. 4246 * @throws { BusinessError } 17100001 - Init error. 4247 * The WebviewController must be associated with a Web component. 4248 * @syscap SystemCapability.Web.Webview.Core 4249 * @atomicservice 4250 * @since 11 4251 */ 4252 hasImage(callback: AsyncCallback<boolean>): void; 4253 4254 /** 4255 * Get back forward stack list from current webview. 4256 * @returns { BackForwardList } Back forward list for current webview. 4257 * @throws { BusinessError } 17100001 - Init error. 4258 * The WebviewController must be associated with a Web component. 4259 * @syscap SystemCapability.Web.Webview.Core 4260 * @since 9 4261 */ 4262 /** 4263 * Get back forward stack list from current webview. 4264 * @returns { BackForwardList } Back forward list for current webview. 4265 * @throws { BusinessError } 17100001 - Init error. 4266 * The WebviewController must be associated with a Web component. 4267 * @syscap SystemCapability.Web.Webview.Core 4268 * @crossplatform 4269 * @atomicservice 4270 * @since 11 4271 */ 4272 getBackForwardEntries(): BackForwardList; 4273 4274 /** 4275 * Remove resource cache in application. So this method will remove all cache for all web components in the 4276 * same application. 4277 * 4278 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 4279 * in ram. 4280 * @throws { BusinessError } 401 - Invalid input parameter. 4281 * @throws { BusinessError } 17100001 - Init error. 4282 * The WebviewController must be associated with a Web component. 4283 * @syscap SystemCapability.Web.Webview.Core 4284 * @since 9 4285 */ 4286 /** 4287 * Remove resource cache in application. So this method will remove all cache for all web components in the 4288 * same application. 4289 * 4290 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 4291 * in ram. 4292 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4293 * <br>2. Incorrect parameter types. 4294 * @throws { BusinessError } 17100001 - Init error. 4295 * The WebviewController must be associated with a Web component. 4296 * @syscap SystemCapability.Web.Webview.Core 4297 * @crossplatform 4298 * @atomicservice 4299 * @since 11 4300 */ 4301 removeCache(clearRom: boolean): void; 4302 4303 /** 4304 * Scroll to the position. 4305 * 4306 * @param { number } x - the x of the position. 4307 * @param { number } y - the y of the position. 4308 * @throws { BusinessError } 401 - Invalid input parameter. 4309 * @throws { BusinessError } 17100001 - Init error. 4310 * The WebviewController must be associated with a Web component. 4311 * @syscap SystemCapability.Web.Webview.Core 4312 * @since 9 4313 */ 4314 /** 4315 * Scroll to the position. 4316 * 4317 * @param { number } x - the x of the position. 4318 * @param { number } y - the y of the position. 4319 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4320 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4321 * @throws { BusinessError } 17100001 - Init error. 4322 * The WebviewController must be associated with a Web component. 4323 * @syscap SystemCapability.Web.Webview.Core 4324 * @crossplatform 4325 * @atomicservice 4326 * @since 11 4327 */ 4328 /** 4329 * Scroll to the position. 4330 * 4331 * @param { number } x - the x of the position. 4332 * @param { number } y - the y of the position. 4333 * @param { number } duration - the scroll animation duration. Unit: millisecond. 4334 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4335 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4336 * @throws { BusinessError } 17100001 - Init error. 4337 * The WebviewController must be associated with a Web component. 4338 * @syscap SystemCapability.Web.Webview.Core 4339 * @crossplatform 4340 * @atomicservice 4341 * @since 14 4342 */ 4343 scrollTo(x: number, y: number, duration?: number): void; 4344 4345 /** 4346 * Scroll by the delta position. 4347 * 4348 * @param { number } deltaX - the delta x of the position. 4349 * @param { number } deltaY - the delta y of the position. 4350 * @throws { BusinessError } 401 - Invalid input parameter. 4351 * @throws { BusinessError } 17100001 - Init error. 4352 * The WebviewController must be associated with a Web component. 4353 * @syscap SystemCapability.Web.Webview.Core 4354 * @since 9 4355 */ 4356 /** 4357 * Scroll by the delta position. 4358 * 4359 * @param { number } deltaX - the delta x of the position. 4360 * @param { number } deltaY - the delta y of the position. 4361 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4362 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4363 * @throws { BusinessError } 17100001 - Init error. 4364 * The WebviewController must be associated with a Web component. 4365 * @syscap SystemCapability.Web.Webview.Core 4366 * @crossplatform 4367 * @atomicservice 4368 * @since 11 4369 */ 4370 /** 4371 * Scroll by the delta position. 4372 * 4373 * @param { number } deltaX - the delta x of the position. 4374 * @param { number } deltaY - the delta y of the position. 4375 * @param { number } duration - the scroll animation duration. Unit: millisecond. 4376 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4377 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4378 * @throws { BusinessError } 17100001 - Init error. 4379 * The WebviewController must be associated with a Web component. 4380 * @syscap SystemCapability.Web.Webview.Core 4381 * @crossplatform 4382 * @atomicservice 4383 * @since 14 4384 */ 4385 scrollBy(deltaX: number, deltaY: number, duration?: number): void; 4386 4387 /** 4388 * Slide by the speed. 4389 * 4390 * @param { number } vx - the x speed of the speed. 4391 * @param { number } vy - the y speed of the speed. 4392 * @throws { BusinessError } 401 - Invalid input parameter. 4393 * @throws { BusinessError } 17100001 - Init error. 4394 * The WebviewController must be associated with a Web component. 4395 * @syscap SystemCapability.Web.Webview.Core 4396 * @since 9 4397 */ 4398 /** 4399 * Slide by the speed. 4400 * 4401 * @param { number } vx - the x speed of the speed. 4402 * @param { number } vy - the y speed of the speed. 4403 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4404 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4405 * @throws { BusinessError } 17100001 - Init error. 4406 * The WebviewController must be associated with a Web component. 4407 * @syscap SystemCapability.Web.Webview.Core 4408 * @atomicservice 4409 * @since 11 4410 */ 4411 slideScroll(vx: number, vy: number): void; 4412 4413 /** 4414 * Serialize the access stack of the web, that is, the history of access. 4415 * @returns { Uint8Array } Web access stack after serialization. 4416 * @throws { BusinessError } 17100001 - Init error. 4417 * The WebviewController must be associated with a Web component. 4418 * @syscap SystemCapability.Web.Webview.Core 4419 * @since 9 4420 */ 4421 /** 4422 * Serialize the access stack of the web, that is, the history of access. 4423 * @returns { Uint8Array } Web access stack after serialization. 4424 * @throws { BusinessError } 17100001 - Init error. 4425 * The WebviewController must be associated with a Web component. 4426 * @syscap SystemCapability.Web.Webview.Core 4427 * @atomicservice 4428 * @since 11 4429 */ 4430 serializeWebState(): Uint8Array; 4431 4432 /** 4433 * Restoring the web access stack, that is, the history of access. 4434 * @param { Uint8Array } state - Web access stack after serialization. 4435 * @throws { BusinessError } 401 - Invalid input parameter. 4436 * @throws { BusinessError } 17100001 - Init error. 4437 * The WebviewController must be associated with a Web component. 4438 * @syscap SystemCapability.Web.Webview.Core 4439 * @since 9 4440 */ 4441 /** 4442 * Restoring the web access stack, that is, the history of access. 4443 * @param { Uint8Array } state - Web access stack after serialization. 4444 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4445 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4446 * @throws { BusinessError } 17100001 - Init error. 4447 * The WebviewController must be associated with a Web component. 4448 * @syscap SystemCapability.Web.Webview.Core 4449 * @atomicservice 4450 * @since 11 4451 */ 4452 restoreWebState(state: Uint8Array): void; 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 * @since 9 4460 */ 4461 /** 4462 * Set whether the Web custom scheme supports cross domain and fetch requests. 4463 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 4464 * @throws { BusinessError } 401 - Invalid input parameter. 4465 * @syscap SystemCapability.Web.Webview.Core 4466 * @atomicservice 4467 * @since 11 4468 */ 4469 /** 4470 * Register Web custom schemes. 4471 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 4472 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4473 * <br>2. Incorrect parameter types. 4474 * @throws { BusinessError } 17100020 - Failed to register custom schemes. 4475 * @syscap SystemCapability.Web.Webview.Core 4476 * @atomicservice 4477 * @since 12 4478 */ 4479 static customizeSchemes(schemes: Array<WebCustomScheme>): void; 4480 4481 /** 4482 * Get certificate for the current website. 4483 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 4484 * @throws { BusinessError } 17100001 - Init error. 4485 * The WebviewController must be associated with a web component. 4486 * @syscap SystemCapability.Web.Webview.Core 4487 * @since 10 4488 */ 4489 /** 4490 * Get certificate for the current website. 4491 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 4492 * @throws { BusinessError } 17100001 - Init error. 4493 * The WebviewController must be associated with a web component. 4494 * @syscap SystemCapability.Web.Webview.Core 4495 * @atomicservice 4496 * @since 11 4497 */ 4498 getCertificate(): Promise<Array<cert.X509Cert>>; 4499 4500 /** 4501 * Get certificate for the current website. 4502 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 4503 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4504 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4505 * @throws { BusinessError } 17100001 - Init error. 4506 * The WebviewController must be associated with a web component. 4507 * @syscap SystemCapability.Web.Webview.Core 4508 * @since 10 4509 */ 4510 /** 4511 * Get certificate for the current website. 4512 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 4513 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4514 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4515 * @throws { BusinessError } 17100001 - Init error. 4516 * The WebviewController must be associated with a web component. 4517 * @syscap SystemCapability.Web.Webview.Core 4518 * @atomicservice 4519 * @since 11 4520 */ 4521 getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void; 4522 4523 /** 4524 * Set audio muted. 4525 * @param { boolean } mute - Set the audio muted or not. 4526 * @throws { BusinessError } 401 - Invalid input parameter. 4527 * @throws { BusinessError } 17100001 - Init error. 4528 * The WebviewController must be associated with a Web component. 4529 * @syscap SystemCapability.Web.Webview.Core 4530 * @since 10 4531 */ 4532 /** 4533 * Set audio muted. 4534 * @param { boolean } mute - Set the audio muted or not. 4535 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4536 * <br>2. Incorrect parameter types. 4537 * @throws { BusinessError } 17100001 - Init error. 4538 * The WebviewController must be associated with a Web component. 4539 * @syscap SystemCapability.Web.Webview.Core 4540 * @atomicservice 4541 * @since 11 4542 */ 4543 setAudioMuted(mute: boolean): void; 4544 4545 /** 4546 * Prefetch the resources required by the page, but will not execute js or render the page. 4547 * @param { string } url - Which url to preresolve/preconnect. 4548 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 4549 * @throws { BusinessError } 17100001 - Init error. 4550 * The WebviewController must be associated with a Web component. 4551 * @throws { BusinessError } 17100002 - Invalid url. 4552 * @syscap SystemCapability.Web.Webview.Core 4553 * @since 10 4554 */ 4555 /** 4556 * Prefetch the resources required by the page, but will not execute js or render the page. 4557 * @param { string } url - Which url to preresolve/preconnect. 4558 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 4559 * @throws { BusinessError } 17100001 - Init error. 4560 * The WebviewController must be associated with a Web component. 4561 * @throws { BusinessError } 17100002 - Invalid url. 4562 * @syscap SystemCapability.Web.Webview.Core 4563 * @atomicservice 4564 * @since 11 4565 */ 4566 prefetchPage(url: string, additionalHeaders?: Array<WebHeader>): void; 4567 4568 /** 4569 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 4570 * @param { string } url - Which url to preresolve/preconnect. 4571 * @param { boolean } preconnectable - Indicates whether to preconnect. 4572 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 4573 * @throws { BusinessError } 17100002 - Invalid url. 4574 * @throws { BusinessError } 171000013 - The number of preconnect sockets is invalid. 4575 * @syscap SystemCapability.Web.Webview.Core 4576 * @since 10 4577 */ 4578 /** 4579 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 4580 * @param { string } url - Which url to preresolve/preconnect. 4581 * @param { boolean } preconnectable - Indicates whether to preconnect. 4582 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 4583 * @throws { BusinessError } 17100002 - Invalid url. 4584 * @throws { BusinessError } 171000013 - The number of preconnect sockets is invalid. 4585 * @syscap SystemCapability.Web.Webview.Core 4586 * @atomicservice 4587 * @since 11 4588 */ 4589 static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void; 4590 4591 /** 4592 * Set custom user agent. 4593 * @param { string } userAgent - User custom agent information. 4594 * @throws { BusinessError } 401 - Invalid input parameter. 4595 * @throws { BusinessError } 17100001 - Init error. 4596 * The WebviewController must be associated with a Web component. 4597 * @syscap SystemCapability.Web.Webview.Core 4598 * @since 10 4599 */ 4600 /** 4601 * Set custom user agent. 4602 * @param { string } userAgent - User custom agent information. 4603 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4604 * <br>2. Incorrect parameter types. 4605 * @throws { BusinessError } 17100001 - Init error. 4606 * The WebviewController must be associated with a Web component. 4607 * @syscap SystemCapability.Web.Webview.Core 4608 * @crossplatform 4609 * @atomicservice 4610 * @since 11 4611 */ 4612 setCustomUserAgent(userAgent: string): void; 4613 4614 /** 4615 * Get custom user agent. 4616 * @returns { string } Get custom User agent information. 4617 * @throws { BusinessError } 17100001 - Init error. 4618 * The WebviewController must be associated with a Web component. 4619 * @syscap SystemCapability.Web.Webview.Core 4620 * @since 10 4621 */ 4622 /** 4623 * Get custom user agent. 4624 * @returns { string } Get custom User agent information. 4625 * @throws { BusinessError } 17100001 - Init error. 4626 * The WebviewController must be associated with a Web component. 4627 * @syscap SystemCapability.Web.Webview.Core 4628 * @crossplatform 4629 * @atomicservice 4630 * @since 11 4631 */ 4632 getCustomUserAgent(): string; 4633 4634 /** 4635 * Set web engine socket connection timeout. 4636 * @param { number } timeout - Socket connection timeout. 4637 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4638 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 4639 * @syscap SystemCapability.Web.Webview.Core 4640 * @atomicservice 4641 * @since 11 4642 */ 4643 static setConnectionTimeout(timeout: number): void; 4644 4645 /** 4646 * Set delegate for download. 4647 * Used to notify the progress of the download triggered from web. 4648 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from web. 4649 * @throws { BusinessError } 17100001 - Init error. 4650 * The WebviewController must be associated with a Web component. 4651 * @syscap SystemCapability.Web.Webview.Core 4652 * @atomicservice 4653 * @since 11 4654 */ 4655 setDownloadDelegate(delegate: WebDownloadDelegate): void; 4656 4657 /** 4658 * Start a download. 4659 * @param { string } url - The download url. 4660 * @throws { BusinessError } 17100001 - Init error. 4661 * The WebviewController must be associated with a Web component. 4662 * @throws { BusinessError } 17100002 - Invalid url. 4663 * @syscap SystemCapability.Web.Webview.Core 4664 * @atomicservice 4665 * @since 11 4666 */ 4667 startDownload(url: string): void; 4668 4669 /** 4670 * Loads the URL use "POST" method with post data. 4671 * 4672 * @param { string } url - Request the URL use "POST" method. 4673 * @param { ArrayBuffer } postData - This data will passed to "POST" request. 4674 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4675 * <br>2. Incorrect parameter types. 4676 * @throws { BusinessError } 17100001 - Init error. 4677 * The WebviewController must be associated with a Web component. 4678 * @throws { BusinessError } 17100002 - Invalid url. 4679 * @syscap SystemCapability.Web.Webview.Core 4680 * @atomicservice 4681 * @since 11 4682 */ 4683 postUrl(url: string, postData: ArrayBuffer): void; 4684 4685 /** 4686 * Create the Web Print Document Adapter. 4687 * @param { string } jobName - The name of the currently printed document. 4688 * @returns { print.PrintDocumentAdapter } Return the Print Document Adapter. 4689 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4690 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4691 * @throws { BusinessError } 17100001 - Init error. 4692 * The WebviewController must be associated with a Web component. 4693 * @syscap SystemCapability.Web.Webview.Core 4694 * @since 11 4695 */ 4696 createWebPrintDocumentAdapter(jobName: string): print.PrintDocumentAdapter; 4697 4698 /** 4699 * Get the security level of the current page. 4700 * 4701 * @returns { SecurityLevel } the security level of current page. 4702 * @throws { BusinessError } 17100001 - Init error. 4703 * The WebviewController must be associated with a Web component. 4704 * @syscap SystemCapability.Web.Webview.Core 4705 * @atomicservice 4706 * @since 11 4707 */ 4708 getSecurityLevel(): SecurityLevel; 4709 4710 /** 4711 * Whether the incognito mode is set. 4712 * 4713 * @returns { boolean } {@code true} has been set the incognito mode; {@code false} otherwise. 4714 * @throws { BusinessError } 17100001 - Init error. 4715 * The WebviewController must be associated with a Web component. 4716 * @syscap SystemCapability.Web.Webview.Core 4717 * @atomicservice 4718 * @since 11 4719 */ 4720 isIncognitoMode(): boolean; 4721 4722 /** 4723 * Set whether scroll is allowed 4724 * 4725 * @param { boolean } enable - Set whether scrolling is allowed 4726 * @param { ScrollType } type - Enable scrolling type 4727 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4728 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4729 * @throws { BusinessError } 17100001 - Init error. 4730 * The WebviewController must be associated with a Web component. 4731 * @syscap SystemCapability.Web.Webview.Core 4732 * @atomicservice 4733 * @since 12 4734 */ 4735 setScrollable(enable: boolean, type?: ScrollType): void; 4736 4737 /** 4738 * Get whether scrolling is allowed. 4739 * @returns { boolean } Get scrolling is allowed information. 4740 * @throws { BusinessError } 17100001 - Init error. 4741 * The WebviewController must be associated with a Web component. 4742 * @syscap SystemCapability.Web.Webview.Core 4743 * @atomicservice 4744 * @since 12 4745 */ 4746 getScrollable(): boolean; 4747 4748 /** 4749 * Set whether print web page background. 4750 * 4751 * @param { boolean } enable - Set whether print web page background 4752 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4753 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 4754 * @throws { BusinessError } 17100001 - Init error. 4755 * The WebviewController must be associated with a Web component. 4756 * @syscap SystemCapability.Web.Webview.Core 4757 * @atomicservice 4758 * @since 12 4759 */ 4760 setPrintBackground(enable: boolean): void; 4761 4762 /** 4763 * Get whether print web page background. 4764 * @returns { boolean } Get whether print web page background. 4765 * @throws { BusinessError } 17100001 - Init error. 4766 * The WebviewController must be associated with a Web component. 4767 * @syscap SystemCapability.Web.Webview.Core 4768 * @atomicservice 4769 * @since 12 4770 */ 4771 getPrintBackground(): boolean; 4772 4773 /** 4774 * Get the url of the last frame that calls the JavaScriptProxy. 4775 * This should be called on the UI thread. 4776 * 4777 * @returns { string } The url of the last frame that calls the JavaScriptProxy. 4778 * @throws { BusinessError } 17100001 - Init error. 4779 * The WebviewController must be associated with a Web component. 4780 * @syscap SystemCapability.Web.Webview.Core 4781 * @atomicservice 4782 * @since 12 4783 */ 4784 getLastJavascriptProxyCallingFrameUrl(): string; 4785 4786 /** 4787 * Start current camera. 4788 * 4789 * @throws { BusinessError } 17100001 - Init error. 4790 * The WebviewController must be associated with a Web component. 4791 * @syscap SystemCapability.Web.Webview.Core 4792 * @atomicservice 4793 * @since 12 4794 */ 4795 startCamera(): void; 4796 4797 /** 4798 * Stop current camera. 4799 * 4800 * @throws { BusinessError } 17100001 - Init error. 4801 * The WebviewController must be associated with a Web component. 4802 * @syscap SystemCapability.Web.Webview.Core 4803 * @atomicservice 4804 * @since 12 4805 */ 4806 stopCamera(): void; 4807 4808 /** 4809 * Close current camera. 4810 * 4811 * @throws { BusinessError } 17100001 - Init error. 4812 * The WebviewController must be associated with a Web component. 4813 * @syscap SystemCapability.Web.Webview.Core 4814 * @atomicservice 4815 * @since 12 4816 */ 4817 closeCamera(): void; 4818 4819 /** 4820 * Pauses all layout, parsing, and JavaScript timers for all WebViews. 4821 * 4822 * @throws { BusinessError } 17100001 - Init error. 4823 * The WebviewController must be associated with a Web component. 4824 * @syscap SystemCapability.Web.Webview.Core 4825 * @atomicservice 4826 * @since 12 4827 */ 4828 static pauseAllTimers(): void; 4829 4830 /** 4831 * Resumes all layout, parsing, and JavaScript timers for all WebViews. 4832 * 4833 * @throws { BusinessError } 17100001 - Init error. 4834 * The WebviewController must be associated with a Web component. 4835 * @syscap SystemCapability.Web.Webview.Core 4836 * @atomicservice 4837 * @since 12 4838 */ 4839 static resumeAllTimers(): void; 4840 4841 /** 4842 * Stop all audio and video playback on the web page. 4843 * 4844 * @throws { BusinessError } 17100001 - Init error. 4845 * The WebviewController must be associated with a Web component. 4846 * @syscap SystemCapability.Web.Webview.Core 4847 * @atomicservice 4848 * @since 12 4849 */ 4850 stopAllMedia(): void; 4851 4852 /** 4853 * Restart playback of all audio and video on the web page. 4854 * 4855 * @throws { BusinessError } 17100001 - Init error. 4856 * The WebviewController must be associated with a Web component. 4857 * @syscap SystemCapability.Web.Webview.Core 4858 * @atomicservice 4859 * @since 12 4860 */ 4861 resumeAllMedia(): void; 4862 4863 /** 4864 * Pause all audio and video playback on the web page. 4865 * 4866 * @throws { BusinessError } 17100001 - Init error. 4867 * The WebviewController must be associated with a Web component. 4868 * @syscap SystemCapability.Web.Webview.Core 4869 * @atomicservice 4870 * @since 12 4871 */ 4872 pauseAllMedia(): void; 4873 4874 /** 4875 * Close fullscreen video. 4876 * 4877 * @throws { BusinessError } 17100001 - Init error. 4878 * The WebviewController must be associated with a Web component. 4879 * @syscap SystemCapability.Web.Webview.Core 4880 * @atomicservice 4881 * @since 12 4882 */ 4883 closeAllMediaPresentations(): void; 4884 4885 /** 4886 * View the playback status of all audio and video on the web page. 4887 * 4888 * @returns { MediaPlaybackState } The playback status of all audio and video. 4889 * @throws { BusinessError } 17100001 - Init error. 4890 * The WebviewController must be associated with a Web component. 4891 * @syscap SystemCapability.Web.Webview.Core 4892 * @atomicservice 4893 * @since 12 4894 */ 4895 getMediaPlaybackState(): MediaPlaybackState; 4896 4897 /** 4898 * Set web scheme handler for specific scheme. This is only used for related web component. 4899 * 4900 * @param { string } scheme - String value for url scheme. 4901 * @param { WebSchemeHandler } handler - Web scheme handler. 4902 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 4903 * @throws { BusinessError } 17100001 - Init error. 4904 * The WebviewController must be associated with a Web component. 4905 * @syscap SystemCapability.Web.Webview.Core 4906 * @atomicservice 4907 * @since 12 4908 */ 4909 setWebSchemeHandler(scheme: string, handler: WebSchemeHandler): void; 4910 4911 /** 4912 * Clear all web scheme handlers for related web component. 4913 * @throws { BusinessError } 17100001 - Init error. 4914 * The WebviewController must be associated with a Web component. 4915 * @syscap SystemCapability.Web.Webview.Core 4916 * @atomicservice 4917 * @since 12 4918 */ 4919 clearWebSchemeHandler(): void; 4920 4921 /** 4922 * Set web scheme handler for specific scheme. This is used for service worker. 4923 * @param { string } scheme - String value for url scheme. 4924 * @param { WebSchemeHandler } handler - Web scheme handler. 4925 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 4926 * @syscap SystemCapability.Web.Webview.Core 4927 * @atomicservice 4928 * @since 12 4929 */ 4930 static setServiceWorkerWebSchemeHandler(scheme: string, handler: WebSchemeHandler): void; 4931 4932 /** 4933 * Clear all web service worker scheme handlers. 4934 * @syscap SystemCapability.Web.Webview.Core 4935 * @atomicservice 4936 * @since 12 4937 */ 4938 static clearServiceWorkerWebSchemeHandler(): void; 4939 4940 /** 4941 * Enable the ability to use Intelligent Tracking Prevention; default is disabled. 4942 * 4943 * @param { boolean } enable {@code true} enable Intelligent Tracking Prevention; {@code false} otherwise. 4944 * @throws { BusinessError } 17100001 - Init error. 4945 * The WebviewController must be associated with a Web component. 4946 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4947 * <br>2. Incorrect parameter types. 4948 * @syscap SystemCapability.Web.Webview.Core 4949 * @atomicservice 4950 * @since 12 4951 */ 4952 enableIntelligentTrackingPrevention(enable: boolean): void; 4953 4954 /** 4955 * Get whether Intelligent Tracking Prevention is enabled. 4956 * 4957 * @returns { boolean } True if enable the Intelligent Tracking Prevention; else false. 4958 * @throws { BusinessError } 17100001 - Init error. 4959 * The WebviewController must be associated with a Web component. 4960 * @syscap SystemCapability.Web.Webview.Core 4961 * @atomicservice 4962 * @since 12 4963 */ 4964 isIntelligentTrackingPreventionEnabled(): boolean; 4965 4966 /** 4967 * Add bypassing hosts for Intelligent Tracking Prevention. 4968 * 4969 * @param { Array<string> } hostList - Hosts that bypass the Intelligent Tracking Prevention. 4970 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4971 * <br>2. Incorrect parameter types. 4972 * @syscap SystemCapability.Web.Webview.Core 4973 * @atomicservice 4974 * @since 12 4975 */ 4976 static addIntelligentTrackingPreventionBypassingList(hostList: Array<string>): void; 4977 4978 /** 4979 * Remove bypassing hosts for Intelligent Tracking Prevention. 4980 * 4981 * @param { Array<string> } hostList - Hosts needs to remove from bypass list. 4982 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 4983 * <br>2. Incorrect parameter types. 4984 * @syscap SystemCapability.Web.Webview.Core 4985 * @atomicservice 4986 * @since 12 4987 */ 4988 static removeIntelligentTrackingPreventionBypassingList(hostList: Array<string>): void; 4989 4990 /** 4991 * Clear bypassing hosts for Intelligent Tracking Prevention. 4992 * 4993 * @syscap SystemCapability.Web.Webview.Core 4994 * @atomicservice 4995 * @since 12 4996 */ 4997 static clearIntelligentTrackingPreventionBypassingList(): void; 4998 4999 /** 5000 * Get the default user agent. 5001 * 5002 * @returns {string} The default user agent string. 5003 * @syscap SystemCapability.Web.Webview.Core 5004 * @since 14 5005 */ 5006 static getDefaultUserAgent(): string; 5007 5008 /** 5009 * Register a callback to intercept web pages playing media. 5010 * 5011 * @param { CreateNativeMediaPlayerCallback } callback - Called everytime when web pages try to play media. 5012 * @syscap SystemCapability.Web.Webview.Core 5013 * @atomicservice 5014 * @since 12 5015 */ 5016 onCreateNativeMediaPlayer(callback: CreateNativeMediaPlayerCallback): void; 5017 5018 /** 5019 * Set enable overall web caching 5020 * 5021 * @syscap SystemCapability.Web.Webview.Core 5022 * @atomicservice 5023 * @since 12 5024 */ 5025 static enableWholeWebPageDrawing(): void; 5026 5027 /** 5028 * Web page snapshot. 5029 * 5030 * @param { SnapshotInfo } info - The snapshot info. 5031 * @param { AsyncCallback<SnapshotResult> } callback - the callback of snapshot. 5032 * @syscap SystemCapability.Web.Webview.Core 5033 * @atomicservice 5034 * @since 12 5035 */ 5036 webPageSnapshot(info: SnapshotInfo, callback: AsyncCallback<SnapshotResult>): void; 5037 5038 /** 5039 * Prefetch the resources request and save it to the memory cache. Only support post request and its Content-Type 5040 * is application/x-www-form-urlencoded now. 5041 * You can prefetch no more than 6 resources. If you want to prefetch the seventh resource, you can clear one of 5042 * the prefetched resources that you won't use any more. Otherwise the oldest resource you prefetched will be 5043 * cleared. 5044 * @param { RequestInfo } request - The information of the request. 5045 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the request. 5046 * @param { string } [cacheKey] - The key for memory cache. Default value is the url of the request. 5047 * Only support number and letters. 5048 * @param { number } [cacheValidTime] - The valid time of the cache for request, ranges greater than 0. 5049 * The unit is second. Default value is 300s. 5050 * The value of cacheValidTime must between 1 and 2147483647. 5051 * @throws { BusinessError } 401 - Invalid input parameter.Possible causes: 1. Mandatory parameters are left unspecified. 5052 * 2. Incorrect parameter types. 3. Parameter verification failed. 5053 * @throws { BusinessError } 17100002 - Invalid url. 5054 * @syscap SystemCapability.Web.Webview.Core 5055 * @atomicservice 5056 * @since 12 5057 */ 5058 static prefetchResource(request: RequestInfo, additionalHeaders?: Array<WebHeader>, cacheKey?: string, 5059 cacheValidTime?: number): void; 5060 5061 /** 5062 * Clear the resource that you prefetch to the memory cache using API{@link prefetchResource}. 5063 * @param { Array<string> } cacheKeyList - The keys for memory cache. 5064 * The key in cacheKeyList only support number and letters. 5065 * @syscap SystemCapability.Web.Webview.Core 5066 * @atomicservice 5067 * @since 12 5068 */ 5069 static clearPrefetchedResource(cacheKeyList: Array<string>): void; 5070 5071 /** 5072 * Set render process mode of the ArkWeb. 5073 * 5074 * @param { RenderProcessMode } mode - The render process mode for the ArkWeb. 5075 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5076 * <br>2. Incorrect parameter types. 5077 * @syscap SystemCapability.Web.Webview.Core 5078 * @atomicservice 5079 * @since 12 5080 */ 5081 static setRenderProcessMode(mode: RenderProcessMode): void; 5082 5083 /** 5084 * Get render process mode of the ArkWeb. 5085 * 5086 * @returns { RenderProcessMode } mode - The render process mode of the ArkWeb. 5087 * @syscap SystemCapability.Web.Webview.Core 5088 * @atomicservice 5089 * @since 12 5090 */ 5091 static getRenderProcessMode(): RenderProcessMode; 5092 5093 /** 5094 * Terminate render process associated with this controller of the ArkWeb. 5095 * 5096 * @returns { boolean } true if it was possible to terminate the render process, otherwise false. 5097 * Calling this on a not yet started, or an already terminated render will have no effect. 5098 * @throws { BusinessError } 17100001 - Init error. 5099 * The WebviewController must be associated with a Web component. 5100 * @syscap SystemCapability.Web.Webview.Core 5101 * @since 12 5102 */ 5103 terminateRenderProcess(): boolean; 5104 5105 /** 5106 * Compile javascript and generate code cache. 5107 * @param { string } url - Url of the javascript. Only support HTTP/HTTPS protocol and length no longer than 2048. 5108 * @param { string | Uint8Array } script - Javascript source code. script must not be empty. 5109 * @param { CacheOptions } cacheOptions - Generate code cache option. 5110 * @returns { Promise<number> } - The promise returned by the function. 5111 * 0 means generate code cache successfully, -1 means internal error. 5112 * @throws { BusinessError } 401 - Invalid input parameter. 5113 * Possible causes: 1. Mandatory parameters are left unspecified. 5114 * 2. Incorrect parameter types. 3. Parameter verification failed. 5115 * @throws { BusinessError } 17100001 - Init error. 5116 * The WebviewController must be associated with a Web component. 5117 * @syscap SystemCapability.Web.Webview.Core 5118 * @since 12 5119 */ 5120 precompileJavaScript(url: string, script: string | Uint8Array, cacheOptions: CacheOptions): Promise<number>; 5121 5122 /** 5123 * Set IP address for host name. 5124 * 5125 * @param { string } hostName - Which host name to be resolved. 5126 * @param { string } address - Resolved IP address. 5127 * @param { number } aliveTime - The validity seconds for resolve cache. 5128 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5129 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5130 * @syscap SystemCapability.Web.Webview.Core 5131 * @atomicservice 5132 * @since 12 5133 */ 5134 static setHostIP(hostName: string, address: string, aliveTime: number): void; 5135 5136 /** 5137 * Clear the host name IP address. 5138 * 5139 * @param { string } hostName - Which host name to be cleared. 5140 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5141 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5142 * @syscap SystemCapability.Web.Webview.Core 5143 * @atomicservice 5144 * @since 12 5145 */ 5146 static clearHostIP(hostName: string): void; 5147 5148 /** 5149 * Warmup the registered service worker associated the url. 5150 * @param { string } url - The url. 5151 * @throws { BusinessError } 17100002 - Invalid url. 5152 * @syscap SystemCapability.Web.Webview.Core 5153 * @atomicservice 5154 * @since 12 5155 */ 5156 static warmupServiceWorker(url: string): void; 5157 5158 /** 5159 * Inject offline resources into cache. 5160 * 5161 * @param { Array<OfflineResourceMap> } resourceMaps - Array of offline resource info maps. 5162 * The count of array must between 1 and 30. 5163 * @throws { BusinessError } 401 - Invalid input parameter. 5164 * Possible causes: 1. Mandatory parameters are left unspecified. 5165 * 2. Incorrect parameter types. 3. Parameter verification failed. 5166 * @throws { BusinessError } 17100001 - Init error. 5167 * The WebviewController must be associated with a Web component. 5168 * @throws { BusinessError } 17100002 - Invalid url. 5169 * @syscap SystemCapability.Web.Webview.Core 5170 * @since 12 5171 */ 5172 injectOfflineResources(resourceMaps: Array<OfflineResourceMap>): void; 5173 5174 /** 5175 * Enable the ability to block Ads, disabled by default. 5176 * 5177 * @param { boolean } enable {@code true} Enable Ads block; {@code false} otherwise. 5178 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5179 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5180 * @throws { BusinessError } 17100001 - Init error. 5181 * The WebviewController must be associated with a Web component. 5182 * @syscap SystemCapability.Web.Webview.Core 5183 * @atomicservice 5184 * @since 12 5185 */ 5186 enableAdsBlock(enable: boolean): void; 5187 5188 /** 5189 * Get whether Ads block is enabled. 5190 * 5191 * @returns { boolean } True if the ability of AdsBlock is enabled; else false. 5192 * @syscap SystemCapability.Web.Webview.Core 5193 * @atomicservice 5194 * @since 12 5195 */ 5196 isAdsBlockEnabled(): boolean; 5197 5198 /** 5199 * Get whether Ads block is enabled for current Webpage. 5200 * 5201 * @returns { boolean } True if the ability of AdsBlock is enabled for current Webpage; else false. 5202 * @syscap SystemCapability.Web.Webview.Core 5203 * @atomicservice 5204 * @since 12 5205 */ 5206 isAdsBlockEnabledForCurPage(): boolean; 5207 5208 /** 5209 * Get the ID of the surface created by ArkWeb. This ID can be used for web page screenshots. 5210 * 5211 * @returns { string } The ID of the surface created by ArkWeb. 5212 * @syscap SystemCapability.Web.Webview.Core 5213 * @atomicservice 5214 * @since 12 5215 */ 5216 getSurfaceId(): string; 5217 5218 /** 5219 * Set the URL trust list for the ArkWeb. 5220 * When the URL trust list has been set, only the URLs in the list can be accessed. 5221 * 5222 * @param { string } urlTrustList - the URL trust list in JSON format. 5223 * An empty string means that all URLs are allowed to access. 5224 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5225 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5226 * @throws { BusinessError } 17100001 - Init error. 5227 * The WebviewController must be associated with a Web component. 5228 * @syscap SystemCapability.Web.Webview.Core 5229 * @atomicservice 5230 * @since 12 5231 */ 5232 setUrlTrustList(urlTrustList: string): void; 5233 5234 /** 5235 * Set a path list, allowing cross-origin request access any origin when the file scheme URLs access resources in this 5236 * path list. Also, When the path list is set, the file scheme URLs only allow access to resources within the path list. 5237 * Path in the path list must meet one of the following path formats(sub path and module name must be provided): 5238 * 5239 * 1. App bundle resource directory, like "/data/storage/el1/bundle/entry/resource/resfile". 5240 * You can get resource directory using Context.resourceDir in AbilityKit. 5241 * 2. A sub path of app files directory, like "/data/storage/el2/base/files/example/" 5242 * or "/data/storage/el2/base/haps/entry/files/example". 5243 * You can get app files directory using Context.filesDir in AbilityKit. 5244 * 5245 * @param { Array<string> } pathList - The path list allow universal access. 5246 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5247 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5248 * @throws { BusinessError } 17100001 - Init error. 5249 * The WebviewController must be associated with a Web component. 5250 * @syscap SystemCapability.Web.Webview.Core 5251 * @since 12 5252 */ 5253 setPathAllowingUniversalAccess(pathList: Array<string>): void; 5254 5255 /** 5256 * Trim memory by different memory pressure level. 5257 * 5258 * @param { PressureLevel } level - The memory pressure level for the ArkWeb. 5259 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5260 * <br>2. Parameter string is too long. 3.Parameter verification failed. 5261 * @syscap SystemCapability.Web.Webview.Core 5262 * @atomicservice 5263 * @since 14 5264 */ 5265 static trimMemoryByPressureLevel(level: PressureLevel): void; 5266 5267 /** 5268 * Enable the BackForwardCache and indicate features that are allowed to enter BackForwardCache. 5269 * Default is disabled. 5270 * 5271 * @param { BackForwardCacheSupportedFeatures } features - The features that supports BackForwardCache. 5272 * @syscap SystemCapability.Web.Webview.Core 5273 * @since 12 5274 */ 5275 static enableBackForwardCache(features: BackForwardCacheSupportedFeatures): void; 5276 5277 /** 5278 * Configure the BackForwardCache. 5279 * 5280 * @param { BackForwardCacheOptions } options - The configuration of BackForwardCache. 5281 * @throws { BusinessError } 17100001 - Init error. 5282 * The WebviewController must be associated with a Web component. 5283 * @syscap SystemCapability.Web.Webview.Core 5284 * @since 12 5285 */ 5286 setBackForwardCacheOptions(options: BackForwardCacheOptions): void; 5287 5288 /** 5289 * 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. 5290 * And the unit is virtual pixel. 5291 * 5292 * @returns { ScrollOffset } scroll offset 5293 * @syscap SystemCapability.Web.Webview.Core 5294 * @atomicservice 5295 * @since 13 5296 */ 5297 getScrollOffset(): ScrollOffset; 5298 5299 /** 5300 * Scrolls by the specified delta position and returns a result indicating whether the scrolling operation was successful or not. 5301 * 5302 * @param { number } deltaX - the delta x of the position. 5303 * @param { number } deltaY - the delta y of the position. 5304 * @returns { boolean } true if the scroll operation is successful, otherwise false. 5305 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5306 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5307 * @throws { BusinessError } 17100001 - Init error. 5308 * The WebviewController must be associated with a Web component. 5309 * @syscap SystemCapability.Web.Webview.Core 5310 * @since 12 5311 */ 5312 scrollByWithResult(deltaX: number, deltaY: number): boolean; 5313 } 5314 5315 /** 5316 * Defines the state for download. 5317 * @enum {number} 5318 * @syscap SystemCapability.Web.Webview.Core 5319 * @atomicservice 5320 * @since 11 5321 */ 5322 enum WebDownloadState { 5323 /** 5324 * The web download is in progress. 5325 * @syscap SystemCapability.Web.Webview.Core 5326 * @atomicservice 5327 * @since 11 5328 */ 5329 IN_PROGRESS = 0, 5330 5331 /** 5332 * The web download has been completed. 5333 * @syscap SystemCapability.Web.Webview.Core 5334 * @atomicservice 5335 * @since 11 5336 */ 5337 COMPLETED, 5338 5339 /** 5340 * The web download was canceled. 5341 * @syscap SystemCapability.Web.Webview.Core 5342 * @atomicservice 5343 * @since 11 5344 */ 5345 CANCELED, 5346 5347 /** 5348 * The web download was interrupted. 5349 * @syscap SystemCapability.Web.Webview.Core 5350 * @atomicservice 5351 * @since 11 5352 */ 5353 INTERRUPTED, 5354 5355 /** 5356 * The web download is pending. 5357 * @syscap SystemCapability.Web.Webview.Core 5358 * @atomicservice 5359 * @since 11 5360 */ 5361 PENDING, 5362 5363 /** 5364 * The web download has been paused. 5365 * @syscap SystemCapability.Web.Webview.Core 5366 * @atomicservice 5367 * @since 11 5368 */ 5369 PAUSED, 5370 5371 /** 5372 * Unknown state. 5373 * @syscap SystemCapability.Web.Webview.Core 5374 * @atomicservice 5375 * @since 11 5376 */ 5377 UNKNOWN, 5378 } 5379 5380 /** 5381 * Defines the error code for download. 5382 * @enum {number} 5383 * @syscap SystemCapability.Web.Webview.Core 5384 * @atomicservice 5385 * @since 11 5386 */ 5387 enum WebDownloadErrorCode { 5388 /** 5389 * Unknown error. 5390 * @syscap SystemCapability.Web.Webview.Core 5391 * @atomicservice 5392 * @since 11 5393 */ 5394 ERROR_UNKNOWN = 0, 5395 5396 /** 5397 * Generic file operation failure. 5398 * @syscap SystemCapability.Web.Webview.Core 5399 * @atomicservice 5400 * @since 11 5401 */ 5402 FILE_FAILED = 1, 5403 5404 /** 5405 * The file cannot be accessed due to certain restrictions. 5406 * @syscap SystemCapability.Web.Webview.Core 5407 * @atomicservice 5408 * @since 11 5409 */ 5410 FILE_ACCESS_DENIED = 2, 5411 5412 /** 5413 * There is not enough disk space. 5414 * @syscap SystemCapability.Web.Webview.Core 5415 * @atomicservice 5416 * @since 11 5417 */ 5418 FILE_NO_SPACE = 3, 5419 5420 /** 5421 * The file name is too long. 5422 * @syscap SystemCapability.Web.Webview.Core 5423 * @atomicservice 5424 * @since 11 5425 */ 5426 FILE_NAME_TOO_LONG = 5, 5427 5428 /** 5429 * The file is too large. 5430 * @syscap SystemCapability.Web.Webview.Core 5431 * @atomicservice 5432 * @since 11 5433 */ 5434 FILE_TOO_LARGE = 6, 5435 5436 /** 5437 * Some temporary problems occurred, such as not enough memory, files in use, and too many files open at the same time. 5438 * @syscap SystemCapability.Web.Webview.Core 5439 * @atomicservice 5440 * @since 11 5441 */ 5442 FILE_TRANSIENT_ERROR = 10, 5443 5444 /** 5445 * The file is blocked from accessing because of some local policy. 5446 * @syscap SystemCapability.Web.Webview.Core 5447 * @atomicservice 5448 * @since 11 5449 */ 5450 FILE_BLOCKED = 11, 5451 5452 /** 5453 * When trying to resume the download, Found that the file is not long enough, maybe the file no longer exists. 5454 * @syscap SystemCapability.Web.Webview.Core 5455 * @atomicservice 5456 * @since 11 5457 */ 5458 FILE_TOO_SHORT = 13, 5459 5460 /** 5461 * Hash mismatch. 5462 * @syscap SystemCapability.Web.Webview.Core 5463 * @atomicservice 5464 * @since 11 5465 */ 5466 FILE_HASH_MISMATCH = 14, 5467 5468 /** 5469 * The file already exists. 5470 * @syscap SystemCapability.Web.Webview.Core 5471 * @atomicservice 5472 * @since 11 5473 */ 5474 FILE_SAME_AS_SOURCE = 15, 5475 5476 /** 5477 * Generic network error. 5478 * @syscap SystemCapability.Web.Webview.Core 5479 * @atomicservice 5480 * @since 11 5481 */ 5482 NETWORK_FAILED = 20, 5483 5484 /** 5485 * The network operation timed out. 5486 * @syscap SystemCapability.Web.Webview.Core 5487 * @atomicservice 5488 * @since 11 5489 */ 5490 NETWORK_TIMEOUT = 21, 5491 5492 /** 5493 * The network was disconnected. 5494 * @syscap SystemCapability.Web.Webview.Core 5495 * @atomicservice 5496 * @since 11 5497 */ 5498 NETWORK_DISCONNECTED = 22, 5499 5500 /** 5501 * Server down. 5502 * @syscap SystemCapability.Web.Webview.Core 5503 * @atomicservice 5504 * @since 11 5505 */ 5506 NETWORK_SERVER_DOWN = 23, 5507 5508 /** 5509 * Invalid network requests,may redirect to unsupported scheme or an invalid URL. 5510 * @syscap SystemCapability.Web.Webview.Core 5511 * @atomicservice 5512 * @since 11 5513 */ 5514 NETWORK_INVALID_REQUEST = 24, 5515 5516 /** 5517 * The server returned a generic error. 5518 * @syscap SystemCapability.Web.Webview.Core 5519 * @atomicservice 5520 * @since 11 5521 */ 5522 SERVER_FAILED = 30, 5523 5524 /** 5525 * The server does not support range requests. 5526 * @syscap SystemCapability.Web.Webview.Core 5527 * @atomicservice 5528 * @since 11 5529 */ 5530 SERVER_NO_RANGE = 31, 5531 5532 /** 5533 * The server does not have the requested data. 5534 * @syscap SystemCapability.Web.Webview.Core 5535 * @atomicservice 5536 * @since 11 5537 */ 5538 SERVER_BAD_CONTENT = 33, 5539 5540 /** 5541 * The server does not allow the file to be downloaded. 5542 * @syscap SystemCapability.Web.Webview.Core 5543 * @atomicservice 5544 * @since 11 5545 */ 5546 SERVER_UNAUTHORIZED = 34, 5547 5548 /** 5549 * Server certificate error. 5550 * @syscap SystemCapability.Web.Webview.Core 5551 * @atomicservice 5552 * @since 11 5553 */ 5554 SERVER_CERT_PROBLEM = 35, 5555 5556 /** 5557 * Server access forbidden. 5558 * @syscap SystemCapability.Web.Webview.Core 5559 * @atomicservice 5560 * @since 11 5561 */ 5562 SERVER_FORBIDDEN = 36, 5563 5564 /** 5565 * Server unreachable. 5566 * @syscap SystemCapability.Web.Webview.Core 5567 * @atomicservice 5568 * @since 11 5569 */ 5570 SERVER_UNREACHABLE = 37, 5571 5572 /** 5573 * The received data does not match content-length. 5574 * @syscap SystemCapability.Web.Webview.Core 5575 * @atomicservice 5576 * @since 11 5577 */ 5578 SERVER_CONTENT_LENGTH_MISMATCH = 38, 5579 5580 /** 5581 * An unexpected cross-origin redirect happened. 5582 * @syscap SystemCapability.Web.Webview.Core 5583 * @atomicservice 5584 * @since 11 5585 */ 5586 SERVER_CROSS_ORIGIN_REDIRECT = 39, 5587 5588 /** 5589 * User cancel. 5590 * @syscap SystemCapability.Web.Webview.Core 5591 * @atomicservice 5592 * @since 11 5593 */ 5594 USER_CANCELED = 40, 5595 5596 /** 5597 * User shut down the application. 5598 * @syscap SystemCapability.Web.Webview.Core 5599 * @atomicservice 5600 * @since 11 5601 */ 5602 USER_SHUTDOWN = 41, 5603 5604 /** 5605 * Application crash. 5606 * @syscap SystemCapability.Web.Webview.Core 5607 * @atomicservice 5608 * @since 11 5609 */ 5610 CRASH = 50, 5611 } 5612 5613 /** 5614 * Represents a download task, You can use this object to operate the corresponding download task. 5615 * @syscap SystemCapability.Web.Webview.Core 5616 * @atomicservice 5617 * @since 11 5618 */ 5619 class WebDownloadItem { 5620 /** 5621 * Get guid. 5622 * @returns { string } - Returns the download's guid. 5623 * @syscap SystemCapability.Web.Webview.Core 5624 * @atomicservice 5625 * @since 11 5626 */ 5627 getGuid(): string; 5628 5629 /** 5630 * Get current speed, in bytes per second. 5631 * @returns { number } - Returns the current download speed. 5632 * @syscap SystemCapability.Web.Webview.Core 5633 * @atomicservice 5634 * @since 11 5635 */ 5636 getCurrentSpeed(): number; 5637 5638 /** 5639 * Get percent complete. 5640 * @returns { number } - Returns -1 if progress is unknown. 100 if the download is already complete. 5641 * @syscap SystemCapability.Web.Webview.Core 5642 * @atomicservice 5643 * @since 11 5644 */ 5645 getPercentComplete(): number; 5646 5647 /** 5648 * Get total bytes. 5649 * @returns { number } - Returns the total bytes received, -1 if the total size is unknown. 5650 * @syscap SystemCapability.Web.Webview.Core 5651 * @atomicservice 5652 * @since 11 5653 */ 5654 getTotalBytes(): number; 5655 5656 /** 5657 * Get state of the web download. 5658 * @returns { WebDownloadState } - Returns the current download state. 5659 * @syscap SystemCapability.Web.Webview.Core 5660 * @atomicservice 5661 * @since 11 5662 */ 5663 getState(): WebDownloadState; 5664 5665 /** 5666 * Get last error code of the web download. 5667 * @returns { WebDownloadErrorCode } - Returns the last error code. 5668 * @syscap SystemCapability.Web.Webview.Core 5669 * @atomicservice 5670 * @since 11 5671 */ 5672 getLastErrorCode(): WebDownloadErrorCode; 5673 5674 /** 5675 * Get http method of the web download request. 5676 * @returns { string } - Returns the http request method. 5677 * @syscap SystemCapability.Web.Webview.Core 5678 * @atomicservice 5679 * @since 11 5680 */ 5681 getMethod(): string; 5682 5683 /** 5684 * Get mime type of the web download. 5685 * @returns { string } - Returns the mimetype. 5686 * @syscap SystemCapability.Web.Webview.Core 5687 * @atomicservice 5688 * @since 11 5689 */ 5690 getMimeType(): string; 5691 5692 /** 5693 * Get url of the web download request. 5694 * @returns { string } - Returns the url. 5695 * @syscap SystemCapability.Web.Webview.Core 5696 * @atomicservice 5697 * @since 11 5698 */ 5699 getUrl(): string; 5700 5701 /** 5702 * Get suggested file name of the web download request. 5703 * @returns { string } - Returns the suggested file name. 5704 * @syscap SystemCapability.Web.Webview.Core 5705 * @atomicservice 5706 * @since 11 5707 */ 5708 getSuggestedFileName(): string; 5709 5710 /** 5711 * Start the web download. 5712 * Used in onBeforeDownload, If you want to start the current download, call this function. 5713 * @param { string } downloadPath - The content will be downloaded to this file. 5714 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 5715 * <br>2. Parameter verification failed. 5716 * @syscap SystemCapability.Web.Webview.Core 5717 * @atomicservice 5718 * @since 11 5719 */ 5720 start(downloadPath: string): void; 5721 5722 /** 5723 * Cancel the web download. 5724 * @syscap SystemCapability.Web.Webview.Core 5725 * @atomicservice 5726 * @since 11 5727 */ 5728 cancel(): void; 5729 5730 /** 5731 * Pause the web download. 5732 * @throws { BusinessError } 17100019 - The download task is not started yet. 5733 * @syscap SystemCapability.Web.Webview.Core 5734 * @atomicservice 5735 * @since 11 5736 */ 5737 pause(): void; 5738 5739 /** 5740 * Resume the web download. 5741 * Use WebDownloadManager.resumeDownload to resume deserialized downloads. 5742 * WebDownloadItem.resume is only used to resume the currently paused download. 5743 * @throws { BusinessError } 17100016 - The download task is not paused. 5744 * @syscap SystemCapability.Web.Webview.Core 5745 * @atomicservice 5746 * @since 11 5747 */ 5748 resume(): void; 5749 5750 /** 5751 * Get received bytes. 5752 * @returns { number } - Returns the received bytes. 5753 * @syscap SystemCapability.Web.Webview.Core 5754 * @atomicservice 5755 * @since 11 5756 */ 5757 getReceivedBytes(): number; 5758 5759 /** 5760 * Get full path of the web download. 5761 * @returns { string } - Returns the full path of the download. 5762 * @syscap SystemCapability.Web.Webview.Core 5763 * @atomicservice 5764 * @since 11 5765 */ 5766 getFullPath(): string; 5767 5768 /** 5769 * Serialize web download to typed array. 5770 * @returns { Uint8Array } - Returns the serialized data. 5771 * @syscap SystemCapability.Web.Webview.Core 5772 * @atomicservice 5773 * @since 11 5774 */ 5775 serialize(): Uint8Array; 5776 5777 /** 5778 * Deserialize web download from typed array. 5779 * @param { Uint8Array } serializedData - The serialized data. 5780 * @returns { WebDownloadItem } - Deserialize the serialized data into a WebDownloadItem. 5781 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 5782 * <br>2. Parameter verification failed. 5783 * @syscap SystemCapability.Web.Webview.Core 5784 * @atomicservice 5785 * @since 11 5786 */ 5787 static deserialize(serializedData: Uint8Array): WebDownloadItem; 5788 } 5789 5790 /** 5791 * The download state is notified through this delegate. 5792 * @syscap SystemCapability.Web.Webview.Core 5793 * @atomicservice 5794 * @since 11 5795 */ 5796 class WebDownloadDelegate { 5797 /** 5798 * Callback will be triggered before web download start. 5799 * @param { Callback<WebDownloadItem> } callback - The callback of download will be start. 5800 * @syscap SystemCapability.Web.Webview.Core 5801 * @atomicservice 5802 * @since 11 5803 */ 5804 onBeforeDownload(callback: Callback<WebDownloadItem>): void; 5805 5806 /** 5807 * Callback will be triggered when web download is processing. 5808 * @param { Callback<WebDownloadItem> } callback - The callback of download did update. 5809 * @syscap SystemCapability.Web.Webview.Core 5810 * @atomicservice 5811 * @since 11 5812 */ 5813 onDownloadUpdated(callback: Callback<WebDownloadItem>): void; 5814 5815 /** 5816 * Callback will be triggered when web download is completed. 5817 * @param { Callback<WebDownloadItem> } callback - The callback of download did finish. 5818 * @syscap SystemCapability.Web.Webview.Core 5819 * @atomicservice 5820 * @since 11 5821 */ 5822 onDownloadFinish(callback: Callback<WebDownloadItem>): void; 5823 5824 /** 5825 * Callback will be triggered when web download is interrupted or canceled. 5826 * @param { Callback<WebDownloadItem> } callback - The callback of download did fail. 5827 * @syscap SystemCapability.Web.Webview.Core 5828 * @atomicservice 5829 * @since 11 5830 */ 5831 onDownloadFailed(callback: Callback<WebDownloadItem>): void; 5832 } 5833 5834 /** 5835 * You can trigger download manually through this interface, or resume failed or canceled downloads. 5836 * @syscap SystemCapability.Web.Webview.Core 5837 * @atomicservice 5838 * @since 11 5839 */ 5840 class WebDownloadManager { 5841 /** 5842 * Set a delegate used to receive the progress of the download triggered from WebDownloadManager. 5843 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from WebDownloadManager. 5844 * @syscap SystemCapability.Web.Webview.Core 5845 * @atomicservice 5846 * @since 11 5847 */ 5848 static setDownloadDelegate(delegate: WebDownloadDelegate): void; 5849 5850 /** 5851 * Resume the canceled or failed download. 5852 * @param { WebDownloadItem } webDownloadItem - Download that need to be resume. 5853 * @throws { BusinessError } 17100018 - No WebDownloadDelegate has been set yet. 5854 * @syscap SystemCapability.Web.Webview.Core 5855 * @atomicservice 5856 * @since 11 5857 */ 5858 static resumeDownload(webDownloadItem: WebDownloadItem): void; 5859 } 5860 5861 /** 5862 * The http body stream of the request. 5863 * 5864 * @syscap SystemCapability.Web.Webview.Core 5865 * @atomicservice 5866 * @since 12 5867 */ 5868 class WebHttpBodyStream { 5869 /** 5870 * Initialize data stream. 5871 * 5872 * @returns { Promise<void> } The promise of data stream is initialized. 5873 * @throws { BusinessError } 17100022 - Failed to initialize the HTTP body stream. 5874 * @syscap SystemCapability.Web.Webview.Core 5875 * @atomicservice 5876 * @since 12 5877 */ 5878 initialize(): Promise<void>; 5879 /** 5880 * Read the data stream to the buffer. 5881 * 5882 * @param { number } size - Read size. 5883 * @returns { Promise<ArrayBuffer> } Read array buffer of result. 5884 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 5885 * <br>2. Incorrect parameter types. 3.Parameter verification failed. 5886 * @syscap SystemCapability.Web.Webview.Core 5887 * @atomicservice 5888 * @since 12 5889 */ 5890 read(size: number): Promise<ArrayBuffer>; 5891 /** 5892 * Get the total size of the data stream. When data is chunked, always return zero. 5893 * 5894 * @returns { number } Return size of data stream size. 5895 * @syscap SystemCapability.Web.Webview.Core 5896 * @atomicservice 5897 * @since 12 5898 */ 5899 getSize(): number; 5900 /** 5901 * Get the current position of the data stream. 5902 * 5903 * @returns { number } Return position in post data stream. 5904 * @syscap SystemCapability.Web.Webview.Core 5905 * @atomicservice 5906 * @since 12 5907 */ 5908 getPosition(): number; 5909 /** 5910 * Whether data stream is chunked. 5911 * 5912 * @returns { boolean } Whether data stream is chunked. 5913 * @syscap SystemCapability.Web.Webview.Core 5914 * @atomicservice 5915 * @since 12 5916 */ 5917 isChunked(): boolean; 5918 /** 5919 * Whether all data stream has been consumed. For chunked uploads, 5920 * returns false until the first read attempt. 5921 * 5922 * @returns { boolean } Whether data stream has been consumed. 5923 * @syscap SystemCapability.Web.Webview.Core 5924 * @atomicservice 5925 * @since 12 5926 */ 5927 isEof(): boolean; 5928 /** 5929 * Returns true if the upload data in the stream is entirely in memory, and all read requests will succeed 5930 * synchronously. Expected to return false for chunked requests. 5931 * 5932 * @returns { boolean } Whether the data stream is in memory. 5933 * @syscap SystemCapability.Web.Webview.Core 5934 * @atomicservice 5935 * @since 12 5936 */ 5937 isInMemory(): boolean; 5938 } 5939 5940 /** 5941 * Defines the resource type of request. 5942 * @enum {number} 5943 * @syscap SystemCapability.Web.Webview.Core 5944 * @since 12 5945 */ 5946 enum WebResourceType { 5947 /** 5948 * Top level page. 5949 * 5950 * @syscap SystemCapability.Web.Webview.Core 5951 * @since 12 5952 */ 5953 MAIN_FRAME = 0, 5954 5955 /** 5956 * Frame or Iframe. 5957 * 5958 * @syscap SystemCapability.Web.Webview.Core 5959 * @since 12 5960 */ 5961 SUB_FRAME = 1, 5962 5963 /** 5964 * CSS stylesheet. 5965 * 5966 * @syscap SystemCapability.Web.Webview.Core 5967 * @since 12 5968 */ 5969 STYLE_SHEET = 2, 5970 5971 /** 5972 * External script. 5973 * 5974 * @syscap SystemCapability.Web.Webview.Core 5975 * @since 12 5976 */ 5977 SCRIPT = 3, 5978 5979 /** 5980 * Image (jpg/gif/png/etc). 5981 * 5982 * @syscap SystemCapability.Web.Webview.Core 5983 * @since 12 5984 */ 5985 IMAGE = 4, 5986 5987 /** 5988 * Font. 5989 * 5990 * @syscap SystemCapability.Web.Webview.Core 5991 * @since 12 5992 */ 5993 FONT_RESOURCE = 5, 5994 5995 /** 5996 * Some other subresource. This is the default type if the actual type is unknown. 5997 * 5998 * @syscap SystemCapability.Web.Webview.Core 5999 * @since 12 6000 */ 6001 SUB_RESOURCE = 6, 6002 6003 /** 6004 * Object (or embed) tag for a plugin, or a resource that a plugin requested. 6005 * 6006 * @syscap SystemCapability.Web.Webview.Core 6007 * @since 12 6008 */ 6009 OBJECT = 7, 6010 6011 /** 6012 * Media resource. 6013 * 6014 * @syscap SystemCapability.Web.Webview.Core 6015 * @since 12 6016 */ 6017 MEDIA = 8, 6018 6019 /** 6020 * Main resource of a dedicated worker. 6021 * 6022 * @syscap SystemCapability.Web.Webview.Core 6023 * @since 12 6024 */ 6025 WORKER = 9, 6026 6027 /** 6028 * Main resource of a shared worker. 6029 * 6030 * @syscap SystemCapability.Web.Webview.Core 6031 * @since 12 6032 */ 6033 SHARED_WORKER = 10, 6034 6035 /** 6036 * Explicitly requested prefetch. 6037 * 6038 * @syscap SystemCapability.Web.Webview.Core 6039 * @since 12 6040 */ 6041 PREFETCH = 11, 6042 6043 /** 6044 * Favicon. 6045 * 6046 * @syscap SystemCapability.Web.Webview.Core 6047 * @since 12 6048 */ 6049 FAVICON = 12, 6050 6051 /** 6052 * XMLHttpRequest. 6053 * 6054 * @syscap SystemCapability.Web.Webview.Core 6055 * @since 12 6056 */ 6057 XHR = 13, 6058 6059 /** 6060 * Ping request for <a ping>/sendBeacon. 6061 * 6062 * @syscap SystemCapability.Web.Webview.Core 6063 * @since 12 6064 */ 6065 PING = 14, 6066 6067 /** 6068 * The main resource of a service worker. 6069 * 6070 * @syscap SystemCapability.Web.Webview.Core 6071 * @since 12 6072 */ 6073 SERVICE_WORKER = 15, 6074 6075 /** 6076 * Report of Content Security Policy violations. 6077 * 6078 * @syscap SystemCapability.Web.Webview.Core 6079 * @since 12 6080 */ 6081 CSP_REPORT = 16, 6082 6083 /** 6084 * Resource that a plugin requested. 6085 * 6086 * @syscap SystemCapability.Web.Webview.Core 6087 * @since 12 6088 */ 6089 PLUGIN_RESOURCE = 17, 6090 6091 /** 6092 * A main-frame service worker navigation preload request. 6093 * 6094 * @syscap SystemCapability.Web.Webview.Core 6095 * @since 12 6096 */ 6097 NAVIGATION_PRELOAD_MAIN_FRAME = 19, 6098 6099 /** 6100 * A sub-frame service worker navigation preload request. 6101 * 6102 * @syscap SystemCapability.Web.Webview.Core 6103 * @since 12 6104 */ 6105 NAVIGATION_PRELOAD_SUB_FRAME = 20, 6106 } 6107 6108 /** 6109 * Defines the Web resource request used for scheme handler. 6110 * 6111 * @syscap SystemCapability.Web.Webview.Core 6112 * @atomicservice 6113 * @since 12 6114 */ 6115 class WebSchemeHandlerRequest { 6116 /** 6117 * Gets request headers. 6118 * 6119 * @returns { Array<WebHeader> } Return the request headers. 6120 * @syscap SystemCapability.Web.Webview.Core 6121 * @atomicservice 6122 * @since 12 6123 */ 6124 getHeader(): Array<WebHeader>; 6125 /** 6126 * Gets the request URL. 6127 * 6128 * @returns { string } Return the request URL. 6129 * @syscap SystemCapability.Web.Webview.Core 6130 * @atomicservice 6131 * @since 12 6132 */ 6133 getRequestUrl(): string; 6134 /** 6135 * Get request method. 6136 * 6137 * @returns { string } Return the request method. 6138 * @syscap SystemCapability.Web.Webview.Core 6139 * @atomicservice 6140 * @since 12 6141 */ 6142 getRequestMethod(): string; 6143 /** 6144 * Get referrer of request. 6145 * 6146 * @returns { string } Return referrer of request. 6147 * @syscap SystemCapability.Web.Webview.Core 6148 * @atomicservice 6149 * @since 12 6150 */ 6151 getReferrer(): string; 6152 /** 6153 * Check whether the request is for getting the main frame. 6154 * 6155 * @returns { boolean } Whether request is main frame. 6156 * @syscap SystemCapability.Web.Webview.Core 6157 * @atomicservice 6158 * @since 12 6159 */ 6160 isMainFrame(): boolean; 6161 /** 6162 * Check whether the request is associated with gesture. 6163 * 6164 * @returns { boolean } Whether request has user gesture. 6165 * @syscap SystemCapability.Web.Webview.Core 6166 * @atomicservice 6167 * @since 12 6168 */ 6169 hasGesture(): boolean; 6170 /** 6171 * Get http body stream. 6172 * 6173 * @returns { WebHttpBodyStream | null } Return http body stream. If request has no http body stream, return null. 6174 * @syscap SystemCapability.Web.Webview.Core 6175 * @atomicservice 6176 * @since 12 6177 */ 6178 getHttpBodyStream(): WebHttpBodyStream | null; 6179 /** 6180 * Get request's resource type. 6181 * 6182 * @returns { WebResourceType } Return the request's resource type. 6183 * @syscap SystemCapability.Web.Webview.Core 6184 * @since 12 6185 */ 6186 getRequestResourceType(): WebResourceType; 6187 /** 6188 * Gets the URL of frame which trigger this request. 6189 * 6190 * @returns { string } Return the URL of frame which trigger this request. 6191 * @syscap SystemCapability.Web.Webview.Core 6192 * @since 12 6193 */ 6194 getFrameUrl(): string; 6195 } 6196 6197 /** 6198 * Defines the Web resource response used for scheme handler. 6199 * 6200 * @syscap SystemCapability.Web.Webview.Core 6201 * @atomicservice 6202 * @since 12 6203 */ 6204 class WebSchemeHandlerResponse { 6205 /** 6206 * Constructor. 6207 * 6208 * @syscap SystemCapability.Web.Webview.Core 6209 * @atomicservice 6210 * @since 12 6211 */ 6212 constructor(); 6213 /** 6214 * Set the resolved URL after redirects or changed as a result of HSTS. 6215 * 6216 * @param { string } url - Set response url for redirects. 6217 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6218 * @syscap SystemCapability.Web.Webview.Core 6219 * @atomicservice 6220 * @since 12 6221 */ 6222 setUrl(url: string): void; 6223 /** 6224 * Get the resolved URL after redirects or changed as a result of HSTS. 6225 * 6226 * @returns { string } Return response url for redirects. 6227 * @syscap SystemCapability.Web.Webview.Core 6228 * @atomicservice 6229 * @since 12 6230 */ 6231 getUrl(): string; 6232 /** 6233 * Set net error code. 6234 * @param { WebNetErrorList } code - Set net error code. 6235 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6236 * <br>2. Incorrect parameter types. 6237 * @syscap SystemCapability.Web.Webview.Core 6238 * @atomicservice 6239 * @since 12 6240 */ 6241 setNetErrorCode(code: WebNetErrorList): void; 6242 /** 6243 * Get net error code. 6244 * 6245 * @returns { WebNetErrorList } Return response error code. 6246 * @syscap SystemCapability.Web.Webview.Core 6247 * @atomicservice 6248 * @since 12 6249 */ 6250 getNetErrorCode(): WebNetErrorList; 6251 /** 6252 * Set http status code. 6253 * 6254 * @param { number } code - Http status code. 6255 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6256 * @syscap SystemCapability.Web.Webview.Core 6257 * @atomicservice 6258 * @since 12 6259 */ 6260 setStatus(code: number): void; 6261 /** 6262 * Get http status code. 6263 * 6264 * @returns { number } Return http status code. 6265 * @syscap SystemCapability.Web.Webview.Core 6266 * @atomicservice 6267 * @since 12 6268 */ 6269 getStatus(): number; 6270 /** 6271 * Set status text. 6272 * 6273 * @param { string } text - Status text. 6274 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6275 * @syscap SystemCapability.Web.Webview.Core 6276 * @atomicservice 6277 * @since 12 6278 */ 6279 setStatusText(text: string): void; 6280 /** 6281 * Get status text. 6282 * 6283 * @returns { string } Return http status text. 6284 * @syscap SystemCapability.Web.Webview.Core 6285 * @atomicservice 6286 * @since 12 6287 */ 6288 getStatusText(): string; 6289 /** 6290 * Set mime type. 6291 * 6292 * @param { string } type - Mime type. 6293 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6294 * @syscap SystemCapability.Web.Webview.Core 6295 * @atomicservice 6296 * @since 12 6297 */ 6298 setMimeType(type: string): void; 6299 /** 6300 * Get mime type. 6301 * 6302 * @returns { string } Return mime type of response. 6303 * @syscap SystemCapability.Web.Webview.Core 6304 * @atomicservice 6305 * @since 12 6306 */ 6307 getMimeType(): string; 6308 /** 6309 * Set the response encoding. 6310 * 6311 * @param { string } encoding - Encoding. 6312 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6313 * @syscap SystemCapability.Web.Webview.Core 6314 * @atomicservice 6315 * @since 12 6316 */ 6317 setEncoding(encoding: string): void; 6318 /** 6319 * Get the response encoding. 6320 * 6321 * @returns { string } Return encoding of response. 6322 * @syscap SystemCapability.Web.Webview.Core 6323 * @atomicservice 6324 * @since 12 6325 */ 6326 getEncoding(): string; 6327 /** 6328 * Set response hander value by name. 6329 * 6330 * @param { string } name - Header name. 6331 * @param { string } value - Header value. 6332 * @param { boolean } overwrite - Whether to overwrite. 6333 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6334 * <br>2. Incorrect parameter types. 6335 * @syscap SystemCapability.Web.Webview.Core 6336 * @atomicservice 6337 * @since 12 6338 */ 6339 setHeaderByName(name: string, value: string, overwrite: boolean): void; 6340 /** 6341 * Get the header value by name from the response. 6342 * 6343 * @param { string } name - Header name. 6344 * @returns { string } Return header value by name. 6345 * @syscap SystemCapability.Web.Webview.Core 6346 * @atomicservice 6347 * @since 12 6348 */ 6349 getHeaderByName(name: string): string 6350 } 6351 6352 /** 6353 * Used to intercept url requests. Response headers and body can be sent through 6354 * WebResourceHandler. 6355 * 6356 * @syscap SystemCapability.Web.Webview.Core 6357 * @atomicservice 6358 * @since 12 6359 */ 6360 class WebResourceHandler { 6361 /** 6362 * Pass response headers to intercepted requests. 6363 * 6364 * @param { WebSchemeHandlerResponse } response - Set response header to intercept. 6365 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6366 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6367 * @syscap SystemCapability.Web.Webview.Core 6368 * @atomicservice 6369 * @since 12 6370 */ 6371 didReceiveResponse(response: WebSchemeHandlerResponse): void; 6372 /** 6373 * Pass response body data to intercepted requests. 6374 * 6375 * @param { ArrayBuffer } data - Set response body to intercept. 6376 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6377 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6378 * @syscap SystemCapability.Web.Webview.Core 6379 * @atomicservice 6380 * @since 12 6381 */ 6382 didReceiveResponseBody(data: ArrayBuffer): void; 6383 /** 6384 * Notify that this request should be finished and there is no more data available. 6385 * 6386 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6387 * @syscap SystemCapability.Web.Webview.Core 6388 * @atomicservice 6389 * @since 12 6390 */ 6391 didFinish(): void; 6392 /** 6393 * Notify that this request should be failed. 6394 * 6395 * @param { WebNetErrorList } code - Set response error code to intercept. 6396 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Incorrect parameter types. 6397 * @throws { BusinessError } 17100021 - The resource handler is invalid. 6398 * @syscap SystemCapability.Web.Webview.Core 6399 * @atomicservice 6400 * @since 12 6401 */ 6402 didFail(code: WebNetErrorList): void; 6403 } 6404 6405 /** 6406 * This class is used to intercept requests for a specified scheme. 6407 * 6408 * @syscap SystemCapability.Web.Webview.Core 6409 * @atomicservice 6410 * @since 12 6411 */ 6412 class WebSchemeHandler { 6413 /** 6414 * Callback for handling the request. 6415 * 6416 * @param { function } callback - Callback of handling the request. If callback return false, 6417 * it means no interception. 6418 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 6419 * <br>2. Incorrect parameter types. 6420 * @syscap SystemCapability.Web.Webview.Core 6421 * @atomicservice 6422 * @since 12 6423 */ 6424 onRequestStart( 6425 callback: (request: WebSchemeHandlerRequest, handler: WebResourceHandler) => boolean): void; 6426 6427 /** 6428 * Callback when the request is completed. 6429 * 6430 * @param { Callback<WebSchemeHandlerRequest> } callback - Callback of request is completed. 6431 * @throws { BusinessError } 401 - Invalid input parameter. 6432 * @syscap SystemCapability.Web.Webview.Core 6433 * @atomicservice 6434 * @since 12 6435 */ 6436 onRequestStop(callback: Callback<WebSchemeHandlerRequest>): void; 6437 } 6438 6439 /** 6440 * Enum type supplied to {@link handleStatusChanged} for indicating the playback status. 6441 * @enum {number} 6442 * @syscap SystemCapability.Web.Webview.Core 6443 * @atomicservice 6444 * @since 12 6445 */ 6446 enum PlaybackStatus { 6447 /** 6448 * Player status is paused. 6449 * @syscap SystemCapability.Web.Webview.Core 6450 * @atomicservice 6451 * @since 12 6452 */ 6453 PAUSED = 0, 6454 /** 6455 * Player status is playing. 6456 * @syscap SystemCapability.Web.Webview.Core 6457 * @atomicservice 6458 * @since 12 6459 */ 6460 PLAYING, 6461 } 6462 6463 /** 6464 * Enum type supplied to {@link handleNetworkStateChanged} for indicating the native player network state. 6465 * @enum {number} 6466 * @syscap SystemCapability.Web.Webview.Core 6467 * @atomicservice 6468 * @since 12 6469 */ 6470 enum NetworkState { 6471 /** 6472 * Player does not do any download tasks. 6473 * @syscap SystemCapability.Web.Webview.Core 6474 * @atomicservice 6475 * @since 12 6476 */ 6477 EMPTY = 0, 6478 /** 6479 * Player downloads finished, waiting for next task. 6480 * @syscap SystemCapability.Web.Webview.Core 6481 * @atomicservice 6482 * @since 12 6483 */ 6484 IDLE, 6485 /** 6486 * Player is downloading contents. 6487 * @syscap SystemCapability.Web.Webview.Core 6488 * @atomicservice 6489 * @since 12 6490 */ 6491 LOADING, 6492 /** 6493 * Player downloads failed, due to network error. 6494 * @syscap SystemCapability.Web.Webview.Core 6495 * @atomicservice 6496 * @since 12 6497 */ 6498 NETWORK_ERROR 6499 } 6500 6501 /** 6502 * Enum type supplied to {@link handleReadyStateChanged} for indicating the native player network state. 6503 * @enum {number} 6504 * @syscap SystemCapability.Web.Webview.Core 6505 * @atomicservice 6506 * @since 12 6507 */ 6508 enum ReadyState { 6509 /** 6510 * Player hasn't downloaded anything. 6511 * @syscap SystemCapability.Web.Webview.Core 6512 * @atomicservice 6513 * @since 12 6514 */ 6515 HAVE_NOTHING = 0, 6516 /** 6517 * Player has downloaded metadata. 6518 * @syscap SystemCapability.Web.Webview.Core 6519 * @atomicservice 6520 * @since 12 6521 */ 6522 HAVE_METADATA, 6523 /** 6524 * Player has played all downloaded media data. 6525 * @syscap SystemCapability.Web.Webview.Core 6526 * @atomicservice 6527 * @since 12 6528 */ 6529 HAVE_CURRENT_DATA, 6530 /** 6531 * The buffered media data is not enough, and will cause jank. 6532 * @syscap SystemCapability.Web.Webview.Core 6533 * @atomicservice 6534 * @since 12 6535 */ 6536 HAVE_FUTURE_DATA, 6537 /** 6538 * The buffered media data is enough. 6539 * @syscap SystemCapability.Web.Webview.Core 6540 * @atomicservice 6541 * @since 12 6542 */ 6543 HAVE_ENOUGH_DATA, 6544 } 6545 6546 /** 6547 * Enum type supplied to {@link handleError} for indicating the error type of native media player. 6548 * @enum {number} 6549 * @syscap SystemCapability.Web.Webview.Core 6550 * @atomicservice 6551 * @since 12 6552 */ 6553 enum MediaError { 6554 /** 6555 * Network error 6556 * @syscap SystemCapability.Web.Webview.Core 6557 * @atomicservice 6558 * @since 12 6559 */ 6560 NETWORK_ERROR = 1, 6561 /** 6562 * Media format error, such as not a valid file. 6563 * @syscap SystemCapability.Web.Webview.Core 6564 * @atomicservice 6565 * @since 12 6566 */ 6567 FORMAT_ERROR, 6568 /** 6569 * Decode error, such as decoder doesn't support this format. 6570 * @syscap SystemCapability.Web.Webview.Core 6571 * @atomicservice 6572 * @since 12 6573 */ 6574 DECODE_ERROR 6575 } 6576 6577 /** 6578 * The native media player status handler. 6579 * Apps should use this class to handle native media player's status. 6580 * 6581 * @typedef NativeMediaPlayerHandler 6582 * @syscap SystemCapability.Web.Webview.Core 6583 * @atomicservice 6584 * @since 12 6585 */ 6586 interface NativeMediaPlayerHandler { 6587 6588 /** 6589 * Handle native media player playback status. 6590 * 6591 * @param { PlaybackStatus } status - Playback status of native media player. 6592 * @syscap SystemCapability.Web.Webview.Core 6593 * @atomicservice 6594 * @since 12 6595 */ 6596 handleStatusChanged(status: PlaybackStatus): void 6597 6598 /** 6599 * Handle native media player volume. 6600 * volume: float 6601 * value range: [0 - 1.0] 6602 * 6603 * @param { number } volume - Current volume of native media player. 6604 * @syscap SystemCapability.Web.Webview.Core 6605 * @atomicservice 6606 * @since 12 6607 */ 6608 handleVolumeChanged(volume: number): void 6609 6610 /** 6611 * Handle native media player muted status. 6612 * 6613 * @param { boolean } muted - Current mute status of native media player. 6614 * @syscap SystemCapability.Web.Webview.Core 6615 * @atomicservice 6616 * @since 12 6617 */ 6618 handleMutedChanged(muted: boolean): void 6619 6620 /** 6621 * Handle playback rate of native media player. 6622 * playbackRate: float 6623 * value range: [0 - infinity] 6624 * 6625 * @param { number } playbackRate - Current playback rate of native media player. 6626 * @syscap SystemCapability.Web.Webview.Core 6627 * @atomicservice 6628 * @since 12 6629 */ 6630 handlePlaybackRateChanged(playbackRate: number): void 6631 6632 /** 6633 * Handle duration time of media. 6634 * duration: float 6635 * value range: [0 - infinity] 6636 * 6637 * @param { number } duration - Duration time (in seconds) of media. 6638 * @syscap SystemCapability.Web.Webview.Core 6639 * @atomicservice 6640 * @since 12 6641 */ 6642 handleDurationChanged(duration: number): void 6643 6644 /** 6645 * Handle current playing time of media. 6646 * currentPlayTime: float 6647 * value range: [0 - duration] 6648 * 6649 * @param { number } currentPlayTime - Current playing time (in seconds) of media. 6650 * @syscap SystemCapability.Web.Webview.Core 6651 * @atomicservice 6652 * @since 12 6653 */ 6654 handleTimeUpdate(currentPlayTime: number): void 6655 6656 /** 6657 * Handle buffered end time of media. 6658 * bufferedEndTime: float 6659 * value range: [0 - duration] 6660 * 6661 * @param { number } bufferedEndTime - Buffered end time (in seconds) of media. 6662 * @syscap SystemCapability.Web.Webview.Core 6663 * @atomicservice 6664 * @since 12 6665 */ 6666 handleBufferedEndTimeChanged(bufferedEndTime: number): void 6667 6668 /** 6669 * Handle native player ended event. 6670 * 6671 * @syscap SystemCapability.Web.Webview.Core 6672 * @atomicservice 6673 * @since 12 6674 */ 6675 handleEnded(): void 6676 6677 /** 6678 * Handle network state of native media player. 6679 * 6680 * @param { NetworkState } state - Network state of native media player. 6681 * @syscap SystemCapability.Web.Webview.Core 6682 * @atomicservice 6683 * @since 12 6684 */ 6685 handleNetworkStateChanged(state: NetworkState): void 6686 6687 /** 6688 * Handle ready state of native media player. 6689 * 6690 * @param { ReadyState } state - Ready state of native media player. 6691 * @syscap SystemCapability.Web.Webview.Core 6692 * @atomicservice 6693 * @since 12 6694 */ 6695 handleReadyStateChanged(state: ReadyState): void 6696 6697 /** 6698 * Handle native media player fullscreen state changed event. 6699 * 6700 * @param { boolean } fullscreen - Fullscreen state of native media player. 6701 * @syscap SystemCapability.Web.Webview.Core 6702 * @atomicservice 6703 * @since 12 6704 */ 6705 handleFullscreenChanged(fullscreen: boolean): void 6706 6707 /** 6708 * Handle native media player seeking state. 6709 * 6710 * @syscap SystemCapability.Web.Webview.Core 6711 * @atomicservice 6712 * @since 12 6713 */ 6714 handleSeeking(): void 6715 6716 /** 6717 * Handle native media player seek finished state. 6718 * 6719 * @syscap SystemCapability.Web.Webview.Core 6720 * @atomicservice 6721 * @since 12 6722 */ 6723 handleSeekFinished(): void 6724 6725 /** 6726 * Handle native media player error event. 6727 * 6728 * @param { MediaError } error - Error type of native media player. 6729 * @param { string } errorMessage - Description of current error. 6730 * @syscap SystemCapability.Web.Webview.Core 6731 * @atomicservice 6732 * @since 12 6733 */ 6734 handleError(error: MediaError, errorMessage: string): void 6735 6736 /** 6737 * Handle size of video. 6738 * 6739 * @param { number } width - Width of video. 6740 * @param { number } height - Height of video. 6741 * @syscap SystemCapability.Web.Webview.Core 6742 * @atomicservice 6743 * @since 12 6744 */ 6745 handleVideoSizeChanged(width: number, height: number): void 6746 } 6747 6748 /** 6749 * The scenarios for suspending the media player. 6750 * @enum {number} 6751 * @syscap SystemCapability.Web.Webview.Core 6752 * @since 12 6753 */ 6754 enum SuspendType { 6755 /** 6756 * Page enters the BackForwardCache. 6757 * @syscap SystemCapability.Web.Webview.Core 6758 * @since 12 6759 */ 6760 ENTER_BACK_FORWARD_CACHE = 0, 6761 6762 /** 6763 * Page enters background. 6764 * @syscap SystemCapability.Web.Webview.Core 6765 * @since 12 6766 */ 6767 ENTER_BACKGROUND, 6768 6769 /** 6770 * Cleanup when the number of paused media player over limit. 6771 * @syscap SystemCapability.Web.Webview.Core 6772 * @since 12 6773 */ 6774 AUTO_CLEANUP 6775 } 6776 6777 /** 6778 * The bridge between web core and native media player. 6779 * Apps should implements this interface, and pass an instance to web core. 6780 * Then web core can control native media player by this bridge. 6781 * 6782 * @typedef NativeMediaPlayerBridge 6783 * @syscap SystemCapability.Web.Webview.Core 6784 * @atomicservice 6785 * @since 12 6786 */ 6787 interface NativeMediaPlayerBridge { 6788 /** 6789 * Notify native media player that the rect of video tag has changed. 6790 * 6791 * @param { number } x - The x position of video tag in web component. 6792 * @param { number } y - The y position of video tag in web component. 6793 * @param { number } width - The width of video tag. 6794 * @param { number } height - The height of video tag. 6795 * @syscap SystemCapability.Web.Webview.Core 6796 * @atomicservice 6797 * @since 12 6798 */ 6799 updateRect(x: number, y: number, width: number, height: number): void 6800 6801 /** 6802 * Request to play. 6803 * 6804 * @syscap SystemCapability.Web.Webview.Core 6805 * @atomicservice 6806 * @since 12 6807 */ 6808 play(): void 6809 6810 /** 6811 * Request to pause. 6812 * 6813 * @syscap SystemCapability.Web.Webview.Core 6814 * @atomicservice 6815 * @since 12 6816 */ 6817 pause(): void 6818 6819 /** 6820 * Request to fast forward / back forward to targetTime. 6821 * targetTime: float 6822 * value range: [0 - duration] 6823 * 6824 * @param { number } targetTime - The target time (in seconds) to FF/BF to. 6825 * @syscap SystemCapability.Web.Webview.Core 6826 * @atomicservice 6827 * @since 12 6828 */ 6829 seek(targetTime: number): void 6830 6831 /** 6832 * Request to change volume of native media player. 6833 * volume: float 6834 * value range: [0 - 1.0] 6835 * 6836 * @param { number } volume - The volume of native media player. 6837 * @syscap SystemCapability.Web.Webview.Core 6838 * @atomicservice 6839 * @since 12 6840 */ 6841 setVolume(volume: number): void 6842 6843 /** 6844 * Request to mute native media player. 6845 * 6846 * @param { boolean } muted - Should mute native media player. 6847 * @syscap SystemCapability.Web.Webview.Core 6848 * @atomicservice 6849 * @since 12 6850 */ 6851 setMuted(muted: boolean): void 6852 6853 /** 6854 * Request to change playback rate of native media player. 6855 * playbackRate: float 6856 * value range: [0 - 10.0] 6857 * 6858 * @param { number } playbackRate - The playback rate of native media player. 6859 * @syscap SystemCapability.Web.Webview.Core 6860 * @atomicservice 6861 * @since 12 6862 */ 6863 setPlaybackRate(playbackRate: number): void 6864 6865 /** 6866 * Request to release native media player. 6867 * 6868 * @syscap SystemCapability.Web.Webview.Core 6869 * @atomicservice 6870 * @since 12 6871 */ 6872 release(): void 6873 6874 /** 6875 * Request to enter fullscreen. 6876 * 6877 * @syscap SystemCapability.Web.Webview.Core 6878 * @atomicservice 6879 * @since 12 6880 */ 6881 enterFullscreen(): void 6882 6883 /** 6884 * Request to exit fullscreen. 6885 * 6886 * @syscap SystemCapability.Web.Webview.Core 6887 * @atomicservice 6888 * @since 12 6889 */ 6890 exitFullscreen(): void 6891 6892 /** 6893 * Resume the native media player. 6894 * 6895 * @syscap SystemCapability.Web.Webview.Core 6896 * @since 12 6897 */ 6898 resumePlayer?(): void 6899 6900 /** 6901 * Suspend to release native media player, not the NativeMediaPlayerBridge. The 6902 * embedder should save the status of player when release the native media player 6903 * through NativeMediaPlayerBridge. 6904 * 6905 * @param { SuspendType } type - The scenario for suspending the media player. 6906 * @syscap SystemCapability.Web.Webview.Core 6907 * @since 12 6908 */ 6909 suspendPlayer?(type: SuspendType): void 6910 } 6911 6912 /** 6913 * Enum type for indicating the media type of native media player. 6914 * @enum {number} 6915 * @syscap SystemCapability.Web.Webview.Core 6916 * @atomicservice 6917 * @since 12 6918 */ 6919 enum MediaType { 6920 /** 6921 * Media type is video. 6922 * @syscap SystemCapability.Web.Webview.Core 6923 * @atomicservice 6924 * @since 12 6925 */ 6926 VIDEO = 0, 6927 /** 6928 * Media type is audio. 6929 * @syscap SystemCapability.Web.Webview.Core 6930 * @atomicservice 6931 * @since 12 6932 */ 6933 AUDIO 6934 } 6935 6936 /** 6937 * Enum type for indicating the media source type of native media player. 6938 * @enum {number} 6939 * @syscap SystemCapability.Web.Webview.Core 6940 * @atomicservice 6941 * @since 12 6942 */ 6943 enum SourceType { 6944 /** 6945 * Source type is URL. 6946 * @syscap SystemCapability.Web.Webview.Core 6947 * @atomicservice 6948 * @since 12 6949 */ 6950 URL = 0, 6951 /** 6952 * Source type is blob. 6953 * @syscap SystemCapability.Web.Webview.Core 6954 * @atomicservice 6955 * @since 12 6956 */ 6957 MSE 6958 } 6959 6960 /** 6961 * Media source information. Uri and format. 6962 * 6963 * @syscap SystemCapability.Web.Webview.Core 6964 * @atomicservice 6965 * @since 12 6966 */ 6967 class MediaSourceInfo { 6968 /** 6969 * Source type, most time is URL. 6970 * @type { SourceType } 6971 * @syscap SystemCapability.Web.Webview.Core 6972 * @since 12 6973 */ 6974 type: SourceType; 6975 6976 /** 6977 * Media source, most time is Uri. 6978 * @type { string } 6979 * @syscap SystemCapability.Web.Webview.Core 6980 * @atomicservice 6981 * @since 12 6982 */ 6983 source: string; 6984 6985 /** 6986 * Media format, such as mp4, webm, m3u8 etc. 6987 * @type { string } 6988 * @syscap SystemCapability.Web.Webview.Core 6989 * @atomicservice 6990 * @since 12 6991 */ 6992 format: string; 6993 } 6994 6995 /** 6996 * Rectangle definition. 6997 * 6998 * @typedef RectEvent 6999 * @syscap SystemCapability.Web.Webview.Core 7000 * @since 12 7001 */ 7002 interface RectEvent { 7003 /** 7004 * X coordinator of top left point. 7005 * 7006 * @type { number } 7007 * @syscap SystemCapability.Web.Webview.Core 7008 * @since 12 7009 */ 7010 x: number; 7011 /** 7012 * Y coordinator of top left point. 7013 * 7014 * @type { number } 7015 * @syscap SystemCapability.Web.Webview.Core 7016 * @since 12 7017 */ 7018 y: number; 7019 /** 7020 * Width of this rectangle. 7021 * 7022 * @type { number } 7023 * @syscap SystemCapability.Web.Webview.Core 7024 * @since 12 7025 */ 7026 width: number; 7027 /** 7028 * Height of this rectangle. 7029 * 7030 * @type { number } 7031 * @syscap SystemCapability.Web.Webview.Core 7032 * @since 12 7033 */ 7034 height: number; 7035 } 7036 7037 /** 7038 * Surface information. 7039 * 7040 * @syscap SystemCapability.Web.Webview.Core 7041 * @atomicservice 7042 * @since 12 7043 */ 7044 class NativeMediaPlayerSurfaceInfo { 7045 /** 7046 * Id of surface. 7047 * @type { string } 7048 * @syscap SystemCapability.Web.Webview.Core 7049 * @atomicservice 7050 * @since 12 7051 */ 7052 id: string; 7053 7054 /** 7055 * Surface rect info. 7056 * @type { RectEvent } 7057 * @syscap SystemCapability.Web.Webview.Core 7058 * @since 12 7059 */ 7060 rect: RectEvent; 7061 } 7062 7063 /** 7064 * Enum type for indicating the preload type. 7065 * @enum {number} 7066 * @syscap SystemCapability.Web.Webview.Core 7067 * @atomicservice 7068 * @since 12 7069 */ 7070 enum Preload { 7071 /** 7072 * Doesn't do preload. 7073 * @syscap SystemCapability.Web.Webview.Core 7074 * @atomicservice 7075 * @since 12 7076 */ 7077 NONE = 0, 7078 /** 7079 * Only preload metadata. 7080 * @syscap SystemCapability.Web.Webview.Core 7081 * @atomicservice 7082 * @since 12 7083 */ 7084 METADATA, 7085 /** 7086 * Preload enough data to ensure playing is smooth. 7087 * @syscap SystemCapability.Web.Webview.Core 7088 * @atomicservice 7089 * @since 12 7090 */ 7091 AUTO 7092 } 7093 7094 /** 7095 * Media information. 7096 * 7097 * @typedef MediaInfo 7098 * @syscap SystemCapability.Web.Webview.Core 7099 * @atomicservice 7100 * @since 12 7101 */ 7102 interface MediaInfo { 7103 /** 7104 * Id of media element. 7105 * @type { string } 7106 * @syscap SystemCapability.Web.Webview.Core 7107 * @since 12 7108 */ 7109 embedID: string, 7110 /** 7111 * Media type : Video or Audio. 7112 * @type { MediaType } 7113 * @syscap SystemCapability.Web.Webview.Core 7114 * @atomicservice 7115 * @since 12 7116 */ 7117 mediaType: MediaType, 7118 /** 7119 * Media source list, player should choose an appropriate one to play. 7120 * @type { MediaSourceInfo[] } 7121 * @syscap SystemCapability.Web.Webview.Core 7122 * @atomicservice 7123 * @since 12 7124 */ 7125 mediaSrcList: MediaSourceInfo[], 7126 /** 7127 * Surface to render media content on. 7128 * @type { NativeMediaPlayerSurfaceInfo } 7129 * @syscap SystemCapability.Web.Webview.Core 7130 * @atomicservice 7131 * @since 12 7132 */ 7133 surfaceInfo: NativeMediaPlayerSurfaceInfo, 7134 /** 7135 * Should show media controls. 7136 * @type { boolean } 7137 * @syscap SystemCapability.Web.Webview.Core 7138 * @atomicservice 7139 * @since 12 7140 */ 7141 controlsShown: boolean, 7142 /** 7143 * Limit media controls items. 7144 * Such as 'nodownload', 'nofullscreen', 'noremoteplayback' 7145 * @type { string[] } 7146 * @syscap SystemCapability.Web.Webview.Core 7147 * @atomicservice 7148 * @since 12 7149 */ 7150 controlList: string[], 7151 /** 7152 * Player should be muted; 7153 * @type { boolean } 7154 * @syscap SystemCapability.Web.Webview.Core 7155 * @atomicservice 7156 * @since 12 7157 */ 7158 muted: boolean, 7159 /** 7160 * Player should show poster before media first frame shown. 7161 * @type { string } 7162 * @syscap SystemCapability.Web.Webview.Core 7163 * @atomicservice 7164 * @since 12 7165 */ 7166 posterUrl: string, 7167 /** 7168 * Preload type. 7169 * @type { Preload } 7170 * @syscap SystemCapability.Web.Webview.Core 7171 * @atomicservice 7172 * @since 12 7173 */ 7174 preload: Preload, 7175 /** 7176 * Header information of a media network request. 7177 * @type { Record<string, string> } 7178 * @syscap SystemCapability.Web.Webview.Core 7179 * @since 12 7180 */ 7181 headers: Record<string, string>, 7182 /** 7183 * The information list of attributes of media tag. 7184 * @type { Record<string, string> } 7185 * @syscap SystemCapability.Web.Webview.Core 7186 * @since 12 7187 */ 7188 attributes: Record<string, string>, 7189 } 7190 7191 /** 7192 * The callback of creating a native media player. 7193 * 7194 * @typedef { function } 7195 * @param { NativeMediaPlayerHandler } handler - callback information of onCreateNativeMediaPlayer. 7196 * @param { MediaInfo } mediaInfo - callback information of onCreateNativeMediaPlayer. 7197 * @returns { NativeMediaPlayerBridge } Returns whether the app takes over the media. 7198 * @syscap SystemCapability.Web.Webview.Core 7199 * @atomicservice 7200 * @since 12 7201 */ 7202 type CreateNativeMediaPlayerCallback = 7203 (handler: NativeMediaPlayerHandler, mediaInfo: MediaInfo) => NativeMediaPlayerBridge; 7204 7205 /** 7206 * This class is used to set adblock config. 7207 * @syscap SystemCapability.Web.Webview.Core 7208 * @atomicservice 7209 * @since 12 7210 */ 7211 class AdsBlockManager { 7212 /** 7213 * set Ads Block ruleset file, containing easylist rules. 7214 * @param {string} rulesFile - absolute file path contains app customized ads block rules. 7215 * @param {boolean} replace - (@code true)replace internal rules;(@code false) add to internal rules. 7216 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7217 * <br>2. Incorrect parameter types. 7218 * @syscap SystemCapability.Web.Webview.Core 7219 * @atomicservice 7220 * @since 12 7221 */ 7222 static setAdsBlockRules(rulesFile: string, replace: boolean): void; 7223 7224 /** 7225 * Add items to Ads Block Disallow list. 7226 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 7227 * Ads Block will be disallowed for the web page. 7228 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7229 * <br>2. Incorrect parameter types. 7230 * @syscap SystemCapability.Web.Webview.Core 7231 * @atomicservice 7232 * @since 12 7233 */ 7234 static addAdsBlockDisallowedList(domainSuffixes: Array<string>): void; 7235 7236 /** 7237 * Add items to Ads Block Allow list. 7238 * By default, ads block is allowed for all pages unless they are added to the 7239 * disallow list. The priority of allowlist is higher than the disallowlist. It is 7240 * used to re-enable ads block on the page that matches disallow list. 7241 * @param { Array<string> } domainSuffixes - list of domain suffix, if web page url matches someone in the list, 7242 * Ads Block will be allowed for the web page. 7243 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7244 * <br>2. Incorrect parameter types. 7245 * @syscap SystemCapability.Web.Webview.Core 7246 * @atomicservice 7247 * @since 12 7248 */ 7249 static addAdsBlockAllowedList(domainSuffixes: Array<string>): void; 7250 7251 /** 7252 * remove items from Ads Block Disallowed list. 7253 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from disallow list 7254 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7255 * <br>2. Incorrect parameter types. 7256 * @syscap SystemCapability.Web.Webview.Core 7257 * @atomicservice 7258 * @since 12 7259 */ 7260 static removeAdsBlockDisallowedList(domainSuffixes: Array<string>): void; 7261 7262 /** 7263 * remove items from Ads Block Allowed list. 7264 * @param { Array<string> } domainSuffixes - list of domain suffix needed be removed from allow list 7265 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7266 * <br>2. Incorrect parameter types. 7267 * @syscap SystemCapability.Web.Webview.Core 7268 * @atomicservice 7269 * @since 12 7270 */ 7271 static removeAdsBlockAllowedList(domainSuffixes: Array<string>): void; 7272 7273 /** 7274 * clear Ads Block Disallowed list. 7275 * @syscap SystemCapability.Web.Webview.Core 7276 * @atomicservice 7277 * @since 12 7278 */ 7279 static clearAdsBlockDisallowedList(): void; 7280 7281 /** 7282 * clear Ads Block Allowed list. 7283 * @syscap SystemCapability.Web.Webview.Core 7284 * @atomicservice 7285 * @since 12 7286 */ 7287 static clearAdsBlockAllowedList(): void; 7288 } 7289 7290 /** 7291 * This class is used to enable back forward cache supported features. 7292 * 7293 * @syscap SystemCapability.Web.Webview.Core 7294 * @since 12 7295 */ 7296 class BackForwardCacheSupportedFeatures { 7297 /** 7298 * Whether cache the pages that use native embed. 7299 * Default is false; 7300 * 7301 * @type { boolean } 7302 * @syscap SystemCapability.Web.Webview.Core 7303 * @since 12 7304 */ 7305 nativeEmbed: boolean; 7306 7307 /** 7308 * Whether cache the pages that use media take over. 7309 * Default is false; 7310 * 7311 * @type { boolean } 7312 * @syscap SystemCapability.Web.Webview.Core 7313 * @since 12 7314 */ 7315 mediaTakeOver: boolean; 7316 7317 /** 7318 * @syscap SystemCapability.Web.Webview.Core 7319 * @since 12 7320 */ 7321 constructor(); 7322 } 7323 7324 /** 7325 * This class is used to set back forward cache options. 7326 * 7327 * @syscap SystemCapability.Web.Webview.Core 7328 * @since 12 7329 */ 7330 class BackForwardCacheOptions { 7331 /** 7332 * Set the maximum size of pages that can cache. 7333 * Default is 1, max is 50. 7334 * 7335 * @type { number } 7336 * @syscap SystemCapability.Web.Webview.Core 7337 * @since 12 7338 */ 7339 size: number; 7340 7341 /** 7342 * Set the lifetime in seconds in the BackForwardCache. 7343 * Default is 600. 7344 * 7345 * @type { number } 7346 * @syscap SystemCapability.Web.Webview.Core 7347 * @since 12 7348 */ 7349 timeToLive: number; 7350 7351 /** 7352 * @syscap SystemCapability.Web.Webview.Core 7353 * @since 12 7354 */ 7355 constructor(); 7356 } 7357 7358 /** 7359 * Enum type supplied to {@link insertProxyRule} for indicating the scheme filter for proxy. 7360 * @enum { number } 7361 * @syscap SystemCapability.Web.Webview.Core 7362 * @since 15 7363 */ 7364 enum ProxySchemeFilter { 7365 /** 7366 * This indicates all the schemes will use the proxy. 7367 * @syscap SystemCapability.Web.Webview.Core 7368 * @since 15 7369 */ 7370 MATCH_ALL_SCHEMES = 0, 7371 /** 7372 * This indicates only the HTTP requests will use the proxy. 7373 * @syscap SystemCapability.Web.Webview.Core 7374 * @since 15 7375 */ 7376 MATCH_HTTP = 1, 7377 /** 7378 * This indicates only the HTTPS requests will use the proxy. 7379 * @syscap SystemCapability.Web.Webview.Core 7380 * @since 15 7381 */ 7382 MATCH_HTTPS = 2, 7383} 7384/** 7385 * The ProxyConfig used by applyProxyOverride. 7386 * 7387 * @syscap SystemCapability.Web.Webview.Core 7388 * @since 15 7389 */ 7390class ProxyConfig { 7391 /** 7392 * Insert a bypass rule that indicates URLs that should skip the override proxy and connect the server directly instead. 7393 * These maybe URLs or IP addresses and wildcards are supported. e.g. "*.example.com" means that requests to 7394 * "https://www.example.com" and "http://test.example.com" will connect the server directly. 7395 * 7396 * @param { string } bypassRule - The bypass rule. 7397 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7398 * <br>2. Incorrect parameter types. 7399 * @syscap SystemCapability.Web.Webview.Core 7400 * @since 15 7401 */ 7402 insertBypassRule(bypassRule: string): void; 7403 /** 7404 * Insert a proxy rule that indicates URLs that match the schemeFilter will connect the server directly. 7405 * 7406 * @param { ProxySchemeFilter } schemeFilter - The scheme filter for this rule. 7407 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7408 * <br>2. Incorrect parameter types. 7409 * @syscap SystemCapability.Web.Webview.Core 7410 * @since 15 7411 */ 7412 insertDirectRule(schemeFilter?: ProxySchemeFilter): void; 7413 /** 7414 * Insert a proxy rule which indicates that requests matching the schemeFilter should use an override proxy, all requests will 7415 * use the proxy rule if schemeFilter is null. 7416 * 7417 * The format for proxy is [scheme://]host[:port]. Scheme is optional and must be HTTP, HTTPS, or SOCKS if present. Scheme defaults to HTTP. 7418 * Host is an IPv6 literal with brackets, an IPv4 literal or one or more labels seperated by a period. Port number is optional and defaults 7419 * to 80 for HTTP, 443 for HTTPS and 1080 for SOCKS. 7420 * 7421 * e.g. example.com host: example.com 7422 * https://example.com scheme: https host: example.com 7423 * example.com:8888 host: example.com port: 8888 7424 * https://example.com:8888 scheme:https host: example.com port:8888 7425 * 192.168.1.1 host: 192.168.1.1 7426 * 192.168.1.1:8888 host:192.168.1.1 port: 8888 7427 * [10:20:30:40:50:60:70:80] 7428 * 7429 * @param { string } proxyRule - The proxy rule. 7430 * @param { ProxySchemeFilter } schemeFilter - The scheme filter for this rule. 7431 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7432 * <br>2. Incorrect parameter types. 7433 * @syscap SystemCapability.Web.Webview.Core 7434 * @since 15 7435 */ 7436 insertProxyRule(proxyRule: string, schemeFilter?: ProxySchemeFilter): void; 7437 /** 7438 * Hostnames without a period in them (and that are not IP literals) will skip the proxy and connect the server directly. 7439 * Examples: "abc", "local", "some-domain". 7440 * 7441 * @syscap SystemCapability.Web.Webview.Core 7442 * @since 15 7443 */ 7444 bypassHostnamesWithoutPeriod(): void; 7445 /** 7446 * By default, certain hostnames implicitly bypass the proxy if they are link-local IPs, or localhost addresses. For instance 7447 * hostnames matching any of (non-exhaustive list): localhost *.localhost [::1] 127.0.0.1/8 169.254/16 [FE80::]/10 7448 * Call this function to override the default behavior and force localhost and link-local URLs to be sent through the proxy. 7449 * 7450 * @syscap SystemCapability.Web.Webview.Core 7451 * @since 15 7452 */ 7453 clearImplicitRules(): void; 7454 /** 7455 * Reverse the bypass rules. 7456 * 7457 * If false all URLs will use proxy settings except URLs match the bypass rules. 7458 * If true only URLs in the bypass list will use proxy, and all other URLs will be connected to directly. 7459 * 7460 * @param { boolean } reverse - If reverse the bypass rule. 7461 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7462 * <br>2. Incorrect parameter types. 7463 * @syscap SystemCapability.Web.Webview.Core 7464 * @since 15 7465 */ 7466 enableReverseBypass(reverse: boolean): void; 7467 /** 7468 * Returns the bypass rules. 7469 * 7470 * @returns { Array<string> } The bypass rules. 7471 * @syscap SystemCapability.Web.Webview.Core 7472 * @since 15 7473 */ 7474 getBypassRules(): Array<string>; 7475 /** 7476 * Returns the proxy rules. 7477 * 7478 * @returns { Array<ProxyRule> } The proxy rules. 7479 * @syscap SystemCapability.Web.Webview.Core 7480 * @since 15 7481 */ 7482 getProxyRules(): Array<ProxyRule>; 7483 /** 7484 * Returns if reverse bypass rules. 7485 * 7486 * @returns { boolean } If reverse bypass enabled. 7487 * @syscap SystemCapability.Web.Webview.Core 7488 * @since 15 7489 */ 7490 isReverseBypassEnabled(): boolean; 7491} 7492 7493/** 7494 * The ProxyRule used by insertProxyRule. 7495 * 7496 * @syscap SystemCapability.Web.Webview.Core 7497 * @since 15 7498 */ 7499class ProxyRule { 7500 /** 7501 * Returns the scheme filter used for this rule. 7502 * 7503 * @returns { ProxySchemeFilter } The scheme filter used for this rule. 7504 * @syscap SystemCapability.Web.Webview.Core 7505 * @since 15 7506 */ 7507 getSchemeFilter(): ProxySchemeFilter; 7508 /** 7509 * Returns the proxy URL. 7510 * 7511 * @returns { string } The proxy URL. 7512 * @syscap SystemCapability.Web.Webview.Core 7513 * @since 15 7514 */ 7515 getUrl(): string; 7516} 7517 7518/** 7519 * The callback for proxy changed. 7520 * 7521 * @typedef { function } 7522 * @syscap SystemCapability.Web.Webview.Core 7523 * @since 15 7524 */ 7525type OnProxyConfigChangeCallback = () => void; 7526 7527/** 7528 * This class is used for set proxy for ArkWeb. 7529 * 7530 * @syscap SystemCapability.Web.Webview.Core 7531 * @since 15 7532 */ 7533class ProxyController { 7534 /** 7535 * Sets ProxyConfig which will be used by all Webs in the app. URLs that match patterns in the bypass list will connect the server directly. 7536 * Instead, the request will use the proxy specified by the config. Requests are not guaranteed to use the new proxy immediately; wait for 7537 * the listener before loading a page. This listener will be called on the UI thread. 7538 * Note: calling applyProxyOverride will cause any existing system wide setting to be ignored. 7539 * 7540 * @param { ProxyConfig } proxyConfig - The proxy config. 7541 * @param { OnProxyConfigChangeCallback } callback - Called when the proxy has been changed. 7542 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7543 * <br>2. Incorrect parameter types. 7544 * @syscap SystemCapability.Web.Webview.Core 7545 * @since 15 7546 */ 7547 static applyProxyOverride(proxyConfig: ProxyConfig, callback: OnProxyConfigChangeCallback): void; 7548 /** 7549 * Remove the proxy config. Requests are not guaranteed to not use the proxy; wait for the listener before loading a page. This listener 7550 * will be called on the UI thread. 7551 * 7552 * @param { OnProxyConfigChangeCallback } callback - Called when the proxy has been changed. 7553 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 7554 * <br>2. Incorrect parameter types. 7555 * @syscap SystemCapability.Web.Webview.Core 7556 * @since 15 7557 */ 7558 static removeProxyOverride(callback: OnProxyConfigChangeCallback): void; 7559} 7560 7561} 7562 7563export default webview; 7564