1/* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkWeb 19 */ 20 21/// <reference path="../component/units.d.ts" /> 22 23import { AsyncCallback } from './@ohos.base'; 24import { Callback } from './@ohos.base'; 25import { Resource } from 'GlobalResource'; 26import cert from './@ohos.security.cert'; 27import image from './@ohos.multimedia.image'; 28import type print from './@ohos.print'; 29 30/** 31 * This module provides the capability to manage web modules. 32 * 33 * @namespace webview 34 * @syscap SystemCapability.Web.Webview.Core 35 * @since 9 36 */ 37/** 38 * This module provides the capability to manage web modules. 39 * 40 * @namespace webview 41 * @syscap SystemCapability.Web.Webview.Core 42 * @crossplatform 43 * @since 10 44 */ 45/** 46 * This module provides the capability to manage web modules. 47 * 48 * @namespace webview 49 * @syscap SystemCapability.Web.Webview.Core 50 * @crossplatform 51 * @atomicservice 52 * @since 11 53 */ 54declare namespace webview { 55 /** 56 * Defines the Web's request/response header. 57 * 58 * @interface WebHeader 59 * @syscap SystemCapability.Web.Webview.Core 60 * @since 9 61 */ 62 /** 63 * Defines the Web's request/response header. 64 * 65 * @interface WebHeader 66 * @syscap SystemCapability.Web.Webview.Core 67 * @crossplatform 68 * @since 10 69 */ 70 /** 71 * Defines the Web's request/response header. 72 * 73 * @interface WebHeader 74 * @syscap SystemCapability.Web.Webview.Core 75 * @crossplatform 76 * @atomicservice 77 * @since 11 78 */ 79 interface WebHeader { 80 /** 81 * Gets the key of the request/response header. 82 * @syscap SystemCapability.Web.Webview.Core 83 * @since 9 84 */ 85 /** 86 * Gets the key of the request/response header. 87 * @syscap SystemCapability.Web.Webview.Core 88 * @crossplatform 89 * @since 10 90 */ 91 /** 92 * Gets the key of the request/response header. 93 * @syscap SystemCapability.Web.Webview.Core 94 * @crossplatform 95 * @atomicservice 96 * @since 11 97 */ 98 headerKey: string; 99 100 /** 101 * Gets the value of the request/response header. 102 * @syscap SystemCapability.Web.Webview.Core 103 * @since 9 104 */ 105 /** 106 * Gets the value of the request/response header. 107 * @syscap SystemCapability.Web.Webview.Core 108 * @crossplatform 109 * @since 10 110 */ 111 /** 112 * Gets the value of the request/response header. 113 * @syscap SystemCapability.Web.Webview.Core 114 * @crossplatform 115 * @atomicservice 116 * @since 11 117 */ 118 headerValue: string; 119 } 120 121 /** 122 * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. 123 * @enum {number} 124 * @syscap SystemCapability.Web.Webview.Core 125 * @since 9 126 */ 127 /** 128 * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest. 129 * @enum {number} 130 * @syscap SystemCapability.Web.Webview.Core 131 * @atomicservice 132 * @since 11 133 */ 134 enum WebHitTestType { 135 /** 136 * The edit text. 137 * @syscap SystemCapability.Web.Webview.Core 138 * @since 9 139 */ 140 /** 141 * The edit text. 142 * @syscap SystemCapability.Web.Webview.Core 143 * @atomicservice 144 * @since 11 145 */ 146 EditText, 147 148 /** 149 * The email address. 150 * @syscap SystemCapability.Web.Webview.Core 151 * @since 9 152 */ 153 /** 154 * The email address. 155 * @syscap SystemCapability.Web.Webview.Core 156 * @atomicservice 157 * @since 11 158 */ 159 Email, 160 161 /** 162 * The HTML::a tag with src=http. 163 * @syscap SystemCapability.Web.Webview.Core 164 * @since 9 165 */ 166 /** 167 * The HTML::a tag with src=http. 168 * @syscap SystemCapability.Web.Webview.Core 169 * @atomicservice 170 * @since 11 171 */ 172 HttpAnchor, 173 174 /** 175 * The HTML::a tag with src=http + HTML::img. 176 * @syscap SystemCapability.Web.Webview.Core 177 * @since 9 178 */ 179 /** 180 * The HTML::a tag with src=http + HTML::img. 181 * @syscap SystemCapability.Web.Webview.Core 182 * @atomicservice 183 * @since 11 184 */ 185 HttpAnchorImg, 186 187 /** 188 * The HTML::img tag. 189 * @syscap SystemCapability.Web.Webview.Core 190 * @since 9 191 */ 192 /** 193 * The HTML::img tag. 194 * @syscap SystemCapability.Web.Webview.Core 195 * @atomicservice 196 * @since 11 197 */ 198 Img, 199 200 /** 201 * The map address. 202 * @syscap SystemCapability.Web.Webview.Core 203 * @since 9 204 */ 205 /** 206 * The map address. 207 * @syscap SystemCapability.Web.Webview.Core 208 * @atomicservice 209 * @since 11 210 */ 211 Map, 212 213 /** 214 * The phone number. 215 * @syscap SystemCapability.Web.Webview.Core 216 * @since 9 217 */ 218 /** 219 * The phone number. 220 * @syscap SystemCapability.Web.Webview.Core 221 * @atomicservice 222 * @since 11 223 */ 224 Phone, 225 226 /** 227 * Other unknown HitTest. 228 * @syscap SystemCapability.Web.Webview.Core 229 * @since 9 230 */ 231 /** 232 * Other unknown HitTest. 233 * @syscap SystemCapability.Web.Webview.Core 234 * @atomicservice 235 * @since 11 236 */ 237 Unknown 238 } 239 240 /** 241 * Defines the mode for using HttpDns. 242 * @enum {number} 243 * @syscap SystemCapability.Web.Webview.Core 244 * @since 10 245 */ 246 /** 247 * Defines the mode for using HttpDns. 248 * @enum {number} 249 * @syscap SystemCapability.Web.Webview.Core 250 * @atomicservice 251 * @since 11 252 */ 253 enum SecureDnsMode { 254 /** 255 * Do not use HttpDns, can be used to revoke previously used HttpDns configuration. 256 * @syscap SystemCapability.Web.Webview.Core 257 * @since 10 258 */ 259 /** 260 * Do not use HttpDns, can be used to revoke previously used HttpDns configuration. 261 * @syscap SystemCapability.Web.Webview.Core 262 * @atomicservice 263 * @since 11 264 */ 265 OFF = 0, 266 /** 267 * By default, the user-settings of HttpDns is used for dns resolution, and if it fails, 268 * the system dns is used for resolution. 269 * @syscap SystemCapability.Web.Webview.Core 270 * @since 10 271 */ 272 /** 273 * By default, the user-settings of HttpDns is used for dns resolution, and if it fails, 274 * the system dns is used for resolution. 275 * @syscap SystemCapability.Web.Webview.Core 276 * @atomicservice 277 * @since 11 278 */ 279 AUTO = 1, 280 /** 281 * Use the user-settings of HttpDns for dns resolution. If it fails, it will not 282 * fall back to the system dns, which will directly cause the page to fail to load. 283 * @syscap SystemCapability.Web.Webview.Core 284 * @since 10 285 */ 286 /** 287 * Use the user-settings of HttpDns for dns resolution. If it fails, it will not 288 * fall back to the system dns, which will directly cause the page to fail to load. 289 * @syscap SystemCapability.Web.Webview.Core 290 * @atomicservice 291 * @since 11 292 */ 293 SECURE_ONLY = 2, 294 } 295 296 /** 297 * Defines the security level for the page. 298 * 299 * @enum {number} 300 * @syscap SystemCapability.Web.Webview.Core 301 * @atomicservice 302 * @since 11 303 */ 304 enum SecurityLevel { 305 /** 306 * Unable to determine whether it is safe or not, the non-http/https protocol used. 307 * 308 * @syscap SystemCapability.Web.Webview.Core 309 * @atomicservice 310 * @since 11 311 */ 312 NONE = 0, 313 314 /** 315 * Indicates the HTTPS protocol used by the page and the authentication is successful. 316 * 317 * @syscap SystemCapability.Web.Webview.Core 318 * @atomicservice 319 * @since 11 320 */ 321 SECURE = 1, 322 323 /** 324 * The page is insecure. For example, the HTTP protocol is used or the HTTPS protocol 325 * is used but use an legacy TLS version. 326 * 327 * @syscap SystemCapability.Web.Webview.Core 328 * @atomicservice 329 * @since 11 330 */ 331 WARNING = 2, 332 333 /** 334 * Attempted HTTPS and failed, the authentication is failed. 335 * 336 * @syscap SystemCapability.Web.Webview.Core 337 * @atomicservice 338 * @since 11 339 */ 340 DANGEROUS = 3, 341 } 342 343 /** 344 * Defines the hit test value, related to {@link getHitTestValue} method. 345 * 346 * @interface HitTestValue 347 * @syscap SystemCapability.Web.Webview.Core 348 * @since 9 349 */ 350 /** 351 * Defines the hit test value, related to {@link getHitTestValue} method. 352 * 353 * @interface HitTestValue 354 * @syscap SystemCapability.Web.Webview.Core 355 * @atomicservice 356 * @since 11 357 */ 358 interface HitTestValue { 359 360 /** 361 * Get the hit test type. 362 * 363 * @syscap SystemCapability.Web.Webview.Core 364 * @since 9 365 */ 366 /** 367 * Get the hit test type. 368 * 369 * @syscap SystemCapability.Web.Webview.Core 370 * @atomicservice 371 * @since 11 372 */ 373 type: WebHitTestType; 374 375 /** 376 * Get the hit test extra data. 377 * 378 * @syscap SystemCapability.Web.Webview.Core 379 * @since 9 380 */ 381 /** 382 * Get the hit test extra data. 383 * 384 * @syscap SystemCapability.Web.Webview.Core 385 * @atomicservice 386 * @since 11 387 */ 388 extra: string; 389 } 390 391 /** 392 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 393 * 394 * @interface WebCustomScheme 395 * @syscap SystemCapability.Web.Webview.Core 396 * @since 9 397 */ 398 /** 399 * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. 400 * 401 * @interface WebCustomScheme 402 * @syscap SystemCapability.Web.Webview.Core 403 * @atomicservice 404 * @since 11 405 */ 406 interface WebCustomScheme { 407 408 /** 409 * Name of the custom scheme. 410 * 411 * @syscap SystemCapability.Web.Webview.Core 412 * @since 9 413 */ 414 /** 415 * Name of the custom scheme. 416 * 417 * @syscap SystemCapability.Web.Webview.Core 418 * @atomicservice 419 * @since 11 420 */ 421 schemeName: string; 422 423 /** 424 * Whether Cross-Origin Resource Sharing is supported. 425 * 426 * @syscap SystemCapability.Web.Webview.Core 427 * @since 9 428 */ 429 /** 430 * Whether Cross-Origin Resource Sharing is supported. 431 * 432 * @syscap SystemCapability.Web.Webview.Core 433 * @atomicservice 434 * @since 11 435 */ 436 isSupportCORS: boolean; 437 438 /** 439 * Whether fetch request is supported. 440 * 441 * @syscap SystemCapability.Web.Webview.Core 442 * @since 9 443 */ 444 /** 445 * Whether fetch request is supported. 446 * 447 * @syscap SystemCapability.Web.Webview.Core 448 * @atomicservice 449 * @since 11 450 */ 451 isSupportFetch: boolean; 452 } 453 454 /** 455 * Provides basic information of web storage. 456 * 457 * @interface WebStorageOrigin 458 * @syscap SystemCapability.Web.Webview.Core 459 * @since 9 460 */ 461 /** 462 * Provides basic information of web storage. 463 * 464 * @interface WebStorageOrigin 465 * @syscap SystemCapability.Web.Webview.Core 466 * @atomicservice 467 * @since 11 468 */ 469 interface WebStorageOrigin { 470 /** 471 * Url source. 472 * 473 * @syscap SystemCapability.Web.Webview.Core 474 * @since 9 475 */ 476 /** 477 * Url source. 478 * 479 * @syscap SystemCapability.Web.Webview.Core 480 * @atomicservice 481 * @since 11 482 */ 483 origin: string; 484 /** 485 * Specify the amount of storage for the source. 486 * 487 * @syscap SystemCapability.Web.Webview.Core 488 * @since 9 489 */ 490 /** 491 * Specify the amount of storage for the source. 492 * 493 * @syscap SystemCapability.Web.Webview.Core 494 * @atomicservice 495 * @since 11 496 */ 497 usage: number; 498 /** 499 * the callback of getOriginUsage. 500 * 501 * @syscap SystemCapability.Web.Webview.Core 502 * @since 9 503 */ 504 /** 505 * the callback of getOriginUsage. 506 * 507 * @syscap SystemCapability.Web.Webview.Core 508 * @atomicservice 509 * @since 11 510 */ 511 quota: number; 512 } 513 514 /** 515 * Subscribe to a callback of a specified type of web event once. 516 * 517 * @param {string} type Types of web event. 518 * @param {Callback<void>} callback Indicate callback used to receive the web event. 519 * 520 * @throws { BusinessError } 401 - Invalid input parameter. 521 * @syscap SystemCapability.Web.Webview.Core 522 * @since 9 523 */ 524 /** 525 * Subscribe to a callback of a specified type of web event once. 526 * 527 * @param {string} type Types of web event. 528 * @param {Callback<void>} callback Indicate callback used to receive the web event. 529 * 530 * @throws { BusinessError } 401 - Invalid input parameter. 531 * @syscap SystemCapability.Web.Webview.Core 532 * @atomicservice 533 * @since 11 534 */ 535 function once(type: string, callback: Callback<void>): void; 536 537 /** 538 * Provides methods for managing web storage.3 539 * 540 * @syscap SystemCapability.Web.Webview.Core 541 * @since 9 542 */ 543 /** 544 * Provides methods for managing web storage.3 545 * 546 * @syscap SystemCapability.Web.Webview.Core 547 * @atomicservice 548 * @since 11 549 */ 550 class WebStorage { 551 /** 552 * Delete all the storage data. 553 * 554 * @syscap SystemCapability.Web.Webview.Core 555 * @since 9 556 */ 557 /** 558 * Delete all the storage data. 559 * 560 * @param { boolean } incognito - {@code true} delete all the storage data in incognito mode; 561 * {@code false} otherwise. 562 * @syscap SystemCapability.Web.Webview.Core 563 * @atomicservice 564 * @since 11 565 */ 566 static deleteAllData(incognito?: boolean): void; 567 568 /** 569 * Delete the storage data with the origin. 570 * 571 * @param { string } origin - The origin which to be deleted. 572 * @throws { BusinessError } 401 - Invalid input parameter. 573 * @throws { BusinessError } 17100011 - Invalid origin. 574 * @syscap SystemCapability.Web.Webview.Core 575 * @since 9 576 */ 577 /** 578 * Delete the storage data with the origin. 579 * 580 * @param { string } origin - The origin which to be deleted. 581 * @throws { BusinessError } 401 - Invalid input parameter. 582 * @throws { BusinessError } 17100011 - Invalid origin. 583 * @syscap SystemCapability.Web.Webview.Core 584 * @atomicservice 585 * @since 11 586 */ 587 static deleteOrigin(origin: string): void; 588 589 /** 590 * Get current all the web storage origins. 591 * @returns { Promise<Array<WebStorageOrigin>> } - returns all the WebStorageOrigin. 592 * @throws { BusinessError } 401 - Invalid input parameter. 593 * @throws { BusinessError } 17100012 - Invalid web storage origin. 594 * @syscap SystemCapability.Web.Webview.Core 595 * @since 9 596 */ 597 /** 598 * Get current all the web storage origins. 599 * @returns { Promise<Array<WebStorageOrigin>> } - returns all the WebStorageOrigin. 600 * @throws { BusinessError } 401 - Invalid input parameter. 601 * @throws { BusinessError } 17100012 - Invalid web storage origin. 602 * @syscap SystemCapability.Web.Webview.Core 603 * @atomicservice 604 * @since 11 605 */ 606 static getOrigins(): Promise<Array<WebStorageOrigin>>; 607 608 /** 609 * Get current all the web storage origins. 610 * @param { AsyncCallback<Array<WebStorageOrigin>> } callback - callback used to return all the WebStorageOrigin. 611 * @throws { BusinessError } 401 - Invalid input parameter. 612 * @throws { BusinessError } 17100012 - Invalid web storage origin. 613 * @syscap SystemCapability.Web.Webview.Core 614 * @since 9 615 */ 616 /** 617 * Get current all the web storage origins. 618 * @param { AsyncCallback<Array<WebStorageOrigin>> } callback - callback used to return all the WebStorageOrigin. 619 * @throws { BusinessError } 401 - Invalid input parameter. 620 * @throws { BusinessError } 17100012 - Invalid web storage origin. 621 * @syscap SystemCapability.Web.Webview.Core 622 * @atomicservice 623 * @since 11 624 */ 625 static getOrigins(callback: AsyncCallback<Array<WebStorageOrigin>>): void; 626 627 /** 628 * Get the web storage quota with the origin. 629 * @param { string } origin - The origin which to be inquired. 630 * @returns { Promise<number> } - the promise returned by the function 631 * @throws { BusinessError } 401 - Invalid input parameter. 632 * @throws { BusinessError } 17100011 - Invalid origin. 633 * @syscap SystemCapability.Web.Webview.Core 634 * @since 9 635 */ 636 /** 637 * Get the web storage quota with the origin. 638 * @param { string } origin - The origin which to be inquired. 639 * @returns { Promise<number> } - the promise returned by the function 640 * @throws { BusinessError } 401 - Invalid input parameter. 641 * @throws { BusinessError } 17100011 - Invalid origin. 642 * @syscap SystemCapability.Web.Webview.Core 643 * @atomicservice 644 * @since 11 645 */ 646 static getOriginQuota(origin: string): Promise<number>; 647 648 /** 649 * Get the web storage quota with the origin. 650 * @param { string } origin - The origin which to be inquired. 651 * @param { AsyncCallback<number> } callback - the callback of getOriginQuota. 652 * @throws { BusinessError } 401 - Invalid input parameter. 653 * @throws { BusinessError } 17100011 - Invalid origin. 654 * @syscap SystemCapability.Web.Webview.Core 655 * @since 9 656 */ 657 /** 658 * Get the web storage quota with the origin. 659 * @param { string } origin - The origin which to be inquired. 660 * @param { AsyncCallback<number> } callback - the callback of getOriginQuota. 661 * @throws { BusinessError } 401 - Invalid input parameter. 662 * @throws { BusinessError } 17100011 - Invalid origin. 663 * @syscap SystemCapability.Web.Webview.Core 664 * @atomicservice 665 * @since 11 666 */ 667 static getOriginQuota(origin: string, callback: AsyncCallback<number>): void; 668 669 /** 670 * Get the web amount of storage with the origin. 671 * @param { string } origin - The origin which to be inquired. 672 * @returns { Promise<number> } - the promise returned by the function 673 * @throws { BusinessError } 401 - Invalid input parameter. 674 * @throws { BusinessError } 17100011 - Invalid origin. 675 * @syscap SystemCapability.Web.Webview.Core 676 * @since 9 677 */ 678 /** 679 * Get the web amount of storage with the origin. 680 * @param { string } origin - The origin which to be inquired. 681 * @returns { Promise<number> } - the promise returned by the function 682 * @throws { BusinessError } 401 - Invalid input parameter. 683 * @throws { BusinessError } 17100011 - Invalid origin. 684 * @syscap SystemCapability.Web.Webview.Core 685 * @atomicservice 686 * @since 11 687 */ 688 static getOriginUsage(origin: string): Promise<number>; 689 690 /** 691 * Get the web amount of storage with the origin. 692 * @param { string } origin - The origin which to be inquired. 693 * @param { AsyncCallback<number> } callback - the callback of getOriginUsage. 694 * @throws { BusinessError } 401 - Invalid input parameter. 695 * @throws { BusinessError } 17100011 - Invalid origin. 696 * @syscap SystemCapability.Web.Webview.Core 697 * @since 9 698 */ 699 /** 700 * Get the web amount of storage with the origin. 701 * @param { string } origin - The origin which to be inquired. 702 * @param { AsyncCallback<number> } callback - the callback of getOriginUsage. 703 * @throws { BusinessError } 401 - Invalid input parameter. 704 * @throws { BusinessError } 17100011 - Invalid origin. 705 * @syscap SystemCapability.Web.Webview.Core 706 * @atomicservice 707 * @since 11 708 */ 709 static getOriginUsage(origin: string, callback: AsyncCallback<number>): void; 710 } 711 712 /** 713 * Provides methods for managing web database. 714 * @syscap SystemCapability.Web.Webview.Core 715 * @since 9 716 */ 717 /** 718 * Provides methods for managing web database. 719 * @syscap SystemCapability.Web.Webview.Core 720 * @crossplatform 721 * @atomicservice 722 * @since 11 723 */ 724 class WebDataBase { 725 /** 726 * Get whether instances holds any http authentication credentials. 727 * @returns { boolean } true if instances saved any http authentication credentials otherwise false. 728 * @syscap SystemCapability.Web.Webview.Core 729 * @since 9 730 */ 731 /** 732 * Get whether instances holds any http authentication credentials. 733 * @returns { boolean } true if instances saved any http authentication credentials otherwise false. 734 * @syscap SystemCapability.Web.Webview.Core 735 * @crossplatform 736 * @atomicservice 737 * @since 11 738 */ 739 static existHttpAuthCredentials(): boolean; 740 741 /** 742 * Delete all http authentication credentials. 743 * 744 * @syscap SystemCapability.Web.Webview.Core 745 * @since 9 746 */ 747 /** 748 * Delete all http authentication credentials. 749 * 750 * @syscap SystemCapability.Web.Webview.Core 751 * @crossplatform 752 * @atomicservice 753 * @since 11 754 */ 755 static deleteHttpAuthCredentials(): void; 756 757 /** 758 * Get http authentication credentials. 759 * @param { string } host - The host to which the credentials apply. 760 * @param { string } realm - The realm to which the credentials apply. 761 * @returns { Array<string> } Return an array containing username and password. 762 * @throws { BusinessError } 401 - Invalid input parameter. 763 * @syscap SystemCapability.Web.Webview.Core 764 * @since 9 765 */ 766 /** 767 * Get http authentication credentials. 768 * @param { string } host - The host to which the credentials apply. 769 * @param { string } realm - The realm to which the credentials apply. 770 * @returns { Array<string> } Return an array containing username and password. 771 * @throws { BusinessError } 401 - Invalid input parameter. 772 * @syscap SystemCapability.Web.Webview.Core 773 * @crossplatform 774 * @atomicservice 775 * @since 11 776 */ 777 static getHttpAuthCredentials(host: string, realm: string): Array<string>; 778 779 /** 780 * Save http authentication credentials. 781 * @param { string } host - The host to which the credentials apply. 782 * @param { string } realm - The realm to which the credentials apply. 783 * @param { string } username - The username. 784 * @param { string } password - The password. 785 * @throws { BusinessError } 401 - Invalid input parameter. 786 * @syscap SystemCapability.Web.Webview.Core 787 * @since 9 788 */ 789 /** 790 * Save http authentication credentials. 791 * @param { string } host - The host to which the credentials apply. 792 * @param { string } realm - The realm to which the credentials apply. 793 * @param { string } username - The username. 794 * @param { string } password - The password. 795 * @throws { BusinessError } 401 - Invalid input parameter. 796 * @syscap SystemCapability.Web.Webview.Core 797 * @crossplatform 798 * @atomicservice 799 * @since 11 800 */ 801 static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; 802 } 803 804 /** 805 * Provides a method for managing web geographic location permissions. 806 * @syscap SystemCapability.Web.Webview.Core 807 * @since 9 808 */ 809 /** 810 * Provides a method for managing web geographic location permissions. 811 * @syscap SystemCapability.Web.Webview.Core 812 * @atomicservice 813 * @since 11 814 */ 815 class GeolocationPermissions { 816 /** 817 * Allow geolocation permissions for specifies source. 818 * @param { string } origin - Url source. 819 * @throws { BusinessError } 401 - Invalid input parameter. 820 * @throws { BusinessError } 17100011 - Invalid origin. 821 * @syscap SystemCapability.Web.Webview.Core 822 * @since 9 823 */ 824 /** 825 * Allow geolocation permissions for specifies source. 826 * @param { string } origin - Url source. 827 * @param { boolean } incognito - {@code true} Allow geolocation permissions for specifies source 828 * in incognito mode; {@code false} otherwise. 829 * @throws { BusinessError } 401 - Invalid input parameter. 830 * @throws { BusinessError } 17100011 - Invalid origin. 831 * @syscap SystemCapability.Web.Webview.Core 832 * @atomicservice 833 * @since 11 834 */ 835 static allowGeolocation(origin: string, incognito?: boolean): void; 836 837 /** 838 * Delete geolocation permissions for specifies source. 839 * @param { string } origin - Url source. 840 * @throws { BusinessError } 401 - Invalid input parameter. 841 * @throws { BusinessError } 17100011 - Invalid origin. 842 * @syscap SystemCapability.Web.Webview.Core 843 * @since 9 844 */ 845 /** 846 * Delete geolocation permissions for specifies source. 847 * @param { string } origin - Url source. 848 * @param { boolean } incognito - {@code true} delete geolocation permissions for specifies source 849 * in incognito mode; {@code false} otherwise. 850 * @throws { BusinessError } 401 - Invalid input parameter. 851 * @throws { BusinessError } 17100011 - Invalid origin. 852 * @syscap SystemCapability.Web.Webview.Core 853 * @atomicservice 854 * @since 11 855 */ 856 static deleteGeolocation(origin: string, incognito?: boolean): void; 857 858 /** 859 * Delete all geolocation permissions. 860 * 861 * @syscap SystemCapability.Web.Webview.Core 862 * @since 9 863 */ 864 /** 865 * Delete all geolocation permissions. 866 * 867 * @param { boolean } incognito - {@code true} delete all geolocation in incognito mode; 868 * {@code false} otherwise. 869 * @syscap SystemCapability.Web.Webview.Core 870 * @atomicservice 871 * @since 11 872 */ 873 static deleteAllGeolocation(incognito?: boolean): void; 874 875 /** 876 * Gets the geolocation permission status of the specified source. 877 * @param { string } origin - Url source. 878 * @returns { Promise<boolean> } A Promise instance that obtains the permission 879 * status of the specified source and obtains successfully, 880 * true for authorization, false for access denial. Failed 881 * to get, indicating that the permission status of the 882 * specified source does not exist. 883 * @throws { BusinessError } 401 - Invalid input parameter. 884 * @throws { BusinessError } 17100011 - Invalid origin. 885 * @syscap SystemCapability.Web.Webview.Core 886 * @since 9 887 */ 888 /** 889 * Gets the geolocation permission status of the specified source. 890 * @param { string } origin - Url source. 891 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 892 * specified source in incognito mode; {@code false} otherwise. 893 * @returns { Promise<boolean> } A Promise instance that obtains the permission 894 * status of the specified source and obtains successfully, 895 * true for authorization, false for access denial. Failed 896 * to get, indicating that the permission status of the 897 * specified source does not exist. 898 * @throws { BusinessError } 401 - Invalid input parameter. 899 * @throws { BusinessError } 17100011 - Invalid origin. 900 * @syscap SystemCapability.Web.Webview.Core 901 * @atomicservice 902 * @since 11 903 */ 904 static getAccessibleGeolocation(origin: string, incognito?: boolean): Promise<boolean>; 905 906 /** 907 * Gets the geolocation permission status of the specified source. 908 * @param { string } origin - Url source. 909 * @param { AsyncCallback<boolean> } callback - Returns the geolocation permission status for 910 * the specified source. Successful acquisition, 911 * true means authorized, false means access is 912 * denied. Failed to get, indicating that the 913 * permission status of the specified source does 914 * not exist. 915 * @throws { BusinessError } 401 - Invalid input parameter. 916 * @throws { BusinessError } 17100011 - Invalid origin. 917 * @syscap SystemCapability.Web.Webview.Core 918 * @since 9 919 */ 920 /** 921 * Gets the geolocation permission status of the specified source. 922 * @param { string } origin - Url source. 923 * @param { AsyncCallback<boolean> } callback - Returns the geolocation permission status for 924 * the specified source. Successful acquisition, 925 * true means authorized, false means access is 926 * denied. Failed to get, indicating that the 927 * permission status of the specified source does 928 * not exist. 929 * @param { boolean } incognito - {@code true} gets the geolocation permission status of the 930 * specified source in incognito mode; {@code false} otherwise. 931 * @throws { BusinessError } 401 - Invalid input parameter. 932 * @throws { BusinessError } 17100011 - Invalid origin. 933 * @syscap SystemCapability.Web.Webview.Core 934 * @atomicservice 935 * @since 11 936 */ 937 static getAccessibleGeolocation(origin: string, callback: AsyncCallback<boolean>, incognito?: boolean): void; 938 939 /** 940 * Get all stored geolocation permission url source. 941 * 942 * @returns { Promise<Array<string>> } A Promise instance that gets all source information about 943 * the stored geolocation permission state. 944 * @throws { BusinessError } 401 - Invalid input parameter. 945 * @syscap SystemCapability.Web.Webview.Core 946 * @since 9 947 */ 948 /** 949 * Get all stored geolocation permission url source. 950 * @param { boolean } incognito - {@code true} get all stored geolocation permission url source 951 * in incognito mode; {@code false} otherwise. 952 * @returns { Promise<Array<string>> } A Promise instance that gets all source information about 953 * the stored geolocation permission state. 954 * @throws { BusinessError } 401 - Invalid input parameter. 955 * @syscap SystemCapability.Web.Webview.Core 956 * @atomicservice 957 * @since 11 958 */ 959 static getStoredGeolocation(incognito?: boolean): Promise<Array<string>>; 960 961 /** 962 * Get all stored geolocation permission url source. 963 * @param { AsyncCallback<Array<string>> } callback - Returns all source information for 964 * stored geolocation permission states. 965 * @throws { BusinessError } 401 - Invalid input parameter. 966 * @syscap SystemCapability.Web.Webview.Core 967 * @since 9 968 */ 969 /** 970 * Get all stored geolocation permission url source. 971 * @param { AsyncCallback<Array<string>> } callback - Returns all source information for 972 * stored geolocation permission states. 973 * @param { boolean } incognito - {@code true} gets all stored geolocation permission url 974 * source in incognito mode; {@code false} otherwise. 975 * @throws { BusinessError } 401 - Invalid input parameter. 976 * @syscap SystemCapability.Web.Webview.Core 977 * @atomicservice 978 * @since 11 979 */ 980 static getStoredGeolocation(callback: AsyncCallback<Array<string>>, incognito?: boolean): void; 981 } 982 983 /** 984 * Provides methods for managing the web cookies. 985 * 986 * @syscap SystemCapability.Web.Webview.Core 987 * @since 9 988 */ 989 /** 990 * Provides methods for managing the web cookies. 991 * 992 * @syscap SystemCapability.Web.Webview.Core 993 * @crossplatform 994 * @atomicservice 995 * @since 11 996 */ 997 class WebCookieManager { 998 /** 999 * Gets all cookies for the given URL. 1000 * 1001 * @param { string } url - The URL for which the cookies are requested. 1002 * @returns { string } - The cookie value for the given URL. 1003 * @throws { BusinessError } 401 - Invalid input parameter. 1004 * @throws { BusinessError } 17100002 - Invalid url. 1005 * @syscap SystemCapability.Web.Webview.Core 1006 * @since 9 1007 * @deprecated since 11 1008 * @useinstead ohos.web.webview.WebCookieManager#fetchCookieSync 1009 */ 1010 static getCookie(url: string): string; 1011 1012 /** 1013 * Gets all cookies for the given URL. 1014 * 1015 * @param { string } url - The URL for which the cookies are requested. 1016 * @param { boolean } incognito - {@code true} gets all cookies for the given URL 1017 * in incognito mode; {@code false} otherwise. 1018 * @returns { string } - The cookie value for the given URL. 1019 * @throws { BusinessError } 401 - Invalid input parameter. 1020 * @throws { BusinessError } 17100002 - Invalid url. 1021 * @syscap SystemCapability.Web.Webview.Core 1022 * @atomicservice 1023 * @since 11 1024 */ 1025 static fetchCookieSync(url: string, incognito?: boolean): string; 1026 1027 /** 1028 * Gets all cookies for the given URL Asynchronously. 1029 * 1030 * @param { string } url - The URL for which the cookies are requested. 1031 * @returns { Promise<string> } - A promise resolved after the cookies of given URL have been gotten. 1032 * @throws { BusinessError } 401 - Invalid input parameter. 1033 * @throws { BusinessError } 17100002 - Invalid url. 1034 * @syscap SystemCapability.Web.Webview.Core 1035 * @crossplatform 1036 * @atomicservice 1037 * @since 11 1038 */ 1039 static fetchCookie(url: string): Promise<string>; 1040 1041 /** 1042 * Gets all cookies for the given URL Asynchronously. 1043 * 1044 * @param { string } url - The URL for which the cookies are requested. 1045 * @param { AsyncCallback<string> } callback - Called after the cookies of given URL have been gotten. 1046 * @throws { BusinessError } 401 - Invalid input parameter. 1047 * @throws { BusinessError } 17100002 - Invalid url. 1048 * @syscap SystemCapability.Web.Webview.Core 1049 * @crossplatform 1050 * @atomicservice 1051 * @since 11 1052 */ 1053 static fetchCookie(url: string, callback: AsyncCallback<string>): void; 1054 1055 /** 1056 * Set a single cookie (key-value pair) for the given URL. 1057 * 1058 * @param { string } url - The URL for which the cookie is to be set. 1059 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1060 * @throws { BusinessError } 401 - Invalid input parameter. 1061 * @throws { BusinessError } 17100002 - Invalid url. 1062 * @throws { BusinessError } 17100005 - Invalid cookie value. 1063 * @syscap SystemCapability.Web.Webview.Core 1064 * @since 9 1065 * @deprecated since 11 1066 * @useinstead ohos.web.webview.WebCookieManager#configCookieSync 1067 */ 1068 static setCookie(url: string, value: string): void; 1069 1070 /** 1071 * Set a single cookie (key-value pair) for the given URL. 1072 * 1073 * @param { string } url - The URL for which the cookie is to be set. 1074 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1075 * @param { boolean } incognito - {@code true} set a single cookie (key-value pair) for the given URL 1076 * in incognito mode; {@code false} otherwise. 1077 * @throws { BusinessError } 401 - Invalid input parameter. 1078 * @throws { BusinessError } 17100002 - Invalid url. 1079 * @throws { BusinessError } 17100005 - Invalid cookie value. 1080 * @syscap SystemCapability.Web.Webview.Core 1081 * @atomicservice 1082 * @since 11 1083 */ 1084 static configCookieSync(url: string, value: string, incognito?: boolean): void; 1085 1086 /** 1087 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1088 * 1089 * @param { string } url - The URL for which the cookie is to be set. 1090 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1091 * @returns { Promise<void> } - A promise resolved after the cookies of given URL have been set. 1092 * @throws { BusinessError } 401 - Invalid input parameter. 1093 * @throws { BusinessError } 17100002 - Invalid url. 1094 * @throws { BusinessError } 17100005 - Invalid cookie value. 1095 * @syscap SystemCapability.Web.Webview.Core 1096 * @crossplatform 1097 * @atomicservice 1098 * @since 11 1099 */ 1100 static configCookie(url: string, value: string): Promise<void>; 1101 1102 /** 1103 * Set a single cookie (key-value pair) for the given URL Asynchronously. 1104 * 1105 * @param { string } url - The URL for which the cookie is to be set. 1106 * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header. 1107 * @param { AsyncCallback<void> } callback - Called after the cookies have been set. 1108 * @throws { BusinessError } 401 - Invalid input parameter. 1109 * @throws { BusinessError } 17100002 - Invalid url. 1110 * @throws { BusinessError } 17100005 - Invalid cookie value. 1111 * @syscap SystemCapability.Web.Webview.Core 1112 * @crossplatform 1113 * @atomicservice 1114 * @since 11 1115 */ 1116 static configCookie(url: string, value: string, callback: AsyncCallback<void>): void; 1117 1118 /** 1119 * Save the cookies Asynchronously. 1120 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1121 * @throws { BusinessError } 401 - Invalid input parameter. 1122 * @syscap SystemCapability.Web.Webview.Core 1123 * @since 9 1124 */ 1125 /** 1126 * Save the cookies Asynchronously. 1127 * @returns { Promise<void> } - A promise resolved after the cookies have been saved. 1128 * @throws { BusinessError } 401 - Invalid input parameter. 1129 * @syscap SystemCapability.Web.Webview.Core 1130 * @atomicservice 1131 * @since 11 1132 */ 1133 static saveCookieAsync(): Promise<void>; 1134 1135 /** 1136 * Save the cookies Asynchronously. 1137 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1138 * @throws { BusinessError } 401 - Invalid input parameter. 1139 * @syscap SystemCapability.Web.Webview.Core 1140 * @since 9 1141 */ 1142 /** 1143 * Save the cookies Asynchronously. 1144 * @param { AsyncCallback<void> } callback - Called after the cookies have been saved. 1145 * @throws { BusinessError } 401 - Invalid input parameter. 1146 * @syscap SystemCapability.Web.Webview.Core 1147 * @atomicservice 1148 * @since 11 1149 */ 1150 static saveCookieAsync(callback: AsyncCallback<void>): void; 1151 1152 /** 1153 * Get whether the instance can send and accept cookies. 1154 * 1155 * @returns { boolean } True if the instance can send and accept cookies else false. 1156 * @syscap SystemCapability.Web.Webview.Core 1157 * @since 9 1158 */ 1159 /** 1160 * Get whether the instance can send and accept cookies. 1161 * 1162 * @returns { boolean } True if the instance can send and accept cookies else false. 1163 * @syscap SystemCapability.Web.Webview.Core 1164 * @atomicservice 1165 * @since 11 1166 */ 1167 static isCookieAllowed(): boolean; 1168 1169 /** 1170 * Set whether the instance should send and accept cookies. 1171 * By default this is set to be true. 1172 * 1173 * @param { boolean } accept - Whether the instance should send and accept cookies. 1174 * @throws { BusinessError } 401 - Invalid input parameter. 1175 * @syscap SystemCapability.Web.Webview.Core 1176 * @since 9 1177 */ 1178 /** 1179 * Set whether the instance should send and accept cookies. 1180 * By default this is set to be true. 1181 * 1182 * @param { boolean } accept - Whether the instance should send and accept cookies. 1183 * @throws { BusinessError } 401 - Invalid input parameter. 1184 * @syscap SystemCapability.Web.Webview.Core 1185 * @atomicservice 1186 * @since 11 1187 */ 1188 static putAcceptCookieEnabled(accept: boolean): void; 1189 1190 /** 1191 * Get whether the instance can send and accept thirdparty cookies. 1192 * 1193 * @returns { boolean } True if the instance can send and accept thirdparty cookies else false. 1194 * @syscap SystemCapability.Web.Webview.Core 1195 * @since 9 1196 */ 1197 /** 1198 * Get whether the instance can send and accept thirdparty cookies. 1199 * 1200 * @returns { boolean } True if the instance can send and accept thirdparty cookies else false. 1201 * @syscap SystemCapability.Web.Webview.Core 1202 * @atomicservice 1203 * @since 11 1204 */ 1205 static isThirdPartyCookieAllowed(): boolean; 1206 1207 /** 1208 * Set whether the instance should send and accept thirdparty cookies. 1209 * By default this is set to be false. 1210 * 1211 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 1212 * @throws { BusinessError } 401 - Invalid input parameter. 1213 * @syscap SystemCapability.Web.Webview.Core 1214 * @since 9 1215 */ 1216 /** 1217 * Set whether the instance should send and accept thirdparty cookies. 1218 * By default this is set to be false. 1219 * 1220 * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies. 1221 * @throws { BusinessError } 401 - Invalid input parameter. 1222 * @syscap SystemCapability.Web.Webview.Core 1223 * @atomicservice 1224 * @since 11 1225 */ 1226 static putAcceptThirdPartyCookieEnabled(accept: boolean): void; 1227 1228 /** 1229 * Check whether exists any cookies. 1230 * 1231 * @returns { boolean } True if exists more than one cookie else false; 1232 * @syscap SystemCapability.Web.Webview.Core 1233 * @since 9 1234 */ 1235 /** 1236 * Check whether exists any cookies. 1237 * 1238 * @param { boolean } incognito - {@code true} check whether exists any cookies. 1239 * in incognito mode; {@code false} otherwise. 1240 * @returns { boolean } True if exists more than one cookie else false; 1241 * @syscap SystemCapability.Web.Webview.Core 1242 * @atomicservice 1243 * @since 11 1244 */ 1245 static existCookie(incognito?: boolean): boolean; 1246 1247 /** 1248 * Remove all cookies. 1249 * @syscap SystemCapability.Web.Webview.Core 1250 * @since 9 1251 * @deprecated since 11 1252 * @useinstead ohos.web.webview.WebCookieManager#clearAllCookiesSync 1253 */ 1254 static deleteEntireCookie(): void; 1255 1256 /** 1257 * Remove all cookies. 1258 * 1259 * @param { boolean } incognito - {@code true} remove all cookies in incognito mode; 1260 * {@code false} otherwise. 1261 * @syscap SystemCapability.Web.Webview.Core 1262 * @atomicservice 1263 * @since 11 1264 */ 1265 static clearAllCookiesSync(incognito?: boolean): void; 1266 1267 /** 1268 * Remove all cookies Asynchronously. 1269 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 1270 * @throws { BusinessError } 401 - Invalid input parameter. 1271 * @syscap SystemCapability.Web.Webview.Core 1272 * @crossplatform 1273 * @atomicservice 1274 * @since 11 1275 */ 1276 static clearAllCookies(): Promise<void>; 1277 1278 /** 1279 * Remove all cookies Asynchronously. 1280 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 1281 * @throws { BusinessError } 401 - Invalid input parameter. 1282 * @syscap SystemCapability.Web.Webview.Core 1283 * @crossplatform 1284 * @atomicservice 1285 * @since 11 1286 */ 1287 static clearAllCookies(callback: AsyncCallback<void>): void; 1288 1289 /** 1290 * Delete the session cookies. 1291 * @syscap SystemCapability.Web.Webview.Core 1292 * @since 9 1293 * @deprecated since 11 1294 * @useinstead ohos.web.webview.WebCookieManager#clearSessionCookieSync 1295 */ 1296 static deleteSessionCookie(): void; 1297 1298 /** 1299 * Delete the session cookies. 1300 * @syscap SystemCapability.Web.Webview.Core 1301 * @atomicservice 1302 * @since 11 1303 */ 1304 static clearSessionCookieSync(): void; 1305 1306 /** 1307 * Delete the session cookies Asynchronously. 1308 * @returns { Promise<void> } - A promise resolved after the cookies have been deleted. 1309 * @throws { BusinessError } 401 - Invalid input parameter. 1310 * @syscap SystemCapability.Web.Webview.Core 1311 * @atomicservice 1312 * @since 11 1313 */ 1314 static clearSessionCookie(): Promise<void>; 1315 1316 /** 1317 * Delete the session cookies Asynchronously. 1318 * @param { AsyncCallback<void> } callback - Called after the cookies have been deleted. 1319 * @throws { BusinessError } 401 - Invalid input parameter. 1320 * parameter. 1321 * @syscap SystemCapability.Web.Webview.Core 1322 * @atomicservice 1323 * @since 11 1324 */ 1325 static clearSessionCookie(callback: AsyncCallback<void>): void; 1326 } 1327 1328 /** 1329 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 1330 * 1331 * @enum {number} 1332 * @syscap SystemCapability.Web.Webview.Core 1333 * @since 10 1334 */ 1335 /** 1336 * Enum type supplied to {@link onMessageEventExt} for indicating the type of web message. 1337 * 1338 * @enum {number} 1339 * @syscap SystemCapability.Web.Webview.Core 1340 * @atomicservice 1341 * @since 11 1342 */ 1343 enum WebMessageType { 1344 /** 1345 * Unsupported data type. 1346 * 1347 * @syscap SystemCapability.Web.Webview.Core 1348 * @since 10 1349 */ 1350 /** 1351 * Unsupported data type. 1352 * 1353 * @syscap SystemCapability.Web.Webview.Core 1354 * @atomicservice 1355 * @since 11 1356 */ 1357 NOT_SUPPORT, 1358 1359 /** 1360 * The string data type. 1361 * 1362 * @syscap SystemCapability.Web.Webview.Core 1363 * @since 10 1364 */ 1365 /** 1366 * The string data type. 1367 * 1368 * @syscap SystemCapability.Web.Webview.Core 1369 * @atomicservice 1370 * @since 11 1371 */ 1372 STRING, 1373 1374 /** 1375 * The number data type. 1376 * 1377 * @syscap SystemCapability.Web.Webview.Core 1378 * @since 10 1379 */ 1380 /** 1381 * The number data type. 1382 * 1383 * @syscap SystemCapability.Web.Webview.Core 1384 * @atomicservice 1385 * @since 11 1386 */ 1387 NUMBER, 1388 1389 /** 1390 * The boolean data type. 1391 * 1392 * @syscap SystemCapability.Web.Webview.Core 1393 * @since 10 1394 */ 1395 /** 1396 * The boolean data type. 1397 * 1398 * @syscap SystemCapability.Web.Webview.Core 1399 * @atomicservice 1400 * @since 11 1401 */ 1402 BOOLEAN, 1403 1404 /** 1405 * The arraybuffer data type. 1406 * 1407 * @syscap SystemCapability.Web.Webview.Core 1408 * @since 10 1409 */ 1410 /** 1411 * The arraybuffer data type. 1412 * 1413 * @syscap SystemCapability.Web.Webview.Core 1414 * @atomicservice 1415 * @since 11 1416 */ 1417 ARRAY_BUFFER, 1418 1419 /** 1420 * The array data type. 1421 * 1422 * @syscap SystemCapability.Web.Webview.Core 1423 * @since 10 1424 */ 1425 /** 1426 * The array data type. 1427 * 1428 * @syscap SystemCapability.Web.Webview.Core 1429 * @atomicservice 1430 * @since 11 1431 */ 1432 ARRAY, 1433 1434 /** 1435 * The error data type. 1436 * 1437 * @syscap SystemCapability.Web.Webview.Core 1438 * @since 10 1439 */ 1440 /** 1441 * The error data type. 1442 * 1443 * @syscap SystemCapability.Web.Webview.Core 1444 * @atomicservice 1445 * @since 11 1446 */ 1447 ERROR 1448 } 1449 1450 /** 1451 * The message received or sent from web message port. 1452 * 1453 * @syscap SystemCapability.Web.Webview.Core 1454 * @since 10 1455 */ 1456 /** 1457 * The message received or sent from web message port. 1458 * 1459 * @syscap SystemCapability.Web.Webview.Core 1460 * @atomicservice 1461 * @since 11 1462 */ 1463 class WebMessageExt { 1464 /** 1465 * Get the type of the web message. 1466 * @returns { WebMessageType } - Returns data of WebMessageType type 1467 * @syscap SystemCapability.Web.Webview.Core 1468 * @since 10 1469 */ 1470 /** 1471 * Get the type of the web message. 1472 * @returns { WebMessageType } - Returns data of WebMessageType type 1473 * @syscap SystemCapability.Web.Webview.Core 1474 * @atomicservice 1475 * @since 11 1476 */ 1477 getType(): WebMessageType; 1478 1479 /** 1480 * Get the string value of the web message. 1481 * @returns { string } - Returns data of string type 1482 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1483 * 1484 * @syscap SystemCapability.Web.Webview.Core 1485 * @since 10 1486 */ 1487 /** 1488 * Get the string value of the web message. 1489 * @returns { string } - Returns data of string type 1490 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1491 * 1492 * @syscap SystemCapability.Web.Webview.Core 1493 * @atomicservice 1494 * @since 11 1495 */ 1496 getString(): string; 1497 1498 /** 1499 * Get the number value of the web message. 1500 * @returns { number } - Returns data of number type 1501 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1502 * 1503 * @syscap SystemCapability.Web.Webview.Core 1504 * @since 10 1505 */ 1506 /** 1507 * Get the number value of the web message. 1508 * @returns { number } - Returns data of number type 1509 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1510 * 1511 * @syscap SystemCapability.Web.Webview.Core 1512 * @atomicservice 1513 * @since 11 1514 */ 1515 getNumber(): number; 1516 1517 /** 1518 * Get the boolean value of the web message. 1519 * @returns { boolean } - Returns data of Boolean type 1520 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1521 * 1522 * @syscap SystemCapability.Web.Webview.Core 1523 * @since 10 1524 */ 1525 /** 1526 * Get the boolean value of the web message. 1527 * @returns { boolean } - Returns data of Boolean type 1528 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1529 * 1530 * @syscap SystemCapability.Web.Webview.Core 1531 * @atomicservice 1532 * @since 11 1533 */ 1534 getBoolean(): boolean; 1535 1536 /** 1537 * Get the array buffer value of the web message. 1538 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 1539 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1540 * 1541 * @syscap SystemCapability.Web.Webview.Core 1542 * @since 10 1543 */ 1544 /** 1545 * Get the array buffer value of the web message. 1546 * @returns { ArrayBuffer } - Returns data of ArrayBuffer type 1547 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1548 * 1549 * @syscap SystemCapability.Web.Webview.Core 1550 * @atomicservice 1551 * @since 11 1552 */ 1553 getArrayBuffer(): ArrayBuffer; 1554 1555 /** 1556 * Get the array value of the web message. 1557 * @returns { Array<string | number | boolean> } - Returns data of Array type 1558 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1559 * 1560 * @syscap SystemCapability.Web.Webview.Core 1561 * @since 10 1562 */ 1563 /** 1564 * Get the array value of the web message. 1565 * @returns { Array<string | number | boolean> } - Returns data of Array type 1566 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1567 * 1568 * @syscap SystemCapability.Web.Webview.Core 1569 * @atomicservice 1570 * @since 11 1571 */ 1572 getArray(): Array<string | number | boolean>; 1573 1574 /** 1575 * Get the error value of the web message. 1576 * @returns { Error } - Returns data of Error type 1577 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1578 * 1579 * @syscap SystemCapability.Web.Webview.Core 1580 * @since 10 1581 */ 1582 /** 1583 * Get the error value of the web message. 1584 * @returns { Error } - Returns data of Error type 1585 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1586 * 1587 * @syscap SystemCapability.Web.Webview.Core 1588 * @atomicservice 1589 * @since 11 1590 */ 1591 getError(): Error; 1592 1593 /** 1594 * Set the type of the web message. 1595 * @param { WebMessageType } type - set WebMessageType type data 1596 * @throws { BusinessError } 401 - Invalid input parameter. 1597 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1598 * 1599 * @syscap SystemCapability.Web.Webview.Core 1600 * @since 10 1601 */ 1602 /** 1603 * Set the type of the web message. 1604 * @param { WebMessageType } type - set WebMessageType type data 1605 * @throws { BusinessError } 401 - Invalid input parameter. 1606 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1607 * 1608 * @syscap SystemCapability.Web.Webview.Core 1609 * @atomicservice 1610 * @since 11 1611 */ 1612 setType(type: WebMessageType): void; 1613 1614 /** 1615 * Set the string value of the web message. 1616 * @param { string } message - set string type data 1617 * @throws { BusinessError } 401 - Invalid input parameter. 1618 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1619 * 1620 * @syscap SystemCapability.Web.Webview.Core 1621 * @since 10 1622 */ 1623 /** 1624 * Set the string value of the web message. 1625 * @param { string } message - set string type data 1626 * @throws { BusinessError } 401 - Invalid input parameter. 1627 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1628 * 1629 * @syscap SystemCapability.Web.Webview.Core 1630 * @atomicservice 1631 * @since 11 1632 */ 1633 setString(message: string): void; 1634 1635 /** 1636 * Set the number value of the web message. 1637 * @param { number } message - set number type data 1638 * @throws { BusinessError } 401 - Invalid input parameter. 1639 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1640 * 1641 * @syscap SystemCapability.Web.Webview.Core 1642 * @since 10 1643 */ 1644 /** 1645 * Set the number value of the web message. 1646 * @param { number } message - set number type data 1647 * @throws { BusinessError } 401 - Invalid input parameter. 1648 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1649 * 1650 * @syscap SystemCapability.Web.Webview.Core 1651 * @atomicservice 1652 * @since 11 1653 */ 1654 setNumber(message: number): void; 1655 1656 /** 1657 * Set the boolean value of the web message. 1658 * @param { boolean } message - set boolean type data 1659 * @throws { BusinessError } 401 - Invalid input parameter. 1660 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1661 * 1662 * @syscap SystemCapability.Web.Webview.Core 1663 * @since 10 1664 */ 1665 /** 1666 * Set the boolean value of the web message. 1667 * @param { boolean } message - set boolean type data 1668 * @throws { BusinessError } 401 - Invalid input parameter. 1669 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1670 * 1671 * @syscap SystemCapability.Web.Webview.Core 1672 * @atomicservice 1673 * @since 11 1674 */ 1675 setBoolean(message: boolean): void; 1676 1677 /** 1678 * Set the array buffer value of the web message. 1679 * @param { ArrayBuffer } message - set ArrayBuffer type data 1680 * @throws { BusinessError } 401 - Invalid input parameter. 1681 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1682 * 1683 * @syscap SystemCapability.Web.Webview.Core 1684 * @since 10 1685 */ 1686 /** 1687 * Set the array buffer value of the web message. 1688 * @param { ArrayBuffer } message - set ArrayBuffer type data 1689 * @throws { BusinessError } 401 - Invalid input parameter. 1690 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1691 * 1692 * @syscap SystemCapability.Web.Webview.Core 1693 * @atomicservice 1694 * @since 11 1695 */ 1696 setArrayBuffer(message: ArrayBuffer): void; 1697 1698 /** 1699 * Set the array value of the web message. 1700 * @param { Array<string | number | boolean> } message - set Array type data 1701 * @throws { BusinessError } 401 - Invalid input parameter. 1702 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1703 * @syscap SystemCapability.Web.Webview.Core 1704 * @since 10 1705 */ 1706 /** 1707 * Set the array value of the web message. 1708 * @param { Array<string | number | boolean> } message - set Array type data 1709 * @throws { BusinessError } 401 - Invalid input parameter. 1710 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1711 * @syscap SystemCapability.Web.Webview.Core 1712 * @atomicservice 1713 * @since 11 1714 */ 1715 setArray(message: Array<string | number | boolean>): void; 1716 1717 /** 1718 * Set the error value of the web message. 1719 * @param { Error } message - set Error type data 1720 * @throws { BusinessError } 401 - Invalid input parameter. 1721 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1722 * 1723 * @syscap SystemCapability.Web.Webview.Core 1724 * @since 10 1725 */ 1726 /** 1727 * Set the error value of the web message. 1728 * @param { Error } message - set Error type data 1729 * @throws { BusinessError } 401 - Invalid input parameter. 1730 * @throws { BusinessError } 17100014 - The type does not match with the value of the web message. 1731 * 1732 * @syscap SystemCapability.Web.Webview.Core 1733 * @atomicservice 1734 * @since 11 1735 */ 1736 setError(message: Error): void; 1737 } 1738 1739 /** 1740 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 1741 * 1742 * @syscap SystemCapability.Web.Webview.Core 1743 * @since 9 1744 */ 1745 /** 1746 * WebMessage type supplied to {@link onMessageEventExt} for indicating the type of web message. 1747 * 1748 * @syscap SystemCapability.Web.Webview.Core 1749 * @atomicservice 1750 * @since 11 1751 */ 1752 type WebMessage = ArrayBuffer | string; 1753 /** 1754 * Define html web message port. 1755 * @interface WebMessagePort 1756 * @syscap SystemCapability.Web.Webview.Core 1757 * @since 9 1758 */ 1759 /** 1760 * Define html web message port. 1761 * @interface WebMessagePort 1762 * @syscap SystemCapability.Web.Webview.Core 1763 * @crossplatform 1764 * @atomicservice 1765 * @since 11 1766 */ 1767 interface WebMessagePort { 1768 /** 1769 * The flag indicates whether more formats are supported than string and array buffers. 1770 * 1771 * @syscap SystemCapability.Web.Webview.Core 1772 * @since 10 1773 */ 1774 /** 1775 * The flag indicates whether more formats are supported than string and array buffers. 1776 * 1777 * @syscap SystemCapability.Web.Webview.Core 1778 * @atomicservice 1779 * @since 11 1780 */ 1781 isExtentionType?: boolean; 1782 1783 /** 1784 * Close port. 1785 * @syscap SystemCapability.Web.Webview.Core 1786 * @since 9 1787 */ 1788 /** 1789 * Close port. 1790 * @syscap SystemCapability.Web.Webview.Core 1791 * @crossplatform 1792 * @atomicservice 1793 * @since 11 1794 */ 1795 close(): void; 1796 1797 /** 1798 * Post a message to other port. 1799 * @param { WebMessage } message - Message to send. 1800 * @throws { BusinessError } 401 - Invalid input parameter. 1801 * @throws { BusinessError } 17100010 - Can not post message using this port. 1802 * @syscap SystemCapability.Web.Webview.Core 1803 * @since 9 1804 */ 1805 /** 1806 * Post a message to other port. 1807 * @param { WebMessage } message - Message to send. 1808 * @throws { BusinessError } 401 - Invalid input parameter. 1809 * @throws { BusinessError } 17100010 - Can not post message using this port. 1810 * @syscap SystemCapability.Web.Webview.Core 1811 * @crossplatform 1812 * @atomicservice 1813 * @since 11 1814 */ 1815 postMessageEvent(message: WebMessage): void; 1816 1817 /** 1818 * Receive message from other port. 1819 * @param { function } callback - Callback function for receiving messages. 1820 * @throws { BusinessError } 401 - Invalid input parameter. 1821 * @throws { BusinessError } 17100006 - Can not register message event using this port. 1822 * @syscap SystemCapability.Web.Webview.Core 1823 * @since 9 1824 */ 1825 /** 1826 * Receive message from other port. 1827 * @param { function } callback - Callback function for receiving messages. 1828 * @throws { BusinessError } 401 - Invalid input parameter. 1829 * @throws { BusinessError } 17100006 - Can not register message event using this port. 1830 * @syscap SystemCapability.Web.Webview.Core 1831 * @crossplatform 1832 * @atomicservice 1833 * @since 11 1834 */ 1835 onMessageEvent(callback: (result: WebMessage) => void): void; 1836 1837 /** 1838 * Post a message to other port. 1839 * @param { WebMessageExt } message - Message to send. 1840 * @throws { BusinessError } 401 - Invalid input parameter. 1841 * @throws { BusinessError } 17100010 - Can not post message using this port. 1842 * @syscap SystemCapability.Web.Webview.Core 1843 * @since 10 1844 */ 1845 /** 1846 * Post a message to other port. 1847 * @param { WebMessageExt } message - Message to send. 1848 * @throws { BusinessError } 401 - Invalid input parameter. 1849 * @throws { BusinessError } 17100010 - Can not post message using this port. 1850 * @syscap SystemCapability.Web.Webview.Core 1851 * @atomicservice 1852 * @since 11 1853 */ 1854 postMessageEventExt(message: WebMessageExt): void; 1855 1856 /** 1857 * Receive message from other port. 1858 * @param { function } callback - Callback function for receiving messages. 1859 * @throws { BusinessError } 401 - Invalid input parameter. 1860 * @throws { BusinessError } 17100006 - Can not register message event using this port. 1861 * @syscap SystemCapability.Web.Webview.Core 1862 * @since 10 1863 */ 1864 /** 1865 * Receive message from other port. 1866 * @param { function } callback - Callback function for receiving messages. 1867 * @throws { BusinessError } 401 - Invalid input parameter. 1868 * @throws { BusinessError } 17100006 - Can not register message event using this port. 1869 * @syscap SystemCapability.Web.Webview.Core 1870 * @atomicservice 1871 * @since 11 1872 */ 1873 onMessageEventExt(callback: (result: WebMessageExt) => void): void; 1874 } 1875 1876 /** 1877 * Provides information for history item in BackForwardList. 1878 * @interface HistoryItem 1879 * @syscap SystemCapability.Web.Webview.Core 1880 * @since 9 1881 */ 1882 /** 1883 * Provides information for history item in BackForwardList. 1884 * @interface HistoryItem 1885 * @syscap SystemCapability.Web.Webview.Core 1886 * @crossplatform 1887 * @atomicservice 1888 * @since 11 1889 */ 1890 interface HistoryItem { 1891 /** 1892 * Pixelmap of icon. 1893 * @syscap SystemCapability.Web.Webview.Core 1894 * @since 9 1895 */ 1896 /** 1897 * Pixelmap of icon. 1898 * @syscap SystemCapability.Web.Webview.Core 1899 * @atomicservice 1900 * @since 11 1901 */ 1902 icon: image.PixelMap; 1903 1904 /** 1905 * Url of this history item. 1906 * @syscap SystemCapability.Web.Webview.Core 1907 * @since 9 1908 */ 1909 /** 1910 * Url of this history item. 1911 * @syscap SystemCapability.Web.Webview.Core 1912 * @crossplatform 1913 * @atomicservice 1914 * @since 11 1915 */ 1916 historyUrl: string; 1917 1918 /** 1919 * Original request url of this history item. 1920 * @syscap SystemCapability.Web.Webview.Core 1921 * @since 9 1922 */ 1923 /** 1924 * Original request url of this history item. 1925 * @syscap SystemCapability.Web.Webview.Core 1926 * @crossplatform 1927 * @atomicservice 1928 * @since 11 1929 */ 1930 historyRawUrl: string; 1931 1932 /** 1933 * Title of this history item. 1934 * @syscap SystemCapability.Web.Webview.Core 1935 * @since 9 1936 */ 1937 /** 1938 * Title of this history item. 1939 * @syscap SystemCapability.Web.Webview.Core 1940 * @crossplatform 1941 * @atomicservice 1942 * @since 11 1943 */ 1944 title: string; 1945 } 1946 1947 /** 1948 * Provides back and forward history list information method. related to {@link HistoryItem}. 1949 * @interface BackForwardList 1950 * @syscap SystemCapability.Web.Webview.Core 1951 * @since 9 1952 */ 1953 /** 1954 * Provides back and forward history list information method. related to {@link HistoryItem}. 1955 * @interface BackForwardList 1956 * @syscap SystemCapability.Web.Webview.Core 1957 * @crossplatform 1958 * @atomicservice 1959 * @since 11 1960 */ 1961 interface BackForwardList { 1962 /** 1963 * Current index in BackForwardList. 1964 * @syscap SystemCapability.Web.Webview.Core 1965 * @since 9 1966 */ 1967 /** 1968 * Current index in BackForwardList. 1969 * @syscap SystemCapability.Web.Webview.Core 1970 * @crossplatform 1971 * @atomicservice 1972 * @since 11 1973 */ 1974 currentIndex: number; 1975 1976 /** 1977 * Size of in BackForwardList. 1978 * @syscap SystemCapability.Web.Webview.Core 1979 * @since 9 1980 */ 1981 /** 1982 * Size of in BackForwardList. 1983 * @syscap SystemCapability.Web.Webview.Core 1984 * @crossplatform 1985 * @atomicservice 1986 * @since 11 1987 */ 1988 size: number; 1989 1990 /** 1991 * Get history entry at given index. 1992 * 1993 * @param { number } index Index of back forward list entry. 1994 * @returns { HistoryItem } HistoryItem at given index in back forward list. 1995 * @throws { BusinessError } 401 - Invalid input parameter. 1996 * @syscap SystemCapability.Web.Webview.Core 1997 * @since 9 1998 */ 1999 /** 2000 * Get history entry at given index. 2001 * 2002 * @param { number } index Index of back forward list entry. 2003 * @returns { HistoryItem } HistoryItem at given index in back forward list. 2004 * @throws { BusinessError } 401 - Invalid input parameter. 2005 * @syscap SystemCapability.Web.Webview.Core 2006 * @crossplatform 2007 * @atomicservice 2008 * @since 11 2009 */ 2010 getItemAtIndex(index: number): HistoryItem; 2011 } 2012 2013 /** 2014 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 2015 * @enum {number} 2016 * @syscap SystemCapability.Web.Webview.Core 2017 * @since 10 2018 */ 2019 /** 2020 * Enum type supplied to {@link runJavaScriptExt} for indicating the result of JavaScript code execution. 2021 * @enum {number} 2022 * @syscap SystemCapability.Web.Webview.Core 2023 * @atomicservice 2024 * @since 11 2025 */ 2026 enum JsMessageType { 2027 /** 2028 * Unsupported data type. 2029 * @syscap SystemCapability.Web.Webview.Core 2030 * @since 10 2031 */ 2032 /** 2033 * Unsupported data type. 2034 * @syscap SystemCapability.Web.Webview.Core 2035 * @atomicservice 2036 * @since 11 2037 */ 2038 NOT_SUPPORT, 2039 2040 /** 2041 * The string data type. 2042 * @syscap SystemCapability.Web.Webview.Core 2043 * @since 10 2044 */ 2045 /** 2046 * The string data type. 2047 * @syscap SystemCapability.Web.Webview.Core 2048 * @atomicservice 2049 * @since 11 2050 */ 2051 STRING, 2052 2053 /** 2054 * The number data type. 2055 * @syscap SystemCapability.Web.Webview.Core 2056 * @since 10 2057 */ 2058 /** 2059 * The number data type. 2060 * @syscap SystemCapability.Web.Webview.Core 2061 * @atomicservice 2062 * @since 11 2063 */ 2064 NUMBER, 2065 2066 /** 2067 * The boolean data type. 2068 * @syscap SystemCapability.Web.Webview.Core 2069 * @since 10 2070 */ 2071 /** 2072 * The boolean data type. 2073 * @syscap SystemCapability.Web.Webview.Core 2074 * @atomicservice 2075 * @since 11 2076 */ 2077 BOOLEAN, 2078 2079 /** 2080 * The arraybuffer data type. 2081 * @syscap SystemCapability.Web.Webview.Core 2082 * @since 10 2083 */ 2084 /** 2085 * The arraybuffer data type. 2086 * @syscap SystemCapability.Web.Webview.Core 2087 * @atomicservice 2088 * @since 11 2089 */ 2090 ARRAY_BUFFER, 2091 2092 /** 2093 * The array data type. 2094 * @syscap SystemCapability.Web.Webview.Core 2095 * @since 10 2096 */ 2097 /** 2098 * The array data type. 2099 * @syscap SystemCapability.Web.Webview.Core 2100 * @atomicservice 2101 * @since 11 2102 */ 2103 ARRAY 2104 } 2105 2106 /** 2107 * The message for indicating the of result of JavaScript code execution. 2108 * @syscap SystemCapability.Web.Webview.Core 2109 * @since 10 2110 */ 2111 /** 2112 * The message for indicating the of result of JavaScript code execution. 2113 * @syscap SystemCapability.Web.Webview.Core 2114 * @atomicservice 2115 * @since 11 2116 */ 2117 class JsMessageExt { 2118 /** 2119 * Get the type of the JavaScript code execution result. 2120 * @returns { JsMessageType } - Returns data of JsMessageType type 2121 * @syscap SystemCapability.Web.Webview.Core 2122 * @since 10 2123 */ 2124 /** 2125 * Get the type of the JavaScript code execution result. 2126 * @returns { JsMessageType } - Returns data of JsMessageType type 2127 * @syscap SystemCapability.Web.Webview.Core 2128 * @atomicservice 2129 * @since 11 2130 */ 2131 getType(): JsMessageType; 2132 2133 /** 2134 * Get the string value of the JavaScript code execution result. 2135 * @returns { string } - Returns data of string type 2136 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2137 * @syscap SystemCapability.Web.Webview.Core 2138 * @since 10 2139 */ 2140 /** 2141 * Get the string value of the JavaScript code execution result. 2142 * @returns { string } - Returns data of string type 2143 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2144 * @syscap SystemCapability.Web.Webview.Core 2145 * @atomicservice 2146 * @since 11 2147 */ 2148 getString(): string; 2149 2150 /** 2151 * Get the number value of the JavaScript code execution result. 2152 * @returns { number } - Returns data of number type 2153 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2154 * @syscap SystemCapability.Web.Webview.Core 2155 * @since 10 2156 */ 2157 /** 2158 * Get the number value of the JavaScript code execution result. 2159 * @returns { number } - Returns data of number type 2160 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2161 * @syscap SystemCapability.Web.Webview.Core 2162 * @atomicservice 2163 * @since 11 2164 */ 2165 getNumber(): number; 2166 2167 /** 2168 * Get the boolean value of the JavaScript code execution result. 2169 * @returns { boolean } - Returns data of Boolean type 2170 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2171 * @syscap SystemCapability.Web.Webview.Core 2172 * @since 10 2173 */ 2174 /** 2175 * Get the boolean value of the JavaScript code execution result. 2176 * @returns { boolean } - Returns data of Boolean type 2177 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2178 * @syscap SystemCapability.Web.Webview.Core 2179 * @atomicservice 2180 * @since 11 2181 */ 2182 getBoolean(): boolean; 2183 2184 /** 2185 * Get the array buffer value of the JavaScript code execution result. 2186 * @returns { ArrayBuffer } - Returns data of ArrayBuffer 2187 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2188 * @syscap SystemCapability.Web.Webview.Core 2189 * @since 10 2190 */ 2191 /** 2192 * Get the array buffer value of the JavaScript code execution result. 2193 * @returns { ArrayBuffer } - Returns data of ArrayBuffer 2194 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2195 * @syscap SystemCapability.Web.Webview.Core 2196 * @atomicservice 2197 * @since 11 2198 */ 2199 getArrayBuffer(): ArrayBuffer; 2200 2201 /** 2202 * Get the array value of the the JavaScript code execution result. 2203 * @returns { Array<string | number | boolean> } - Returns data of Array type 2204 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2205 * @syscap SystemCapability.Web.Webview.Core 2206 * @since 10 2207 */ 2208 /** 2209 * Get the array value of the the JavaScript code execution result. 2210 * @returns { Array<string | number | boolean> } - Returns data of Array type 2211 * @throws { BusinessError } 17100014 - The type does not match with the value of the result. 2212 * @syscap SystemCapability.Web.Webview.Core 2213 * @atomicservice 2214 * @since 11 2215 */ 2216 getArray(): Array<string | number | boolean>; 2217 } 2218 2219 /** 2220 * Provides methods for controlling the web controller. 2221 * @syscap SystemCapability.Web.Webview.Core 2222 * @since 9 2223 */ 2224 /** 2225 * Provides methods for controlling the web controller. 2226 * @syscap SystemCapability.Web.Webview.Core 2227 * @crossplatform 2228 * @since 10 2229 */ 2230 /** 2231 * Provides methods for controlling the web controller. 2232 * @syscap SystemCapability.Web.Webview.Core 2233 * @crossplatform 2234 * @atomicservice 2235 * @since 11 2236 */ 2237 class WebviewController { 2238 /** 2239 * A constructor used to create a WebviewController object. 2240 * 2241 * @param { string } [webTag] - specified the name of the web component, Empty by default. 2242 * @syscap SystemCapability.Web.Webview.Core 2243 * @atomicservice 2244 * @since 11 2245 */ 2246 constructor(webTag?: string); 2247 2248 /** 2249 * Initialize the web engine before loading the Web components. 2250 * This is a global static API that must be called on the UI thread, and it will have no effect if any 2251 * Web components are loaded. 2252 * @syscap SystemCapability.Web.Webview.Core 2253 * @since 9 2254 */ 2255 /** 2256 * Initialize the web engine before loading the Web components. 2257 * This is a global static API that must be called on the UI thread, and it will have no effect if any 2258 * Web components are loaded. 2259 * @syscap SystemCapability.Web.Webview.Core 2260 * @atomicservice 2261 * @since 11 2262 */ 2263 static initializeWebEngine(): void; 2264 2265 /** 2266 * Set web engine to use HttpDns server to resolve dns. 2267 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 2268 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 2269 * Must be https protocol and only allow one server to be configured. 2270 * @throws { BusinessError } 401 - Invalid input parameter. 2271 * @syscap SystemCapability.Web.Webview.Core 2272 * @since 10 2273 */ 2274 /** 2275 * Set web engine to use HttpDns server to resolve dns. 2276 * @param { SecureDnsMode } secureDnsMode - using HttpDns. 2277 * @param { string } secureDnsConfig - The configuration of the HttpDns server. 2278 * Must be https protocol and only allow one server to be configured. 2279 * @throws { BusinessError } 401 - Invalid input parameter. 2280 * @syscap SystemCapability.Web.Webview.Core 2281 * @atomicservice 2282 * @since 11 2283 */ 2284 static setHttpDns(secureDnsMode: SecureDnsMode, secureDnsConfig: string): void; 2285 2286 /** 2287 * Enables debugging of web contents. 2288 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 2289 * @throws { BusinessError } 401 - Invalid input parameter. 2290 * @syscap SystemCapability.Web.Webview.Core 2291 * @since 9 2292 */ 2293 /** 2294 * Enables debugging of web contents. 2295 * @param { boolean } webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise. 2296 * @throws { BusinessError } 401 - Invalid input parameter. 2297 * @syscap SystemCapability.Web.Webview.Core 2298 * @atomicservice 2299 * @since 11 2300 */ 2301 static setWebDebuggingAccess(webDebuggingAccess: boolean): void; 2302 2303 /** 2304 * Enable the ability to check website security risks. 2305 * Illegal and fraudulent websites are mandatory enabled and can't be disabled by this function. 2306 * @param { boolean } enable - {@code true} enable check the website security risks; {@code false} otherwise. 2307 * @throws { BusinessError } 401 - Invalid input parameter. 2308 * @syscap SystemCapability.Web.Webview.Core 2309 * @atomicservice 2310 * @since 11 2311 */ 2312 enableSafeBrowsing(enable: boolean): void; 2313 2314 /** 2315 * Get whether checking website security risks is enabled. 2316 * @returns { boolean } True if enable the ability to check website security risks else false. 2317 * @syscap SystemCapability.Web.Webview.Core 2318 * @atomicservice 2319 * @since 11 2320 */ 2321 isSafeBrowsingEnabled(): boolean; 2322 2323 /** 2324 * Checks whether the web page can go forward. 2325 * @returns { boolean } True if the web page can go forward else false. 2326 * @throws { BusinessError } 17100001 - Init error. 2327 * The WebviewController must be associated with a Web component. 2328 * @syscap SystemCapability.Web.Webview.Core 2329 * @since 9 2330 */ 2331 /** 2332 * Checks whether the web page can go forward. 2333 * @returns { boolean } True if the web page can go forward else false. 2334 * @throws { BusinessError } 17100001 - Init error. 2335 * The WebviewController must be associated with a Web component. 2336 * @syscap SystemCapability.Web.Webview.Core 2337 * @crossplatform 2338 * @atomicservice 2339 * @since 11 2340 */ 2341 accessForward(): boolean; 2342 2343 /** 2344 * Checks whether the web page can go back. 2345 * @returns { boolean } True if the web page can go back else false. 2346 * @throws { BusinessError } 17100001 - Init error. 2347 * The WebviewController must be associated with a Web component. 2348 * @syscap SystemCapability.Web.Webview.Core 2349 * @since 9 2350 */ 2351 /** 2352 * Checks whether the web page can go back. 2353 * @returns { boolean } True if the web page can go back else false. 2354 * @throws { BusinessError } 17100001 - Init error. 2355 * The WebviewController must be associated with a Web component. 2356 * @syscap SystemCapability.Web.Webview.Core 2357 * @crossplatform 2358 * @atomicservice 2359 * @since 11 2360 */ 2361 accessBackward(): boolean; 2362 2363 /** 2364 * Checks whether the web page can go back or forward the given number of steps. 2365 * 2366 * @param { number } step - The number of steps. 2367 * @returns { boolean } True if the web page can go back else false. 2368 * @throws { BusinessError } 401 - Invalid input parameter. 2369 * @throws { BusinessError } 17100001 - Init error. 2370 * The WebviewController must be associated with a Web component. 2371 * @syscap SystemCapability.Web.Webview.Core 2372 * @since 9 2373 */ 2374 /** 2375 * Checks whether the web page can go back or forward the given number of steps. 2376 * 2377 * @param { number } step - The number of steps. 2378 * @returns { boolean } True if the web page can go back else false. 2379 * @throws { BusinessError } 401 - Invalid input parameter. 2380 * @throws { BusinessError } 17100001 - Init error. 2381 * The WebviewController must be associated with a Web component. 2382 * @syscap SystemCapability.Web.Webview.Core 2383 * @crossplatform 2384 * @atomicservice 2385 * @since 11 2386 */ 2387 accessStep(step: number): boolean; 2388 2389 /** 2390 * Goes forward in the history of the web page. 2391 * 2392 * @throws { BusinessError } 17100001 - Init error. 2393 * The WebviewController must be associated with a Web component. 2394 * @syscap SystemCapability.Web.Webview.Core 2395 * @since 9 2396 */ 2397 /** 2398 * Goes forward in the history of the web page. 2399 * 2400 * @throws { BusinessError } 17100001 - Init error. 2401 * The WebviewController must be associated with a Web component. 2402 * @syscap SystemCapability.Web.Webview.Core 2403 * @crossplatform 2404 * @atomicservice 2405 * @since 11 2406 */ 2407 forward(): void; 2408 2409 /** 2410 * Goes back in the history of the web page. 2411 * 2412 * @throws { BusinessError } 17100001 - Init error. 2413 * The WebviewController must be associated with a Web component. 2414 * @syscap SystemCapability.Web.Webview.Core 2415 * @since 9 2416 */ 2417 /** 2418 * Goes back in the history of the web page. 2419 * 2420 * @throws { BusinessError } 17100001 - Init error. 2421 * The WebviewController must be associated with a Web component. 2422 * @syscap SystemCapability.Web.Webview.Core 2423 * @crossplatform 2424 * @atomicservice 2425 * @since 11 2426 */ 2427 backward(): void; 2428 2429 /** 2430 * Clears the history in the Web. 2431 * 2432 * @throws { BusinessError } 17100001 - Init error. 2433 * The WebviewController must be associated with a Web component. 2434 * @syscap SystemCapability.Web.Webview.Core 2435 * @since 9 2436 */ 2437 /** 2438 * Clears the history in the Web. 2439 * 2440 * @throws { BusinessError } 17100001 - Init error. 2441 * The WebviewController must be associated with a Web component. 2442 * @syscap SystemCapability.Web.Webview.Core 2443 * @crossplatform 2444 * @atomicservice 2445 * @since 11 2446 */ 2447 clearHistory(): void; 2448 2449 /** 2450 * Let the Web active. 2451 * 2452 * @throws { BusinessError } 17100001 - Init error. 2453 * The WebviewController must be associated with a Web component. 2454 * @syscap SystemCapability.Web.Webview.Core 2455 * @since 9 2456 */ 2457 /** 2458 * Let the Web active. 2459 * 2460 * @throws { BusinessError } 17100001 - Init error. 2461 * The WebviewController must be associated with a Web component. 2462 * @syscap SystemCapability.Web.Webview.Core 2463 * @atomicservice 2464 * @since 11 2465 */ 2466 onActive(): void; 2467 2468 /** 2469 * Let the Web inactive. 2470 * 2471 * @throws { BusinessError } 17100001 - Init error. 2472 * The WebviewController must be associated with a Web component. 2473 * @syscap SystemCapability.Web.Webview.Core 2474 * @since 9 2475 */ 2476 /** 2477 * Let the Web inactive. 2478 * 2479 * @throws { BusinessError } 17100001 - Init error. 2480 * The WebviewController must be associated with a Web component. 2481 * @syscap SystemCapability.Web.Webview.Core 2482 * @atomicservice 2483 * @since 11 2484 */ 2485 onInactive(): void; 2486 2487 /** 2488 * Refreshes the current URL. 2489 * 2490 * @throws { BusinessError } 17100001 - Init error. 2491 * The WebviewController must be associated with a Web component. 2492 * @syscap SystemCapability.Web.Webview.Core 2493 * @since 9 2494 */ 2495 /** 2496 * Refreshes the current URL. 2497 * 2498 * @throws { BusinessError } 17100001 - Init error. 2499 * The WebviewController must be associated with a Web component. 2500 * @syscap SystemCapability.Web.Webview.Core 2501 * @crossplatform 2502 * @atomicservice 2503 * @since 11 2504 */ 2505 refresh(): void; 2506 2507 /** 2508 * Loads the data or URL. 2509 * 2510 * @param { string } data - A string encoded according to "Base64" or "URL". 2511 * @param { string } mimeType - Media type. For example: "text/html". 2512 * @param { string } encoding - Encoding type. For example: "UTF-8". 2513 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 2514 * which is assigned to window.origin by the Web component. 2515 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 2516 * history records to realize the back and forth function. 2517 * This property is invalid when baseUrl is empty. 2518 * @throws { BusinessError } 401 - Invalid input parameter. 2519 * @throws { BusinessError } 17100001 - Init error. 2520 * The WebviewController must be associated with a Web component. 2521 * @throws { BusinessError } 17100002 - Invalid url. 2522 * @syscap SystemCapability.Web.Webview.Core 2523 * @since 9 2524 */ 2525 /** 2526 * Loads the data or URL. 2527 * 2528 * @param { string } data - A string encoded according to "Base64" or "URL". 2529 * @param { string } mimeType - Media type. For example: "text/html". 2530 * @param { string } encoding - Encoding type. For example: "UTF-8". 2531 * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol), 2532 * which is assigned to window.origin by the Web component. 2533 * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by 2534 * history records to realize the back and forth function. 2535 * This property is invalid when baseUrl is empty. 2536 * @throws { BusinessError } 401 - Invalid input parameter. 2537 * @throws { BusinessError } 17100001 - Init error. 2538 * The WebviewController must be associated with a Web component. 2539 * @syscap SystemCapability.Web.Webview.Core 2540 * @crossplatform 2541 * @atomicservice 2542 * @since 11 2543 */ 2544 loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string): void; 2545 2546 /** 2547 * Loads the data or URL. 2548 * 2549 * @param { string | Resource } url - The URL to load. 2550 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 2551 * @throws { BusinessError } 401 - Invalid input parameter. 2552 * @throws { BusinessError } 17100001 - Init error. 2553 * The WebviewController must be associated with a Web component. 2554 * @throws { BusinessError } 17100002 - Invalid url. 2555 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 2556 * @syscap SystemCapability.Web.Webview.Core 2557 * @since 9 2558 */ 2559 /** 2560 * Loads the data or URL. 2561 * 2562 * @param { string | Resource } url - The URL to load. 2563 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 2564 * @throws { BusinessError } 401 - Invalid input parameter. 2565 * @throws { BusinessError } 17100001 - Init error. 2566 * The WebviewController must be associated with a Web component. 2567 * @throws { BusinessError } 17100002 - Invalid url. 2568 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 2569 * @syscap SystemCapability.Web.Webview.Core 2570 * @crossplatform 2571 * @since 10 2572 */ 2573 /** 2574 * Loads the data or URL. 2575 * 2576 * @param { string | Resource } url - The URL to load. 2577 * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL. 2578 * @throws { BusinessError } 401 - Invalid input parameter. 2579 * @throws { BusinessError } 17100001 - Init error. 2580 * The WebviewController must be associated with a Web component. 2581 * @throws { BusinessError } 17100002 - Invalid url. 2582 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 2583 * @syscap SystemCapability.Web.Webview.Core 2584 * @crossplatform 2585 * @atomicservice 2586 * @since 11 2587 */ 2588 loadUrl(url: string | Resource, headers?: Array<WebHeader>): void; 2589 2590 /** 2591 * Gets the type of HitTest. 2592 * @returns { WebHitTestType } The type of HitTest. 2593 * @throws { BusinessError } 17100001 - Init error. 2594 * The WebviewController must be associated with a Web component. 2595 * @syscap SystemCapability.Web.Webview.Core 2596 * @since 9 2597 */ 2598 /** 2599 * Gets the type of HitTest. 2600 * @returns { WebHitTestType } The type of HitTest. 2601 * @throws { BusinessError } 17100001 - Init error. 2602 * The WebviewController must be associated with a Web component. 2603 * @syscap SystemCapability.Web.Webview.Core 2604 * @atomicservice 2605 * @since 11 2606 */ 2607 getHitTest(): WebHitTestType; 2608 2609 /** 2610 * Stores the current page as a web archive. 2611 * 2612 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 2613 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 2614 * stored by the file name of baseName. If true, the file name is 2615 * automatically generated based on the current URL and stored in the file 2616 * directory of baseName. 2617 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 2618 * will either be the filename under which the file was stored, or empty 2619 * if storing the file failed. 2620 * @throws { BusinessError } 401 - Invalid input parameter. 2621 * @throws { BusinessError } 17100001 - Init error. 2622 * The WebviewController must be associated with a Web component. 2623 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 2624 * @syscap SystemCapability.Web.Webview.Core 2625 * @since 9 2626 */ 2627 /** 2628 * Stores the current page as a web archive. 2629 * 2630 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 2631 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 2632 * stored by the file name of baseName. If true, the file name is 2633 * automatically generated based on the current URL and stored in the file 2634 * directory of baseName. 2635 * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter 2636 * will either be the filename under which the file was stored, or empty 2637 * if storing the file failed. 2638 * @throws { BusinessError } 401 - Invalid input parameter. 2639 * @throws { BusinessError } 17100001 - Init error. 2640 * The WebviewController must be associated with a Web component. 2641 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 2642 * @syscap SystemCapability.Web.Webview.Core 2643 * @atomicservice 2644 * @since 11 2645 */ 2646 storeWebArchive(baseName: string, autoName: boolean): Promise<string>; 2647 2648 /** 2649 * Stores the current page as a web archive. 2650 * 2651 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 2652 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 2653 * stored by the file name of baseName. If true, the file name is 2654 * automatically generated based on the current URL and stored in the file 2655 * directory of baseName. 2656 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 2657 * will either be the filename under which the file was stored, 2658 * or empty if storing the file failed. 2659 * @throws { BusinessError } 401 - Invalid input parameter. 2660 * @throws { BusinessError } 17100001 - Init error. 2661 * The WebviewController must be associated with a Web component. 2662 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 2663 * @syscap SystemCapability.Web.Webview.Core 2664 * @since 9 2665 */ 2666 /** 2667 * Stores the current page as a web archive. 2668 * 2669 * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null. 2670 * @param { boolean } autoName - Decide whether to automatically generate the file name. If false, it is 2671 * stored by the file name of baseName. If true, the file name is 2672 * automatically generated based on the current URL and stored in the file 2673 * directory of baseName. 2674 * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter 2675 * will either be the filename under which the file was stored, 2676 * or empty if storing the file failed. 2677 * @throws { BusinessError } 401 - Invalid input parameter. 2678 * @throws { BusinessError } 17100001 - Init error. 2679 * The WebviewController must be associated with a Web component. 2680 * @throws { BusinessError } 17100003 - Invalid resource path or file type. 2681 * @syscap SystemCapability.Web.Webview.Core 2682 * @atomicservice 2683 * @since 11 2684 */ 2685 storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback<string>): void; 2686 2687 /** 2688 * Let the Web zoom by. 2689 * 2690 * @param { number } factor - The zoom factor. 2691 * @throws { BusinessError } 401 - Invalid input parameter. 2692 * @throws { BusinessError } 17100001 - Init error. 2693 * The WebviewController must be associated with a Web component. 2694 * @throws { BusinessError } 17100004 - Function not enable. 2695 * @syscap SystemCapability.Web.Webview.Core 2696 * @since 9 2697 */ 2698 /** 2699 * Let the Web zoom by. 2700 * 2701 * @param { number } factor - The zoom factor. 2702 * @throws { BusinessError } 401 - Invalid input parameter. 2703 * @throws { BusinessError } 17100001 - Init error. 2704 * The WebviewController must be associated with a Web component. 2705 * @throws { BusinessError } 17100004 - Function not enable. 2706 * @syscap SystemCapability.Web.Webview.Core 2707 * @crossplatform 2708 * @atomicservice 2709 * @since 11 2710 */ 2711 zoom(factor: number): void; 2712 2713 /** 2714 * Let the Web zoom in. 2715 * 2716 * @throws { BusinessError } 17100001 - Init error. 2717 * The WebviewController must be associated with a Web component. 2718 * @throws { BusinessError } 17100004 - Function not enable. 2719 * @syscap SystemCapability.Web.Webview.Core 2720 * @since 9 2721 */ 2722 /** 2723 * Let the Web zoom in. 2724 * 2725 * @throws { BusinessError } 17100001 - Init error. 2726 * The WebviewController must be associated with a Web component. 2727 * @throws { BusinessError } 17100004 - Function not enable. 2728 * @syscap SystemCapability.Web.Webview.Core 2729 * @atomicservice 2730 * @since 11 2731 */ 2732 zoomIn(): void; 2733 2734 /** 2735 * Let the Web zoom out. 2736 * 2737 * @throws { BusinessError } 17100001 - Init error. 2738 * The WebviewController must be associated with a Web component. 2739 * @throws { BusinessError } 17100004 - Function not enable. 2740 * @syscap SystemCapability.Web.Webview.Core 2741 * @since 9 2742 */ 2743 /** 2744 * Let the Web zoom out. 2745 * 2746 * @throws { BusinessError } 17100001 - Init error. 2747 * The WebviewController must be associated with a Web component. 2748 * @throws { BusinessError } 17100004 - Function not enable. 2749 * @syscap SystemCapability.Web.Webview.Core 2750 * @atomicservice 2751 * @since 11 2752 */ 2753 zoomOut(): void; 2754 2755 /** 2756 * Gets the hit test value of HitTest. 2757 * @returns { HitTestValue } Return the element information of the clicked area. 2758 * @throws { BusinessError } 17100001 - Init error. 2759 * The WebviewController must be associated with a Web component. 2760 * @syscap SystemCapability.Web.Webview.Core 2761 * @since 9 2762 */ 2763 /** 2764 * Gets the hit test value of HitTest. 2765 * @returns { HitTestValue } Return the element information of the clicked area. 2766 * @throws { BusinessError } 17100001 - Init error. 2767 * The WebviewController must be associated with a Web component. 2768 * @syscap SystemCapability.Web.Webview.Core 2769 * @atomicservice 2770 * @since 11 2771 */ 2772 getHitTestValue(): HitTestValue; 2773 2774 /** 2775 * Gets the id for the current Web. 2776 * @returns { number } Returns the index value of the current Web component. 2777 * @throws { BusinessError } 17100001 - Init error. 2778 * The WebviewController must be associated with a Web component. 2779 * @syscap SystemCapability.Web.Webview.Core 2780 * @since 9 2781 */ 2782 /** 2783 * Gets the id for the current Web. 2784 * @returns { number } Returns the index value of the current Web component. 2785 * @throws { BusinessError } 17100001 - Init error. 2786 * The WebviewController must be associated with a Web component. 2787 * @syscap SystemCapability.Web.Webview.Core 2788 * @atomicservice 2789 * @since 11 2790 */ 2791 getWebId(): number; 2792 2793 /** 2794 * Gets the default user agent. 2795 * @returns { string } Return user agent information. 2796 * @throws { BusinessError } 17100001 - Init error. 2797 * The WebviewController must be associated with a Web component. 2798 * @syscap SystemCapability.Web.Webview.Core 2799 * @since 9 2800 */ 2801 /** 2802 * Gets the default user agent. 2803 * @returns { string } Return user agent information. 2804 * @throws { BusinessError } 17100001 - Init error. 2805 * The WebviewController must be associated with a Web component. 2806 * @syscap SystemCapability.Web.Webview.Core 2807 * @atomicservice 2808 * @since 11 2809 */ 2810 getUserAgent(): string; 2811 2812 /** 2813 * Gets the title of current Web page. 2814 * @returns { string } Return to File Selector Title. 2815 * @throws { BusinessError } 17100001 - Init error. 2816 * The WebviewController must be associated with a Web component. 2817 * @syscap SystemCapability.Web.Webview.Core 2818 * @since 9 2819 */ 2820 /** 2821 * Gets the title of current Web page. 2822 * @returns { string } Return to File Selector Title. 2823 * @throws { BusinessError } 17100001 - Init error. 2824 * The WebviewController must be associated with a Web component. 2825 * @syscap SystemCapability.Web.Webview.Core 2826 * @crossplatform 2827 * @atomicservice 2828 * @since 11 2829 */ 2830 getTitle(): string; 2831 2832 /** 2833 * Gets the content height of current Web page. 2834 * @returns { number } Returns the page height of the current page. 2835 * @throws { BusinessError } 17100001 - Init error. 2836 * The WebviewController must be associated with a Web component. 2837 * @syscap SystemCapability.Web.Webview.Core 2838 * @since 9 2839 */ 2840 /** 2841 * Gets the content height of current Web page. 2842 * @returns { number } Returns the page height of the current page. 2843 * @throws { BusinessError } 17100001 - Init error. 2844 * The WebviewController must be associated with a Web component. 2845 * @syscap SystemCapability.Web.Webview.Core 2846 * @crossplatform 2847 * @atomicservice 2848 * @since 11 2849 */ 2850 getPageHeight(): number; 2851 2852 /** 2853 * Goes forward or back backOrForward in the history of the web page. 2854 * 2855 * @param { number } step - Steps to go forward or backward. 2856 * @throws { BusinessError } 401 - Invalid input parameter. 2857 * @throws { BusinessError } 17100001 - Init error. 2858 * The WebviewController must be associated with a Web component. 2859 * @syscap SystemCapability.Web.Webview.Core 2860 * @since 9 2861 */ 2862 /** 2863 * Goes forward or back backOrForward in the history of the web page. 2864 * 2865 * @param { number } step - Steps to go forward or backward. 2866 * @throws { BusinessError } 401 - Invalid input parameter. 2867 * @throws { BusinessError } 17100001 - Init error. 2868 * The WebviewController must be associated with a Web component. 2869 * @syscap SystemCapability.Web.Webview.Core 2870 * @crossplatform 2871 * @atomicservice 2872 * @since 11 2873 */ 2874 backOrForward(step: number): void; 2875 2876 /** 2877 * Gets the request focus. 2878 * 2879 * @throws { BusinessError } 17100001 - Init error. 2880 * The WebviewController must be associated with a Web component. 2881 * @syscap SystemCapability.Web.Webview.Core 2882 * @since 9 2883 */ 2884 /** 2885 * Gets the request focus. 2886 * 2887 * @throws { BusinessError } 17100001 - Init error. 2888 * The WebviewController must be associated with a Web component. 2889 * @syscap SystemCapability.Web.Webview.Core 2890 * @atomicservice 2891 * @since 11 2892 */ 2893 requestFocus(): void; 2894 2895 /** 2896 * Create web message ports 2897 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 2898 * those ports to communication with html pages. 2899 * @throws { BusinessError } 17100001 - Init error. 2900 * The WebviewController must be associated with a Web component. 2901 * @syscap SystemCapability.Web.Webview.Core 2902 * @since 9 2903 */ 2904 /** 2905 * Create web message ports 2906 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 2907 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 2908 * those ports to communication with html pages. 2909 * @throws { BusinessError } 401 - Invalid input parameter. 2910 * @throws { BusinessError } 17100001 - Init error. 2911 * The WebviewController must be associated with a Web component. 2912 * @syscap SystemCapability.Web.Webview.Core 2913 * @since 10 2914 */ 2915 /** 2916 * Create web message ports 2917 * @param { boolean } isExtentionType - Set whether the web message port supports extention type. 2918 * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use 2919 * those ports to communication with html pages. 2920 * @throws { BusinessError } 401 - Invalid input parameter. 2921 * @throws { BusinessError } 17100001 - Init error. 2922 * The WebviewController must be associated with a Web component. 2923 * @syscap SystemCapability.Web.Webview.Core 2924 * @crossplatform 2925 * @atomicservice 2926 * @since 11 2927 */ 2928 createWebMessagePorts(isExtentionType?: boolean): Array<WebMessagePort>; 2929 2930 /** 2931 * Post web message port to html 2932 * 2933 * @param { string } name - Data name information to send. 2934 * @param { Array<WebMessagePort> } ports - Port number array information to send. 2935 * @param { string } uri - URI to receive this information. 2936 * @throws { BusinessError } 401 - Invalid input parameter. 2937 * @throws { BusinessError } 17100001 - Init error. 2938 * The WebviewController must be associated with a Web component. 2939 * @syscap SystemCapability.Web.Webview.Core 2940 * @since 9 2941 */ 2942 /** 2943 * Post web message port to html 2944 * 2945 * @param { string } name - Data name information to send. 2946 * @param { Array<WebMessagePort> } ports - Port number array information to send. 2947 * @param { string } uri - URI to receive this information. 2948 * @throws { BusinessError } 401 - Invalid input parameter. 2949 * @throws { BusinessError } 17100001 - Init error. 2950 * The WebviewController must be associated with a Web component. 2951 * @syscap SystemCapability.Web.Webview.Core 2952 * @crossplatform 2953 * @atomicservice 2954 * @since 11 2955 */ 2956 postMessage(name: string, ports: Array<WebMessagePort>, uri: string): void; 2957 2958 /** 2959 * Stops the current load. 2960 * 2961 * @throws { BusinessError } 17100001 - Init error. 2962 * The WebviewController must be associated with a Web component. 2963 * @syscap SystemCapability.Web.Webview.Core 2964 * @since 9 2965 */ 2966 /** 2967 * Stops the current load. 2968 * 2969 * @throws { BusinessError } 17100001 - Init error. 2970 * The WebviewController must be associated with a Web component. 2971 * @syscap SystemCapability.Web.Webview.Core 2972 * @crossplatform 2973 * @atomicservice 2974 * @since 11 2975 */ 2976 stop(): void; 2977 2978 /** 2979 * Registers the JavaScript object and method list. 2980 * 2981 * @param { object } object - Application side JavaScript objects participating in registration. 2982 * @param { string } name - The name of the registered object, which is consistent with the 2983 * object name called in the window. 2984 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 2985 * in the registration. 2986 * @throws { BusinessError } 401 - Invalid input parameter. 2987 * @throws { BusinessError } 17100001 - Init error. 2988 * The WebviewController must be associated with a Web component. 2989 * @syscap SystemCapability.Web.Webview.Core 2990 * @since 9 2991 */ 2992 /** 2993 * Registers the JavaScript object and method list. 2994 * 2995 * @param { object } object - Application side JavaScript objects participating in registration. 2996 * @param { string } name - The name of the registered object, which is consistent with the 2997 * object name called in the window. 2998 * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating 2999 * in the registration. 3000 * @throws { BusinessError } 401 - Invalid input parameter. 3001 * @throws { BusinessError } 17100001 - Init error. 3002 * The WebviewController must be associated with a Web component. 3003 * @syscap SystemCapability.Web.Webview.Core 3004 * @atomicservice 3005 * @since 11 3006 */ 3007 registerJavaScriptProxy(object: object, name: string, methodList: Array<string>): void; 3008 3009 /** 3010 * Deletes a registered JavaScript object with given name. 3011 * 3012 * @param { string } name - The name of a registered JavaScript object to be deleted. 3013 * @throws { BusinessError } 401 - Invalid input parameter. 3014 * @throws { BusinessError } 17100001 - Init error. 3015 * The WebviewController must be associated with a Web component. 3016 * @throws { BusinessError } 17100008 - Cannot delete JavaScriptProxy. 3017 * @syscap SystemCapability.Web.Webview.Core 3018 * @since 9 3019 */ 3020 /** 3021 * Deletes a registered JavaScript object with given name. 3022 * 3023 * @param { string } name - The name of a registered JavaScript object to be deleted. 3024 * @throws { BusinessError } 401 - Invalid input parameter. 3025 * @throws { BusinessError } 17100001 - Init error. 3026 * The WebviewController must be associated with a Web component. 3027 * @throws { BusinessError } 17100008 - Cannot delete JavaScriptProxy. 3028 * @syscap SystemCapability.Web.Webview.Core 3029 * @atomicservice 3030 * @since 11 3031 */ 3032 deleteJavaScriptRegister(name: string): void; 3033 3034 /** 3035 * Search all instances of 'searchString' on the page and highlights them, 3036 * result will be notify through callback onSearchResultReceive. 3037 * 3038 * @param { string } searchString - String to be search. 3039 * @throws { BusinessError } 401 - Invalid input parameter. 3040 * @throws { BusinessError } 17100001 - Init error. 3041 * The WebviewController must be associated with a Web component. 3042 * @syscap SystemCapability.Web.Webview.Core 3043 * @since 9 3044 */ 3045 /** 3046 * Search all instances of 'searchString' on the page and highlights them, 3047 * result will be notify through callback onSearchResultReceive. 3048 * 3049 * @param { string } searchString - String to be search. 3050 * @throws { BusinessError } 401 - Invalid input parameter. 3051 * @throws { BusinessError } 17100001 - Init error. 3052 * The WebviewController must be associated with a Web component. 3053 * @syscap SystemCapability.Web.Webview.Core 3054 * @atomicservice 3055 * @since 11 3056 */ 3057 searchAllAsync(searchString: string): void; 3058 3059 /** 3060 * Clears the highlighting surrounding text matches created by searchAllAsync. 3061 * 3062 * @throws { BusinessError } 17100001 - Init error. 3063 * The WebviewController must be associated with a Web component. 3064 * @syscap SystemCapability.Web.Webview.Core 3065 * @since 9 3066 */ 3067 /** 3068 * Clears the highlighting surrounding text matches created by searchAllAsync. 3069 * 3070 * @throws { BusinessError } 17100001 - Init error. 3071 * The WebviewController must be associated with a Web component. 3072 * @syscap SystemCapability.Web.Webview.Core 3073 * @atomicservice 3074 * @since 11 3075 */ 3076 clearMatches(): void; 3077 3078 /** 3079 * Highlights and scrolls to the next match search. 3080 * 3081 * @param { boolean } forward - Step of search is back or forward. 3082 * @throws { BusinessError } 401 - Invalid input parameter. 3083 * @throws { BusinessError } 17100001 - Init error. 3084 * The WebviewController must be associated with a Web component. 3085 * @syscap SystemCapability.Web.Webview.Core 3086 * @since 9 3087 */ 3088 /** 3089 * Highlights and scrolls to the next match search. 3090 * 3091 * @param { boolean } forward - Step of search is back or forward. 3092 * @throws { BusinessError } 401 - Invalid input parameter. 3093 * @throws { BusinessError } 17100001 - Init error. 3094 * The WebviewController must be associated with a Web component. 3095 * @syscap SystemCapability.Web.Webview.Core 3096 * @atomicservice 3097 * @since 11 3098 */ 3099 searchNext(forward: boolean): void; 3100 3101 /** 3102 * Clears the ssl cache in the Web. 3103 * 3104 * @throws { BusinessError } 17100001 - Init error. 3105 * The WebviewController must be associated with a Web component. 3106 * @syscap SystemCapability.Web.Webview.Core 3107 * @since 9 3108 */ 3109 /** 3110 * Clears the ssl cache in the Web. 3111 * 3112 * @throws { BusinessError } 17100001 - Init error. 3113 * The WebviewController must be associated with a Web component. 3114 * @syscap SystemCapability.Web.Webview.Core 3115 * @atomicservice 3116 * @since 11 3117 */ 3118 clearSslCache(): void; 3119 3120 /** 3121 * Clears the client authentication certificate cache in the Web. 3122 * 3123 * @throws { BusinessError } 17100001 - Init error. 3124 * The WebviewController must be associated with a Web component. 3125 * @syscap SystemCapability.Web.Webview.Core 3126 * @since 9 3127 */ 3128 /** 3129 * Clears the client authentication certificate cache in the Web. 3130 * 3131 * @throws { BusinessError } 17100001 - Init error. 3132 * The WebviewController must be associated with a Web component. 3133 * @syscap SystemCapability.Web.Webview.Core 3134 * @atomicservice 3135 * @since 11 3136 */ 3137 clearClientAuthenticationCache(): void; 3138 3139 /** 3140 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3141 * 3142 * @param { string } script - JavaScript Script. 3143 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 3144 * This parameter will be the result of JavaScript script execution. 3145 * If the JavaScript script fails to execute or has no return value, 3146 * null will be returned. 3147 * @throws { BusinessError } 401 - Invalid input parameter. 3148 * @throws { BusinessError } 17100001 - Init error. 3149 * The WebviewController must be associated with a Web component. 3150 * @syscap SystemCapability.Web.Webview.Core 3151 * @since 9 3152 */ 3153 /** 3154 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3155 * 3156 * @param { string } script - JavaScript Script. 3157 * @returns { Promise<string> } A promise is solved after the JavaScript script is executed. 3158 * This parameter will be the result of JavaScript script execution. 3159 * If the JavaScript script fails to execute or has no return value, 3160 * null will be returned. 3161 * @throws { BusinessError } 401 - Invalid input parameter. 3162 * @throws { BusinessError } 17100001 - Init error. 3163 * The WebviewController must be associated with a Web component. 3164 * @syscap SystemCapability.Web.Webview.Core 3165 * @crossplatform 3166 * @atomicservice 3167 * @since 11 3168 */ 3169 runJavaScript(script: string): Promise<string>; 3170 3171 /** 3172 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3173 * 3174 * @param { string } script - JavaScript Script. 3175 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 3176 * @throws { BusinessError } 401 - Invalid input parameter. 3177 * @throws { BusinessError } 17100001 - Init error. 3178 * The WebviewController must be associated with a Web component. 3179 * @syscap SystemCapability.Web.Webview.Core 3180 * @since 9 3181 */ 3182 /** 3183 * Loads a piece of code and execute JS code in the context of the currently displayed page. 3184 * 3185 * @param { string } script - JavaScript Script. 3186 * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results. 3187 * @throws { BusinessError } 401 - Invalid input parameter. 3188 * @throws { BusinessError } 17100001 - Init error. 3189 * The WebviewController must be associated with a Web component. 3190 * @syscap SystemCapability.Web.Webview.Core 3191 * @crossplatform 3192 * @atomicservice 3193 * @since 11 3194 */ 3195 runJavaScript(script: string, callback: AsyncCallback<string>): void; 3196 3197 /** 3198 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3199 * 3200 * @param { string } script - JavaScript Script. 3201 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3202 * This parameter will be the result of JavaScript script execution. 3203 * If the JavaScript script fails to execute or has no return value, 3204 * a none type value will be returned. 3205 * @throws { BusinessError } 401 - Invalid input parameter. 3206 * @throws { BusinessError } 17100001 - Init error. 3207 * The WebviewController must be associated with a Web component. 3208 * @syscap SystemCapability.Web.Webview.Core 3209 * @since 10 3210 */ 3211 /** 3212 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3213 * 3214 * @param { string } script - JavaScript Script. 3215 * @returns { Promise<JsMessageExt> } A promise is solved after the JavaScript script is executed. 3216 * This parameter will be the result of JavaScript script execution. 3217 * If the JavaScript script fails to execute or has no return value, 3218 * a none type value will be returned. 3219 * @throws { BusinessError } 401 - Invalid input parameter. 3220 * @throws { BusinessError } 17100001 - Init error. 3221 * The WebviewController must be associated with a Web component. 3222 * @syscap SystemCapability.Web.Webview.Core 3223 * @atomicservice 3224 * @since 11 3225 */ 3226 runJavaScriptExt(script: string): Promise<JsMessageExt>; 3227 3228 /** 3229 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3230 * 3231 * @param { string } script - JavaScript Script. 3232 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 3233 * @throws { BusinessError } 401 - Invalid input parameter. 3234 * @throws { BusinessError } 17100001 - Init error. 3235 * The WebviewController must be associated with a Web component. 3236 * @syscap SystemCapability.Web.Webview.Core 3237 * @since 10 3238 */ 3239 /** 3240 * Execute JavaScript code in the context of the currently displayed page, and return the result. 3241 * 3242 * @param { string } script - JavaScript Script. 3243 * @param { AsyncCallback<JsMessageExt> } callback - Callbacks execute JavaScript script results. 3244 * @throws { BusinessError } 401 - Invalid input parameter. 3245 * @throws { BusinessError } 17100001 - Init error. 3246 * The WebviewController must be associated with a Web component. 3247 * @syscap SystemCapability.Web.Webview.Core 3248 * @atomicservice 3249 * @since 11 3250 */ 3251 runJavaScriptExt(script: string, callback: AsyncCallback<JsMessageExt>): void; 3252 3253 /** 3254 * Gets the url of current Web page. 3255 * @returns { string } Return the url of the current page. 3256 * @throws { BusinessError } 17100001 - Init error. 3257 * The WebviewController must be associated with a Web component. 3258 * @syscap SystemCapability.Web.Webview.Core 3259 * @since 9 3260 */ 3261 /** 3262 * Gets the url of current Web page. 3263 * @returns { string } Return the url of the current page. 3264 * @throws { BusinessError } 17100001 - Init error. 3265 * The WebviewController must be associated with a Web component. 3266 * @syscap SystemCapability.Web.Webview.Core 3267 * @crossplatform 3268 * @atomicservice 3269 * @since 11 3270 */ 3271 getUrl(): string; 3272 3273 /** 3274 * Scroll the contents of this Webview up by half the view size. 3275 * 3276 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 3277 * the page content will scroll up half the size of the viewframe, 3278 * and when set to true, it will jump to the top of the page. 3279 * @throws { BusinessError } 401 - Invalid input parameter. 3280 * @throws { BusinessError } 17100001 - Init error. 3281 * The WebviewController must be associated with a Web component. 3282 * @syscap SystemCapability.Web.Webview.Core 3283 * @since 9 3284 */ 3285 /** 3286 * Scroll the contents of this Webview up by half the view size. 3287 * 3288 * @param { boolean } top - Whether to jump to the top of the page, if set to false, 3289 * the page content will scroll up half the size of the viewframe, 3290 * and when set to true, it will jump to the top of the page. 3291 * @throws { BusinessError } 401 - Invalid input parameter. 3292 * @throws { BusinessError } 17100001 - Init error. 3293 * The WebviewController must be associated with a Web component. 3294 * @syscap SystemCapability.Web.Webview.Core 3295 * @atomicservice 3296 * @since 11 3297 */ 3298 pageUp(top: boolean): void; 3299 3300 /** 3301 * Scroll the contents of this Webview down by half the view size. 3302 * 3303 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 3304 * the page content will scroll up half the size of the viewframe, 3305 * and when set to true, it will jump to the top of the page. 3306 * @throws { BusinessError } 401 - Invalid input parameter. 3307 * @throws { BusinessError } 17100001 - Init error. 3308 * The WebviewController must be associated with a Web component. 3309 * @syscap SystemCapability.Web.Webview.Core 3310 * @since 9 3311 */ 3312 /** 3313 * Scroll the contents of this Webview down by half the view size. 3314 * 3315 * @param { boolean } bottom - Whether to jump to the top of the page, if set to false, 3316 * the page content will scroll up half the size of the viewframe, 3317 * and when set to true, it will jump to the top of the page. 3318 * @throws { BusinessError } 401 - Invalid input parameter. 3319 * @throws { BusinessError } 17100001 - Init error. 3320 * The WebviewController must be associated with a Web component. 3321 * @syscap SystemCapability.Web.Webview.Core 3322 * @atomicservice 3323 * @since 11 3324 */ 3325 pageDown(bottom: boolean): void; 3326 3327 /** 3328 * Gets the original url of current Web page. 3329 * @returns { string } Return the original url of the current page. 3330 * @throws { BusinessError } 17100001 - Init error. 3331 * The WebviewController must be associated with a Web component. 3332 * @syscap SystemCapability.Web.Webview.Core 3333 * @since 9 3334 */ 3335 /** 3336 * Gets the original url of current Web page. 3337 * @returns { string } Return the original url of the current page. 3338 * @throws { BusinessError } 17100001 - Init error. 3339 * The WebviewController must be associated with a Web component. 3340 * @syscap SystemCapability.Web.Webview.Core 3341 * @atomicservice 3342 * @since 11 3343 */ 3344 getOriginalUrl(): string; 3345 3346 /** 3347 * Gets the favicon of current Web page. 3348 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 3349 * @throws { BusinessError } 17100001 - Init error. 3350 * The WebviewController must be associated with a Web component. 3351 * @syscap SystemCapability.Web.Webview.Core 3352 * @since 9 3353 */ 3354 /** 3355 * Gets the favicon of current Web page. 3356 * @returns { image.PixelMap } Return the favicon bitmap of the current page. 3357 * @throws { BusinessError } 17100001 - Init error. 3358 * The WebviewController must be associated with a Web component. 3359 * @syscap SystemCapability.Web.Webview.Core 3360 * @atomicservice 3361 * @since 11 3362 */ 3363 getFavicon(): image.PixelMap; 3364 3365 /** 3366 * Put network state for web. Which is used to set window.navigator.onLine property in 3367 * JavaScript. 3368 * @param { boolean } enable - Whether enable window.navigator.onLine. 3369 * @throws { BusinessError } 401 - Invalid input parameter. 3370 * @throws { BusinessError } 17100001 - Init error. 3371 * The WebviewController must be associated with a Web component. 3372 * @syscap SystemCapability.Web.Webview.Core 3373 * @since 9 3374 */ 3375 /** 3376 * Put network state for web. Which is used to set window.navigator.onLine property in 3377 * JavaScript. 3378 * @param { boolean } enable - Whether enable window.navigator.onLine. 3379 * @throws { BusinessError } 401 - Invalid input parameter. 3380 * @throws { BusinessError } 17100001 - Init error. 3381 * The WebviewController must be associated with a Web component. 3382 * @syscap SystemCapability.Web.Webview.Core 3383 * @atomicservice 3384 * @since 11 3385 */ 3386 setNetworkAvailable(enable: boolean): void; 3387 3388 /** 3389 * Query if current document has image. 3390 * 3391 * @returns { Promise<boolean> } A promise resolved after query image has finished. 3392 * @throws { BusinessError } 401 - Invalid input parameter. 3393 * @throws { BusinessError } 17100001 - Init error. 3394 * The WebviewController must be associated with a Web component. 3395 * @syscap SystemCapability.Web.Webview.Core 3396 * @since 9 3397 */ 3398 /** 3399 * Query if current document has image. 3400 * 3401 * @returns { Promise<boolean> } A promise resolved after query image has finished. 3402 * @throws { BusinessError } 401 - Invalid input parameter. 3403 * @throws { BusinessError } 17100001 - Init error. 3404 * The WebviewController must be associated with a Web component. 3405 * @syscap SystemCapability.Web.Webview.Core 3406 * @atomicservice 3407 * @since 11 3408 */ 3409 hasImage(): Promise<boolean>; 3410 3411 /** 3412 * Query if current document has image. 3413 * 3414 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 3415 * @throws { BusinessError } 401 - Invalid input parameter. 3416 * @throws { BusinessError } 17100001 - Init error. 3417 * The WebviewController must be associated with a Web component. 3418 * @syscap SystemCapability.Web.Webview.Core 3419 * @since 9 3420 */ 3421 /** 3422 * Query if current document has image. 3423 * 3424 * @param { AsyncCallback<boolean> } callback - Called after query image has finished. 3425 * @throws { BusinessError } 401 - Invalid input parameter. 3426 * @throws { BusinessError } 17100001 - Init error. 3427 * The WebviewController must be associated with a Web component. 3428 * @syscap SystemCapability.Web.Webview.Core 3429 * @atomicservice 3430 * @since 11 3431 */ 3432 hasImage(callback: AsyncCallback<boolean>): void; 3433 3434 /** 3435 * Get back forward stack list from current webview. 3436 * @returns { BackForwardList } Back forward list for current webview. 3437 * @throws { BusinessError } 17100001 - Init error. 3438 * The WebviewController must be associated with a Web component. 3439 * @syscap SystemCapability.Web.Webview.Core 3440 * @since 9 3441 */ 3442 /** 3443 * Get back forward stack list from current webview. 3444 * @returns { BackForwardList } Back forward list for current webview. 3445 * @throws { BusinessError } 17100001 - Init error. 3446 * The WebviewController must be associated with a Web component. 3447 * @syscap SystemCapability.Web.Webview.Core 3448 * @crossplatform 3449 * @atomicservice 3450 * @since 11 3451 */ 3452 getBackForwardEntries(): BackForwardList; 3453 3454 /** 3455 * Remove resource cache in application. So this method will remove all cache for all web components in the 3456 * same application. 3457 * 3458 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 3459 * in ram. 3460 * @throws { BusinessError } 401 - Invalid input parameter. 3461 * @throws { BusinessError } 17100001 - Init error. 3462 * The WebviewController must be associated with a Web component. 3463 * @syscap SystemCapability.Web.Webview.Core 3464 * @since 9 3465 */ 3466 /** 3467 * Remove resource cache in application. So this method will remove all cache for all web components in the 3468 * same application. 3469 * 3470 * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache 3471 * in ram. 3472 * @throws { BusinessError } 401 - Invalid input parameter. 3473 * @throws { BusinessError } 17100001 - Init error. 3474 * The WebviewController must be associated with a Web component. 3475 * @syscap SystemCapability.Web.Webview.Core 3476 * @crossplatform 3477 * @atomicservice 3478 * @since 11 3479 */ 3480 removeCache(clearRom: boolean): void; 3481 3482 /** 3483 * Scroll to the position. 3484 * 3485 * @param { number } x - the x of the position. 3486 * @param { number } y - the y of the position. 3487 * @throws { BusinessError } 401 - Invalid input parameter. 3488 * @throws { BusinessError } 17100001 - Init error. 3489 * The WebviewController must be associated with a Web component. 3490 * @syscap SystemCapability.Web.Webview.Core 3491 * @since 9 3492 */ 3493 /** 3494 * Scroll to the position. 3495 * 3496 * @param { number } x - the x of the position. 3497 * @param { number } y - the y of the position. 3498 * @throws { BusinessError } 401 - Invalid input parameter. 3499 * @throws { BusinessError } 17100001 - Init error. 3500 * The WebviewController must be associated with a Web component. 3501 * @syscap SystemCapability.Web.Webview.Core 3502 * @crossplatform 3503 * @atomicservice 3504 * @since 11 3505 */ 3506 scrollTo(x: number, y: number): void; 3507 3508 /** 3509 * Scroll by the delta position. 3510 * 3511 * @param { number } deltaX - the delta x of the position. 3512 * @param { number } deltaY - the delta y of the position. 3513 * @throws { BusinessError } 401 - Invalid input parameter. 3514 * @throws { BusinessError } 17100001 - Init error. 3515 * The WebviewController must be associated with a Web component. 3516 * @syscap SystemCapability.Web.Webview.Core 3517 * @since 9 3518 */ 3519 /** 3520 * Scroll by the delta position. 3521 * 3522 * @param { number } deltaX - the delta x of the position. 3523 * @param { number } deltaY - the delta y of the position. 3524 * @throws { BusinessError } 401 - Invalid input parameter. 3525 * @throws { BusinessError } 17100001 - Init error. 3526 * The WebviewController must be associated with a Web component. 3527 * @syscap SystemCapability.Web.Webview.Core 3528 * @crossplatform 3529 * @atomicservice 3530 * @since 11 3531 */ 3532 scrollBy(deltaX: number, deltaY: number): void; 3533 3534 /** 3535 * Slide by the speed. 3536 * 3537 * @param { number } vx - the x speed of the speed. 3538 * @param { number } vy - the y speed of the speed. 3539 * @throws { BusinessError } 401 - Invalid input parameter. 3540 * @throws { BusinessError } 17100001 - Init error. 3541 * The WebviewController must be associated with a Web component. 3542 * @syscap SystemCapability.Web.Webview.Core 3543 * @since 9 3544 */ 3545 /** 3546 * Slide by the speed. 3547 * 3548 * @param { number } vx - the x speed of the speed. 3549 * @param { number } vy - the y speed of the speed. 3550 * @throws { BusinessError } 401 - Invalid input parameter. 3551 * @throws { BusinessError } 17100001 - Init error. 3552 * The WebviewController must be associated with a Web component. 3553 * @syscap SystemCapability.Web.Webview.Core 3554 * @atomicservice 3555 * @since 11 3556 */ 3557 slideScroll(vx: number, vy: number): void; 3558 3559 /** 3560 * Serialize the access stack of the web, that is, the history of access. 3561 * @returns { Uint8Array } Web access stack after serialization. 3562 * @throws { BusinessError } 17100001 - Init error. 3563 * The WebviewController must be associated with a Web component. 3564 * @syscap SystemCapability.Web.Webview.Core 3565 * @since 9 3566 */ 3567 /** 3568 * Serialize the access stack of the web, that is, the history of access. 3569 * @returns { Uint8Array } Web access stack after serialization. 3570 * @throws { BusinessError } 17100001 - Init error. 3571 * The WebviewController must be associated with a Web component. 3572 * @syscap SystemCapability.Web.Webview.Core 3573 * @atomicservice 3574 * @since 11 3575 */ 3576 serializeWebState(): Uint8Array; 3577 3578 /** 3579 * Restoring the web access stack, that is, the history of access. 3580 * @param { Uint8Array } state - Web access stack after serialization. 3581 * @throws { BusinessError } 401 - Invalid input parameter. 3582 * @throws { BusinessError } 17100001 - Init error. 3583 * The WebviewController must be associated with a Web component. 3584 * @syscap SystemCapability.Web.Webview.Core 3585 * @since 9 3586 */ 3587 /** 3588 * Restoring the web access stack, that is, the history of access. 3589 * @param { Uint8Array } state - Web access stack after serialization. 3590 * @throws { BusinessError } 401 - Invalid input parameter. 3591 * @throws { BusinessError } 17100001 - Init error. 3592 * The WebviewController must be associated with a Web component. 3593 * @syscap SystemCapability.Web.Webview.Core 3594 * @atomicservice 3595 * @since 11 3596 */ 3597 restoreWebState(state: Uint8Array): void; 3598 3599 /** 3600 * Set whether the Web custom scheme supports cross domain and fetch requests. 3601 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 3602 * @throws { BusinessError } 401 - Invalid input parameter. 3603 * @syscap SystemCapability.Web.Webview.Core 3604 * @since 9 3605 */ 3606 /** 3607 * Set whether the Web custom scheme supports cross domain and fetch requests. 3608 * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme. 3609 * @throws { BusinessError } 401 - Invalid input parameter. 3610 * @syscap SystemCapability.Web.Webview.Core 3611 * @atomicservice 3612 * @since 11 3613 */ 3614 static customizeSchemes(schemes: Array<WebCustomScheme>): void; 3615 3616 /** 3617 * Get certificate for the current website. 3618 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 3619 * @throws { BusinessError } 17100001 - Init error. 3620 * The WebviewController must be associated with a web component. 3621 * @syscap SystemCapability.Web.Webview.Core 3622 * @since 10 3623 */ 3624 /** 3625 * Get certificate for the current website. 3626 * @returns { Promise<Array<cert.X509Cert>> } the promise of the current website's certificate. 3627 * @throws { BusinessError } 17100001 - Init error. 3628 * The WebviewController must be associated with a web component. 3629 * @syscap SystemCapability.Web.Webview.Core 3630 * @atomicservice 3631 * @since 11 3632 */ 3633 getCertificate(): Promise<Array<cert.X509Cert>>; 3634 3635 /** 3636 * Get certificate for the current website. 3637 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 3638 * @throws { BusinessError } 401 - Invalid input parameter. 3639 * @throws { BusinessError } 17100001 - Init error. 3640 * The WebviewController must be associated with a web component. 3641 * @syscap SystemCapability.Web.Webview.Core 3642 * @since 10 3643 */ 3644 /** 3645 * Get certificate for the current website. 3646 * @param {AsyncCallback<Array<cert.X509Cert>>} callback - the callback of getCertificate. 3647 * @throws { BusinessError } 401 - Invalid input parameter. 3648 * @throws { BusinessError } 17100001 - Init error. 3649 * The WebviewController must be associated with a web component. 3650 * @syscap SystemCapability.Web.Webview.Core 3651 * @atomicservice 3652 * @since 11 3653 */ 3654 getCertificate(callback: AsyncCallback<Array<cert.X509Cert>>): void; 3655 3656 /** 3657 * Set audio muted. 3658 * @param { boolean } mute - Set the audio muted or not. 3659 * @throws { BusinessError } 401 - Invalid input parameter. 3660 * @throws { BusinessError } 17100001 - Init error. 3661 * The WebviewController must be associated with a Web component. 3662 * @syscap SystemCapability.Web.Webview.Core 3663 * @since 10 3664 */ 3665 /** 3666 * Set audio muted. 3667 * @param { boolean } mute - Set the audio muted or not. 3668 * @throws { BusinessError } 401 - Invalid input parameter. 3669 * @throws { BusinessError } 17100001 - Init error. 3670 * The WebviewController must be associated with a Web component. 3671 * @syscap SystemCapability.Web.Webview.Core 3672 * @atomicservice 3673 * @since 11 3674 */ 3675 setAudioMuted(mute: boolean): void; 3676 3677 /** 3678 * Prefetch the resources required by the page, but will not execute js or render the page. 3679 * @param { string } url - Which url to preresolve/preconnect. 3680 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 3681 * @throws { BusinessError } 17100001 - Init error. 3682 * The WebviewController must be associated with a Web component. 3683 * @throws { BusinessError } 17100002 - Invalid url. 3684 * @syscap SystemCapability.Web.Webview.Core 3685 * @since 10 3686 */ 3687 /** 3688 * Prefetch the resources required by the page, but will not execute js or render the page. 3689 * @param { string } url - Which url to preresolve/preconnect. 3690 * @param { Array<WebHeader> } [additionalHeaders] - Additional HTTP request header of the URL. 3691 * @throws { BusinessError } 17100001 - Init error. 3692 * The WebviewController must be associated with a Web component. 3693 * @throws { BusinessError } 17100002 - Invalid url. 3694 * @syscap SystemCapability.Web.Webview.Core 3695 * @atomicservice 3696 * @since 11 3697 */ 3698 prefetchPage(url: string, additionalHeaders?: Array<WebHeader>): void; 3699 3700 /** 3701 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 3702 * @param { string } url - Which url to preresolve/preconnect. 3703 * @param { boolean } preconnectable - Indicates whether to preconnect. 3704 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 3705 * @throws { BusinessError } 17100002 - Invalid url. 3706 * @throws { BusinessError } 171000013 - The number of preconnect sockets is invalid. 3707 * @syscap SystemCapability.Web.Webview.Core 3708 * @since 10 3709 */ 3710 /** 3711 * Preresolve or Preconnect the url. This API can be called before loading the url to make loading faster. 3712 * @param { string } url - Which url to preresolve/preconnect. 3713 * @param { boolean } preconnectable - Indicates whether to preconnect. 3714 * @param { number } numSockets - If preconnectable is true, this parameter indicates the number of sockets to be preconnected. 3715 * @throws { BusinessError } 17100002 - Invalid url. 3716 * @throws { BusinessError } 171000013 - The number of preconnect sockets is invalid. 3717 * @syscap SystemCapability.Web.Webview.Core 3718 * @atomicservice 3719 * @since 11 3720 */ 3721 static prepareForPageLoad(url: string, preconnectable: boolean, numSockets: number): void; 3722 3723 /** 3724 * Set custom user agent. 3725 * @param { string } userAgent - User custom agent information. 3726 * @throws { BusinessError } 401 - Invalid input parameter. 3727 * @throws { BusinessError } 17100001 - Init error. 3728 * The WebviewController must be associated with a Web component. 3729 * @syscap SystemCapability.Web.Webview.Core 3730 * @since 10 3731 */ 3732 /** 3733 * Set custom user agent. 3734 * @param { string } userAgent - User custom agent information. 3735 * @throws { BusinessError } 401 - Invalid input parameter. 3736 * @throws { BusinessError } 17100001 - Init error. 3737 * The WebviewController must be associated with a Web component. 3738 * @syscap SystemCapability.Web.Webview.Core 3739 * @crossplatform 3740 * @atomicservice 3741 * @since 11 3742 */ 3743 setCustomUserAgent(userAgent: string): void; 3744 3745 /** 3746 * Get custom user agent. 3747 * @returns { string } Get custom User agent information. 3748 * @throws { BusinessError } 17100001 - Init error. 3749 * The WebviewController must be associated with a Web component. 3750 * @syscap SystemCapability.Web.Webview.Core 3751 * @since 10 3752 */ 3753 /** 3754 * Get custom user agent. 3755 * @returns { string } Get custom User agent information. 3756 * @throws { BusinessError } 17100001 - Init error. 3757 * The WebviewController must be associated with a Web component. 3758 * @syscap SystemCapability.Web.Webview.Core 3759 * @crossplatform 3760 * @atomicservice 3761 * @since 11 3762 */ 3763 getCustomUserAgent(): string; 3764 3765 /** 3766 * Set web engine socket connection timeout. 3767 * @param { number } timeout - Socket connection timeout. 3768 * @throws { BusinessError } 401 - Invalid input parameter. 3769 * @syscap SystemCapability.Web.Webview.Core 3770 * @atomicservice 3771 * @since 11 3772 */ 3773 static setConnectionTimeout(timeout: number): void; 3774 3775 /** 3776 * Set delegate for download. 3777 * Used to notify the progress of the download triggered from web. 3778 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from web. 3779 * @throws { BusinessError } 17100001 - Init error. 3780 * The WebviewController must be associated with a Web component. 3781 * @syscap SystemCapability.Web.Webview.Core 3782 * @atomicservice 3783 * @since 11 3784 */ 3785 setDownloadDelegate(delegate: WebDownloadDelegate): void; 3786 3787 3788 /** 3789 * Start a download. 3790 * @param { string } url - The download url. 3791 * @throws { BusinessError } 17100001 - Init error. 3792 * The WebviewController must be associated with a Web component. 3793 * @throws { BusinessError } 17100002 - Invalid url. 3794 * @syscap SystemCapability.Web.Webview.Core 3795 * @atomicservice 3796 * @since 11 3797 */ 3798 startDownload(url: string): void; 3799 3800 /** 3801 * Loads the URL use "POST" method with post data. 3802 * 3803 * @param { string } url - Request the URL use "POST" method. 3804 * @param { ArrayBuffer } postData - This data will passed to "POST" request. 3805 * @throws { BusinessError } 401 - Invalid input parameter. 3806 * @throws { BusinessError } 17100001 - Init error. 3807 * The WebviewController must be associated with a Web component. 3808 * @throws { BusinessError } 17100002 - Invalid url. 3809 * @syscap SystemCapability.Web.Webview.Core 3810 * @atomicservice 3811 * @since 11 3812 */ 3813 postUrl(url: string, postData: ArrayBuffer): void; 3814 3815 /** 3816 * Create the Web Print Document Adapter. 3817 * @param { string } jobName - The name of the currently printed document. 3818 * @returns { print.PrintDocumentAdapter } Return the Print Document Adapter. 3819 * @throws { BusinessError } 401 - Invalid input parameter. 3820 * @throws { BusinessError } 17100001 - Init error. 3821 * The WebviewController must be associated with a Web component. 3822 * @syscap SystemCapability.Web.Webview.Core 3823 * @since 11 3824 */ 3825 createWebPrintDocumentAdapter(jobName: string): print.PrintDocumentAdapter; 3826 3827 /** 3828 * Get the security level of the current page. 3829 * 3830 * @returns { SecurityLevel } the security level of current page. 3831 * @throws { BusinessError } 17100001 - Init error. 3832 * The WebviewController must be associated with a Web component. 3833 * @syscap SystemCapability.Web.Webview.Core 3834 * @atomicservice 3835 * @since 11 3836 */ 3837 getSecurityLevel(): SecurityLevel; 3838 3839 /** 3840 * Whether the incognito mode is set. 3841 * 3842 * @returns { boolean } {@code true} has been set the incognito mode; {@code false} otherwise. 3843 * @throws { BusinessError } 17100001 - Init error. 3844 * The WebviewController must be associated with a Web component. 3845 * @syscap SystemCapability.Web.Webview.Core 3846 * @atomicservice 3847 * @since 11 3848 */ 3849 isIncognitoMode(): boolean; 3850 } 3851 3852 /** 3853 * Defines the state for download. 3854 * @enum {number} 3855 * @syscap SystemCapability.Web.Webview.Core 3856 * @atomicservice 3857 * @since 11 3858 */ 3859 enum WebDownloadState { 3860 /** 3861 * The web download is in progress. 3862 * @syscap SystemCapability.Web.Webview.Core 3863 * @atomicservice 3864 * @since 11 3865 */ 3866 IN_PROGRESS = 0, 3867 3868 /** 3869 * The web download has been completed. 3870 * @syscap SystemCapability.Web.Webview.Core 3871 * @atomicservice 3872 * @since 11 3873 */ 3874 COMPLETED, 3875 3876 /** 3877 * The web download was canceled. 3878 * @syscap SystemCapability.Web.Webview.Core 3879 * @atomicservice 3880 * @since 11 3881 */ 3882 CANCELED, 3883 3884 /** 3885 * The web download was interrupted. 3886 * @syscap SystemCapability.Web.Webview.Core 3887 * @atomicservice 3888 * @since 11 3889 */ 3890 INTERRUPTED, 3891 3892 /** 3893 * The web download is pending. 3894 * @syscap SystemCapability.Web.Webview.Core 3895 * @atomicservice 3896 * @since 11 3897 */ 3898 PENDING, 3899 3900 /** 3901 * The web download has been paused. 3902 * @syscap SystemCapability.Web.Webview.Core 3903 * @atomicservice 3904 * @since 11 3905 */ 3906 PAUSED, 3907 3908 /** 3909 * Unknown state. 3910 * @syscap SystemCapability.Web.Webview.Core 3911 * @atomicservice 3912 * @since 11 3913 */ 3914 UNKNOWN, 3915 } 3916 3917 /** 3918 * Defines the error code for download. 3919 * @enum {number} 3920 * @syscap SystemCapability.Web.Webview.Core 3921 * @atomicservice 3922 * @since 11 3923 */ 3924 enum WebDownloadErrorCode { 3925 /** 3926 * Unknown error. 3927 * @syscap SystemCapability.Web.Webview.Core 3928 * @atomicservice 3929 * @since 11 3930 */ 3931 ERROR_UNKNOWN = 0, 3932 3933 /** 3934 * Generic file operation failure. 3935 * @syscap SystemCapability.Web.Webview.Core 3936 * @atomicservice 3937 * @since 11 3938 */ 3939 FILE_FAILED = 1, 3940 3941 /** 3942 * The file cannot be accessed due to certain restrictions. 3943 * @syscap SystemCapability.Web.Webview.Core 3944 * @atomicservice 3945 * @since 11 3946 */ 3947 FILE_ACCESS_DENIED = 2, 3948 3949 /** 3950 * There is not enough disk space. 3951 * @syscap SystemCapability.Web.Webview.Core 3952 * @atomicservice 3953 * @since 11 3954 */ 3955 FILE_NO_SPACE = 3, 3956 3957 /** 3958 * The file name is too long. 3959 * @syscap SystemCapability.Web.Webview.Core 3960 * @atomicservice 3961 * @since 11 3962 */ 3963 FILE_NAME_TOO_LONG = 5, 3964 3965 /** 3966 * The file is too large. 3967 * @syscap SystemCapability.Web.Webview.Core 3968 * @atomicservice 3969 * @since 11 3970 */ 3971 FILE_TOO_LARGE = 6, 3972 3973 /** 3974 * Some temporary problems occurred, such as not enough memory, files in use, and too many files open at the same time. 3975 * @syscap SystemCapability.Web.Webview.Core 3976 * @atomicservice 3977 * @since 11 3978 */ 3979 FILE_TRANSIENT_ERROR = 10, 3980 3981 /** 3982 * The file is blocked from accessing because of some local policy. 3983 * @syscap SystemCapability.Web.Webview.Core 3984 * @atomicservice 3985 * @since 11 3986 */ 3987 FILE_BLOCKED = 11, 3988 3989 /** 3990 * When trying to resume the download, Found that the file is not long enough, maybe the file no longer exists. 3991 * @syscap SystemCapability.Web.Webview.Core 3992 * @atomicservice 3993 * @since 11 3994 */ 3995 FILE_TOO_SHORT = 13, 3996 3997 /** 3998 * Hash mismatch. 3999 * @syscap SystemCapability.Web.Webview.Core 4000 * @atomicservice 4001 * @since 11 4002 */ 4003 FILE_HASH_MISMATCH = 14, 4004 4005 /** 4006 * The file already exists. 4007 * @syscap SystemCapability.Web.Webview.Core 4008 * @atomicservice 4009 * @since 11 4010 */ 4011 FILE_SAME_AS_SOURCE = 15, 4012 4013 /** 4014 * Generic network error. 4015 * @syscap SystemCapability.Web.Webview.Core 4016 * @atomicservice 4017 * @since 11 4018 */ 4019 NETWORK_FAILED = 20, 4020 4021 /** 4022 * The network operation timed out. 4023 * @syscap SystemCapability.Web.Webview.Core 4024 * @atomicservice 4025 * @since 11 4026 */ 4027 NETWORK_TIMEOUT = 21, 4028 4029 /** 4030 * The network was disconnected. 4031 * @syscap SystemCapability.Web.Webview.Core 4032 * @atomicservice 4033 * @since 11 4034 */ 4035 NETWORK_DISCONNECTED = 22, 4036 4037 /** 4038 * Server down. 4039 * @syscap SystemCapability.Web.Webview.Core 4040 * @atomicservice 4041 * @since 11 4042 */ 4043 NETWORK_SERVER_DOWN = 23, 4044 4045 /** 4046 * Invalid network requests,may redirect to unsupported scheme or an invalid URL. 4047 * @syscap SystemCapability.Web.Webview.Core 4048 * @atomicservice 4049 * @since 11 4050 */ 4051 NETWORK_INVALID_REQUEST = 24, 4052 4053 /** 4054 * The server returned a generic error. 4055 * @syscap SystemCapability.Web.Webview.Core 4056 * @atomicservice 4057 * @since 11 4058 */ 4059 SERVER_FAILED = 30, 4060 4061 /** 4062 * The server does not support range requests. 4063 * @syscap SystemCapability.Web.Webview.Core 4064 * @atomicservice 4065 * @since 11 4066 */ 4067 SERVER_NO_RANGE = 31, 4068 4069 /** 4070 * The server does not have the requested data. 4071 * @syscap SystemCapability.Web.Webview.Core 4072 * @atomicservice 4073 * @since 11 4074 */ 4075 SERVER_BAD_CONTENT = 33, 4076 4077 /** 4078 * The server does not allow the file to be downloaded. 4079 * @syscap SystemCapability.Web.Webview.Core 4080 * @atomicservice 4081 * @since 11 4082 */ 4083 SERVER_UNAUTHORIZED = 34, 4084 4085 /** 4086 * Server certificate error. 4087 * @syscap SystemCapability.Web.Webview.Core 4088 * @atomicservice 4089 * @since 11 4090 */ 4091 SERVER_CERT_PROBLEM = 35, 4092 4093 /** 4094 * Server access forbidden. 4095 * @syscap SystemCapability.Web.Webview.Core 4096 * @atomicservice 4097 * @since 11 4098 */ 4099 SERVER_FORBIDDEN = 36, 4100 4101 /** 4102 * Server unreachable. 4103 * @syscap SystemCapability.Web.Webview.Core 4104 * @atomicservice 4105 * @since 11 4106 */ 4107 SERVER_UNREACHABLE = 37, 4108 4109 /** 4110 * The received data does not match content-length. 4111 * @syscap SystemCapability.Web.Webview.Core 4112 * @atomicservice 4113 * @since 11 4114 */ 4115 SERVER_CONTENT_LENGTH_MISMATCH = 38, 4116 4117 /** 4118 * An unexpected cross-origin redirect happened. 4119 * @syscap SystemCapability.Web.Webview.Core 4120 * @atomicservice 4121 * @since 11 4122 */ 4123 SERVER_CROSS_ORIGIN_REDIRECT = 39, 4124 4125 /** 4126 * User cancel. 4127 * @syscap SystemCapability.Web.Webview.Core 4128 * @atomicservice 4129 * @since 11 4130 */ 4131 USER_CANCELED = 40, 4132 4133 /** 4134 * User shut down the application. 4135 * @syscap SystemCapability.Web.Webview.Core 4136 * @atomicservice 4137 * @since 11 4138 */ 4139 USER_SHUTDOWN = 41, 4140 4141 /** 4142 * Application crash. 4143 * @syscap SystemCapability.Web.Webview.Core 4144 * @atomicservice 4145 * @since 11 4146 */ 4147 CRASH = 50, 4148 } 4149 4150 /** 4151 * Represents a download task, You can use this object to operate the corresponding download task. 4152 * @syscap SystemCapability.Web.Webview.Core 4153 * @atomicservice 4154 * @since 11 4155 */ 4156 class WebDownloadItem { 4157 /** 4158 * Get guid. 4159 * @returns { string } - Returns the download's guid. 4160 * @syscap SystemCapability.Web.Webview.Core 4161 * @atomicservice 4162 * @since 11 4163 */ 4164 getGuid(): string; 4165 4166 /** 4167 * Get current speed, in bytes per second. 4168 * @returns { number } - Returns the current download speed. 4169 * @syscap SystemCapability.Web.Webview.Core 4170 * @atomicservice 4171 * @since 11 4172 */ 4173 getCurrentSpeed(): number; 4174 4175 /** 4176 * Get percent complete. 4177 * @returns { number } - Returns -1 if progress is unknown. 100 if the download is already complete. 4178 * @syscap SystemCapability.Web.Webview.Core 4179 * @atomicservice 4180 * @since 11 4181 */ 4182 getPercentComplete(): number; 4183 4184 /** 4185 * Get total bytes. 4186 * @returns { number } - Returns the total bytes received, -1 if the total size is unknown. 4187 * @syscap SystemCapability.Web.Webview.Core 4188 * @atomicservice 4189 * @since 11 4190 */ 4191 getTotalBytes(): number; 4192 4193 /** 4194 * Get state of the web download. 4195 * @returns { WebDownloadState } - Returns the current download state. 4196 * @syscap SystemCapability.Web.Webview.Core 4197 * @atomicservice 4198 * @since 11 4199 */ 4200 getState(): WebDownloadState; 4201 4202 /** 4203 * Get last error code of the web download. 4204 * @returns { WebDownloadErrorCode } - Returns the last error code. 4205 * @syscap SystemCapability.Web.Webview.Core 4206 * @atomicservice 4207 * @since 11 4208 */ 4209 getLastErrorCode(): WebDownloadErrorCode; 4210 4211 /** 4212 * Get http method of the web download request. 4213 * @returns { string } - Returns the http request method. 4214 * @syscap SystemCapability.Web.Webview.Core 4215 * @atomicservice 4216 * @since 11 4217 */ 4218 getMethod(): string; 4219 4220 /** 4221 * Get mime type of the web download. 4222 * @returns { string } - Returns the mimetype. 4223 * @syscap SystemCapability.Web.Webview.Core 4224 * @atomicservice 4225 * @since 11 4226 */ 4227 getMimeType(): string; 4228 4229 /** 4230 * Get url of the web download request. 4231 * @returns { string } - Returns the url. 4232 * @syscap SystemCapability.Web.Webview.Core 4233 * @atomicservice 4234 * @since 11 4235 */ 4236 getUrl(): string; 4237 4238 /** 4239 * Get suggested file name of the web download request. 4240 * @returns { string } - Returns the suggested file name. 4241 * @syscap SystemCapability.Web.Webview.Core 4242 * @atomicservice 4243 * @since 11 4244 */ 4245 getSuggestedFileName(): string; 4246 4247 /** 4248 * Start the web download. 4249 * Used in onBeforeDownload, If you want to start the current download, call this function. 4250 * @param { string } downloadPath - The content will be downloaded to this file. 4251 * @throws { BusinessError } 401 - Invalid input parameter. 4252 * @syscap SystemCapability.Web.Webview.Core 4253 * @atomicservice 4254 * @since 11 4255 */ 4256 start(downloadPath: string): void; 4257 4258 /** 4259 * Cancel the web download. 4260 * @syscap SystemCapability.Web.Webview.Core 4261 * @atomicservice 4262 * @since 11 4263 */ 4264 cancel(): void; 4265 4266 /** 4267 * Pause the web download. 4268 * @throws { BusinessError } 17100019 - The download has not been started yet. 4269 * @syscap SystemCapability.Web.Webview.Core 4270 * @atomicservice 4271 * @since 11 4272 */ 4273 pause(): void; 4274 4275 /** 4276 * Resume the web download. 4277 * Use WebDownloadManager.resumeDownload to resume deserialized downloads. 4278 * WebDownloadItem.resume is only used to resume the currently paused download. 4279 * @throws { BusinessError } 17100016 - The download is not paused. 4280 * @syscap SystemCapability.Web.Webview.Core 4281 * @atomicservice 4282 * @since 11 4283 */ 4284 resume(): void; 4285 4286 /** 4287 * Get received bytes. 4288 * @returns { number } - Returns the received bytes. 4289 * @syscap SystemCapability.Web.Webview.Core 4290 * @atomicservice 4291 * @since 11 4292 */ 4293 getReceivedBytes(): number; 4294 4295 /** 4296 * Get full path of the web download. 4297 * @returns { string } - Returns the full path of the download. 4298 * @syscap SystemCapability.Web.Webview.Core 4299 * @atomicservice 4300 * @since 11 4301 */ 4302 getFullPath(): string; 4303 4304 /** 4305 * Serialize web download to typed array. 4306 * @returns { Uint8Array } - Returns the serialized data. 4307 * @syscap SystemCapability.Web.Webview.Core 4308 * @atomicservice 4309 * @since 11 4310 */ 4311 serialize(): Uint8Array; 4312 4313 /** 4314 * Deserialize web download from typed array. 4315 * @param { Uint8Array } serializedData - The serialized data. 4316 * @returns { WebDownloadItem } - Deserialize the serialized data into a WebDownloadItem. 4317 * @throws { BusinessError } 401 - Invalid input parameter. 4318 * @syscap SystemCapability.Web.Webview.Core 4319 * @atomicservice 4320 * @since 11 4321 */ 4322 static deserialize(serializedData: Uint8Array): WebDownloadItem; 4323 } 4324 4325 /** 4326 * The download state is notified through this delegate. 4327 * @syscap SystemCapability.Web.Webview.Core 4328 * @atomicservice 4329 * @since 11 4330 */ 4331 class WebDownloadDelegate { 4332 /** 4333 * Callback will be triggered before web download start. 4334 * @param { Callback<WebDownloadItem> } callback - The callback of download will be start. 4335 * @syscap SystemCapability.Web.Webview.Core 4336 * @atomicservice 4337 * @since 11 4338 */ 4339 onBeforeDownload(callback: Callback<WebDownloadItem>): void; 4340 4341 /** 4342 * Callback will be triggered when web download is processing. 4343 * @param { Callback<WebDownloadItem> } callback - The callback of download did update. 4344 * @syscap SystemCapability.Web.Webview.Core 4345 * @atomicservice 4346 * @since 11 4347 */ 4348 onDownloadUpdated(callback: Callback<WebDownloadItem>): void; 4349 4350 /** 4351 * Callback will be triggered when web download is completed. 4352 * @param { Callback<WebDownloadItem> } callback - The callback of download did finish. 4353 * @syscap SystemCapability.Web.Webview.Core 4354 * @atomicservice 4355 * @since 11 4356 */ 4357 onDownloadFinish(callback: Callback<WebDownloadItem>): void; 4358 4359 /** 4360 * Callback will be triggered when web download is interrupted or canceled. 4361 * @param { Callback<WebDownloadItem> } callback - The callback of download did fail. 4362 * @syscap SystemCapability.Web.Webview.Core 4363 * @atomicservice 4364 * @since 11 4365 */ 4366 onDownloadFailed(callback: Callback<WebDownloadItem>): void; 4367 } 4368 4369 /** 4370 * You can trigger download manually through this interface, or resume failed or canceled downloads. 4371 * @syscap SystemCapability.Web.Webview.Core 4372 * @atomicservice 4373 * @since 11 4374 */ 4375 class WebDownloadManager { 4376 /** 4377 * Set a delegate used to receive the progress of the download triggered from WebDownloadManager. 4378 * @param { WebDownloadDelegate } delegate - Delegate used for download triggered from WebDownloadManager. 4379 * @syscap SystemCapability.Web.Webview.Core 4380 * @atomicservice 4381 * @since 11 4382 */ 4383 static setDownloadDelegate(delegate: WebDownloadDelegate): void; 4384 4385 /** 4386 * Resume the canceled or failed download. 4387 * @param { WebDownloadItem } webDownloadItem - Download that need to be resume. 4388 * @throws { BusinessError } 17100018 - No WebDownloadDelegate has been set yet. 4389 * @syscap SystemCapability.Web.Webview.Core 4390 * @atomicservice 4391 * @since 11 4392 */ 4393 static resumeDownload(webDownloadItem: WebDownloadItem): void; 4394 } 4395} 4396 4397export default webview; 4398