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