A web view provider that has been registered with the PAPI and returned to the extension that registered it. It is able to be disposed with dispose.

The PAPI returns this type from papi.webViewProviders.register.

interface IDisposableWebViewProvider {
    dispose: UnsubscriberAsync;
    onDidDispose: PlatformEvent<void>;
    getWebView(savedWebViewDefinition: SavedWebViewDefinition, getWebViewOptions: GetWebViewOptions, webViewNonce: string): Promise<undefined | WebViewDefinition>;
}

Hierarchy (view full)

Properties

Methods

Properties

dispose: UnsubscriberAsync

Release resources and notify dependent services when tearing down an object

onDidDispose: PlatformEvent<void>

Event that emits when dispose is called on an object

Methods

  • Receives a SavedWebViewDefinition and fills it out into a full WebViewDefinition, providing the contents of the web view and other properties that are important for displaying the web view.

    The PAPI calls this method as part of opening a new web view or (re)loading an existing web view. If you want to create WebViewControllers for the web views the PAPI creates from this method, you should register it using papi.webViewProviders.registerWebViewController before returning from this method (resolving the returned promise). The WebViewFactory abstract class handles this for you, so please consider extending it.

    Parameters

    • savedWebViewDefinition: SavedWebViewDefinition

      The saved web view information from which to build a complete web view definition. Filled out with all SavedWebViewDefinition properties of the existing web view if an existing webview is being called for (matched by ID). Just provides the minimal properties required on SavedWebViewDefinition if this is a new request or if the web view with the existing ID was not found.

    • getWebViewOptions: GetWebViewOptions

      Various options that affect what calling papi.webViews.openWebView should do. When options are passed to papi.webViews.openWebView, some defaults are set up on the options, then those options are passed directly through to this method. That way, if you want to adjust what this method does based on the contents of the options passed to papi.WebViews.openWebView, you can. You can even read other properties on these options if someone passes options with other properties to papi.webViews.openWebView.

    • webViewNonce: string

      Nonce used to perform privileged interactions with the web view created from this method's returned WebViewDefinition such as papi.webViewProviders.postMessageToWebView. The web view service generates this nonce and sends it only here to this web view provider that creates the web view with this id. It is generally recommended that this web view provider not share this nonce with anyone else but only use it within itself and in the web view controller created for this web view if applicable (See papi.webViewProviders.registerWebViewController).

    Returns Promise<undefined | WebViewDefinition>

    Full WebViewDefinition including the content and other important display properties based on the SavedWebViewDefinition provided