• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/// <reference path="../component/units.d.ts" />
17
18import {AsyncCallback} from "./basic";
19import {Callback} from "./basic";
20import {Resource} from 'GlobalResource';
21import image from "./@ohos.multimedia.image";
22
23/**
24 * This module provides the capability to manage web modules.
25 *
26 * @since 9
27 * @syscap SystemCapability.Web.Webview.Core
28 */
29declare namespace webview {
30    /**
31     * Defines the Web's request/response header.
32     * @since 9
33     */
34    interface WebHeader {
35        /**
36         * Gets the key of the request/response header.
37         * @since 9
38         */
39        headerKey: string;
40
41        /**
42         * Gets the value of the request/response header.
43         * @since 9
44         */
45        headerValue: string;
46    }
47
48    /**
49     * Enum type supplied to {@link getHitTest} for indicating the cursor node HitTest.
50     * @since 9
51     */
52    enum WebHitTestType {
53        /**
54         * The edit text.
55         * @since 9
56         */
57        EditText,
58
59        /**
60         * The email address.
61         * @since 9
62         */
63        Email,
64
65        /**
66         * The HTML::a tag with src=http.
67         * @since 9
68         */
69        HttpAnchor,
70
71        /**
72         * The HTML::a tag with src=http + HTML::img.
73         * @since 9
74         */
75        HttpAnchorImg,
76
77        /**
78         * The HTML::img tag.
79         * @since 9
80         */
81        Img,
82
83        /**
84         * The map address.
85         * @since 9
86         */
87        Map,
88
89        /**
90         * The phone number.
91         * @since 9
92         */
93        Phone,
94
95        /**
96         * Other unknown HitTest.
97         * @since 9
98         */
99        Unknown
100    }
101
102    /**
103     * Defines the hit test value, related to {@link getHitTestValue} method.
104     * @since 9
105     */
106    interface HitTestValue {
107
108        /**
109         * Get the hit test type.
110         *
111         * @since 9
112         */
113        type: WebHitTestType;
114
115        /**
116         * Get the hit test extra data.
117         *
118         * @since 9
119         */
120        extra: string;
121    }
122
123    /**
124     * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method.
125     * @since 9
126     */
127    interface WebCustomScheme {
128
129        /**
130         * Name of the custom scheme.
131         *
132         * @since 9
133         */
134        schemeName: string;
135
136        /**
137         * Whether Cross-Origin Resource Sharing is supported.
138         *
139         * @since 9
140         */
141        isSupportCORS: boolean;
142
143        /**
144         * Whether fetch request is supported.
145         *
146         * @since 9
147         */
148        isSupportFetch: boolean;
149    }
150
151    /**
152     * Provides basic information of web storage.
153     * @name WebStorageOrigin
154     * @since 9
155     * @syscap SystemCapability.Web.Webview.Core
156     */
157    interface WebStorageOrigin {
158        origin: string;
159        usage: number;
160        quota: number;
161    }
162
163    /**
164     * Subscribe to a callback of a specified type of web event once.
165     *
166     * @param type Types of web event.
167     * @param callback Indicate callback used to receive the web event.
168     *
169     * @throws { BusinessError } 401 - Invalid input parameter.
170     *
171     * @since 9
172     */
173    function once(type: string, callback: Callback<void>): void;
174
175    /**
176     * Provides methods for managing web storage.
177     * @name WebStorage
178     * @since 9
179     * @syscap SystemCapability.Web.Webview.Core
180     */
181    class WebStorage {
182        /**
183         * Delete all the storage data.
184         *
185         * @since 9
186         */
187        static deleteAllData(): void;
188
189        /**
190         * Delete the storage data with the origin.
191         *
192         * @param { string } origin - The origin which to be deleted.
193         * @throws { BusinessError } 401 - Invalid input parameter.
194         * @throws { BusinessError } 17100011 - Invalid origin.
195         * @since 9
196         */
197        static deleteOrigin(origin: string): void;
198
199        /**
200         * Get current all the web storage origins.
201         *
202         * @throws { BusinessError } 401 - Invalid input parameter.
203         * @throws { BusinessError } 17100012 - Invalid web storage origin.
204         * @since 9
205         */
206        static getOrigins(): Promise<Array<WebStorageOrigin>>;
207        static getOrigins(callback: AsyncCallback<Array<WebStorageOrigin>>): void;
208
209        /**
210         * Get the web storage quota with the origin.
211         * @param { string } origin -  The origin which to be inquired.
212         * @throws { BusinessError } 401 - Invalid input parameter.
213         * @throws { BusinessError } 17100011 - Invalid origin.
214         * @since 9
215         */
216        static getOriginQuota(origin: string): Promise<number>;
217        static getOriginQuota(origin: string, callback: AsyncCallback<number>): void;
218
219        /**
220         * Get the web storage quota with the origin.
221         * @param { string } origin -  The origin which to be inquired.
222         * @throws { BusinessError } 401 - Invalid input parameter.
223         * @throws { BusinessError } 17100011 - Invalid origin.
224         * @since 9
225         */
226        static getOriginUsage(origin: string): Promise<number> ;
227        static getOriginUsage(origin: string, callback: AsyncCallback<number>): void;
228    }
229
230    /**
231     * Provides methods for managing web database.
232     * @name WebDataBase
233     * @since 9
234     * @syscap SystemCapability.Web.Webview.Core
235     */
236    class WebDataBase {
237        /**
238        * Get whether instances holds any http authentication credentials.
239        * @returns { boolean } true if instances saved any http authentication credentials otherwise false.
240        *
241        * @since 9
242        */
243        static existHttpAuthCredentials(): boolean;
244
245        /**
246         * Delete all http authentication credentials.
247         *
248         * @since 9
249         */
250        static deleteHttpAuthCredentials(): void;
251
252        /**
253         * Get http authentication credentials.
254         * @param { string } host - The host to which the credentials apply.
255         * @param { string } realm - The realm to which the credentials apply.
256         * @throws { BusinessError } 401 - Invalid input parameter.
257         * @returns { Array<string> } Return an array containing username and password.
258         * @since 9
259         */
260        static getHttpAuthCredentials(host: string, realm: string): Array<string>;
261
262        /**
263         * Save http authentication credentials.
264         * @param { string } host - The host to which the credentials apply.
265         * @param { string } realm - The realm to which the credentials apply.
266         * @param { string } username - The username.
267         * @param { string } password - The password.
268         * @throws { BusinessError } 401 - Invalid input parameter.
269         *
270         * @since 9
271         */
272        static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void;
273      }
274
275    /**
276     * Provides a method for managing web geographic location permissions.
277     * @name GeolocationPermissions
278     * @since 9
279     * @syscap SystemCapability.Web.Webview.Core
280     */
281    class GeolocationPermissions {
282        /**
283         * Allow geolocation permissions for specifies source.
284         * @param { string } origin - Url source.
285         * @throws { BusinessError } 401 - Invalid input parameter.
286         * @throws { BusinessError } 17100011 - Invalid origin.
287         *
288         * @since 9
289         */
290        static allowGeolocation(origin: string): void;
291
292        /**
293         * Delete geolocation permissions for specifies source.
294         * @param { string } origin - Url source.
295         * @throws { BusinessError } 401 - Invalid input parameter.
296         * @throws { BusinessError } 17100011 - Invalid origin.
297         *
298         * @since 9
299         */
300        static deleteGeolocation(origin: string): void;
301
302        /**
303         * Delete all geolocation permissions.
304         *
305         * @since 9
306         */
307         static deleteAllGeolocation(): void;
308
309        /**
310         * Gets the geolocation permission status of the specified source.
311         * @param { string } origin - Url source.
312         * @param { AsyncCallback<boolean> } callback - Return to the specified source
313         *                                              geographic location permission status.
314         * @throws { BusinessError } 401 - Invalid input parameter.
315         * @throws { BusinessError } 17100011 - Invalid origin.
316         * @returns { Promise<boolean> } Return whether there is a saved result.
317         *
318         * @since 9
319         */
320        static getAccessibleGeolocation(origin: string): Promise<boolean>;
321        static getAccessibleGeolocation(origin: string, callback: AsyncCallback<boolean>): void;
322
323        /**
324         * Get all stored geolocation permission url source.
325         * @param { AsyncCallback<boolean> } callback - Return all source information of
326         *                                              stored geographic location permission status.
327         * @throws { BusinessError } 401 - Invalid input parameter.
328         * @returns { Promise<Array<string>> } Return whether there is a saved result.
329         *
330         * @since 9
331         */
332        static getStoredGeolocation(): Promise<Array<string>>;
333        static getStoredGeolocation(callback: AsyncCallback<Array<string>>): void;
334    }
335
336      /**
337       * Provides methods for managing the web cookies.
338       *
339       * @since 9
340       */
341       class WebCookieManager {
342        /**
343         * Gets all cookies for the given URL.
344         *
345         * @param { string } url - The URL for which the cookies are requested.
346         * @throws { BusinessError } 401 - Invalid input parameter.
347         * @throws { BusinessError } 17100002 - Invalid url.
348         * @returns The cookie value for the given URL.
349         *
350         * @since 9
351         */
352        static getCookie(url: string): string;
353
354        /**
355         * Set a single cookie (key-value pair) for the given URL.
356         *
357         * @param { string } url - The URL for which the cookie is to be set.
358         * @param { string } value - The cookie as a string, using the format of the 'Set-Cookie' HTTP response header.
359         * @throws { BusinessError } 401 - Invalid input parameter.
360         * @throws { BusinessError } 17100002 - Invalid url.
361         * @throws { BusinessError } 17100005 - Invalid cookie value.
362         *
363         * @since 9
364         */
365        static setCookie(url: string, value: string): void;
366
367        /**
368         * Save the cookies Asynchronously.
369         *
370         * @param { AsyncCallback<void> } callback - Called after the cookies have been saved.
371         * @throws { BusinessError } 401 - Invalid input parameter.
372         * @returns { Promise<void> } A promise resolved after the cookies have been saved.
373         *
374         * @since 9
375         */
376        static saveCookieAsync(): Promise<void>;
377        static saveCookieAsync(callback: AsyncCallback<void>): void;
378
379        /**
380         * Get whether the instance can send and accept cookies.
381         *
382         * @returns { boolean } True if the instance can send and accept cookies else false.
383         *
384         * @since 9
385         */
386        static isCookieAllowed(): boolean;
387
388        /**
389         * Set whether the instance should send and accept cookies.
390         * By default this is set to be true.
391         *
392         * @param { boolean } accept - Whether the instance should send and accept cookies.
393         * @throws { BusinessError } 401 - Invalid input parameter.
394         *
395         * @since 9
396         */
397        static putAcceptCookieEnabled(accept: boolean): void;
398
399        /**
400         * Get whether the instance can send and accept thirdparty cookies.
401         *
402         * @returns { boolean } True if the instance can send and accept thirdparty cookies else false.
403         *
404         * @since 9
405         */
406        static isThirdPartyCookieAllowed(): boolean;
407
408        /**
409         * Set whether the instance should send and accept thirdparty cookies.
410         * By default this is set to be false.
411         *
412         * @param { boolean } accept - Whether the instance should send and accept thirdparty cookies.
413         * @throws { BusinessError } 401 - Invalid input parameter.
414         *
415         * @since 9
416         */
417        static putAcceptThirdPartyCookieEnabled(accept: boolean): void;
418
419        /**
420         * Check whether exists any cookies.
421         *
422         * @returns { boolean } True if exists more than one cookie else false;
423         *
424         * @since 9
425         */
426        static existCookie(): boolean;
427
428        /**
429         * Remove all cookies.
430         *
431         * @since 9
432         */
433        static deleteEntireCookie(): void;
434
435        /**
436         * Delete the session cookies.
437         *
438         * @since 9
439         */
440        static deleteSessionCookie(): void;
441    }
442
443    type WebMessage = ArrayBuffer | string;
444    /**
445     * Define html web message port.
446     * @since 9
447     */
448    interface WebMessagePort {
449        /**
450         * Close port.
451         * @since 9
452         */
453        close(): void;
454
455        /**
456         * Post a message to other port.
457         * @param { WebMessage } message - Message to send.
458         * @throws { BusinessError } 401 - Invalid input parameter.
459         * @throws { BusinessError } 17100010 - Can not post message using this port.
460         *
461         * @since 9
462         */
463        postMessageEvent(message: WebMessage): void;
464
465        /**
466         * Receive message from other port.
467         * @param { (result: WebMessage) => void } callback - Callback function for receiving messages.
468         * @throws { BusinessError } 401 - Invalid input parameter.
469         * @throws { BusinessError } 17100006 - Can not register message event using this port.
470         *
471         * @since 9
472         */
473        onMessageEvent(callback: (result: WebMessage) => void): void;
474    }
475
476    /**
477     * Provides information for history item in BackForwardList.
478     * @name HistoryItem
479     * @since 9
480     * @syscap SystemCapability.Web.Webview.Core
481     */
482     interface HistoryItem {
483        /**
484         * Pixelmap of icon.
485         *
486         * @since 9
487         */
488        icon: image.PixelMap;
489
490        /**
491         * Url of this history item.
492         *
493         * @since 9
494         */
495        historyUrl: string;
496
497        /**
498         * Original request url of this history item.
499         *
500         * @since 9
501         */
502        historyRawUrl: string;
503
504        /**
505         * Title of this history item.
506         *
507         * @since 9
508         */
509        title: string;
510    }
511
512    /**
513     * Provides back and forward history list information method. related to {@link HistoryItem}.
514     * @name BackForwardList
515     * @since 9
516     * @syscap SystemCapability.Web.Webview.Core
517     */
518    interface BackForwardList {
519        /**
520         * Current index in BackForwardList.
521         *
522         * @since 9
523         */
524        currentIndex: number;
525
526        /**
527         * Size of in BackForwardList.
528         *
529         * @since 9
530         */
531        size: number;
532
533        /**
534         * Get history entry at given index.
535         *
536         * @param { number } index Index of back forward list entry.
537         * @throws { BusinessError } 401 - Invalid input parameter.
538         * @returns { HistoryItem } HistoryItem at given index in back forward list.
539         *
540         * @since 9
541         */
542        getItemAtIndex(index: number): HistoryItem;
543    }
544
545    /**
546     * Provides methods for controlling the web controller.
547     *
548     * @since 9
549     */
550     class WebviewController {
551        /**
552         * Initialize the web engine before loading the Web components.
553         * This is a global static API that must be called on the UI thread, and it will have no effect if any
554         * Web components are loaded.
555         *
556         * @since 9
557         */
558        static initializeWebEngine(): void;
559
560        /**
561         * Enables debugging of web contents.
562         * @param webDebuggingAccess {@code true} enables debugging of web contents; {@code false} otherwise.
563         * @throws { BusinessError } 401 - Invalid input parameter.
564         *
565         * @since 9
566         */
567        static setWebDebuggingAccess(webDebuggingAccess: boolean): void;
568
569        /**
570         * Checks whether the web page can go forward.
571         *
572         * @throws { BusinessError } 17100001 - Init error.
573         *                           The WebviewController must be associated with a Web component.
574         * @returns { boolean } True if the web page can go forward else false.
575         *
576         * @since 9
577         */
578        accessForward(): boolean;
579
580        /**
581         * Checks whether the web page can go back.
582         *
583         * @throws { BusinessError } 17100001 - Init error.
584         *                           The WebviewController must be associated with a Web component.
585         * @returns { boolean } True if the web page can go back else false.
586         *
587         * @since 9
588         */
589        accessBackward(): boolean;
590
591        /**
592         * Checks whether the web page can go back or forward the given number of steps.
593         *
594         * @param { number } step - The number of steps.
595         * @throws { BusinessError } 401 - Invalid input parameter.
596         * @throws { BusinessError } 17100001 - Init error.
597         *                           The WebviewController must be associated with a Web component.
598         * @returns { boolean } True if the web page can go back else false.
599         *
600         * @since 9
601         */
602        accessStep(step: number): boolean;
603
604        /**
605         * Goes forward in the history of the web page.
606         *
607         * @throws { BusinessError } 17100001 - Init error.
608         *                           The WebviewController must be associated with a Web component.
609         *
610         * @since 9
611         */
612        forward(): void;
613
614        /**
615         * Goes back in the history of the web page.
616         *
617         * @throws { BusinessError } 17100001 - Init error.
618         *                           The WebviewController must be associated with a Web component.
619         *
620         * @since 9
621         */
622        backward(): void;
623
624        /**
625         * Clears the history in the Web.
626         *
627         * @throws { BusinessError } 17100001 - Init error.
628         *                           The WebviewController must be associated with a Web component.
629         * @since 9
630         */
631        clearHistory(): void;
632
633        /**
634         * Let the Web active.
635         *
636         * @throws { BusinessError } 17100001 - Init error.
637         *                           The WebviewController must be associated with a Web component.
638         * @since 9
639         */
640        onActive(): void;
641
642        /**
643         * Let the Web inactive.
644         *
645         * @throws { BusinessError } 17100001 - Init error.
646         *                           The WebviewController must be associated with a Web component.
647         * @since 9
648         */
649        onInactive(): void;
650
651        /**
652         * Refreshes the current URL.
653         *
654         * @throws { BusinessError } 17100001 - Init error.
655         *                           The WebviewController must be associated with a Web component.
656         * @since 9
657         */
658        refresh(): void;
659
660        /**
661         * Loads the data or URL.
662         *
663         * @param { string } data - A string encoded according to "Base64" or "URL".
664         * @param { string } mimeType - Media type. For example: "text/html".
665         * @param { string } encoding - Encoding type. For example: "UTF-8".
666         * @param { string } [baseUrl] - A specified URL path ("http"/"https"/"data" protocol),
667         *                             which is assigned to window.origin by the Web component.
668         * @param { string } [historyUrl] - History URL. When it is not empty, it can be managed by
669         *                                history records to realize the back and forth function.
670         *                                This property is invalid when baseUrl is empty.
671         * @throws { BusinessError } 401 - Invalid input parameter.
672         * @throws { BusinessError } 17100001 - Init error.
673         *                           The WebviewController must be associated with a Web component.
674         * @throws { BusinessError } 17100002 - Invalid url.
675         *
676         * @since 9
677         */
678        loadData(data: string, mimeType: string, encoding: string, baseUrl?: string, historyUrl?: string): void;
679
680        /**
681         * Loads the data or URL.
682         *
683         * @param { string | Resource } url - The URL to load.
684         * @param { Array<WebHeader> } [headers] - Additional HTTP request header for URL.
685         * @throws { BusinessError } 401 - Invalid input parameter.
686         * @throws { BusinessError } 17100001 - Init error.
687         *                           The WebviewController must be associated with a Web component.
688         * @throws { BusinessError } 17100002 - Invalid url.
689         * @throws { BusinessError } 17100003 - Invalid resource path or file type.
690         *
691         * @since 9
692         */
693        loadUrl(url: string | Resource, headers?: Array<WebHeader>): void;
694
695        /**
696         * Gets the type of HitTest.
697         *
698         * @throws { BusinessError } 17100001 - Init error.
699         *                           The WebviewController must be associated with a Web component.
700         * @returns { WebHitTestType } The type of HitTest.
701         *
702         * @since 9
703         */
704        getHitTest(): WebHitTestType;
705
706        /**
707         * Stores the current page as a web archive.
708         *
709         * @param { string } baseName - Where the generated offline webpage is stored, This value cannot be null.
710         * @param { boolean } autoName - If it is false, the filename will be automatically generated according to
711         *                               the url and the generated offline webpage will be stored in the directory
712         *                               specified by baseName. If it is true, the offline webpage will be directly
713         *                               stored in the path specified by baseName.
714         * @param { AsyncCallback<string> } callback - called after the web archive has been stored. The parameter
715         *                                             will either be the filename under which the file was stored,
716         *                                             or empty if storing the file failed.
717         * @throws { BusinessError } 401 - Invalid input parameter.
718         * @throws { BusinessError } 17100001 - Init error.
719         *                           The WebviewController must be associated with a Web component.
720         * @throws { BusinessError } 17100003 - Invalid resource path or file type.
721         * @returns { Promise<string> } a promise resolved after the web archive has been stored. The parameter
722         *                              will either be the filename under which the file was stored, or empty
723         *                              if storing the file failed.
724         *
725         * @since 9
726         */
727        storeWebArchive(baseName: string, autoName: boolean): Promise<string>;
728        storeWebArchive(baseName: string, autoName: boolean, callback: AsyncCallback<string>): void;
729
730        /**
731         * Let the Web zoom by.
732         *
733         * @param { number } factor - The zoom factor.
734         * @throws { BusinessError } 401 - Invalid input parameter.
735         * @throws { BusinessError } 17100001 - Init error.
736         *                           The WebviewController must be associated with a Web component.
737         * @throws { BusinessError } 17100004 - Function not enable.
738         *
739         * @since 9
740         */
741        zoom(factor: number): void;
742
743        /**
744         * Let the Web zoom in.
745         *
746         * @throws { BusinessError } 17100001 - Init error.
747         *                           The WebviewController must be associated with a Web component.
748         * @throws { BusinessError } 17100004 - Function not enable.
749         *
750         * @since 9
751         */
752        zoomIn(): void;
753
754        /**
755         * Let the Web zoom out.
756         *
757         * @throws { BusinessError } 17100001 - Init error.
758         *                           The WebviewController must be associated with a Web component.
759         * @throws { BusinessError } 17100004 - Function not enable.
760         *
761         * @since 9
762         */
763        zoomOut(): void;
764
765        /**
766         * Gets the hit test value of HitTest.
767         *
768         * @throws { BusinessError } 17100001 - Init error.
769         *                           The WebviewController must be associated with a Web component.
770         * @returns { HitTestValue } Return the element information of the clicked area.
771         *
772         * @since 9
773         */
774        getHitTestValue(): HitTestValue;
775
776        /**
777         * Gets the id for the current Web.
778         *
779         * @throws { BusinessError } 17100001 - Init error.
780         *                           The WebviewController must be associated with a Web component.
781         * @returns { number } Returns the index value of the current Web component.
782         *
783         * @since 9
784         */
785        getWebId(): number;
786
787        /**
788         * Gets the default user agent.
789         *
790         * @throws { BusinessError } 17100001 - Init error.
791         *                           The WebviewController must be associated with a Web component.
792         * @returns { string } Return user agent information.
793         *
794         * @since 9
795         */
796        getUserAgent(): string;
797
798        /**
799         * Gets the title of current Web page.
800         *
801         * @throws { BusinessError } 17100001 - Init error.
802         *                           The WebviewController must be associated with a Web component.
803         * @returns { string } Return to File Selector Title.
804         *
805         * @since 9
806         */
807        getTitle(): string;
808
809        /**
810         * Gets the content height of current Web page.
811         *
812         * @throws { BusinessError } 17100001 - Init error.
813         *                           The WebviewController must be associated with a Web component.
814         * @returns { number } Returns the page height of the current page.
815         *
816         * @since 9
817         */
818        getPageHeight(): number;
819
820        /**
821         * Goes forward or back backOrForward in the history of the web page.
822         *
823         * @param { number } step - Steps to go forward or backward.
824         * @throws { BusinessError } 401 - Invalid input parameter.
825         * @throws { BusinessError } 17100001 - Init error.
826         *                           The WebviewController must be associated with a Web component.
827         *
828         * @since 9
829         */
830        backOrForward(step: number): void;
831
832        /**
833         * Gets the request focus.
834         *
835         * @throws { BusinessError } 17100001 - Init error.
836         *                           The WebviewController must be associated with a Web component.
837         *
838         * @since 9
839         */
840        requestFocus(): void;
841
842        /**
843         * Create web message ports
844         *
845         * @throws { BusinessError } 17100001 - Init error.
846         *                           The WebviewController must be associated with a Web component.
847         * @returns { Array<WebMessagePort> } An array represent 2 WebMessagePort, then can use
848         *                                    those ports to communication with html pages.
849         *
850         * @since 9
851         */
852        createWebMessagePorts(): Array<WebMessagePort>;
853
854        /**
855         * Post web message port to html
856         *
857         * @param { string } name - Data name information to send.
858         * @param { Array<WebMessagePort> } ports - Port number array information to send.
859         * @param { string } uri - URI to receive this information.
860         * @throws { BusinessError } 401 - Invalid input parameter.
861         * @throws { BusinessError } 17100001 - Init error.
862         *                           The WebviewController must be associated with a Web component.
863         *
864         * @since 9
865         */
866        postMessage(name: string, ports: Array<WebMessagePort>, uri: string): void;
867
868        /**
869         * Stops the current load.
870         *
871         * @throws { BusinessError } 17100001 - Init error.
872         *                           The WebviewController must be associated with a Web component.
873         *
874         * @since 9
875         */
876        stop(): void;
877
878        /**
879         * Registers the JavaScript object and method list.
880         *
881         * @param { object } object - Application side JavaScript objects participating in registration.
882         * @param { string } name - The name of the registered object, which is consistent with the
883         *                          object name called in the window.
884         * @param { Array<string> } methodList - Thr method of the application side JavaScript object participating
885         *                                       in the registration.
886         * @throws { BusinessError } 401 - Invalid input parameter.
887         * @throws { BusinessError } 17100001 - Init error.
888         *                           The WebviewController must be associated with a Web component.
889         *
890         * @since 9
891         */
892        registerJavaScriptProxy(object: object, name: string, methodList: Array<string>): void;
893
894        /**
895         * Deletes a registered JavaScript object with given name.
896         *
897         * @param { string } name - The name of a registered JavaScript object to be deleted.
898         * @throws { BusinessError } 401 - Invalid input parameter.
899         * @throws { BusinessError } 17100001 - Init error.
900         *                           The WebviewController must be associated with a Web component.
901         * @throws { BusinessError } 17100008 - Cannot delete JavaScriptProxy.
902         *
903         * @since 9
904         */
905        deleteJavaScriptRegister(name: string): void;
906
907        /**
908         * Search all instances of 'searchString' on the page and highlights them,
909         * result will be notify through callback onSearchResultReceive.
910         *
911         * @param { string } searchString - String to be search.
912         * @throws { BusinessError } 401 - Invalid input parameter.
913         * @throws { BusinessError } 17100001 - Init error.
914         *                         The WebviewController must be associated with a Web component.
915         *
916         * @since 9
917         */
918        searchAllAsync(searchString: string): void;
919
920        /**
921         * Clears the highlighting surrounding text matches created by searchAllAsync.
922         *
923         * @throws { BusinessError } 17100001 - Init error.
924         *                           The WebviewController must be associated with a Web component.
925         *
926         * @since 9
927         */
928        clearMatches(): void;
929
930        /**
931         * Highlights and scrolls to the next match search.
932         *
933         * @param { boolean } forward - Step of search is back or forward.
934         * @throws { BusinessError } 401 - Invalid input parameter.
935         * @throws { BusinessError } 17100001 - Init error.
936         *                           The WebviewController must be associated with a Web component.
937         *
938         * @since 9
939         */
940        searchNext(forward: boolean): void;
941
942        /**
943         * Clears the ssl cache in the Web.
944         *
945         * @throws { BusinessError } 17100001 - Init error.
946         *                           The WebviewController must be associated with a Web component.
947         *
948         * @since 9
949         */
950        clearSslCache(): void;
951
952        /**
953         * Clears the client authentication certificate cache in the Web.
954         *
955         * @throws { BusinessError } 17100001 - Init error.
956         *                           The WebviewController must be associated with a Web component.
957         *
958         * @since 9
959         */
960        clearClientAuthenticationCache(): void;
961
962        /**
963         * Loads a piece of code and execute JS code in the context of the currently displayed page.
964         *
965         * @param { string } script - JavaScript Script.
966         * @param { AsyncCallback<string> } callback - Callbacks execute JavaScript script results.
967         * @throws { BusinessError } 401 - Invalid input parameter.
968         * @throws { BusinessError } 17100001 - Init error.
969         *                           The WebviewController must be associated with a Web component.
970         * @returns { Promise<string> } A promise is solved after the JavaScript script is executed.
971         *                              This parameter will be the result of JavaScript script execution.
972         *                              If the JavaScript script fails to execute or has no return value,
973         *                              null will be returned.
974         *
975         * @since 9
976         */
977        runJavaScript(script: string): Promise<string>;
978        runJavaScript(script: string, callback: AsyncCallback<string>): void;
979
980        /**
981         * Gets the url of current Web page.
982         *
983         * @throws { BusinessError } 17100001 - Init error.
984         *                           The WebviewController must be associated with a Web component.
985         * @returns { string } Return the url of the current page.
986         *
987         * @since 9
988         */
989        getUrl(): string;
990
991        /**
992         * Scroll the contents of this Webview up by half the view size.
993         *
994         * @param { boolean } top - Jump to the top of the page if true.
995         * @throws { BusinessError } 401 - Invalid input parameter.
996         * @throws { BusinessError } 17100001 - Init error.
997         *                           The WebviewController must be associated with a Web component.
998         *
999         * @since 9
1000         */
1001        pageUp(top:boolean): void;
1002
1003        /**
1004         * Scroll the contents of this Webview down by half the view size.
1005         *
1006         * @param { boolean } bottom - Jump to the bottom of the page if true.
1007         * @throws { BusinessError } 401 - Invalid input parameter.
1008         * @throws { BusinessError } 17100001 - Init error.
1009         *                           The WebviewController must be associated with a Web component.
1010         *
1011         * @since 9
1012         */
1013        pageDown(bottom:boolean): void;
1014
1015        /**
1016         * Gets the original url of current Web page.
1017         *
1018         * @throws { BusinessError } 17100001 - Init error.
1019         *                           The WebviewController must be associated with a Web component.
1020         * @returns { string } Return the original url of the current page.
1021         *
1022         * @since 9
1023         */
1024        getOriginalUrl(): string;
1025
1026        /**
1027         * Gets the favicon of current Web page.
1028         *
1029         * @throws { BusinessError } 17100001 - Init error.
1030         *                           The WebviewController must be associated with a Web component.
1031         * @returns { image.PixelMap } Return the favicon bitmap of the current page.
1032         *
1033         * @since 9
1034         */
1035        getFavicon(): image.PixelMap;
1036
1037        /**
1038         * Put network state for web. Which is used to set window.navigator.isOnline property in
1039         * JavaScript.
1040         *
1041         * @throws { BusinessError } 401 - Invalid input parameter.
1042         * @throws { BusinessError } 17100001 - Init error.
1043         *                           The WebviewController must be associated with a Web component.
1044         *
1045         * @param { boolean } enable - Whether enable window.navigator.isOnline.
1046         * @since 9
1047         */
1048        setNetworkAvailable(enable: boolean): void;
1049
1050        /**
1051         * Query if current document has image.
1052         *
1053         * @param { AsyncCallback<boolean> } callback - Called after query image has finished.
1054         * @throws { BusinessError } 401 - Invalid input parameter.
1055         * @throws { BusinessError } 17100001 - Init error.
1056         *                           The WebviewController must be associated with a Web component.
1057         * @returns { Promise<boolean> } A promise resolved after query image has finished.
1058         *
1059         * @since 9
1060         */
1061        hasImage(): Promise<boolean>;
1062        hasImage(callback: AsyncCallback<boolean>): void;
1063
1064        /**
1065         * Get back forward stack list from current webview.
1066         *
1067         * @throws { BusinessError } 17100001 - Init error.
1068         *                           The WebviewController must be associated with a Web component.
1069         * @returns { BackForwardList } Back forward list for current webview.
1070         *
1071         * @since 9
1072         */
1073        getBackForwardEntries(): BackForwardList;
1074
1075        /**
1076         * Remove resource cache in application. So this method will remove all cache for all web components in the
1077         * same application.
1078         *
1079         * @param { boolean } clearRom - Remove cache in both rom and ram if true. Otherwise only clear cache
1080         *                               in ram.
1081         * @throws { BusinessError } 401 - Invalid input parameter.
1082         * @throws { BusinessError } 17100001 - Init error.
1083         *                           The WebviewController must be associated with a Web component.
1084         * @since 9
1085         */
1086        removeCache(clearRom: boolean): void;
1087
1088        /**
1089         * Scroll to the position.
1090         *
1091         * @param { number } x - the x of the position.
1092         * @param { number } y - the y of the position.
1093         * @throws { BusinessError } 401 - Invalid input parameter.
1094         * @throws { BusinessError } 17100001 - Init error.
1095         *                           The WebviewController must be associated with a Web component.
1096         *
1097         * @since 9
1098         */
1099        scrollTo(x:number, y:number): void;
1100
1101        /**
1102         * Scroll by the delta position.
1103         *
1104         * @param { number } deltaX - the delta x of the position.
1105         * @param { number } deltaY - the delta y of the position.
1106         * @throws { BusinessError } 401 - Invalid input parameter.
1107         * @throws { BusinessError } 17100001 - Init error.
1108         *                           The WebviewController must be associated with a Web component.
1109         *
1110         * @since 9
1111         */
1112        scrollBy(deltaX:number, deltaY:number): void;
1113
1114        /**
1115         * Slide by the speed.
1116         *
1117         * @param { number } vx - the x speed of the speed.
1118         * @param { number } vy - the y speed of the speed.
1119         * @throws { BusinessError } 401 - Invalid input parameter.
1120         * @throws { BusinessError } 17100001 - Init error.
1121         *                           The WebviewController must be associated with a Web component.
1122         *
1123         * @since 9
1124         */
1125        slideScroll(vx:number, vy:number): void;
1126
1127        /**
1128         * Serialize the access stack of the web, that is, the history of access.
1129         *
1130         * @throws { BusinessError } 17100001 - Init error.
1131         *                           The WebviewController must be associated with a Web component.
1132         * @returns { Uint8Array } Web access stack after serialization.
1133         *
1134         * @since 9
1135         */
1136        serializeWebState(): Uint8Array;
1137
1138        /**
1139         * Restoring the web access stack, that is, the history of access.
1140         *
1141         * @param { Uint8Array } state - Web access stack after serialization.
1142         * @throws { BusinessError } 401 - Invalid input parameter.
1143         * @throws { BusinessError } 17100001 - Init error.
1144         *                           The WebviewController must be associated with a Web component.
1145         * @since 9
1146         */
1147        restoreWebState(state: Uint8Array): void;
1148
1149        /**
1150         * Set whether the Web custom scheme supports cross domain and fetch requests.
1151         *
1152         * @param { Array<WebCustomScheme> } schemes - Configuration of web custom scheme.
1153         *
1154         * @throws { BusinessError } 401 - Invalid input parameter.
1155         *
1156         * @since 9
1157         */
1158        static customizeSchemes(schemes: Array<WebCustomScheme>): void;
1159    }
1160}
1161
1162export default webview;