diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 27551e01d652a9c69d5b4346a1eff29fdab5a60a..19a18af97796e6ca5150501cc374a515fdf9b02e 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -157,73 +157,6 @@ declare enum CacheMode { Only, } -/** - * Define html5 web message port. - * @since 9 - */ -declare class WebMessagePort { - /** - * Constructor. - * @since 9 - */ - constructor(); - - /** - * Close port. - * @since 9 - */ - close(): void; - - /** - * Post a message to other port. - * @since 9 - */ - postMessageEvent(message: WebMessageEvent): void; - - /** - * Receive message from other port. - * @since 9 - */ - onMessageEvent(callback: (result: string) => void): void; -} - - -/** - * Define html5 web message, which include message and ports. - * @since 9 - */ -declare class WebMessageEvent { - /** - * Constructor. - * @since 9 - */ - constructor(); - - /** - * Get message. - * @since 9 - */ - getData(): string; - - /** - * Set message. - * @since 9 - */ - setData(data: string): void; - - /** - * Get ports. - * @since 9 - */ - getPorts(): Array; - - /** - * Set ports. - * @since 9 - */ - setPorts(ports: Array): void; -} - /** * Enum type supplied to {@link renderExitReason} when onRenderExited being called. * @since 9 @@ -290,6 +223,18 @@ declare enum FileSelectorMode { FileSaveMode, } +/** + * Enum type of protected resources. + * @since 9 + */ +declare enum ProtectedResourceType { + /** + * Sysex messages to be sent to or received from MIDI devices. + * @since 9 + */ + MidiSysex = "TYPE_MIDI_SYSEX", +} + /** * Encompassed message information as parameters to {@link onFileSelectorShow} method. * @since 9 @@ -334,220 +279,119 @@ declare class FileSelectorParam { } /** - * Defines the js result. - * @since 8 - */ -declare class JsResult { - /** - * Constructor. - * @since 8 - */ - constructor(); - - /** - * Handle the user's JavaScript result if cancel the dialog. - * @since 8 - */ - handleCancel(): void; - - /** - * Handle the user's JavaScript result if confirm the dialog. - * @since 8 - */ - handleConfirm(): void; - - /** - * Handle the user's JavaScript result if confirm the prompt dialog. - * @since 9 - */ - handlePromptConfirm(result: string): void; -} - -/** - * Defines the file selector result, related to {@link onFileSelectorShow} method. + * Encompassed message information as parameters to {@link onFileSelectorShow} method. * @since 9 */ -declare class FileSelectorResult { +declare class WebContextMenuParam { /** * Constructor. * @since 9 */ constructor(); - /** - * select a list of files. + /** + * Gets x offset in web page + * * @since 9 */ - handleFileList(fileList: Array): void; -} - -/** - * Defines the hit test value, related to {@link getHitTestValue} method. - * @since 9 - */ -declare class HitTestValue { - /** - * Constructor. - * @since 9 - */ - constructor(); + x(): number; /** - * get the hit test type. - * @since 9 - */ - getType(): HitTestType; + * Gets y offset in web page + * + * @since 9 + */ + y(): number; /** - * get the hit test extra data. - * @since 9 - */ - getExtra(): string; -} + * Get the checked link url + * + * @since 9 + */ + getLinkUrl() :string; -/** - * Defines the http auth request result, related to {@link onHttpAuthRequest} method. - * @since 9 - */ -declare class HttpAuthHandler { /** - * Constructor. + * Get the unchecked link url * @since 9 */ - constructor(); + getUnfilterendLinkUrl() : string; /** - * confirm. - * @since 9 - */ - confirm(userName: string, password: string): boolean; + * Get the checked src url + * + * @since 9 + */ + getSourceUrl(): string; /** - * cancel. - * @since 9 - */ - cancel(): void; + * Gets whether current element has image content + * + * @since 9 + */ + existsImageContents(): boolean; /** - * isHttpAuthInfoSaved. + * Gets whether current element is a link * @since 9 */ - isHttpAuthInfoSaved(): boolean; + isLink(): boolean; } -/** - * Defines the accessible resource type, related to {@link onPermissionRequest} method. - * @since 9 - */ -declare enum ProtectedResourceType { - /** - * The MidiSysex resource. - * @since 9 - */ - MidiSysex = "TYPE_MIDI_SYSEX" -} + /** - * Defines the onPermissionRequest callback, related to {@link onPermissionRequest} method. - * @since 9 + * Defines the js result. + * @since 8 */ -declare class PermissionRequest { +declare class JsResult { /** * Constructor. - * @since 9 + * @since 8 */ constructor(); /** - * Reject the request. - * @since 9 - */ - deny(): void; - - /** - * Gets the source if the webpage that attempted to access the restricted resource. - * @since 9 + * Handle the user's JavaScript result if cancel the dialog. + * @since 8 */ - getOrigin(): string; + handleCancel(): void; /** - * Gets the resource that the webpage is trying to access. - * @since 9 + * Handle the user's JavaScript result if confirm the dialog. + * @since 8 */ - getAccessibleResource(): Array; + handleConfirm(): void; /** - * Grant origin access to a given resource. + * Handle the user's JavaScript result if confirm the prompt dialog. * @since 9 */ - grant(resources: Array): void; + handlePromptConfirm(result: string): void; } /** -* Defines the context menu param, related to {@link WebContextMenuParam} method. -* @since 9 -*/ -declare class WebContextMenuParam { + * Defines the file selector result, related to {@link onFileSelectorShow} method. + * @since 9 + */ +declare class FileSelectorResult { /** * Constructor. * @since 9 */ constructor(); - /** - * Horizontal offset coordinates of the menu within the Web component. - * @return The context menu x coordinate. - * - * @since 9 - */ - x(): number; - - /** - * Vertical offset coordinates for the menu within the Web component. - * @return The context menu y coordinate. - * - * @since 9 - */ - y(): number; - - /** - * If the long-press location is the link returns the link's security-checked URL. - * @return If relate to a link return link url, else return null. - * - * @since 9 - */ - getLinkUrl(): string; - - /** - * If the long-press location is the link returns the link's original URL. - * @return If relate to a link return unfilterend link url, else return null. - * - * @since 9 - */ - getUnfilterendLinkUrl(): string; - - /** - * Returns the SRC URL if the selected element has a SRC attribute. - * @return If this context menu is "src" attribute, return link url, else return null. - * - * @since 9 - */ - getSourceUrl(): string; - - /** - * Long press menu location has image content. - * @return Return whether this context menu has image content. - * - * @since 9 - */ - existsImageContents(): boolean; + /** + * select a list of files. + * @since 9 + */ + handleFileList(fileList: Array): void; } /** - * Defines the context menu result, related to {@link WebContextMenuResult} method. + * Defines the hit test value, related to {@link getHitTestValue} method. * @since 9 */ -declare class WebContextMenuResult { +declare class HitTestValue { /** * Constructor. * @since 9 @@ -555,20 +399,16 @@ declare class WebContextMenuResult { constructor(); /** - * When close context menu without other call in WebContextMenuResult, - * User should call this function to close menu - * + * get the hit test type. * @since 9 */ - closeContextMenu(): void; + getType(): HitTestType; /** - * If WebContextMenuParam has image content, this function will copy image ralated to this context menu. - * If WebContextMenuParam has not image content, this function will do nothing. - * + * get the hit test extra data. * @since 9 */ - copyImage(): void; + getExtra(): string; } /** @@ -736,54 +576,6 @@ declare class WebResourceRequest { * @since 8 */ getResponseCode(): number; - - /** - * Sets the response data. - * @param data the response data. - * - * @since 9 - */ - setResponseData(data: string); - - /** - * Sets the response encoding. - * @param encoding the response encoding. - * - * @since 9 - */ - setResponseEncoding(encoding: string); - - /** - * Sets the response MIME type. - * @param mimeType the response MIME type. - * - * @since 9 - */ - setResponseMimeType(mimeType: string); - - /** - * Sets the reason message. - * @param reason the reason message. - * - * @since 9 - */ - setReasonMessage(reason: string); - - /** - * Sets the response headers. - * @param header the response headers. - * - * @since 9 - */ - setResponseHeader(header: Array
); - - /** - * Sets the response code. - * @param code the response code. - * - * @since 9 - */ - setResponseCode(code: number); } /** @@ -857,6 +649,7 @@ declare class JsGeolocation { /** * Defines the Web cookie. * @since 8 + * @deprecated since 9 */ declare class WebCookie { /** @@ -865,53 +658,6 @@ declare class WebCookie { */ constructor(); - /** - * Get whether cookies can be send or accepted. - * @return true if can send and accept cookies else false. - * - * @since 9 - */ - isCookieAllowed(): boolean; - - /** - * Get whether third party cookies can be send or accepted. - * @return true if can send and accept third party cookies else false. - * - * @since 9 - */ - isThirdPartyCookieAllowed(): boolean; - - /** - * Get whether file scheme cookies can be send or accepted. - * @return true if can send and accept else false. - * @since 9 - */ - isFileURICookieAllowed(): boolean; - - /** - * Set whether cookies can be send or accepted. - * @param accept whether can send and accept cookies - * - * @since 9 - */ - putAcceptCookieEnabled(accept: boolean): void; - - /** - * Set whether third party cookies can be send or accepted. - * @param accept true if can send and accept else false. - * - * @since 9 - */ - putAcceptThirdPartyCookieEnabled(accept: boolean): void; - - /** - * Set whether file scheme cookies can be send or accepted. - * @param accept true if can send and accept else false. - * - * @since 9 - */ - putAcceptFileURICookieEnabled(accept: boolean): void; - /** * Sets the cookie. * @since 8 @@ -919,63 +665,12 @@ declare class WebCookie { */ setCookie(); - /** - * Sets the cookie. - * @since 9 - */ - setCookie(url: string, value: string): boolean; - /** * Saves the cookies. * @since 8 * @deprecated since 9 */ saveCookie(); - - /** - * Saves the cookies. - * @since 9 - */ - saveCookieSync(): boolean; - - /** - * Gets all cookies for the given URL. - * - * @param url the URL for which the cookies are requested. - * @return the cookie value for the given URL. - * - * @since 9 - */ - getCookie(url: string): string; - - /** - * Check whether exists any cookies. - * - * @return true if exists cookies else false; - * @since 9 - */ - existCookie(): boolean; - - /** - * Delete all cookies. - * - * @since 9 - */ - deleteEntireCookie(): void; - - /** - * Delete session cookies. - * - * @since 9 - */ - deleteSessionCookie(): void; - - /** - * Delete all expired cookies. - * - * @since 9 - */ - deleteExpiredCookie(): void; } /** @@ -1035,21 +730,6 @@ declare class WebCookie { */ runJavaScript(options: { script: string, callback?: (result: string) => void }); - /** - * Create web message ports - * - * @since 9 - */ - createWebMessagePorts(): Array; - - /** - * Post web message port to html5 - * @param options The options with a message event and a uri. - * - * @since 9 - */ - postMessage(options: { message: WebMessageEvent, uri: string}): void; - /** * Loads the data or URL. * @param options The options with the data or URL and other information. @@ -1173,33 +853,6 @@ declare class WebCookie { * @since 9 */ backOrForward(step: number): void; - - /** - * Gets network cookie manager - * @since 9 - */ - getCookieManager() : WebCookie - - /** - * Search all instances of 'searchString' on the page and highlights them, - * result will be notify through callback onSearchResultReceive. - * @param searchString string to be search. - * @since 9 - */ - searchAllAsync(searchString: string): void; - - /** - * Clears the highlighting surrounding text matches created by searchAllAsync. - * @since 9 - */ - clearMatches(): void; - - /** - * Highlights and scrolls to the next match search. - * @param forward step of search is back or forward. - * @since 9 - */ - searchNext(forward: boolean): void; } /** @@ -1596,50 +1249,6 @@ declare class WebAttribute extends CommonMethod { * @since 9 */ onScaleChange(callback: (event: {oldScale: number, newScale: number}) => void): WebAttribute; - - /** - * Triggered when the browser needs credentials from the user. - * @param callback The triggered when the browser needs credentials from the user. - * - * @since 9 - */ - onHttpAuthRequest(callback: (event?: { handler: HttpAuthHandler, host: string, realm: string }) => boolean): WebAttribute; - - /** - * Triggered when the resouces loading is intercepted. - * @param callback The triggered callback when the resouces loading is intercepted. - * - * @return If the response value is null, the Web will continue to load the resouces. Otherwise, the response value will be used - * @since 9 - */ - onInterceptRequest(callback: (event?: { request: WebResourceRequest}) => WebResourceResponse): WebAttribute; - - /** - * Triggered when the host application that web content from the specified origin is attempting to access the resources. - * @param callback The triggered callback when the host application that web content from the specified origin is - * attempting to access the resources. - * - * @since 9 - */ - onPermissionRequest(callback: (event?: { request: PermissionRequest }) => void): WebAttribute; - - /** - * Triggered when called to allow custom display of the context menu. - * @param callback The triggered callback when called to allow custom display of the context menu. - * - * @return If custom display return true.Otherwise, default display return false. - * @since 9 - */ - onContextMenuShow(callback: (event?: { param: WebContextMenuParam, result: WebContextMenuResult }) => boolean): WebAttribute; - - /** - * Notify search result to host application through onSearchResultReceive. - * @param callback function Triggered when the host application call searchAllAsync - * or searchNext api on WebController and the request is valid. - * - * @since 9 - */ - onSearchResultReceive(callback: (event?: {activeMatchOrdinal: number, numberOfMatches: number, isDoneCounting: boolean}) => void): WebAttribute } declare const Web: WebInterface; diff --git a/api/@ohos.web.webview.d.ts b/api/@ohos.web.webview.d.ts index c044f40b8fb5c7a256b5d812bd2f5e8cd627711d..64dc01b7bcd891c282351e247a407203337e1d34 100644 --- a/api/@ohos.web.webview.d.ts +++ b/api/@ohos.web.webview.d.ts @@ -121,7 +121,112 @@ declare namespace webview { * @since 9 */ static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; - } + } + + /** + * Defines the Web cookie. + * @since 9 + */ + class WebCookieManager { + + /** + * Get whether cookies can be send or accepted. + * @return true if can send and accept cookies else false. + * + * @since 9 + */ + static isCookieAllowed(): boolean; + + /** + * Get whether third party cookies can be send or accepted. + * @return true if can send and accept third party cookies else false. + * + * @since 9 + */ + static isThirdPartyCookieAllowed(): boolean; + + /** + * Get whether file scheme cookies can be send or accepted. + * @return true if can send and accept else false. + * @since 9 + */ + static isFileURICookieAllowed(): boolean; + + /** + * Set whether cookies can be send or accepted. + * @param accept whether can send and accept cookies + * + * @since 9 + */ + static putAcceptCookieEnabled(accept: boolean): void; + + /** + * Set whether third party cookies can be send or accepted. + * @param accept true if can send and accept else false. + * + * @since 9 + */ + static putAcceptThirdPartyCookieEnabled(accept: boolean): void; + + /** + * Set whether file scheme cookies can be send or accepted. + * @param accept true if can send and accept else false. + * + * @since 9 + */ + static putAcceptFileURICookieEnabled(accept: boolean): void; + + /** + * Sets the cookie. + * @since 9 + */ + static setCookie(url: string, value: string): boolean; + + /** + * Saves the cookies. + * @since 9 + */ + static saveCookieSync(): boolean; + + /** + * Gets all cookies for the given URL. + * + * @param url the URL for which the cookies are requested. + * @return the cookie value for the given URL. + * + * @since 9 + */ + static getCookie(url: string): string; + + /** + * Check whether exists any cookies. + * + * @return true if exists cookies else false; + * @since 9 + */ + static existCookie(): boolean; + + /** + * Delete all cookies. + * + * @since 9 + */ + static deleteEntireCookie(): void; + + /** + * Delete session cookies. + * + * @since 9 + */ + static deleteSessionCookie(): void; + + /** + * Delete all expired cookies. + * + * @since 9 + */ + static deleteExpiredCookie(): void; + } /** * Provides asynchronous methods for manage the webview.